-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* autoconf v2 ready Note: test_package can't use the new Autools generator due to conan-io/conan#11975 * Revert removal of PATH from env_info From review comment * use unix_path instead of private import functions According review comment * use unix_path instead of private import functions According review comment * pass self to unix_path * applied review comments KB-H013 states that everything needs to be installed under bin for tools. This also means that the `PATH` for the actual bin location `bin/bin` needs to be added to the `build_env` * Add licenses to package * Explicitly use an empty includedirs Should fix KB-H071 * Fix setting unix_path for package_info subsystem isn't known at this time * simplified test_package No need to actually compile something with this tool we simply need to know if it runs. The win_bash for the run needs to be set explicitly due to the conf not working properly in the test_package see conan-io/conan#11975 * Revert "simplified test_package" This reverts commit d9ee4de. * use modern tools in test_package * add conan test_v1_package * m4 is a build requirement * Ducktype Autotools `configure` and `make` This allows us to use the msys2 bash without using the conf_info in the test_package. Which is currently problematic due to: conan-io/conan#11975 Contributes to CURA-9574 * Fix paths on windows in test method Contributes to CURA-8831 * Don't ducktype but inherit The ducktyping seems to affect the usage of the Autotools in the main recipe as well Contributes to CURA-8831 * use unix_path for env_info Contributes to CURA-8831 * remove extra lin Contributes to CURA-8831 * don't use unix_path The subsystem isn't known when consuming projects request the info Contributes to CURA-8831 * fix subsystems on Windows Using some duck typing and inheritance to work around GH issue conan-io/conan#11980 Contributes to CURA-9595 * updated autoconf for conan v2 ready support Contribute to CURA-8831 * autoconf bin contains shell scripts not executable Contribute to CURA-8831 * Removed Autotools workaround from test_package Still an issue: conan-io/conan#11975 Contribute to CURA-8831 * m4 is a run requirement not a tool_req Contribute to CURA-8831 * use mingw32 for gnu tuple version 2.69 doesn't known mingw64, it should hold no difference for the end result. Contribute to CURA-8831 * Run the configure command in the build_folder Contributes to CURA-8831 * Use conanbuild env as scope for testing Contribute to CURA-8831 * Ensure that M4 binary from dependency is used Contributes to CURA-8831 * Set win_bash in configure stage Contributes to CURA-8831 * Move conf keys to user space Applies code-review comments * Use *_folder in favor of undocumented *_path Applies code-review comments * Reuse source files from test_package Applies code-review comments * Apply suggestions from code review Co-authored-by: Jordan Williams <jordan@jwillikers.com> * Use export_conandata_patches Bump up the minimum conan version to 1.52 Applies code-review comments * Removed unused conf_info values As descibed in #13490 Applies code-review comments * Check against empty string for conf value bash path Apply code review comment * Update recipes/autoconf/all/conanfile.py Co-authored-by: Chris Mc <prince.chrismc@gmail.com> * Apply suggestions from code review Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Co-authored-by: j.spijker@ultimaker.com <jelle spijker> Co-authored-by: Jordan Williams <jordan@jwillikers.com> Co-authored-by: Chris Mc <prince.chrismc@gmail.com> Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
- Loading branch information
1 parent
9bb635f
commit 5b8511e
Showing
4 changed files
with
178 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,131 @@ | ||
from conans import AutoToolsBuildEnvironment, ConanFile, tools | ||
import contextlib | ||
import os | ||
from os import path | ||
|
||
required_conan_version = ">=1.33.0" | ||
from conan import ConanFile | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.files import copy, get, rmdir, apply_conandata_patches, replace_in_file, export_conandata_patches | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.microsoft import unix_path, is_msvc | ||
|
||
required_conan_version = ">=1.52.0" | ||
|
||
|
||
class AutoconfConan(ConanFile): | ||
name = "autoconf" | ||
description = "Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages" | ||
license = ("GPL-2.0-or-later", "GPL-3.0-or-later") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://www.gnu.org/software/autoconf/" | ||
description = "Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages" | ||
topics = ("autoconf", "configure", "build") | ||
license = ("GPL-2.0-or-later", "GPL-3.0-or-later") | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
exports_sources = "patches/*" | ||
|
||
_autotools = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return os.path.join(self.source_folder, "source_subfolder") | ||
|
||
@property | ||
def _settings_build(self): | ||
# TODO: Remove for Conan v2 | ||
return getattr(self, "settings_build", self.settings) | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def configure(self): | ||
self.win_bash = self._settings_build.os == "Windows" | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("m4/1.4.19") | ||
|
||
def build_requirements(self): | ||
if hasattr(self, "settings_build"): | ||
self.build_requires("m4/1.4.19") | ||
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): | ||
self.build_requires("msys2/cci.latest") | ||
|
||
def package_id(self): | ||
self.info.header_only() | ||
self.info.clear() | ||
|
||
def build_requirements(self): | ||
if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str): | ||
self.tool_requires("msys2/cci.latest") | ||
self.tool_requires("m4/1.4.19") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
get(self, **self.conan_data["sources"][self.version], | ||
destination=self.source_folder, strip_root=True) | ||
|
||
@property | ||
def _datarootdir(self): | ||
return os.path.join(self.package_folder, "bin", "share") | ||
def generate(self): | ||
tc = AutotoolsToolchain(self) | ||
tc.configure_args.extend([ | ||
"--datarootdir=${prefix}/res", | ||
]) | ||
|
||
@property | ||
def _autoconf_datarootdir(self): | ||
return os.path.join(self._datarootdir, "autoconf") | ||
|
||
def _configure_autotools(self): | ||
if self._autotools: | ||
return self._autotools | ||
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||
datarootdir = self._datarootdir | ||
prefix = self.package_folder | ||
if self.settings.os == "Windows": | ||
datarootdir = tools.unix_path(datarootdir) | ||
prefix = tools.unix_path(prefix) | ||
conf_args = [ | ||
"--datarootdir={}".format(datarootdir), | ||
"--prefix={}".format(prefix), | ||
] | ||
self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) | ||
return self._autotools | ||
|
||
def _patch_files(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
|
||
@contextlib.contextmanager | ||
def _build_context(self): | ||
with tools.environment_append(tools.RunEnvironment(self).vars): | ||
yield | ||
if is_msvc(self): | ||
build = "{}-{}-{}".format( | ||
"x86_64" if self._settings_build.arch == "x86_64" else "i686", | ||
"pc" if self._settings_build.arch == "x86" else "win64", | ||
"mingw32") | ||
host = "{}-{}-{}".format( | ||
"x86_64" if self.settings.arch == "x86_64" else "i686", | ||
"pc" if self.settings.arch == "x86" else "win64", | ||
"mingw32") | ||
tc.configure_args.append(f"--build={build}") | ||
tc.configure_args.append(f"--host={host}") | ||
|
||
env = tc.environment() | ||
env.define("INSTALL", unix_path(self, path.join(self.source_folder, 'build-aux', 'install-sh'))) | ||
tc.generate(env) | ||
|
||
deps = AutotoolsDeps(self) | ||
deps.generate() | ||
|
||
ms = VirtualBuildEnv(self) | ||
ms.generate(scope="build") | ||
|
||
def build(self): | ||
self._patch_files() | ||
with self._build_context(): | ||
autotools = self._configure_autotools() | ||
autotools.make() | ||
apply_conandata_patches(self) | ||
replace_in_file(self, path.join(self.source_folder, "Makefile.in"), "M4 = /usr/bin/env m4", "#M4 = /usr/bin/env m4") | ||
|
||
autotools = Autotools(self) | ||
autotools.configure() | ||
autotools.make() | ||
|
||
def package(self): | ||
self.copy("COPYING*", src=self._source_subfolder, dst="licenses") | ||
with self._build_context(): | ||
autotools = self._configure_autotools() | ||
autotools.install() | ||
tools.rmdir(os.path.join(self.package_folder, "bin", "share", "info")) | ||
tools.rmdir(os.path.join(self.package_folder, "bin", "share", "man")) | ||
autotools = Autotools(self) | ||
autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem | ||
|
||
copy(self, "COPYING*", src=self.source_folder, dst=path.join(self.package_folder, "licenses")) | ||
rmdir(self, path.join(self.package_folder, "res", "info")) | ||
rmdir(self, path.join(self.package_folder, "res", "man")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libdirs = [] | ||
self.cpp_info.includedirs = [] | ||
|
||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info("Appending PATH env var with : {}".format(bin_path)) | ||
bin_path = path.join(self.package_folder, "bin") | ||
self.output.info(f"Appending PATH environment variable: {bin_path}") | ||
self.env_info.PATH.append(bin_path) | ||
|
||
ac_macrodir = self._autoconf_datarootdir | ||
self.output.info("Setting AC_MACRODIR to {}".format(ac_macrodir)) | ||
self.env_info.AC_MACRODIR = ac_macrodir | ||
|
||
autoconf = tools.unix_path(os.path.join(self.package_folder, "bin", "autoconf")) | ||
self.output.info("Setting AUTOCONF to {}".format(autoconf)) | ||
self.env_info.AUTOCONF = autoconf | ||
|
||
autoreconf = tools.unix_path(os.path.join(self.package_folder, "bin", "autoreconf")) | ||
self.output.info("Setting AUTORECONF to {}".format(autoreconf)) | ||
self.env_info.AUTORECONF = autoreconf | ||
|
||
autoheader = tools.unix_path(os.path.join(self.package_folder, "bin", "autoheader")) | ||
self.output.info("Setting AUTOHEADER to {}".format(autoheader)) | ||
self.env_info.AUTOHEADER = autoheader | ||
|
||
autom4te = tools.unix_path(os.path.join(self.package_folder, "bin", "autom4te")) | ||
self.output.info("Setting AUTOM4TE to {}".format(autom4te)) | ||
self.env_info.AUTOM4TE = autom4te | ||
|
||
autom4te_perllibdir = self._autoconf_datarootdir | ||
self.output.info("Setting AUTOM4TE_PERLLIBDIR to {}".format(autom4te_perllibdir)) | ||
self.env_info.AUTOM4TE_PERLLIBDIR = autom4te_perllibdir | ||
dataroot_path = path.join(self.package_folder, "res", "autoconf") | ||
self.output.info(f"Defining AC_MACRODIR environment variable: {dataroot_path}") | ||
self.env_info.AC_MACRODIR = dataroot_path | ||
self.buildenv_info.define_path("AC_MACRODIR", dataroot_path) | ||
|
||
self.output.info(f"Defining AUTOM4TE_PERLLIBDIR environment variable: {dataroot_path}") | ||
self.env_info.AUTOM4TE_PERLLIBDIR = dataroot_path | ||
self.buildenv_info.define_path("AUTOM4TE_PERLLIBDIR", dataroot_path) | ||
|
||
autoconf_bin = path.join(bin_path, "autoconf") | ||
self.output.info(f"Defining AUTOCONF environment variable: {autoconf_bin}") | ||
self.env_info.AUTOCONF = autoconf_bin | ||
self.buildenv_info.define_path("AUTOCONF", autoconf_bin) | ||
|
||
autoreconf_bin = path.join(bin_path, "autoreconf") | ||
self.output.info(f"Defining AUTORECONF environment variable: {autoreconf_bin}") | ||
self.env_info.AUTORECONF = autoreconf_bin | ||
self.buildenv_info.define_path("AUTORECONF", autoreconf_bin) | ||
|
||
autoheader_bin = path.join(bin_path, "autoheader") | ||
self.output.info(f"Defining AUTOHEADER environment variable: {autoheader_bin}") | ||
self.env_info.AUTOHEADER = autoheader_bin | ||
self.buildenv_info.define_path("AUTOHEADER", autoheader_bin) | ||
|
||
autom4te_bin = path.join(bin_path, "autom4te") | ||
self.output.info(f"Defining AUTOM4TE environment variable: {autom4te_bin}") | ||
self.env_info.AUTOM4TE = autom4te_bin | ||
self.buildenv_info.define_path("AUTOM4TE", autom4te_bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,53 @@ | ||
from conans import AutoToolsBuildEnvironment, ConanFile, tools | ||
from conan.tools.microsoft import is_msvc | ||
import contextlib | ||
import os | ||
import shutil | ||
from os import path | ||
|
||
required_conan_version = ">=1.45.0" | ||
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" | ||
|
||
|
||
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" | ||
test_type = "explicit" | ||
|
||
@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 build_requirements(self): | ||
self.build_requires(self.tested_reference_str) | ||
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): | ||
self.build_requires("msys2/cci.latest") | ||
|
||
@contextlib.contextmanager | ||
def _build_context(self): | ||
if is_msvc(self): | ||
with tools.vcvars(self): | ||
with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}): | ||
yield | ||
else: | ||
yield | ||
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) | ||
|
||
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(os.path.join(self.source_folder, src), self.build_folder) | ||
self.run("{} --verbose".format(os.environ["AUTOCONF"]), | ||
win_bash=tools.os_info.is_windows, run_environment=True) | ||
self.run("{} --help".format(os.path.join(self.build_folder, "configure").replace("\\", "/")), | ||
win_bash=tools.os_info.is_windows, run_environment=True) | ||
autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||
with self._build_context(): | ||
autotools.configure() | ||
autotools.make() | ||
shutil.copy(path.join(self.source_folder, src), self.build_folder) | ||
|
||
self.run("autoconf --verbose") | ||
|
||
autotools = Autotools(self) | ||
autotools.configure(build_script_folder=self.build_folder) | ||
autotools.make() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
self.run(os.path.join(".", "test_package"), run_environment=True) | ||
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 | ||
|
||
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from conans import AutoToolsBuildEnvironment, ConanFile, tools | ||
from conan.tools.microsoft import is_msvc, unix_path | ||
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", | ||
test_type = "explicit" | ||
|
||
@property | ||
def _settings_build(self): | ||
return getattr(self, "settings_build", self.settings) | ||
|
||
def build_requirements(self): | ||
self.build_requires(self.tested_reference_str) | ||
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): | ||
self.build_requires("msys2/cci.latest") | ||
|
||
@contextlib.contextmanager | ||
def _build_context(self): | ||
if is_msvc(self): | ||
with tools.vcvars(self): | ||
with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}): | ||
yield | ||
else: | ||
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) | ||
self.run("{} --help".format(os.path.join(self.build_folder, "configure").replace("\\", "/")), | ||
win_bash=tools.os_info.is_windows, run_environment=True) | ||
autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||
with self._build_context(): | ||
autotools.configure() | ||
autotools.make() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
self.run(os.path.join(".", "test_package"), run_environment=True) |