forked from yuxudong1024/Summit2024-Prework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallMinGW.m
30 lines (25 loc) · 947 Bytes
/
installMinGW.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
function installMinGW
if ~ispc
disp('Only supported on Windows')
return
end
[FAILED,emsg,eid] = mkdir("c:\mpm");
if FAILED
error(eid,emsg)
end
websave("c:\mpm\mpm.exe", "https://www.mathworks.com/mpm/win64/mpm");
destination = matlabroot;
destinationPath = ['""""', destination, '""""'];
cmd = "powershell Start-Process -Wait -Verb runas -ArgumentList 'install --release=" + matlabRelease().Release + " --destination=" + destinationPath + " --release-status Prerelease --products MATLAB_Support_for_MinGW-w64_C/C++_Compiler' C:\mpm\mpm.exe";
[PASSED, results] = system(cmd);
if ~PASSED
error(results)
end
[FAILED,emsg,eid] = rmdir("c:\mpm\","s");
if FAILED
error(eid,emsg)
end
envs = string(fileread(fullfile(matlabshared.supportpkg.getSupportPackageRoot,"envVariableList")));
lines = split(envs, newline);
mingwLine = lines(startsWith(lines, "MW_MINGW64_LOC"));
setenv("MW_MINGW64_LOC",extractBetween(mingwLine,"|","|"))