Skip to content

Commit

Permalink
build: Allow codegen-only to produce the templated main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsmith committed Oct 16, 2024
1 parent 8748f8a commit 41fe0bc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (b *buildCmd) do() error {
}
}

if b.parseOnly || b.codeGenOnly {
if b.parseOnly {
return nil
}

Expand Down Expand Up @@ -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
Expand Down Expand 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, " "))
Expand Down

0 comments on commit 41fe0bc

Please sign in to comment.