From 41fe0bc40e1b9cc16475a6a863bcfca36b1fccf8 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Wed, 16 Oct 2024 12:24:03 -0500 Subject: [PATCH 1/2] build: Allow codegen-only to produce the templated main.go --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 418d4aa..8a5392d 100644 --- a/main.go +++ b/main.go @@ -349,7 +349,7 @@ func (b *buildCmd) do() error { } } - if b.parseOnly || b.codeGenOnly { + if b.parseOnly { return nil } @@ -760,6 +760,7 @@ type buildParams struct { buildDir string outFile string verbose bool + codeGenOnly bool } // buildProject builds the Go program made up of the user's compiled .up @@ -798,6 +799,13 @@ func buildProject(_ context.Context, b buildParams) error { b.outFile = filepath.Join(b.buildDir, "bin", b.projectName) } + if b.codeGenOnly { + if b.verbose { + fmt.Printf("codegen only, not building executable\n") + } + return nil + } + args := []string{"build", "-o", b.outFile, filepath.Join(pkgName, "cmd", b.projectName)} if b.verbose { fmt.Printf("build command: go %s\n", strings.Join(args, " ")) From 24db1e1d37f1e03fb06587054ed718dc14c8db63 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Wed, 16 Oct 2024 12:31:51 -0500 Subject: [PATCH 2/2] Actually set the value --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 8a5392d..de8a83b 100644 --- a/main.go +++ b/main.go @@ -360,6 +360,7 @@ func (b *buildCmd) do() error { buildDir: b.outDir, outFile: b.outFile, verbose: b.verbose, + codeGenOnly: b.codeGenOnly, } if err := buildProject(context.Background(), params); err != nil { return fmt.Errorf("building project: %w", err)