Skip to content
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

Merged
merged 10 commits into from
Jan 31, 2022

Conversation

hartwork
Copy link
Contributor

@gkdr things that are worth noting:

  • Because this pull requests is not tiny, the individual commits may help tell a story during review.
  • The message client uses a function 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.
  • Tests are working fine on Linux but fail on Windows. The build logs show test execution output. I'll need help understanding Windows test failure. Should be fixed but not necessarily a blocker in my eyes.
  • I have left resolving the .c file includes in the test suite is left for later, maybe after this pull request.

Let me know what you think 🍻

@hartwork hartwork force-pushed the cmake-linux-msys2 branch 4 times, most recently from 65c4ed1 to 8ef19ae Compare January 25, 2022 02:12
Copy link
Owner

@gkdr gkdr left a 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
Copy link
Owner

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

Copy link
Contributor Author

@hartwork hartwork Jan 26, 2022

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.

Copy link
Owner

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
Copy link
Owner

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?

Copy link
Contributor Author

@hartwork hartwork Jan 26, 2022

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.

Copy link
Contributor Author

@hartwork hartwork Jan 26, 2022

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?

Copy link
Contributor Author

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.

Copy link
Owner

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 😬

Copy link
Contributor Author

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
Copy link
Owner

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Owner

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
Copy link
Owner

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.

Copy link
Contributor Author

@hartwork hartwork Jan 26, 2022

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.

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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
Copy link
Owner

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: Related links:

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.

Copy link
Contributor Author

@hartwork hartwork Jan 26, 2022

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})
  1. Test property DEPENDS

Copy link
Owner

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
Copy link
Owner

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)
Copy link
Owner

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?

Copy link
Contributor Author

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.

@hartwork hartwork force-pushed the cmake-linux-msys2 branch 3 times, most recently from fd5a841 to f23f542 Compare January 28, 2022 13:46
@hartwork hartwork requested a review from gkdr January 28, 2022 13:47
@gkdr
Copy link
Owner

gkdr commented Jan 28, 2022

i think i'll create another release before i merge this, so i can update the lurch submodule with some of the changes up until now without having to redo the build.

@hartwork
Copy link
Contributor Author

i think i'll create another release before i merge this, so i can update the lurch submodule with some of the changes up until now without having to redo the build.

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 dev or a commit on a new branch release-0-3-7. So I don't see the blocker, personally.

@gkdr
Copy link
Owner

gkdr commented Jan 29, 2022

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.

@hartwork
Copy link
Contributor Author

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.

@gkdr gkdr merged commit 31f6922 into gkdr:dev Jan 31, 2022
@hartwork hartwork deleted the cmake-linux-msys2 branch January 31, 2022 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants