-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild_installer.m
92 lines (78 loc) · 1.97 KB
/
build_installer.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function build_installer()
version = '20.1.2';
ml = ver('MATLAB');
ml = ml.Release(2:end-1);
arch = computer('arch');
%%
cd(fileparts((mfilename('fullpath'))));
p = pwd;
fid = fopen('bsp.tmpl','r');
f=fread(fid,'*char')';
fclose(fid);
if ispc
win = 'true';
unix = 'false';
else
win = 'false';
unix = 'true';
end
f = strrep(f,'__REPO-ROOT__',p);
f = strrep(f,'__VERSION__',version);
f = strrep(f,'__ML-RELEASE__',ml);
f = strrep(f,'__ARCH__',arch);
f = strrep(f,'__LINUX__',unix);
f = strrep(f,'__WINDOWS__',win);
fid = fopen('bsp.prj','w');
fprintf(fid,'%s',f);
fclose(fid);
addpath(genpath(matlabshared.supportpkg.getSupportPackageRoot));
addpath(genpath('.'));
rmpath(genpath('.'));
ps = {'doc','examples','libm2k'};
paths = '';
for p = ps
pp = genpath(p{:});
ppF = pp;
pp = pp(1:end-1);
pp = strrep(pp,':','</matlabPath><matlabPath>');
paths = [paths,['<matlabPath>',pp,'</matlabPath>']]; %#ok<AGROW>
addpath(ppF);
end
rehash
projectFile = 'bsp.prj';
currentVersion = matlab.addons.toolbox.toolboxVersion(projectFile);
outputFile = ['AnalogDeviceslibm2kBindings_v',currentVersion];
matlab.addons.toolbox.packageToolbox(projectFile,outputFile)
if ~usejava('desktop')
%% Update toolbox paths
mkdir other
movefile([outputFile,'.mltbx'], ['other/',outputFile,'.zip']);
cd other
unzip([outputFile,'.zip'],'out');
cd('out')
cd('metadata');
fid = fopen('configuration.xml','r');
f=fread(fid,'*char')';
fclose(fid);
s = '</matlabPaths>';
sections = strsplit(f,s);
s1 = sections{1};
s2 = sections{2};
newfile = [s1,paths,s,s2];
fid = fopen('configuration.xml','w');
fprintf(fid,'%s',newfile);
fclose(fid);
%% Repack
cd('..');
zip([outputFile,'.zip'], '*');
movefile([outputFile,'.zip'],['../../',outputFile,'.mltbx']);
cd('../..');
rmdir('other','s');
end
delete bsp.prj
%% Check output file
if isfile([outputFile,'.mltbx'])
exit();
else
exit(1);
end