Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Allow codegen-only to produce the templated main.go #133

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 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 All @@ -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)
Expand Down Expand Up @@ -760,6 +761,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 +800,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