Skip to content

Commit 9438f6b

Browse files
lasotedanimtbczoidomemsharded
authored
new win bash mechanism (conan-io#2152)
* new win bash mechanism * Apply suggestions from code review Co-authored-by: Daniel <[email protected]> * fix html * Update reference/conanfile/attributes.rst Co-authored-by: Daniel <[email protected]> Co-authored-by: czoido <[email protected]> Co-authored-by: James <[email protected]>
1 parent ae410fc commit 9438f6b

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

reference/conanfile/attributes.rst

+17
Original file line numberDiff line numberDiff line change
@@ -1698,3 +1698,20 @@ To declare that a recipe provides the functionality of several different recipes
16981698
16991699
If the attribute is omitted, the value of the attribute is assumed to be equal to the current package name. Thus, it's redundant for
17001700
``libjpeg`` recipe to declare that it provides ``libjpeg``, it's already implicitly assumed by Conan.
1701+
1702+
1703+
1704+
win_bash
1705+
--------
1706+
1707+
This is an **experimental** feature introduced in Conan 1.39.
1708+
1709+
When ``True`` it enables the new run in a subsystem bash in Windows mechanism. :ref:`Read more here<conanfile_win_bash>`.
1710+
1711+
.. code-block:: python
1712+
1713+
from conans import ConanFile
1714+
1715+
class FooRecipe(ConanFile):
1716+
...
1717+
win_bash = True

systems_cross_building/windows_subsystems.rst

+32
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ shouldn't specify it.
3737
Running commands inside the subsystem
3838
-------------------------------------
3939

40+
41+
.. _conanfile_win_bash:
42+
43+
self.win_bash
44+
_____________
45+
46+
This is an experimental feature introduced in Conan 1.39. It supersedes the ``run(..., win_bash=True)`` argument but
47+
if the ``run(..., win_bash=True)`` is used, it will have priority so the compatibility with the previous behavior is
48+
guaranteed.
49+
50+
The ``self.win_bash`` is an attribute of the conanfile, when set to ``True`` and only when running in Windows (you don't need
51+
to check if you are in Windows), it will run the ``self.run()`` commands inside a bash shell.
52+
53+
54+
.. note::
55+
56+
The ``bash.exe`` that will run **is not auto-detected** or read from the ``CONAN_BASH_PATH`` anymore, neither the subsystem to be used.
57+
These are the config variables used:
58+
59+
- ``tools.microsoft.bash:subsystem``: Values can be ``msys2``, ``cygwin``, ``msys`` and ``wsl``.
60+
- ``tools.microsoft.bash:path``: Path to the ``bash.exe``
61+
62+
The new :ref:`Autotools, AutotoolsToolchain, AutotoolsDeps and PkgConfigDeps<conan_tools_gnu>` will work automatically
63+
when ``self.win_bash`` is set.
64+
65+
66+
4067
self.run()
4168
__________
4269

@@ -54,6 +81,11 @@ run in Windows-native mode, the compiler won't link against the ``msys-2.0.dll``
5481
AutoToolsBuildEnvironment
5582
_________________________
5683

84+
.. note::
85+
86+
From Conan 1.39 the new :ref:`Autotools<conan_tools_gnu_build_helper>` build helper will use the ``self.win_bash``
87+
conanfile attribute (see above) to adjust automatically all the paths to the subsystem.
88+
5789
In the constructor of the build helper, you have the ``win_bash`` parameter. Set it to ``True`` to
5890
run the ``configure`` and ``make`` commands inside a bash.
5991

0 commit comments

Comments
 (0)