Skip to content

Commit

Permalink
feat(jsii-pacmak): allow disabling go build conditionally (#4196)
Browse files Browse the repository at this point in the history
In CDKTF this step causes our examples to take up to 24GB of Ram and ~5 minutes to have the bindings generated. We split our code into a lot of modules, so if a user just ran `go run ...` and only the parts needed would be compiled they can save a lot of time and resources.
  • Loading branch information
DanielMSchmidt committed Jul 26, 2023
1 parent 906c24d commit 7fc7987
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/jsii-pacmak/lib/targets/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ export class Golang extends Target {
);
return Promise.reject(e);
}
await go('build', ['-modfile', localGoMod.path, './...'], { cwd: pkgDir });

if (process.env.JSII_BUILD_GO) {
// This step is taken to ensure that the generated code is compilable
await go('build', ['-modfile', localGoMod.path, './...'], {
cwd: pkgDir,
});
}

// delete local.go.mod and local.go.sum from the output directory so it doesn't get published
const localGoSum = `${path.basename(localGoMod.path, '.mod')}.sum`;
Expand Down

0 comments on commit 7fc7987

Please sign in to comment.