You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: aa_build_standalone_2_build.m
    path of file: ./repos/automaticanalysis/aa_tools/standalone
    
    the code of the file until where you have to start completion: function aa_build_standalone_2_build(config, outdir)
aa = aaClass('nopath','nogreet');
if isstruct(config) % aap (run-time compile)
    aap = config;
elseif ischar(config) % aap_parameters_defaults file (offline standalone)
    aap=xml_read(config,struct('ReadAttr',0));
end
aap.directory_conventions = prepare_dirlist(aap.directory_conventions);

% MATLAB Toolboxes:
%   Statistics_Toolbox
%   Parallel_Computing_Toolbox
%   Image_Processing_Toolbox
tbx = {...
    '-p',fullfile(matlabroot,'toolbox','stats'),...
    '-p',fullfile(matlabroot,'toolbox','images')...
    %     '-p',fullfile(matlabroot,'toolbox','distco
    
function prepare_spm(aap)
% Prepare spm for deployment with aa
% Based on Guillaume Flandin's spm_make_standalone.m v6416

spmdir = aas_gettoolboxdir(aap,'spm');

%==========================================================================
%-Static listing of SPM toolboxes
%==========================================================================
fid = fopen(fullfile(spmdir,'config','spm_cfg_static_tools.m'),'wt');
fprintf(fid,'function values = spm_cfg_static_tools\n');
fprintf(fid,...
    '%% Static listing of all batch configuration files in the SPM toolbox folder\n');
% create code to insert toolbox config
%-Toolbox autodetection
%-Get the list of toolbox directories
tbxdir = fullfile(spmdir,'toolbox');
d  = dir(tbxdir); d = {d([d.isdir]).name};
dd = regexp(d,'^\.');
%(Beware, regexp returns an array if input cell array is of dim 0 or 1)
if ~iscell(dd), dd = {dd}; end