-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
autoconf: fix package info on windows #14118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,51 @@ | ||
import shutil | ||
from os import path | ||
|
||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.gnu import Autotools | ||
from conan.tools.microsoft import unix_path | ||
|
||
required_conan_version = ">=1.50.0" | ||
from conan.tools.env import Environment, VirtualBuildEnv | ||
from conan.tools.files import copy | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.microsoft import is_msvc | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
exports_sources = "configure.ac", "config.h.in", "Makefile.in", "test_package_c.c", "test_package_cpp.cpp", | ||
generators = "AutotoolsDeps", "AutotoolsToolchain", "VirtualBuildEnv" | ||
settings = "os", "arch", "compiler", "build_type" | ||
test_type = "explicit" | ||
win_bash = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe move this to the build_requirements method for consistency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, it doesn't work in test package (conan bug I guess) |
||
|
||
@property | ||
def _settings_build(self): | ||
# TODO: Remove for Conan v2 | ||
return getattr(self, "settings_build", self.settings) | ||
|
||
@property | ||
def win_bash(self): | ||
return self._settings_build.os == "Windows" | ||
def layout(self): | ||
basic_layout(self) | ||
|
||
def build_requirements(self): | ||
if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): | ||
self.tool_requires("msys2/cci.latest") # The conf `tools.microsoft.bash:path` and `tools.microsoft.bash:subsystem` aren't injected for test_package | ||
self.tool_requires(self.tested_reference_str) | ||
if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str): | ||
self.tool_requires("msys2/cci.latest") | ||
|
||
def generate(self): | ||
env = VirtualBuildEnv(self) | ||
env.generate() | ||
tc = AutotoolsToolchain(self) | ||
tc.generate() | ||
if is_msvc(self): | ||
env = Environment() | ||
env.define("CC", "cl -nologo") | ||
env.define("CXX", "cl -nologo") | ||
env.vars(self).save_script("conanbuild_msvc") | ||
|
||
def build(self): | ||
if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): | ||
return # autoconf needs a bash if there isn't a bash no need to build | ||
|
||
for src in self.exports_sources: | ||
shutil.copy(path.join(self.source_folder, src), self.build_folder) | ||
|
||
for src in ("configure.ac", "config.h.in", "Makefile.in", "test_package_c.c", "test_package_cpp.cpp"): | ||
copy(self, src, self.source_folder, self.build_folder) | ||
self.run("autoconf --verbose") | ||
|
||
autotools = Autotools(self) | ||
autotools.configure(build_script_folder=self.build_folder) | ||
autotools.make() | ||
|
||
def test(self): | ||
if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): | ||
return # autoconf needs a bash if there isn't a bash no need to build | ||
|
||
self.win_bash = None | ||
if can_run(self): | ||
ext = ".exe" if self.settings.os == "Windows" else "" | ||
test_cmd = unix_path(self, path.join(self.build_folder, f"test_package{ext}")) | ||
|
||
self.run(test_cmd, env="conanbuild") | ||
bin_path = os.path.join(self.build_folder, "test_package") | ||
self.run(bin_path, env="conanrun") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
from conans import AutoToolsBuildEnvironment, ConanFile, tools | ||
from conan.tools.microsoft import is_msvc, unix_path | ||
from conan.tools.files import copy | ||
from conan.tools.microsoft import is_msvc | ||
import contextlib | ||
import os | ||
import shutil | ||
|
||
required_conan_version = ">=1.45.0" | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
exports_sources = "../test_package/configure.ac", "../test_package/config.h.in", "../test_package/Makefile.in", "../test_package/test_package_c.c", "../test_package/test_package_cpp.cpp", | ||
settings = "os", "arch", "compiler", "build_type" | ||
test_type = "explicit" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, in conan v1 it's a different mechanism with win_bash in self.run directly. |
||
@property | ||
|
@@ -31,12 +28,11 @@ def _build_context(self): | |
yield | ||
|
||
def build(self): | ||
for src in self.exports_sources: | ||
shutil.copy(os.path.join(self.source_folder, src), self.build_folder) | ||
self.run("autoconf --verbose", | ||
win_bash=tools.os_info.is_windows, run_environment=True) | ||
for src in ("configure.ac", "config.h.in", "Makefile.in", "test_package_c.c", "test_package_cpp.cpp"): | ||
copy(self, src, os.path.join(self.source_folder, os.pardir, "test_package"), self.build_folder) | ||
self.run("autoconf --verbose", win_bash=tools.os_info.is_windows) | ||
self.run("{} --help".format(os.path.join(self.build_folder, "configure").replace("\\", "/")), | ||
win_bash=tools.os_info.is_windows, run_environment=True) | ||
win_bash=tools.os_info.is_windows) | ||
autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||
with self._build_context(): | ||
autotools.configure() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a FIXME comment once CCI uses the Conan version with your pr conan-io/conan#12193
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's fixed in 1.54.0 so for me the TODO comment has already everything