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

Correct encoding of make_program path for AutoTools + msys2 #15047

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions conan/tools/gnu/autotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def make(self, target=None, args=None):
make_program = self._conanfile.conf.get("tools.gnu:make_program",
default="mingw32-make" if self._use_win_mingw()
else "make")
subsystem = deduce_subsystem(self._conanfile, scope="build")
make_program = subsystem_path(subsystem, make_program)
str_args = self._make_args
str_extra_args = " ".join(args) if args is not None else ""
jobs = ""
Expand Down
57 changes: 56 additions & 1 deletion conans/test/functional/toolchains/gnu/autotools/test_win_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from conans.test.assets.autotools import gen_makefile_am, gen_configure_ac
from conans.test.assets.autotools import gen_makefile_am, gen_configure_ac, gen_makefile
from conans.test.assets.sources import gen_function_cpp
from conans.test.conftest import tools_locations
from conans.test.functional.utils import check_exe_run
Expand Down Expand Up @@ -104,3 +104,58 @@ def build(self):
client.save({"conanfile.py": conanfile})
client.run("create .")
assert "ar.exe" in client.out


@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
def test_autotools_support_custom_make():
""" Check that the conf setting `tools.gnu:make_program` works when set with
windows native paths. For example, when set programatically by a package
"""
client = TestClient(path_with_spaces=False)
bash_path = None
make_path = None
try:
bash_path = tools_locations["msys2"]["system"]["path"]["Windows"] + "/bash.exe"
make_path = tools_locations["msys2"]["system"]["path"]["Windows"] + "/make.exe"
except KeyError:
pytest.skip("msys2 path not defined")
if not os.path.exists(make_path):
pytest.skip("msys2 make not installed")

make_path = make_path.replace("/", "\\")
assert os.path.exists(make_path)

save(client.cache.new_config_path, textwrap.dedent("""
tools.microsoft.bash:subsystem=msys2
tools.microsoft.bash:path={}
tools.gnu:make_program={}
tools.build:compiler_executables={{"c": "cl", "cpp": "cl"}}
""".format(bash_path, make_path)))

# The autotools support for "cl" compiler (VS) is very limited, linking with deps doesn't
# work but building a simple app do
makefile = gen_makefile()

conanfile = textwrap.dedent("""
from conans import ConanFile
from conan.tools.gnu import Autotools

class TestConan(ConanFile):
settings = "os", "compiler", "arch", "build_type"
generators = "AutotoolsToolchain"
win_bash = True

def build(self):
# These commands will run in bash activating first the vcvars and
# then inside the bash activating the
autotools = Autotools(self)
autotools.make()
""")

client.save({"conanfile.py": conanfile,
"Makefile": makefile})
client.run("install . -s:b os=Windows -s:h os=Windows")
client.run("build .")
# This used to crash, because ``make_program`` was not unix_path
assert "conanfile.py: Calling build()" in client.out