Skip to content

Commit

Permalink
- support OSX frameworks
Browse files Browse the repository at this point in the history
Signed-off-by: SSE4 <tomskside@gmail.com>
  • Loading branch information
SSE4 committed Sep 13, 2019
1 parent 000bec3 commit f24cfb2
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 29 deletions.
11 changes: 6 additions & 5 deletions howtos/manage_shared_libraries/env_vars.rst
Expand Up @@ -138,15 +138,16 @@ runtime. In Windows, it is enough if the package added its binary folder to the

Security restrictions might apply in OSX
(`read this thread <https://stackoverflow.com/questions/35568122/why-isnt-dyld-library-path-being-propagated-here>`_), so the
``DYLD_LIBRARY_PATH`` environment variable is not directly transferred to the child process. In that case, you have to use it explicitly in
``DYLD_LIBRARY_PATH`` and ``DYLD_FRAMEWORK_PATH` environment variables are not directly transferred to the child process. In that case, you have to use it explicitly in
your *conanfile.py*:
.. code-block:: python
def test(self):
# self.run("./myexe") # won't work, even if 'DYLD_LIBRARY_PATH' is in the env
with tools.environment_append({"DYLD_LIBRARY_PATH": [self.deps_cpp_info["toolA"].lib_paths]}):
self.run("DYLD_LIBRARY_PATH=%s ./myexe" % os.environ['DYLD_LIBRARY_PATH'])
def build(self):
env_build = RunEnvironment(self)
with tools.environment_append(env_build.vars):
# self.run("./myexetool") # won't work, even if 'DYLD_LIBRARY_PATH' and 'DYLD_FRAMEWORK_PATH' are in the env
self.run("DYLD_LIBRARY_PATH=%s DYLD_FRAMEWORK_PATH=%s ./myexetool" % (os.environ['DYLD_LIBRARY_PATH'], os.environ['DYLD_FRAMEWORK_PATH']))
Or you could use ``RunEnvironment`` helper described above.

Expand Down
11 changes: 7 additions & 4 deletions reference/build_helpers/run_environment.rst
Expand Up @@ -3,7 +3,7 @@
RunEnvironment
==============

The ``RunEnvironment`` helper prepares ``PATH``, ``LD_LIBRARY_PATH`` and ``DYLD_LIBRARY_PATH`` environment variables to locate shared libraries and executables of your requirements at runtime.
The ``RunEnvironment`` helper prepares ``PATH``, ``LD_LIBRARY_PATH``, ``DYLD_LIBRARY_PATH`` and ``DYLD_FRAMEWORK_PATH`` environment variables to locate shared libraries, frameworks and executables of your requirements at runtime.

.. warning::

Expand All @@ -29,6 +29,7 @@ This helper is specially useful if:
self.run("....")
# All the requirements bin folder will be available at PATH
# All the lib folders will be available in LD_LIBRARY_PATH and DYLD_LIBRARY_PATH
# All the framework_paths folders will be available in DYLD_FRAMEWORK_PATH
It sets the following environment variables:
Expand All @@ -42,21 +43,23 @@ It sets the following environment variables:
+--------------------+---------------------------------------------------------------------+
| DYLD_LIBRARY_PATH | Containing all the requirements ``lib`` folders. (OSX) |
+--------------------+---------------------------------------------------------------------+
| DYLD_FRAMEWORK_PATH| Containing all the requirements ``framework_paths`` folders. (OSX) |
+--------------------+---------------------------------------------------------------------+

.. important::

Security restrictions might apply in OSX
(`read this thread <https://stackoverflow.com/questions/35568122/why-isnt-dyld-library-path-being-propagated-here>`_), so the
``DYLD_LIBRARY_PATH`` environment variable is not directly transferred to the child process. In that case, you have to use it explicitly in
``DYLD_LIBRARY_PATH`` and ``DYLD_FRAMEWORK_PATH` environment variables are not directly transferred to the child process. In that case, you have to use it explicitly in
your *conanfile.py*:
.. code-block:: python
def build(self):
env_build = RunEnvironment(self)
with tools.environment_append(env_build.vars):
# self.run("./myexetool") # won't work, even if 'DYLD_LIBRARY_PATH' is in the env
self.run("DYLD_LIBRARY_PATH=%s ./myexetool" % os.environ['DYLD_LIBRARY_PATH'])
# self.run("./myexetool") # won't work, even if 'DYLD_LIBRARY_PATH' and 'DYLD_FRAMEWORK_PATH' are in the env
self.run("DYLD_LIBRARY_PATH=%s DYLD_FRAMEWORK_PATH=%s ./myexetool" % (os.environ['DYLD_LIBRARY_PATH'], os.environ['DYLD_FRAMEWORK_PATH']))
This is already handled automatically by the ``self.run(..., run_environment=True)`` argument.

Expand Down
6 changes: 6 additions & 0 deletions reference/conanfile/attributes.rst
Expand Up @@ -868,6 +868,10 @@ This object should be filled in ``package_info()`` method.
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.exelinkflags | Ordered list with linker flags (executables). Defaulted to ``[]`` (empty) |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.frameworks | Ordered list with the framework names (OSX), Defaulted to ``[]`` (empty) |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.frameworkdirs | Ordered list with frameworks search paths (OSX). Defaulted to ``["Frameworks"]`` |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.rootpath | Filled with the root directory of the package, see ``deps_cpp_info`` |
+--------------------------------+---------------------------------------------------------------------------------------------------------+

Expand Down Expand Up @@ -899,6 +903,8 @@ absolute paths:
+-------------------------------------------+---------------------------------------------------------------------+
| self.cpp_info.res_paths | Same as ``resdirs`` but transformed to absolute paths |
+-------------------------------------------+---------------------------------------------------------------------+
| self.cpp_info.framework_paths | Same as ``frameworkdirs`` but transformed to absolute paths |
+-------------------------------------------+---------------------------------------------------------------------+

To get a list of all the dependency names from ```deps_cpp_info```, you can call the `deps` member:

Expand Down
8 changes: 8 additions & 0 deletions reference/generators/cmake.rst
Expand Up @@ -45,6 +45,10 @@ Variables in *conanbuildinfo.cmake*
+--------------------------------+----------------------------------------------------------------------+
| CONAN_C_FLAGS_XXX | C flags |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORKS_XXX | Frameworks (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS_XXX | Framework folders (OSX) (default {CONAN_XXX_ROOT}/Frameworks |
+--------------------------------+----------------------------------------------------------------------+

- **Global declared variables**:

Expand Down Expand Up @@ -74,6 +78,10 @@ Variables in *conanbuildinfo.cmake*
+--------------------------------+----------------------------------------------------------------------+
| CONAN_C_FLAGS | Aggregated C flags |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORKS | Aggregated frameworks (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS | Aggregated framework folders (OSX) |
+--------------------------------+----------------------------------------------------------------------+

- **User information declared variables**:

Expand Down
4 changes: 4 additions & 0 deletions reference/generators/compiler_args.rst
Expand Up @@ -66,6 +66,10 @@ You can use the **compiler_args** generator directly to build simple programs:
+--------------------------------+----------------------------------------------------------------------+
| -D_GLIBCXX_USE_CXX11_ABI=1 | When setting libcxx == "libstdc++11" |
+--------------------------------+----------------------------------------------------------------------+
| -framework XXX | Corresponding to requirements `frameworks` (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| -F XXX | Corresponding to requirements `framework dirs` (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| Other flags | cxxflags, cflags, sharedlinkflags, exelinkflags (applied directly) |
+--------------------------------+----------------------------------------------------------------------+

Expand Down
4 changes: 2 additions & 2 deletions reference/generators/json.rst
Expand Up @@ -69,8 +69,8 @@ The dependencies is a list, with each item belonging to one dependency, and each
- ``description``
- ``rootpath``
- ``sysroot``
- ``include_paths``, ``lib_paths``, ``bin_paths``, ``build_paths``, ``res_paths``
- ``libs``
- ``include_paths``, ``lib_paths``, ``bin_paths``, ``build_paths``, ``res_paths``, ``framework_paths``
- ``libs``, ``frameworks``
- ``defines``, ``cflags``, ``cppflags``, ``sharedlinkflags``, ``exelinkflags``
- ``configs`` (only for multi config dependencies, see below)

Expand Down
8 changes: 8 additions & 0 deletions reference/generators/make.rst
Expand Up @@ -45,6 +45,10 @@ Variables per package. The ``<PKG-NAME>`` placeholder is filled with the name of
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_EXELINK_FLAGS_<PKG-NAME> | Executable linker flags |
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_FRAMEWORKS_<PKG-NAME> | Frameworks (OSX) |
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS_<PKG-NAME> | Framework folders (OSX) (default {CONAN_XXX_ROOT}/Frameworks |
+--------------------------------------+-------------------------------------------------------------------------+

Conan also declares some **global variables** with the aggregated values of all our requirements. The values are ordered in the right order
according to the dependency tree.
Expand Down Expand Up @@ -78,6 +82,10 @@ according to the dependency tree.
+--------------------------------+----------------------------------------------------------------------+
| CONAN_EXELINKFLAGS | Aggregated Executable linker flags |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORKS | Aggregated frameworks (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS | Aggregated framework folders (OSX) |
+--------------------------------+----------------------------------------------------------------------+

.. important::

Expand Down
8 changes: 8 additions & 0 deletions reference/generators/text.rst
Expand Up @@ -44,6 +44,10 @@ For each requirement ``conanbuildinfo.txt`` file declares the following sections
+-----------------------------+---------------------------------------------------------------------+
| [cppflags_XXX] | List with C++ compilation flags |
+-----------------------------+---------------------------------------------------------------------+
| [frameworks_XXX] | List with the framework names (OSX) |
+-----------------------------+---------------------------------------------------------------------+
| [frameworkdirs_XXX] | List with the frameworks search paths (OSX). |
+-----------------------------+---------------------------------------------------------------------+
| [rootpath_XXX] | Root path of the package |
+-----------------------------+---------------------------------------------------------------------+

Expand Down Expand Up @@ -77,3 +81,7 @@ The values are ordered in the right order according to the dependency tree.
+-----------------------------+---------------------------------------------------------------------+
| [cppflags] | List with aggregated C++ compilation flags |
+-----------------------------+---------------------------------------------------------------------+
| [frameworks] | List with aggregated framework names (OSX) |
+-----------------------------+---------------------------------------------------------------------+
| [frameworkdirs] | List with aggregated frameworks search paths (OSX). |
+-----------------------------+---------------------------------------------------------------------+
3 changes: 2 additions & 1 deletion reference/generators/virtualrunenv.rst
Expand Up @@ -45,4 +45,5 @@ Variables declared
+--------------------+---------------------------------------------------------------------+
| DYLD_LIBRARY_PATH | ``lib`` folders of your requirements. |
+--------------------+---------------------------------------------------------------------+

| DYLD_FRAMEWORK_PATH| ``framework_paths`` folders of your requirements. |
+--------------------+---------------------------------------------------------------------+
34 changes: 17 additions & 17 deletions reference/generators/xcode.rst
Expand Up @@ -15,20 +15,20 @@ The **xcode** generator creates a file named ``conanbuildinfo.xcconfig`` that ca

The file declare these variables:

+--------------------------------+----------------------------------------------------------------------+
| VARIABLE | VALUE |
+================================+======================================================================+
| HEADER_SEARCH_PATHS | The requirements `include dirs` |
+--------------------------------+----------------------------------------------------------------------+
| LIBRARY_SEARCH_PATHS | The requirements `lib dirs` |
+--------------------------------+----------------------------------------------------------------------+
| OTHER_LDFLAGS | `-lXXX` corresponding to library names |
+--------------------------------+----------------------------------------------------------------------+
| GCC_PREPROCESSOR_DEFINITIONS | The requirements definitions |
+--------------------------------+----------------------------------------------------------------------+
| OTHER_CFLAGS | The requirements cflags |
+--------------------------------+----------------------------------------------------------------------+
| OTHER_CPLUSPLUSFLAGS | The requirements cxxflags |
+--------------------------------+----------------------------------------------------------------------+
| FRAMEWORK_SEARCH_PATHS | The requirements root folders, so xcode can find packaged frameworks |
+--------------------------------+----------------------------------------------------------------------+
+--------------------------------+---------------------------------------------------------------------------+
| VARIABLE | VALUE |
+================================+===========================================================================+
| HEADER_SEARCH_PATHS | The requirements `include dirs` |
+--------------------------------+---------------------------------------------------------------------------+
| LIBRARY_SEARCH_PATHS | The requirements `lib dirs` |
+--------------------------------+---------------------------------------------------------------------------+
| OTHER_LDFLAGS | `-lXXX` corresponding to library names |
+--------------------------------+---------------------------------------------------------------------------+
| GCC_PREPROCESSOR_DEFINITIONS | The requirements definitions |
+--------------------------------+---------------------------------------------------------------------------+
| OTHER_CFLAGS | The requirements cflags |
+--------------------------------+---------------------------------------------------------------------------+
| OTHER_CPLUSPLUSFLAGS | The requirements cxxflags |
+--------------------------------+---------------------------------------------------------------------------+
| FRAMEWORK_SEARCH_PATHS | The requirements framework folders, so xcode can find packaged frameworks |
+--------------------------------+---------------------------------------------------------------------------+

0 comments on commit f24cfb2

Please sign in to comment.