-
Notifications
You must be signed in to change notification settings - Fork 210
cmake: flatcc_generate_sources + add_custom_command + crossbuild + ci #171
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
Conversation
|
Thanks. It sounds a bit of a hack to add generated files to executables, but if it works ... Do you really need to all output files of flatcc all these places? I worked with a meson build where I just used the most important output file as a dependency because Ninja does not support multiple output files (there is an issue on it). Note that flatcc supports generating gnu make style .dep files, but it probably isn't helpful here. I used it with the meson build where it worked fine. On discussion in related pr on build dependencies. things are coming slowly back to me. I think the benchmarks tests cannot be built with CMake as it is, though I do not recall why. https://github.com/dvidelabs/flatcc/tree/master/test/benchmark They are building on the old meson branch I once made: |
|
Can you please explain exactly what the problem is that you try solve: You mentioned in other PR that tests were always building. But when I use ninja build incrementally, nothing gets build that isn't out of data, at least that I have noticed. Maybe this differ for Make? |
|
On current master, when you do: cmake .. -DFLATCC_TEST=ON -DFLATC_INSTALL=ON
make
make installThe test executables are rebuilt on every make invocation. This is because flatcc is re-run every time. CMake detects that the dependencies of the tests (the includes) are newer and will rebuild the sources + executables. I didn't test the ninja behavior of current master. I'm currently looking into the Windows failure,. |
|
Right, I see that now. ninja -v -j1 |
|
You may also want to look into ci-more branch, especially on Windows to ensure that MSVC 2010 is supported. |
|
The error on appveyor was due to the interaction between a parallel build and cmake's On cmake, I have added a custom target in the json tests because that one is the only location where the sources generated by one This json test approach can be adopted by @wdobbe 's cmake script . I also added a comment how this can be simplified if the cmake minimum version would get bumped to 3.1. Also note that cmake 3.19.1 emits the following warning on your cmake script: |
|
flatcc has a |
No not that I can recall. |
|
Well, the dependency file is actually a source to dependency list, but I think it is constrained because of Ninja. It's been a while. Like this: EDIT : WRONG or ouput1 : src1 src2 src3 EDIT: RIGHT So no that does not give the output. |
|
@mikkelfj It is useful though for consumers of flatcc. cmake can automatically deduce the dependency information. |
|
Yes but it would not be good for the intended purpose because these are separate build steps, especially considering how ninja works and how build generators works towards it. It would probably need to be a different switch. The build model works like multiple sources to a single target in the build graph. Another option would be to ask flatcc to produce a flag file once it has successfully written all output files. But can also do that in a wrapper command: |
|
I'm on Windows now, but I tested it with Please also note that I have enabled |
|
Take a look at the meson build rules on the meson branch: https://github.com/dvidelabs/flatcc/blob/meson/rules/meson.build This build will detect if you make a change in a the third level include file and build a file that depends on any generated output, provided that file has set the fbs file as a dependency. |
Ahh, that was the one - it was four years ago ... thanks! |
|
Ninja should have fixed this now: |
|
I don't really have time to try understand the implications of this right now, but if flatcc does not already support the improved dep file format, I'll certainly be adding it at some point. |
|
Line 209 in ce931d0
|
|
Ah, I misread the monster example. But for the dependency information on other fbs sources, that is not fixed by this. @wdobbe I will take a go at it.. |
|
I'm not sure that I follow - where are the three input files listed? link? flatcc has the -r (--recursive) option to generate everything included, or just the file listed. |
|
I was hinting at Perhaps I should create a cmake script that applies a regex to the fbs sources recursively to grep all dependencies. This will make it work for flatcc itself + its users. |
Ah right. This is something I'd really like to avoid because in real life large projects this can become difficult to manage when schemas are modified and there are many included schema files. But you gotta do what you gotta do. I'm not too keen on hacking a new option in flatcc either, but if it can work with a correct and improved depfile generation, I think that is the way to go. Only I'm not going to fix that right away. It also needs a backwards compatibility mode I suspect. |
9486779 to
b0664cc
Compare
|
@wdobbe @mikkelfj |
From which files? The dep files?
Much appreciated. I presume you have seen the new issue I raised: #170 |
…ation when using find_package
…tem passing correct flags)
|
I rebased on top of master. @mikkelfj |
|
Is it ready? I thought you had abandoned it. |
I think so, I stopped pushing changes because I ran out of ideas 😄 |
|
OK, I'll have a look at some point. But I'll need to make a release before merging. Looking forward to CI fixes. |
|
I messed up my latest force push, but was able to recover using c723a5e. |
a8e7a8a to
d7f50b2
Compare
|
Sorry for not following up on this - we know have a functioning CI build again via #250. As discussed in #217, #217 (comment) this PR is probably doing too much at a time. A new PR #258 has been made. It also addresses the rebuild too much issue. @madebr and @midokura-xavi92 would mind having a look at this PR? It seems to be a fairly simple change, although it does depend on all output of a directory. |
|
I finally got some time to work on flatcc. I'm going to close this PR because we have several build updates going on including PR #258. You are still welcome to comment on that PR and introduce your ideas, but I can't have two major PR on the build system. The plan is make a release soon, before major updates to the build system. |
This pr does the following:
add_custom_commandto generate the sources. Add all generated sources literally toOUTPUTS.The key to don't have sources recompile is to add the generated sources to
add_executable.The flatcc maybe has an argument to return what files are generated, but this is work for #168: add cmake helper function to generate flatbuffer code #169.
flatccshould have an option that returns the generated sources (and nothing else).e.g.:
flatcc -d monster.fbsallows to know the dependant sources + generated sources.flatcc::runtime,flatcc::libflatcc,flatcc::cli) for the 2 libraries + executable, and use it everywhere.make installwill also create these 3 targets. This means that the script by #168: add cmake helper function to generate flatbuffer code #169 can be used by flatcc itself + users of flatcc (by using imported targets). Soflatcccan be used as:I have tested it on cmake 2.8.12.1 (with gmake and ninja).