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 plugin: use build snaps to search paths #2399

Merged
merged 6 commits into from Dec 4, 2018

Conversation

sergiusens
Copy link
Collaborator

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on bug reports?
  • If this is a new feature. Have you discussed the design on the forum?
  • Have you successfully run ./runtests.sh static?
  • Have you successfully run ./runtests.sh tests/unit?

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

@hsitter hsitter left a 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-io
Copy link

codecov-io commented Nov 11, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@305304e). Click here to learn what that means.
The diff coverage is 96.29%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2399   +/-   ##
=========================================
  Coverage          ?   90.09%           
=========================================
  Files             ?      196           
  Lines             ?    12885           
  Branches          ?     1955           
=========================================
  Hits              ?    11609           
  Misses            ?      876           
  Partials          ?      400
Impacted Files Coverage Δ
snapcraft/plugins/cmake.py 87.69% <96.29%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 305304e...e674645. Read the comment docs.


configflags = []
root_path_appended = False
for configflag in self.options.configflags:
Copy link
Contributor

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.

Copy link
Collaborator Author

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 😄

@sergiusens sergiusens changed the title Cmake find root build snaps cmake plugin: use build snaps to search paths Dec 3, 2018
@hsitter
Copy link
Contributor

hsitter commented Dec 4, 2018

Looks better than before 👍

@sergiusens sergiusens merged commit e2f7f38 into canonical:master Dec 4, 2018
@sergiusens sergiusens deleted the cmake-find-root-build-snaps branch December 4, 2018 16:27
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.

None yet

3 participants