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

Add sconsdeps docs #3371

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integrations/build_system/scons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ____________________

.. warning::

This is a **deprecated** feature. Please refer to the :ref:`Migration Guidelines<conan2_migration_guide>`
to find the feature that replaced this one.
This is a **deprecated** feature. Please check the new :ref:`SConsDeps<conan_tools_sconsdeps>`
tool that will be compatible with Conan 2.X.

SCons can be used both to generate and consume Conan packages via the :ref:`scons_generator`
generator. The package recipe ``build()`` method could be similar to:
Expand Down
1 change: 1 addition & 0 deletions reference/conanfile/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ Contents:
tools/scm
tools/build
tools/android
tools/scons
70 changes: 70 additions & 0 deletions reference/conanfile/tools/scons.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. _conan_tools_sconsdeps:

conan.tools.scons
=================

.. important::

Some of the features used in this section are still **under development**. While they
are recommended and usable, and we will try not to break them in future releases, some
breaking changes might still occur.
franramirez688 marked this conversation as resolved.
Show resolved Hide resolved

SConsDeps
---------

Available since: `1.61.0 <https://github.com/conan-io/conan/releases>`_

The ``SConsDeps`` is the dependency generator for `SCons <https://scons.org/>`_. It will
generate a `SConscript_conandeps` file containing the necessary information for SCons to
build against the desired dependencies.

The ``SConsDeps`` generator can be used by name in conanfiles:

.. code-block:: python
:caption: conanfile.py

class Pkg(ConanFile):
czoido marked this conversation as resolved.
Show resolved Hide resolved
generators = "SConsDeps"

.. code-block:: text
:caption: conanfile.txt

[generators]
SConsDeps

It can also be fully instantiated in the conanfile ``generate()`` method:

.. code:: python

from conan import ConanFile
from conan.tools.scons import SConsDeps

class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"

def generate(self):
tc = SConsDeps(self)
tc.generate()

After executing the ``conan install`` command, the ``SConsDeps`` generator will create the
`SConscript_conandeps` file. This file will provide the following information for `SCons`:
``CPPPATH``, ``LIBPATH``, ``BINPATH``, ``LIBS``, ``FRAMEWORKS``, ``FRAMEWORKPATH``,
``CPPDEFINES``, ``CXXFLAGS``, ``CCFLAGS``, ``SHLINKFLAGS``, and ``LINKFLAGS``. This information
is generated for the accumulated list of all dependencies and also for each one of the
requirements. You can load it in your consumer `SConscript` like this:

.. code-block:: python
:caption: consumer `SConscript`

...
info = SConscript('./SConscript_conandeps')
# You can use conandeps to get the information
# for all the dependencies.
flags = info["conandeps"]

# Or use the name of the requirement if
# you only want the information about that one.
flags = info["zlib"]

env.MergeFlags(flags)
...
4 changes: 2 additions & 2 deletions reference/generators/scons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ scons

.. warning::

This is a **deprecated** feature. Please refer to the :ref:`Migration Guidelines<conan2_migration_guide>`
to find the feature that replaced this one.
This is a **deprecated** feature. Please check the new :ref:`SConsDeps<conan_tools_sconsdeps>`
tool that will be compatible with Conan 2.X.

Conan provides :ref:`integration with SCons <scons>` with this generator.

Expand Down