From 586df102a9c29a1f7789b114af3165959f46813b Mon Sep 17 00:00:00 2001 From: imspace Date: Sat, 4 Mar 2023 17:48:01 +0800 Subject: [PATCH] refactor: rewrite compile script in ts --- deno.lock | 11 +++++++++++ gui/scripts/compile.sh | 7 ------- scripts/compile.ts | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) delete mode 100755 gui/scripts/compile.sh create mode 100644 scripts/compile.ts diff --git a/deno.lock b/deno.lock index 27fbada..471fe72 100644 --- a/deno.lock +++ b/deno.lock @@ -40,6 +40,17 @@ "https://deno.land/std@0.160.0/uuid/v1.ts": "7123410ef9ce980a4f2e54a586ccde5ed7063f6f119a70d86eebd92f8e100295", "https://deno.land/std@0.160.0/uuid/v4.ts": "3e983c6ac895ea2a7ba03da927a2438fe1c26ac43fb38dc44f2f8aa50c23cb53", "https://deno.land/std@0.160.0/uuid/v5.ts": "43973aeda44ad212f2ec9b8d6c042b74d5cef4ce583d6aa6fc4cdb339344c74c", + "https://deno.land/std@0.178.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", + "https://deno.land/std@0.178.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", + "https://deno.land/std@0.178.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", + "https://deno.land/std@0.178.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", + "https://deno.land/std@0.178.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", + "https://deno.land/std@0.178.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000", + "https://deno.land/std@0.178.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1", + "https://deno.land/std@0.178.0/path/mod.ts": "4b83694ac500d7d31b0cdafc927080a53dc0c3027eb2895790fb155082b0d232", + "https://deno.land/std@0.178.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", + "https://deno.land/std@0.178.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", + "https://deno.land/std@0.178.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba", "https://deno.land/x/another_cookiejar@v4.1.4/cookie.ts": "72d6a6633ea13dd2f13b53d9726735b194996353a958024072c4d6b077c97baf", "https://deno.land/x/another_cookiejar@v4.1.4/cookie_jar.ts": "9accd36e76929f2f06fa710d2165fb544703617245fa36ac63560b9fa2a22a25", "https://deno.land/x/another_cookiejar@v4.1.4/fetch_wrapper.ts": "d8918c0776413b2d4a675415727973390b4401a026f6dfdcffedce3296b5e0dc", diff --git a/gui/scripts/compile.sh b/gui/scripts/compile.sh deleted file mode 100755 index 74b8e45..0000000 --- a/gui/scripts/compile.sh +++ /dev/null @@ -1,7 +0,0 @@ -TARGETS="x86_64-unknown-linux-gnu,x86_64-pc-windows-msvc,x86_64-apple-darwin,aarch64-apple-darwin" - -# compile for every target in bash -for target in $(echo $TARGETS | sed "s/,/ /g") -do - deno compile --target=$target -o ./binaries/s3si-$target -A ../s3si.ts -done diff --git a/scripts/compile.ts b/scripts/compile.ts new file mode 100644 index 0000000..cbbb346 --- /dev/null +++ b/scripts/compile.ts @@ -0,0 +1,38 @@ +import * as path from "https://deno.land/std@0.178.0/path/mod.ts"; + +if (import.meta.main) { + const __dirname = path.dirname(path.fromFileUrl(import.meta.url)); + const TARGETS = [ + "x86_64-unknown-linux-gnu", + "x86_64-pc-windows-msvc", + "x86_64-apple-darwin", + "aarch64-apple-darwin", + ]; + + for (const target of TARGETS) { + //deno compile --target=$target -o ./binaries/s3si-$target -A ../s3si.ts + const p = Deno.run({ + cmd: [ + "deno", + "compile", + "--target", + target, + "-o", + `../gui/binaries/s3si-${target}`, + "-A", + "../s3si.ts", + ], + cwd: __dirname, + }); + const status = await p.status(); + if (!status.success) { + console.error( + "Failed to run deno compile for target", + target, + "code:", + status.code, + ); + Deno.exit(status.code); + } + } +}