加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gobuild.ts 950 Bytes
一键复制 编辑 原始数据 按行查看 历史
iseki 提交于 2022-06-30 11:19 . build: add build flag -trimpath
const targets: [string, string][] = [
["linux", "amd64"],
["darwin", "amd64"],
["windows", "amd64"],
];
const isSaaS = Deno.args.indexOf("saas") > -1;
const bn = isSaaS ? "murphysec-saas" : "murphysec";
const tags = [!isSaaS ? "pro" : ""].filter((it) => it);
const opts = targets.map((it) => ({
cmd: [
"go",
"build",
"-trimpath",
"-ldflags",
"-s -w",
tags.length > 0 ? ["-tags", ...tags] : [],
"-o",
`out/${bn}-${it[0]}-${it[1]}${it[0] === "windows" ? ".exe" : ""}`,
".",
].flat().filter((it) => it),
env: {GOOS: it[0], GOARCH: it[1]},
stdin: "null" as "null",
}));
console.log(opts);
const process = opts.map((it) => Deno.run(it).status());
const status = await Promise.all(process);
if (status.every((it) => it.success && it.code === 0)) {
console.log("编译成功");
} else {
console.error("编译失败", status);
Deno.exit(-1);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化