Skip to content

Commit c66ad90

Browse files
authored
build: Allow codegen-only to produce the templated main.go (#133)
Fixes #131.
1 parent 8748f8a commit c66ad90

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (b *buildCmd) do() error {
349349
}
350350
}
351351

352-
if b.parseOnly || b.codeGenOnly {
352+
if b.parseOnly {
353353
return nil
354354
}
355355

@@ -360,6 +360,7 @@ func (b *buildCmd) do() error {
360360
buildDir: b.outDir,
361361
outFile: b.outFile,
362362
verbose: b.verbose,
363+
codeGenOnly: b.codeGenOnly,
363364
}
364365
if err := buildProject(context.Background(), params); err != nil {
365366
return fmt.Errorf("building project: %w", err)
@@ -760,6 +761,7 @@ type buildParams struct {
760761
buildDir string
761762
outFile string
762763
verbose bool
764+
codeGenOnly bool
763765
}
764766

765767
// buildProject builds the Go program made up of the user's compiled .up
@@ -798,6 +800,13 @@ func buildProject(_ context.Context, b buildParams) error {
798800
b.outFile = filepath.Join(b.buildDir, "bin", b.projectName)
799801
}
800802

803+
if b.codeGenOnly {
804+
if b.verbose {
805+
fmt.Printf("codegen only, not building executable\n")
806+
}
807+
return nil
808+
}
809+
801810
args := []string{"build", "-o", b.outFile, filepath.Join(pkgName, "cmd", b.projectName)}
802811
if b.verbose {
803812
fmt.Printf("build command: go %s\n", strings.Join(args, " "))

0 commit comments

Comments
 (0)