Skip to content

Commit

Permalink
Add sconsdeps docs (#3371)
Browse files Browse the repository at this point in the history
* basic docs

* minor changes

* add deprecation warnings

* minor changes

* Update reference/conanfile/tools/scons.rst

Co-authored-by: Francisco Ramírez <franchuti688@gmail.com>

---------

Co-authored-by: Francisco Ramírez <franchuti688@gmail.com>
  • Loading branch information
czoido and franramirez688 authored Sep 13, 2023
1 parent 8a4f25f commit d431897
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 4 deletions.
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
72 changes: 72 additions & 0 deletions reference/conanfile/tools/scons.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. _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.

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
from conan import ConanFile
class Pkg(ConanFile):
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

0 comments on commit d431897

Please sign in to comment.