Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/local-app/BUILD.js
2492 views
1
const generatePackage = function (goos, goarch, binaryName, mainFile) {
2
let name = binaryName + "-" + goos + "-" + goarch;
3
let dontTest = !(goos === "linux" && goarch === "amd64");
4
if (goos === "windows") {
5
binaryName += ".exe";
6
}
7
let pkg = {
8
name,
9
type: "go",
10
srcs: ["go.mod", "go.sum", "**/*.go", "version.txt"],
11
deps: [
12
"components/supervisor-api/go:lib",
13
"components/gitpod-protocol/go:lib",
14
"components/local-app-api/go:lib",
15
"components/public-api/go:lib",
16
],
17
env: ["GOOS=" + goos, "GOARCH=" + goarch, "CGO_ENABLED=0"],
18
config: {
19
packaging: "app",
20
dontTest: dontTest,
21
buildCommand: [
22
"sh",
23
"-c",
24
// We need to set GOARCH explicitly here because the `defaultVariant` in `WORKSPACE.yaml` overrides it for the workspace
25
`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}`,
26
],
27
},
28
binaryName,
29
};
30
return pkg;
31
};
32
33
const packages = [];
34
for (binaryName of ["gitpod-local-companion", "gitpod-cli"]) {
35
for (goos of ["linux", "darwin", "windows"]) {
36
for (goarch of ["amd64", "arm64"]) {
37
packages.push(generatePackage(goos, goarch, binaryName, "main/" + binaryName + "/main.go"));
38
}
39
}
40
}
41
42
let appCmds = packages.map((p) => {
43
let binName = p.name;
44
if (p.name.includes("windows")) {
45
binName += ".exe";
46
}
47
return ["cp", "components-local-app--" + p.name + "/" + p.binaryName, "bin/" + binName];
48
});
49
appCmds.unshift(["mkdir", "bin"]);
50
appCmds.push(["sh", "-c", "rm -rf components-*"]);
51
52
packages.push({
53
name: "app",
54
type: "generic",
55
deps: packages.map((d) => ":" + d.name),
56
config: {
57
commands: appCmds,
58
},
59
});
60
61