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

Feature: support OSX frameworks #5552

Merged
merged 5 commits into from Sep 27, 2019
Merged

Conversation

SSE4
Copy link
Contributor

@SSE4 SSE4 commented Jul 29, 2019

Changelog: Feature: Better support OSX frameworks by declaring cppinfo.frameworks.
Docs: conan-io/docs#1414

closes: #5245

part 1
extend CppInfo and DepsCppInfo classes to support frameworks and framework_paths properties.
right now many of bincrafters recipes have the following code to manage frameworks:

def package_info(self):
    ...
    frameworks = ['CoreVideo', 'CoreMedia', 'CoreGraphics', 'CoreFoundation', 'OpenGL', 'Foundation']
    for framework in frameworks:
        self.cpp_info.exelinkflags.append("-framework %s" % framework)
    self.cpp_info.sharedlinkflags = self.cpp_info.exelinkflags

so, frameworks are currently managed with exelinkflags/sharedlinkflags, which is kinda ugly. proposed changes allow to write just something like:
by default, self.cpp_info.framework_paths includes rootpath, not sure if it's wise choice, need to check where frameworks are usually installed by conventions (bin vs lib vs Frameworks vs root)

def package_info(self):
    ...
    self.cpp_info.frameworks = ['CoreVideo', 'CoreMedia', 'CoreGraphics', 'CoreFoundation', 'OpenGL', 'Foundation']

part 2
set DYLD_FRAMEWORK_PATH in RunEnvironment and ConanFile.run, similar to how DYLD_LIBRARY_PATH is currently set. see https://www.manpagez.com/man/1/dyld/ for the details.

part 3
use frameworks and framework_paths in generators. right now implemented only in cmake generator via find_library - frameworks found are appended to the CONAN_LIBS.

changes were tested on SFML branch: https://github.com/bincrafters/conan-sfml/compare/framework/2.5.1?expand=1, which allows to compile frameworks instead of regular libraries via options: -o sfml:shared=True -o sfml:framework=True. as result, it creates two frameworks: SFML.framework and sfml-system.framework.

TODO:

  • write some tests

  • decide which directories should be used by default in self.cpp_info.framework_paths

  • implement other generators (probably, xcode, compiler_args, virtualenv/virtualrunenv, other cmake_* generators)

  • check if we have to change something about editable mode in case of frameworks?

  • Refer to the issue that supports this Pull Request.

  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.

  • I've read the Contributing guide.

  • I've followed the PEP8 style guides for Python code.

  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

@SSE4
Copy link
Contributor Author

SSE4 commented Jul 29, 2019

@jgsogo please take a look at the proposal and lemme know what do you think

@jgsogo
Copy link
Contributor

jgsogo commented Jul 29, 2019

I know nothing about apple frameworks 😞 . If this is going for the next release (cc @lasote) I need to have a look at it almost from scratch, right now I can only say that it looks like promising.

@jgsogo
Copy link
Contributor

jgsogo commented Aug 9, 2019

Can you fix the failing test, @SSE4? As the issue is tagged for v1.19, let's try to push this PR forward

@jgsogo jgsogo added this to the 1.19 milestone Aug 9, 2019
@SSE4
Copy link
Contributor Author

SSE4 commented Aug 9, 2019

@jgsogo yeah, I am planning to add tests, but before going too deep, I want some feedback, if it's a right direction to go or not

@lasote lasote removed this from the 1.19 milestone Aug 19, 2019
@lasote
Copy link
Contributor

lasote commented Aug 19, 2019

In general, I think the idea is ok. The default root dir I don't think is a good choice. We have seen for c3i that it is difficult to check if a package is built correctly without a well know folder structure. I don't know which one is the best, but we could enforce a new one if needed (convention).

Please add tests, make a proposition for the default folder and specify which other generators are you going to adapt for the apple frameworks (if any)

@SSE4
Copy link
Contributor Author

SSE4 commented Aug 19, 2019

yeah, I think:

  1. I'll use Frameworks as a default frameworks root directory
  2. I'll use the following generators for the start cmake*, pkg-config, xcode, compiler-flags, virtual*env

@SSE4 SSE4 marked this pull request as ready for review August 30, 2019 10:43
@SSE4
Copy link
Contributor Author

SSE4 commented Aug 30, 2019

@jgsogo @lasote
changes are ready for the review now:

  1. tests were added
  2. supported generators so far: json, compiler_args, xcode, cmake, cmake-multi, pkg-config, txt
  3. CppInfo and DepsCppInfo now have frameworks and framework_paths attributes
  4. DYLD_FRAMEWORK_PATH is now set by RunEnvironment (and virtualrunenv)
  5. default framework directory is Frameworks

@SSE4 SSE4 force-pushed the frameworks branch 2 times, most recently from 1c46219 to 1d7d70a Compare August 30, 2019 11:24
@SSE4 SSE4 changed the title WIP: OSX frameworks OSX frameworks Sep 4, 2019
@SSE4
Copy link
Contributor Author

SSE4 commented Sep 4, 2019

just removed WIP title, as it was confusing

@SSE4 SSE4 changed the title OSX frameworks Feature: support OSX frameworks Sep 4, 2019
@lasote lasote added this to the 1.19 milestone Sep 13, 2019
@lasote
Copy link
Contributor

lasote commented Sep 13, 2019

@SSE4 Write and link the docs ASAP. It really helps to understand the PR (and it is needed to complete a feature)

@SSE4
Copy link
Contributor Author

SSE4 commented Sep 13, 2019

@lasote docs added

Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

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

Looking good, some important comments

conans/client/generators/compiler_args.py Show resolved Hide resolved
conans/client/generators/cmake.py Outdated Show resolved Hide resolved
conans/client/generators/pkg_config.py Outdated Show resolved Hide resolved
conans/client/generators/xcode.py Show resolved Hide resolved
conans/model/build_info.py Outdated Show resolved Hide resolved
conans/client/generators/cmake.py Show resolved Hide resolved
Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

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

Add a test for find package

conans/client/generators/compiler_args.py Outdated Show resolved Hide resolved
conans/client/generators/pkg_config.py Outdated Show resolved Hide resolved
@lasote lasote assigned memsharded and unassigned lasote Sep 26, 2019
Signed-off-by: SSE4 <tomskside@gmail.com>
@SSE4
Copy link
Contributor Author

SSE4 commented Sep 26, 2019

@lasote added cmake_find_package_frameworks_test

@memsharded memsharded merged commit 8a6df42 into conan-io:develop Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mac: virtualrunenv should set DYLD_FRAMEWORK_PATH
4 participants