-
Notifications
You must be signed in to change notification settings - Fork 13
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
CMake build system + msys2 windows binaries CI #32
Conversation
65c4ed1
to
8ef19ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fantastic, thank you. definitely a major step towards the automated windows build of lurch
. i guess i'm still a bit confused about cmake, so a few questions.
name: coverage_${{ matrix.libsignal }} | ||
path: coverage/ | ||
name: axc_coverage_shared_${{ matrix.BUILD_SHARED_LIBS }}_pthreads_${{ matrix.AXC_WITH_PTHREADS }} | ||
path: build/coverage*.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: i should probably replace this with something like https://github.com/codecov/codecov-action
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will be non-trivial, e.g. because we have four different sets of coverage results right now.
My vote for (1) adding submission rather than replacing artifact upload and (2) doing that after the merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, definitely after the merge. and adding sounds good too :D
|
||
``` | ||
mkdir build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can cmake do this for me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating the build directory? I am not aware it would do that, no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out there is cmake -B build
. I'm not sure if I like having ${PWD}
being in source dir rather than build dir at the time of that call. Is it about the readme or the CI or both? If you're a big fan of cmake -B build
we can do that, instead. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the CI use -B build
rather than mkdir
and cd
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, that feels a lot better. to be honest, it's about my own workflow. i like to do everything in the project root, some sort of build
target that puts its stuff in its own directory so it can easily be ignored/cleaned, and some sort of clean
target to get to a clean state. i'm considering putting a makefile in the project root until i remember the commands 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm considering putting a makefile in the project root until i remember the commands 😬
Please note that unless you are using Ninja locally or name the file GNUmakefile
, it will clash with the one generated by CMake. I'd personally recommend less .github/workflows/linux.yml
whenever you forget a command. Just an idea.
|
||
ninja -v all | ||
ninja -v test # potentially with CTEST_OUTPUT_ON_FAILURE=1 in the environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this env var change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When tests fail, with the variable you get the full test run stdout with error details and without it you'd only get a summary like this one:
# ninja test
[0/1] Running tests...
Test project [..]/axc/build_new
Start 1: test_client
1/2 Test #1: test_client ......................***Failed 2.35 sec
Start 2: test_store
2/2 Test #2: test_store ....................... Passed 1.29 sec
50% tests passed, 1 tests failed out of 2
Total Test time (real) = 3.65 sec
The following tests FAILED:
1 - test_client (Failed)
Errors while running CTest
Output from these tests are in: [..]/axc/build_new/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
FAILED: CMakeFiles/test.util
cd [..]/axc/build_new && /usr/bin/ctest --force-new-ctest-process
ninja: build stopped: subcommand failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: CMAKE_CTEST_ARGUMENTS
would allow us to pass --output-on-failure
to CTest by default I suppose (which would make CTEST_OUTPUT_ON_FAILURE=1
unnecessary), but it needs CMake >=3.17 and we have 3.16 on Ubuntu 20.04 only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i figured something like that, however i wasn't aware of how much of the output is usually swallowed. almost a bit unsettling how quiet it is now 😬
|
||
ninja -v all | ||
ninja -v test # potentially with CTEST_OUTPUT_ON_FAILURE=1 in the environment | ||
ninja -v install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can there also be a target like clean
? a target of that name exists, but it does not seem to clean everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which files are left over that you'd want ninja -v clean
to remove? Probably libaxc.pc
. Anything else?
There is ADDITIONAL_CLEAN_FILES
as a target property as well as a directory property that we could leverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding set_target_properties(axc PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/libaxc.pc)
now to have target clean
remove built file libaxc.pc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i checked again, apparently it does nothing at all:
ninja: Entering directory `build'
[2/2] Cleaning all built files...
Cleaning... 0 files.
doesn't really matter if its in it's own dir, just wondered if i'm using it wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it had nothing to do anymore? It does clean things for me once:
# ninja -v clean
[1/2] /usr/bin/cmake -DCONFIG= -P CMakeFiles/clean_additional.cmake
[2/2] /usr/bin/ninja -t clean
Cleaning... 12 files.
^^
# ninja -v clean
[1/2] /usr/bin/cmake -DCONFIG= -P CMakeFiles/clean_additional.cmake
[2/2] /usr/bin/ninja -t clean
Cleaning... 0 files.
|
||
ninja -v all | ||
ninja -v test # potentially with CTEST_OUTPUT_ON_FAILURE=1 in the environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test
target does not build the test files, i always have to call the all
target first. is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, let me say that I would love ninja test
to depend on a full build. Using add_dependencies(all [..])
does not work because we'd get error non-existent target "all"
. Same for add_dependencies(test all)
. I'm out of other ideas right now. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: Related links:
- CMake upstream ticket https://gitlab.kitware.com/cmake/cmake/-/issues/8774
- StackOverflow discussion https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests
Seems like a time sink of limited value to me, to be honest. If you spot a great solution in there somewhere please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PPS: I should note that two of the advertised workarounds do not work:
- add_test(NAME ${_target} COMMAND ${_target})
+ add_test(NAME run_${_target} COMMAND ${_target})
+ add_dependencies(run_${_target} ${_target})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right that it's not terribly important. quick search also just resulted in the workarounds you tried, i'll leave it at that.
|
||
ninja -v all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ninja seems to swallow the colored output. is there some flag to cmake that can fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting catch. I found this article with both an explanation and a suggested fix. It's default could be made to depend on whether CMake Generator Ninja
is used or not. Happy to improve on that aspect, but I'd still vote for merging before improving to untangle dependencies. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: Going back to make would not fix the issue for those users with Ninja but is also an option, in theory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PPS: I confirm that -fdiagnostics-color=always
brings the color back for GCC with Ninja. A full build is 0.7s with Ninja and 1.6s with GNU make on my machine.
endif() | ||
|
||
if(AXC_WITH_PTHREADS) | ||
target_link_libraries(${_target} PRIVATE Threads::Threads) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this really work on windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, msys2 has mingw-w64-winpthreads-git
and it's part of group mingw-w64-x86_64-toolchain
that we install in CI. Glib2 wouldn't be happy without it.
fd5a841
to
f23f542
Compare
i think i'll create another release before i merge this, so i can update the |
A "last" release with the Makefile sounds good, but does that block the merge? The submodule is set to any commit you want, e.g. either the commit before the merge to |
setting the submodule is one thing, and setting the tag and making a "github release" out of it to notify people is another. for the latter, i'd like to have the changelog in order, which i think just means setting the right date as a header. |
I'm not following. I'll ask you about it in detail on Monday. |
f23f542
to
664a54c
Compare
664a54c
to
1e5cb97
Compare
@gkdr things that are worth noting:
getline
that MinGW doesn't have out of the box, so that is only compiled on Linux for the moment. Could be fixed but not a blocker in my eyes.Let me know what you think 🍻