-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ConanCI bot
committed
May 18, 2023
1 parent
f413a36
commit 9d03c43
Showing
525 changed files
with
14,403 additions
and
1,793 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: ae65a433ae0bbbd5cea7e8f53e515f4a | ||
config: 8449a1f930bcc2a97858d0b4aa010df0 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ Examples | |
examples/tools | ||
examples/cross_build | ||
examples/config_files | ||
examples/graph | ||
examples/dev_flow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
2.0/_sources/examples/conanfile/layout/editable_components.rst.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
.. _examples_conanfile_layout_components_editables: | ||
|
||
Using components and editable packages | ||
-------------------------------------- | ||
|
||
It is possible to define components in the ``layout()`` method, to support the case of ``editable`` packages. | ||
That is, if we want to put a package in ``editable`` mode, and that package defines ``components``, it is | ||
necessary to define the components layout correctly in the ``layout()`` method. | ||
Let's see it in a real example. | ||
|
||
Please, first of all, clone the sources to recreate this project. You can find them in the | ||
`examples2.0 repository <https://github.com/conan-io/examples2>`_ in GitHub: | ||
|
||
.. code-block:: bash | ||
$ git clone https://github.com/conan-io/examples2.git | ||
$ cd examples2/examples/conanfile/layout/editable_components | ||
There we find a ``greetings`` subfolder and package, that contains 2 libraries, the ``hello`` library and the | ||
``bye`` library. Each one is modeled as a ``component`` inside the package recipe: | ||
|
||
.. code-block:: python | ||
:caption: greetings/conanfile.py | ||
class GreetingsConan(ConanFile): | ||
name = "greetings" | ||
version = "0.1" | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeDeps", "CMakeToolchain" | ||
exports_sources = "src/*" | ||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
# This "includedirs" starts in the source folder, wich is "src" | ||
# So the components include dirs is the "src" folder (includes are | ||
# intended to be included as ``#include "hello/hello.h"``) | ||
self.cpp.source.components["hello"].includedirs = ["."] | ||
self.cpp.source.components["bye"].includedirs = ["."] | ||
# compiled libraries "libdirs" will be inside the "build" folder, depending | ||
# on the platform they will be in "build/Release" or directly in "build" folder | ||
bt = "." if self.settings.os != "Windows" else str(self.settings.build_type) | ||
self.cpp.build.components["hello"].libdirs = [bt] | ||
self.cpp.build.components["bye"].libdirs = [bt] | ||
def package(self): | ||
copy(self, "*.h", src=self.source_folder, | ||
dst=join(self.package_folder, "include")) | ||
copy(self, "*.lib", src=self.build_folder, | ||
dst=join(self.package_folder, "lib"), keep_path=False) | ||
copy(self, "*.a", src=self.build_folder, | ||
dst=join(self.package_folder, "lib"), keep_path=False) | ||
def package_info(self): | ||
self.cpp_info.components["hello"].libs = ["hello"] | ||
self.cpp_info.components["bye"].libs = ["bye"] | ||
self.cpp_info.set_property("cmake_file_name", "MYG") | ||
self.cpp_info.set_property("cmake_target_name", "MyGreetings::MyGreetings") | ||
self.cpp_info.components["hello"].set_property("cmake_target_name", "MyGreetings::MyHello") | ||
self.cpp_info.components["bye"].set_property("cmake_target_name", "MyGreetings::MyBye") | ||
While the location of the ``hello`` and ``bye`` libraries in the final package is in the final ``lib`` folder, | ||
then nothing special is needed in the ``package_info()`` method, beyond the definition of the components. In | ||
this case, the customization of the CMake generated filenames and targets is also included, but it is not | ||
necessary for this example. | ||
|
||
The important part is the ``layout()`` definition. Besides the common ``cmake_layout``, it is necessary to | ||
define the location of the components headers (``self.cpp.source`` as they are source code) and the location | ||
of the locally built libraries. As the location of the libraries depends on the platform, the final | ||
``self.cpp.build.components["component"].libdirs`` depends on the platform. | ||
|
||
With this recipe we can put the package in editable mode and locally build it with: | ||
|
||
.. code-block:: bash | ||
$ conan editable add greetings | ||
$ conan build greetings | ||
# we might want to also build the debug config | ||
In the ``app`` folder we have a package recipe to build 2 executables, that link with the ``greeting`` package | ||
components. The ``app/conanfile.py`` recipe there is simple, the ``build()`` method builds and runs both ``example`` | ||
and ``example2`` executables that are built with ``CMakeLists.txt``: | ||
|
||
|
||
.. code-block:: cmake | ||
# Note the MYG file name, not matching the package name, | ||
# because the recipe defined "cmake_file_name" | ||
find_package(MYG) | ||
add_executable(example example.cpp) | ||
# Note the MyGreetings::MyGreetings target name, not matching the package name, | ||
# because the recipe defined "cmake_target_name" | ||
# "example" is linking with the whole package, both "hello" and "bye" components | ||
target_link_libraries(example MyGreetings::MyGreetings) | ||
add_executable(example2 example2.cpp) | ||
# "example2" is only using and linking "hello" component, but not "bye" | ||
target_link_libraries(example2 MyGreetings::MyHello) | ||
.. code-block:: bash | ||
$ conan build app | ||
hello: Release! | ||
bye: Release! | ||
If you now go to the ``bye.cpp`` source file and modify the output message, then build ``greetings`` and | ||
``app`` locally, the final output message for the "bye" component library should change: | ||
|
||
.. code-block:: bash | ||
$ conan build greetings | ||
$ conan build app | ||
hello: Release! | ||
adios: Release! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. _developer_flow: | ||
|
||
Developer tools and flows | ||
========================= | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
dev_flow/debug/step_into_dependencies |
84 changes: 84 additions & 0 deletions
84
2.0/_sources/examples/dev_flow/debug/step_into_dependencies.rst.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
.. _examples_dev_flow_debug_step_into: | ||
|
||
|
||
Debugging and stepping into dependencies | ||
======================================== | ||
|
||
Sometimes, when developing and debugging your own code, it could be useful to be able to step-into the | ||
dependencies source code too. There are a couple of things to take into account: | ||
|
||
- Recipes and packages from ConanCenter do not package always all the debug artifacts necessary to debug. For example in Windows, the ``*.pdb`` files are not packaged, because they are very heavy, and in practice barely used. It is possible to have your own packages to package the PDB files if you want, but that still won't solve the next point. | ||
- Debug artifacts are often not relocatable, that means that such artifacts can only be used in the location they were built from sources. But packages that are uploaded to a server and downloaded to a different machine can put those artifacts in a different folder. Then, the debug artifacts might not correctly locate the source code, the symbols, etc. | ||
|
||
|
||
Building from source | ||
-------------------- | ||
|
||
The recommended approach for debugging dependencies is building them from source in the local cache. This approach should work out of the box for most recipes, including ConanCenter recipes. | ||
|
||
We can reuse the code from the very first example in the tutorial for this use case. Please, first clone the sources to recreate this project, you can find them in the | ||
`examples2.0 repository <https://github.com/conan-io/examples2>`_ in GitHub: | ||
|
||
.. code-block:: bash | ||
$ git clone https://github.com/conan-io/examples2.git | ||
$ cd examples2/tutorial/consuming_packages/simple_cmake_project | ||
Then, lets make sure the dependency is built from source: | ||
|
||
.. code-block:: bash | ||
$ conan install . -s build_type=Debug --build="zlib/*" | ||
... | ||
Install finished successfully | ||
Assuming that we have CMake>=3.23, we can use the presets (otherwise, please use the ``-DCMAKE_TOOLCHAIN_FILE`` arguments): | ||
|
||
.. code-block:: bash | ||
$ cmake . --preset conan-default | ||
This will create our project, that we can start building and debugging. | ||
|
||
|
||
Step into a dependency with Visual Studio | ||
----------------------------------------- | ||
|
||
Once the project is created, in Visual Studio, we can double-click on the ``compressor.sln`` file, or open the file from the open Visual Studio IDE. | ||
|
||
Once the project is open, the first step is building it, making sure the ``Debug`` configuration is the active one, going to ``Build -> Build Solution`` will do it. Then we can define ``compressor`` as the "Startup project" in project view. | ||
|
||
Going to the ``compressor/main.c`` source file, we can introduce a breakpoint in some line there: | ||
|
||
.. code-block:: c++ | ||
:caption: main.c | ||
|
||
int main(void) { | ||
... | ||
|
||
// add a breakpoint in deflateInit line in your IDE | ||
deflateInit(&defstream, Z_BEST_COMPRESSION); | ||
deflate(&defstream, Z_FINISH); | ||
|
||
Clicking on the ``Debug -> Start Debugging`` (or F5), the program will start debugging and stop at the ``deflateInit()`` line. Clicking on the ``Debug -> Step Into``, the IDE should be able to navigate to the ``deflate.c`` source code. If we check this file, its path will be inside the Conan cache, like ``C:\Users\<myuser>\.conan2\p\b\zlib4f7275ba0a71f\b\src\deflate.c`` | ||
|
||
.. code-block:: c++ | ||
:caption: deflate.c | ||
|
||
int ZEXPORT deflateInit_(strm, level, version, stream_size) | ||
z_streamp strm; | ||
int level; | ||
const char *version; | ||
int stream_size; | ||
{ | ||
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, | ||
Z_DEFAULT_STRATEGY, version, stream_size); | ||
/* To do: ignore strm->next_in if we use it as window */ | ||
} | ||
|
||
.. seealso:: | ||
|
||
- Modifying the dependency source code while debugging is not possible with this approach. If that is the intended flow, the recommended approach is to use :ref:`editable package<editable_packages>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.. _examples_graph: | ||
|
||
Graph examples | ||
============== | ||
|
||
This section contains examples about different types of advanced graphs, using different types of ``requires`` and ``tool_requires``, | ||
advanced usage of requirement traits, etc. | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
graph/tool_requires/different_versions | ||
graph/tool_requires/different_options |
Oops, something went wrong.