Replies: 1 comment
-
I had a number of situations like this when I found a solution to my problem in the process of writing a question on StackOverflow 😄 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to understand the idiomatic way in premake to handle build commands
for code generation in a project. As a simple example, consider the
following directory structure:
In this example, the high level build steps for
myapp
would be:generator
application which will be used for code generationgenerator
application built in the previous step, reading themyapp/src/data/error_codes.json
file as input and writingerror_codes.{h,cpp}
files as output to thebuild/generated
directorybuild/generated/error_codes.{h,cpp}
as a library projectcalled
error_codes
myapp
executable which includesbuild/generated/error_codes.h
and links the
error_codes
library projectOmitting all but the important bits for brevity, I imagine the
premake5.lua
for this would something like:
There are a few problems with the above:
error_codes
project no-ops due to a chicken/egg problembuild/generated/error_codes.cpp
filedoesn't exist yet because the pre-build command hasn't run
there's nothing to build
generator
project sort of works as a hacky workaround but isn't ideal
error_codes.json
will not result inerror_codes
projectrebuilding
generator application
Ideally, I'd want the following criteria to be met:
generator
is rebuilt, rebuild theerror_codes
projectStaticLib
project depends on an
ConsoleApp
projectsrc/data/error_codes.json
is modified, rebuild theerror_codes
projectsrc/data/*.json
to thefiles { ... }
directivewould accomplish this but it doesn't seem like it
I feel like the easiest way to accomplish the above would be to leave the
generation step as a pre-build command and make sure it always runs but I
don't think there's an option for that.
I feel like code generation is a pretty common build step so I'd be surprised
if I'm the first person to encounter this but I'm struggling to find a
solution.
My only other thought process is to premake the generator separately and do
code generation completely outside premake. Like:
generator
appgenerator
appmyapp
But it would be a lot more convenient to just premake the whole thing at once.
Edit: And after writing this whole thing up it seems like pre-build steps are running consistently for me now. Pretty sure all I did was update to latest version of premake and move the
prebuildcommands
to the end of myproject
definition so maybe this was a bug that was fixed. Closing this outBeta Was this translation helpful? Give feedback.
All reactions