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 plugin: use build snaps to search paths #2399
cmake plugin: use build snaps to search paths #2399
Conversation
Remove the dependency on make and use native primitives to build using cmake instead. This allows the build to be configured to use e.g.; ninja. LP: #1802314 Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
Leverage CMAKE_FIND_ROOT_PATH to add search paths for things like cmake's find_package and find_library to search within the list of build-snaps provided for a part. LP: #1802314 Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
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.
lgtm 👍
(builds on 2397; this PR on top is horrible to read 🤢 )
Codecov Report
@@ Coverage Diff @@
## master #2399 +/- ##
=========================================
Coverage ? 90.09%
=========================================
Files ? 196
Lines ? 12885
Branches ? 1955
=========================================
Hits ? 11609
Misses ? 876
Partials ? 400
Continue to review full report at Codecov.
|
snapcraft/plugins/cmake.py
Outdated
|
||
configflags = [] | ||
root_path_appended = False | ||
for configflag in self.options.configflags: |
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.
@sergiusens At the time we couldn't think of a way to write the conditional in a more straight forward way. I've since put a stop-gap in place in our tooling, where I ended up writing it like this (untested python translation):
configflags = self.options.configflags[:]
for flag in self.options.configflags:
parts = flag.split('=', 2)
if parts[0] != "-DCMAKE_FIND_ROOT_PATH":
continue
configflags.remove(flag)
build_snap_paths.append(parts[1])
if build_snap_paths:
configflags.append("-DCMAKE_FIND_ROOT_PATH={}".format(";".join(build_snap_paths)))
i.e. instead of handling the append as a condition I've turned it it into a cleanup problem. the loop now pulls the original flag out of the list to "clean it up" and push its value into the path list so it gets joined along with all the other values.
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 chose a different approach, thanks for the nudge 😄
Looks better than before 👍 |
./runtests.sh static
?./runtests.sh tests/unit
?