|
3 | 3 | import os |
4 | 4 | import net.http |
5 | 5 |
|
6 | | -const root = @VROOT |
7 | | - |
8 | 6 | fn main() { |
9 | | - os.chdir(root)! // make sure that the workfolder is stable |
10 | | - |
11 | | - tloc := os.join_path(root, 'thirdparty') |
| 7 | + os.chdir(@VROOT)! // make sure that the workfolder is stable |
| 8 | + tloc := os.join_path(@VROOT, 'thirdparty') |
12 | 9 | loc := os.join_path(tloc, 'wabt') |
13 | | - |
14 | 10 | if os.exists(loc) { |
15 | 11 | eprintln('thirdparty/wabt exists, will not overwrite') |
16 | 12 | eprintln('delete the folder, and execute again') |
17 | 13 | exit(1) |
18 | 14 | } |
19 | 15 | tag := '1.0.32' |
20 | 16 | fname := 'wabt-${tag}' |
21 | | - platform := $if windows { |
22 | | - 'windows' |
| 17 | + mut platform := '' |
| 18 | + $if windows { |
| 19 | + platform = 'windows' |
23 | 20 | } $else $if macos { |
24 | | - 'macos-14' |
| 21 | + platform = 'macos-14' |
25 | 22 | } $else $if linux { |
26 | | - 'ubuntu' |
| 23 | + platform = 'ubuntu' |
27 | 24 | } $else { |
28 | 25 | eprintln('A premade binary library is not available for your system.') |
29 | 26 | eprintln('Build it from source, following the documentation here: https://github.com/WebAssembly/wabt/') |
30 | 27 | exit(1) |
31 | 28 | } |
32 | 29 | url := 'https://github.com/WebAssembly/wabt/releases/download/${tag}/${fname}-${platform}.tar.gz' |
33 | 30 | saveloc := os.join_path(tloc, '${fname}.tar.gz') |
| 31 | + println('>> Url: ${url}') |
| 32 | + println('>> Archive: ${saveloc}') |
34 | 33 | if !os.exists(saveloc) { |
35 | 34 | println('Downloading archive: ${saveloc}, from url: ${url} ...') |
36 | 35 | http.download_file(url, saveloc)! |
37 | 36 | // defer { os.rm(saveloc) or {}! } |
38 | 37 | } |
39 | | - |
40 | 38 | println('Extracting `${tloc}/${fname}` to `${tloc}/wabt` ...') |
41 | 39 | cmd := 'tar -xvf ${saveloc} --directory ${tloc}' |
42 | 40 | if os.system(cmd) != 0 { |
43 | 41 | eprintln('`${cmd}` exited with a non zero exit code') |
44 | 42 | exit(1) |
45 | 43 | } |
46 | | - |
47 | 44 | println(cmd) |
48 | 45 | println('Moving `${tloc}/${fname}` to `${tloc}/wabt` ...') |
49 | | - |
50 | 46 | os.rename_dir('${tloc}/${fname}', loc)! |
51 | 47 | println('Done. You can now use `v test vlib/wasm` .') |
52 | 48 | } |
0 commit comments