0001 function matRad_compileStandalone(isRelease)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 if nargin < 1
0021 isRelease = false;
0022 end
0023
0024 compileWithRT = false;
0025 compileWithoutRT = true;
0026
0027
0028 if ~compileWithRT && ~compileWithoutRT
0029 error('No target specified!');
0030 return;
0031 end
0032
0033 [versionString,versionFull] = matRad_version();
0034
0035
0036 FileName='matRad.prj';
0037 xDoc = xmlread(FileName);
0038
0039 if ismac
0040 suffix = 'Mac';
0041 installSuffix = 'app';
0042 xDoc.getElementsByTagName('unix').item(0).getFirstChild.setData('true');
0043 xDoc.getElementsByTagName('mac').item(0).getFirstChild.setData('true');
0044 xDoc.getElementsByTagName('windows').item(0).getFirstChild.setData('false');
0045 xDoc.getElementsByTagName('linux').item(0).getFirstChild.setData('false');
0046 xDoc.getElementsByTagName('arch').item(0).getFirstChild.setData('maci64');
0047
0048 elseif isunix
0049 suffix = 'Linux';
0050 installSuffix = 'install';
0051 xDoc.getElementsByTagName('unix').item(0).getFirstChild.setData('true');
0052 xDoc.getElementsByTagName('mac').item(0).getFirstChild.setData('false');
0053 xDoc.getElementsByTagName('windows').item(0).getFirstChild.setData('false');
0054 xDoc.getElementsByTagName('linux').item(0).getFirstChild.setData('true');
0055 xDoc.getElementsByTagName('arch').item(0).getFirstChild.setData('glnxa64');
0056
0057 elseif ispc
0058 suffix = 'Win';
0059 installSuffix = 'exe';
0060 xDoc.getElementsByTagName('unix').item(0).getFirstChild.setData('false');
0061 xDoc.getElementsByTagName('mac').item(0).getFirstChild.setData('false');
0062 xDoc.getElementsByTagName('windows').item(0).getFirstChild.setData('true');
0063 xDoc.getElementsByTagName('linux').item(0).getFirstChild.setData('false');
0064 xDoc.getElementsByTagName('arch').item(0).getFirstChild.setData('Win64');
0065 else
0066 error('Platform not supported')
0067 end
0068
0069
0070 xDoc.getElementsByTagName('root').item(0).getFirstChild.setData(matlabroot);
0071
0072
0073 files = xDoc.getElementsByTagName('file');
0074 for i=0:files.getLength - 1
0075 fileName=strrep(strrep(files.item(i).getFirstChild.getData().toCharArray()','/',filesep),'\',filesep);
0076 files.item(i).getFirstChild.setData(fileName);
0077
0078
0079
0080 if hasAttributes(files.item(i))
0081 location=strrep(strrep(files.item(i).getAttribute('location').toCharArray()','/',filesep),'\',filesep);
0082 files.item(i).setAttribute('location',location);
0083 end
0084 end
0085
0086
0087 config = xDoc.getElementsByTagName('configuration');
0088 config.item(0).setAttribute('file',['${PROJECT_ROOT}' filesep FileName]);
0089 config.item(0).setAttribute('location','${PROJECT_ROOT}');
0090 config.item(0).setAttribute('preferred-package-location',['${PROJECT_ROOT}' filesep 'standalone' filesep 'for_redistribution']);
0091
0092 tags = config.item(0).getChildNodes;
0093
0094 for i=0:tags.getLength - 1
0095 if ~isempty(tags.item(i).getFirstChild)
0096 fileName=strrep(strrep(tags.item(i).getFirstChild.getData().toCharArray()','/',filesep),'\',filesep);
0097 tags.item(i).getFirstChild.setData(java.lang.String(fileName));
0098 end
0099 end
0100
0101
0102
0103
0104 vernum = sprintf('%d.%d.%d',versionFull.major,versionFull.minor,versionFull.patch);
0105
0106 tmp_verstr = ['v' vernum];
0107 if ~isRelease && ~isempty(versionFull.commitID) && ~isempty(versionFull.branch)
0108 branchinfo = [versionFull.branch '-' versionFull.commitID(1:8)];
0109 tmp_verstr = [tmp_verstr '_' branchinfo];
0110 addDescription = ['!!!matRad development version build from branch/commit ' branchinfo '!!!'];
0111 desc = xDoc.getElementsByTagName('param.description').item(0).getFirstChild.getData().toCharArray()';
0112 desc = [addDescription ' ' desc];
0113 xDoc.getElementsByTagName('param.description').item(0).getFirstChild.setData(desc);
0114 end
0115
0116
0117 vernum_appCompiler = sprintf('%d.%d',versionFull.major,versionFull.minor);
0118
0119 filename_webRT =['matRad_installer' suffix '64_' tmp_verstr];
0120 filename_withRT =['matRad_installer' suffix '64_wRT_' tmp_verstr];
0121 xDoc.getElementsByTagName('param.web.mcr.name').item(0).getFirstChild.setData(filename_webRT);
0122 xDoc.getElementsByTagName('param.package.mcr.name').item(0).getFirstChild.setData(filename_withRT);
0123 xDoc.getElementsByTagName('param.version').item(0).getFirstChild.setData(vernum_appCompiler);
0124
0125
0126
0127
0128 if isfolder(['standalone' filesep 'for_redistribution' filesep filename_withRT '.' installSuffix])
0129 rmdir(['standalone' filesep 'for_redistribution' filesep filename_withRT '.' installSuffix],'s')
0130 rehash
0131 end
0132
0133 if isfile(['standalone' filesep 'for_redistribution' filesep filename_withRT '.' installSuffix])
0134 delete(['standalone' filesep 'for_redistribution' filesep filename_withRT '.' installSuffix]);
0135 end
0136
0137 if isfolder(['standalone' filesep 'for_redistribution' filesep filename_webRT '.' installSuffix])
0138 rmdir(['standalone' filesep 'for_redistribution' filesep filename_webRT '.' installSuffix],'s')
0139 rehash
0140 end
0141 if isfile(['standalone' filesep 'for_redistribution' filesep filename_webRT '.' installSuffix])
0142 delete(['standalone' filesep 'for_redistribution' filesep filename_webRT '.' installSuffix]);
0143 end
0144
0145
0146 if compileWithRT
0147 xDoc.getElementsByTagName('param.web.mcr').item(0).getFirstChild.setData('false');
0148 xDoc.getElementsByTagName('param.package.mcr').item(0).getFirstChild.setData('true');
0149
0150 xmlwrite(FileName,xDoc);
0151
0152 applicationCompiler('-package',FileName);
0153
0154
0155 tic
0156 worked = false;
0157 while toc<500
0158 pause ( 2 )
0159 if isfolder(['standalone' filesep 'for_redistribution' filesep filename_withRT '.' installSuffix]) || ...
0160 isfile(['standalone' filesep 'for_redistribution' filesep filename_withRT '.' installSuffix])
0161 worked = true;
0162 break
0163 end
0164 end
0165 if worked == false
0166 error('Packaging Failed!');
0167 end
0168 disp('Packaged compiler with runtime');
0169 end
0170
0171 if compileWithoutRT
0172
0173 xDoc.getElementsByTagName('param.web.mcr').item(0).getFirstChild.setData('true');
0174 xDoc.getElementsByTagName('param.package.mcr').item(0).getFirstChild.setData('false');
0175
0176 xmlwrite(FileName,xDoc);
0177
0178 applicationCompiler('-package',FileName);
0179
0180
0181 tic
0182 worked = false;
0183 while toc<500
0184 pause ( 2 )
0185 if isfolder(['standalone' filesep 'for_redistribution' filesep filename_webRT '.' installSuffix]) || ...
0186 isfile(['standalone' filesep 'for_redistribution' filesep filename_webRT '.' installSuffix])
0187 worked = true;
0188 break
0189 end
0190 end
0191
0192 if worked == false
0193 error('Packaging Failed!');
0194 end
0195 disp('Packaged compiler without runtime');
0196 end
0197
0198
0199 disp('Done');
0200
0201