|
1 | 1 | function install() |
2 | | -% Copyright 2022-2023 The MathWorks, Inc. |
| 2 | +% Copyright 2022-2025 The MathWorks, Inc. |
3 | 3 |
|
4 | 4 | %% Run this script once and follow the instructions |
5 | 5 | % Make sure you run this script from this folder. |
6 | 6 |
|
7 | | -MJ_VER = '2.3.5'; |
| 7 | +MJ_VER = '3.3.6'; |
8 | 8 | GLFW_VER = '3.3.7'; |
9 | 9 | urlsList = fileread("tools/links.json"); |
10 | 10 | blockPath = './blocks/'; |
@@ -85,37 +85,76 @@ function install() |
85 | 85 |
|
86 | 86 | %% Local functions |
87 | 87 | function downloadfolder = downloader(urlsList, name, version) |
88 | | - libraryFolder = 'lib'; |
89 | | - downloadfolder = fullfile(pwd, libraryFolder, computer('arch'), name); |
| 88 | + libraryFolder = 'lib'; |
| 89 | + downloadfolder = fullfile(pwd, libraryFolder, computer('arch'), name); |
| 90 | + |
| 91 | + if strcmp(name, 'mujoco') |
| 92 | + % Generate MuJoCo URL based on version and architecture |
| 93 | + downloadLink = generateMujocoUrl(version); |
| 94 | + else |
| 95 | + % Use JSON for other libraries (GLFW) |
90 | 96 | urlJson = jsondecode(urlsList); |
| 97 | + downloadLink = ''; |
91 | 98 | for i=1:length(urlJson.files) |
92 | 99 | obj = urlJson.files(i); |
93 | 100 | if strcmp(obj.name, name) && strcmp(obj.version, version) && strcmp(obj.arch, computer('arch')) |
94 | 101 | downloadLink = obj.downloadLink; |
| 102 | + break; |
95 | 103 | end |
96 | 104 | end |
97 | | - disp(' ') |
98 | | - disp('Download URL is:'); |
99 | | - disp(downloadLink); |
100 | | - |
101 | | - if isfolder(downloadfolder) |
102 | | - disp(' ') |
103 | | - disp('folder exists already. it will be overwritten'); |
| 105 | + |
| 106 | + if isempty(downloadLink) |
| 107 | + error('Download link not found for %s version %s on %s', name, version, computer('arch')); |
104 | 108 | end |
| 109 | + end |
| 110 | + |
| 111 | + disp(' ') |
| 112 | + disp('Download URL is:'); |
| 113 | + disp(downloadLink); |
105 | 114 |
|
106 | | - [~,~,ext]=fileparts(downloadLink); |
107 | | - downloadFile = fullfile(libraryFolder, strcat('download', ext)); |
108 | | - status = mkdir(libraryFolder); %#ok<NASGU> |
109 | | - websave(downloadFile, downloadLink); |
110 | | - if strcmp(ext,'.zip') |
111 | | - unzip(downloadFile, downloadfolder); |
112 | | - elseif strcmp(ext, '.gz') |
113 | | - untar(downloadFile, downloadfolder); |
114 | | - else |
115 | | - error('unknown extension. Unable to extract archive'); |
116 | | - end |
| 115 | + if isfolder(downloadfolder) |
117 | 116 | disp(' ') |
118 | | - disp(name + ' downloaded and extracted to this path:'); |
119 | | - disp(downloadfolder) |
| 117 | + disp('folder exists already. it will be overwritten'); |
| 118 | + end |
| 119 | + |
| 120 | + [~,~,ext]=fileparts(downloadLink); |
| 121 | + downloadFile = fullfile(libraryFolder, strcat('download', ext)); |
| 122 | + status = mkdir(libraryFolder); %#ok<NASGU> |
| 123 | + websave(downloadFile, downloadLink); |
| 124 | + if strcmp(ext,'.zip') |
| 125 | + unzip(downloadFile, downloadfolder); |
| 126 | + elseif strcmp(ext, '.gz') |
| 127 | + untar(downloadFile, downloadfolder); |
| 128 | + else |
| 129 | + error('unknown extension. Unable to extract archive'); |
120 | 130 | end |
| 131 | + disp(' ') |
| 132 | + disp(name + ' downloaded and extracted to this path:'); |
| 133 | + disp(downloadfolder) |
| 134 | +end |
| 135 | + |
| 136 | +function url = generateMujocoUrl(version) |
| 137 | + baseUrl = 'https://github.com/deepmind/mujoco/releases/download/'; |
| 138 | + |
| 139 | + switch computer('arch') |
| 140 | + case 'win64' |
| 141 | + platform = 'windows-x86_64'; |
| 142 | + ext = '.zip'; |
| 143 | + case 'glnxa64' |
| 144 | + platform = 'linux-x86_64'; |
| 145 | + ext = '.tar.gz'; |
| 146 | + case 'maci64' |
| 147 | + platform = 'macos-universal2'; |
| 148 | + ext = '.dmg'; |
| 149 | + case 'maca64' |
| 150 | + % For Apple Silicon Macs |
| 151 | + platform = 'macos-universal2'; |
| 152 | + ext = '.dmg'; |
| 153 | + otherwise |
| 154 | + error('Unsupported architecture: %s', computer('arch')); |
| 155 | + end |
| 156 | + |
| 157 | + % Construct the URL: version/mujoco-version-platform.ext |
| 158 | + url = sprintf('%s%s/mujoco-%s-%s%s', baseUrl, version, version, platform, ext); |
| 159 | +end |
121 | 160 | end |
0 commit comments