The -codegen-only flag does not generate cmd code.
When using the pushup build -codegen-only flag the _runtime/cmd/main.go templating is not performed. So you get different results from:
pushup build
versus
pushup build -codegen-only
cd build
go build
An example:
$ pushup new thing1
$ cd thing1
$ pushup build
//
// // ////// //
// // // // ////// ////// // // //////
////// // // //// // // // // // //
// // // //// // // // // // //
// ////// ////// // // ////// //////
//
//
$ tree build
build
├── app.go
├── bin
│ └── myproject
├── cmd
│ └── myproject
│ └── main.go
├── default.layout.up.go
├── index.up.go
├── pushup_support.go
├── src
│ └── pages
│ └── index.up
└── static
├── htmx.min.js
└── style.css
$ rm -rf build
$ pushup build -codegen-only
//
// // ////// //
// // // // ////// ////// // // //////
////// // // //// // // // // // //
// // // //// // // // // // //
// ////// ////// // // ////// //////
//
//
$ (cd build && go build)
$ tree build
build
├── app.go
├── default.layout.up.go
├── index.up.go
├── pushup_support.go
├── src
│ └── pages
│ └── index.up
└── static
├── htmx.min.js
└── style.css
Good catch - the runtime main I consider not codegen per se (as in lowering Pushup markup to Go code) and more a "linking" step but that's confusing. Ultimately I want that stuff to be part of an API library that only requires the thinnest main.go wrapper.
I think separating these steps into commands where you can stop just short of the next one makes sense to facilitate different use cases. However, I think regardless of what you call the steps, what is missing today is a step that gives you the complete source go just before go build is run. In my case I'm trying to deploy this to Google App Engine with the gcloud utility. I need to avoid the generated code being inside the source directory and also provide the application to GAE as a module, allowing it to make assumptions about the binary name and thus start it up correctly. To make it work I am:
- Clearing my own build dir with
rm -rf gae && mkdir -p gae. - Having
pushupdo codegen withcd src && pushup build -codegen-only -project thesignup -out-dir ../gae/build. - Bringing the module definitions into the build dir with
cp src/go.mod src/go.sum gae. This allows Google's Cloud Build to replicate the same dependency management I'm doing locally. If I usepushup buildthis bit is missed. - Interpolating the cmd runtime code as my own
main.gowithsed -e 's#[{][{][.]ProjectPkg[}][}]#adhoc/thesignup/build#' ../../pushup/_runtime/cmd/main.go > gae/main.go. This is what makes the binary match the module name, in line with App Engine's expectations. - Doing a build locally as Cloud Build would do it in order to get representative errors more quickly:
cd gae && go build - Copying my GAE app definition into the build dir with
cp app.yaml gae. This will eventually be generated based ongo.modsince the golang version declarations need to match. - And finally deploying with
cd gae && gcloud app deploy app.yaml
It seems like the current -codegen-only is targeting the use case where the pushup-generated code is embedded in another application. I want to generate the source for a standalone application but let Cloud Build build it, which is where the module requirement comes into play.
I see now. Thanks for writing out those steps. There's very simple fix for this for the current version of Pushup.