From 7fc79876889504c2eae5888baeb8525d82a4a491 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Wed, 26 Jul 2023 18:17:35 +0200 Subject: [PATCH] feat(jsii-pacmak): allow disabling go build conditionally (#4196) 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. --- packages/jsii-pacmak/lib/targets/go.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/jsii-pacmak/lib/targets/go.ts b/packages/jsii-pacmak/lib/targets/go.ts index 41fd2297c7..3373341811 100644 --- a/packages/jsii-pacmak/lib/targets/go.ts +++ b/packages/jsii-pacmak/lib/targets/go.ts @@ -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`;