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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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
myappwould be:generatorapplication which will be used for code generationgeneratorapplication built in the previous step, reading themyapp/src/data/error_codes.jsonfile as input and writingerror_codes.{h,cpp}files as output to thebuild/generateddirectorybuild/generated/error_codes.{h,cpp}as a library projectcalled
error_codesmyappexecutable which includesbuild/generated/error_codes.hand links the
error_codeslibrary projectOmitting all but the important bits for brevity, I imagine the
premake5.luafor this would something like:
There are a few problems with the above:
error_codesproject no-ops due to a chicken/egg problembuild/generated/error_codes.cppfiledoesn't exist yet because the pre-build command hasn't run
there's nothing to build
generatorproject sort of works as a hacky workaround but isn't ideal
error_codes.jsonwill not result inerror_codesprojectrebuilding
generator application
Ideally, I'd want the following criteria to be met:
generatoris rebuilt, rebuild theerror_codesprojectStaticLibproject depends on an
ConsoleAppprojectsrc/data/error_codes.jsonis modified, rebuild theerror_codesprojectsrc/data/*.jsonto 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:
generatorappgeneratorappmyappBut 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
prebuildcommandsto the end of myprojectdefinition so maybe this was a bug that was fixed. Closing this outBeta Was this translation helpful? Give feedback.
All reactions