-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathBUILD.js
59 lines (56 loc) · 1.98 KB
/
BUILD.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const generatePackage = function (goos, goarch, binaryName, mainFile) {
let name = binaryName + "-" + goos + "-" + goarch;
let dontTest = !(goos === "linux" && goarch === "amd64");
if (goos === "windows") {
binaryName += ".exe";
}
let pkg = {
name,
type: "go",
srcs: ["go.mod", "go.sum", "**/*.go", "version.txt"],
deps: [
"components/supervisor-api/go:lib",
"components/gitpod-protocol/go:lib",
"components/local-app-api/go:lib",
"components/public-api/go:lib",
],
env: ["GOOS=" + goos, "GOARCH=" + goarch, "CGO_ENABLED=0"],
config: {
packaging: "app",
dontTest: dontTest,
buildCommand: [
"sh",
"-c",
// We need to set GOARCH explicitly here because the `defaultVariant` in `WORKSPACE.yaml` overrides it for the workspace
`GOARCH=${goarch} go build -trimpath -ldflags "-X github.com/gitpod-io/local-app/pkg/constants.GitCommit=\${__git_commit} -X github.com/gitpod-io/local-app/pkg/constants.BuildTime=\$(date +%s)" -o ${binaryName} ${mainFile}`,
],
},
binaryName,
};
return pkg;
};
const packages = [];
for (binaryName of ["gitpod-local-companion", "gitpod-cli"]) {
for (goos of ["linux", "darwin", "windows"]) {
for (goarch of ["amd64", "arm64"]) {
packages.push(generatePackage(goos, goarch, binaryName, "main/" + binaryName + "/main.go"));
}
}
}
let appCmds = packages.map((p) => {
let binName = p.name;
if (p.name.includes("windows")) {
binName += ".exe";
}
return ["cp", "components-local-app--" + p.name + "/" + p.binaryName, "bin/" + binName];
});
appCmds.unshift(["mkdir", "bin"]);
appCmds.push(["sh", "-c", "rm -rf components-*"]);
packages.push({
name: "app",
type: "generic",
deps: packages.map((d) => ":" + d.name),
config: {
commands: appCmds,
},
});