diff --git a/recipes/automake/all/conandata.yml b/recipes/automake/all/conandata.yml index 24df7aa715c72..29d48a6c87604 100644 --- a/recipes/automake/all/conandata.yml +++ b/recipes/automake/all/conandata.yml @@ -16,47 +16,27 @@ sources: sha256: "608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8" patches: "1.16.5": - - base_path: "source_subfolder" - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.4.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.4.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" + - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.4.patch" + - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.4.patch" + - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" + - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" "1.16.4": - - base_path: "source_subfolder" - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.4.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.4.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" + - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.4.patch" + - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.4.patch" + - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" + - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" "1.16.3": - - base_path: "source_subfolder" - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.3.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.3.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" + - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.3.patch" + - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.3.patch" + - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" + - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" "1.16.2": - - base_path: "source_subfolder" - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.2.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.2.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.2.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.2.patch" + - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.2.patch" + - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.2.patch" + - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.2.patch" + - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.2.patch" "1.16.1": - - base_path: "source_subfolder" - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.1.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.1.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.1.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.1.patch" + - patch_file: "patches/0001-help2man-no-discard-stderr-0.16.1.patch" + - patch_file: "patches/0002-no-perl-path-in-shebang-0.16.1.patch" + - patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.1.patch" + - patch_file: "patches/0004-introduce-automake_perllibdir-0.16.1.patch" diff --git a/recipes/automake/all/conanfile.py b/recipes/automake/all/conanfile.py index 472f84cf07d88..759b66398e071 100644 --- a/recipes/automake/all/conanfile.py +++ b/recipes/automake/all/conanfile.py @@ -1,7 +1,14 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -import os +from functools import lru_cache +from os import environ, path -required_conan_version = ">=1.33.0" +from conan import ConanFile +from conan.tools.files import get, apply_conandata_patches, rmdir, copy, replace_in_file +from conan.tools.gnu import Autotools +from conan.tools.layout import basic_layout +from conan.tools.microsoft import unix_path +from conan.tools.scm import Version + +required_conan_version = ">=1.50.0" class AutomakeConan(ConanFile): @@ -12,20 +19,11 @@ class AutomakeConan(ConanFile): topics = ("conan", "automake", "configure", "build") license = ("GPL-2.0-or-later", "GPL-3.0-or-later") settings = "os", "arch", "compiler", "build_type" + generators = "AutotoolsDeps", "AutotoolsToolchain", "VirtualBuildEnv" + win_bash = True exports_sources = "patches/*" - _autotools = None - - @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") - - @property - def _version_major_minor(self): - [major, minor, _] = self.version.split(".", 2) - return '{}.{}'.format(major, minor) - @property def _settings_build(self): return getattr(self, "settings_build", self.settings) @@ -34,107 +32,91 @@ def configure(self): del self.settings.compiler.cppstd del self.settings.compiler.libcxx - def requirements(self): - self.requires("autoconf/2.71") - # automake requires perl-Thread-Queue package - def build_requirements(self): if hasattr(self, "settings_build"): - self.build_requires("autoconf/2.71") - if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") + self.tool_requires("autoconf/2.71") + if self._settings_build.os == "Windows" and not environ.get("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") def package_id(self): del self.info.settings.arch del self.info.settings.compiler del self.info.settings.build_type + def layout(self): + basic_layout(self, src_folder="source") + self.cpp.package.includedirs = [] # KB-H071: It is a tool that doesn't contain headers, removing the include directory. + 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], strip_root=True) @property def _datarootdir(self): - return os.path.join(self.package_folder, "res") + return path.join(self.package_folder, "bin", "share") @property def _automake_libdir(self): - return os.path.join(self._datarootdir, "automake-{}".format(self._version_major_minor)) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - conf_args = [ - "--datarootdir={}".format(tools.unix_path(self._datarootdir)), - "--prefix={}".format(tools.unix_path(self.package_folder)), - ] - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools - - def _patch_files(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - if self.settings.os == "Windows": - # tracing using m4 on Windows returns Windows paths => use cygpath to convert to unix paths - tools.replace_in_file(os.path.join(self._source_subfolder, "bin", "aclocal.in"), - " $map_traced_defs{$arg1} = $file;", - " $file = `cygpath -u $file`;\n" - " $file =~ s/^\\s+|\\s+$//g;\n" - " $map_traced_defs{$arg1} = $file;") + version = Version(self.version) + return path.join(self._datarootdir, f"automake-{version.major}.{version.minor}") - def build(self): - self._patch_files() - autotools = self._configure_autotools() - autotools.make() - - def package(self): - self.copy("COPYING*", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self._datarootdir, "info")) - tools.rmdir(os.path.join(self._datarootdir, "man")) - tools.rmdir(os.path.join(self._datarootdir, "doc")) + @lru_cache(1) + def _autotools(self): + autotool = Autotools(self) + autotool.configure() + autotool.make() + return autotool + def build(self): + apply_conandata_patches(self) if self.settings.os == "Windows": - binpath = os.path.join(self.package_folder, "bin") - for filename in os.listdir(binpath): - fullpath = os.path.join(binpath, filename) - if not os.path.isfile(fullpath): - continue - os.rename(fullpath, fullpath + ".exe") - - 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 environment variable:: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) - - bin_ext = ".exe" if self.settings.os == "Windows" else "" - - aclocal = tools.unix_path(os.path.join(self.package_folder, "bin", "aclocal" + bin_ext)) - self.output.info("Appending ACLOCAL environment variable with: {}".format(aclocal)) - self.env_info.ACLOCAL.append(aclocal) - - automake_datadir = tools.unix_path(self._datarootdir) - self.output.info("Setting AUTOMAKE_DATADIR to {}".format(automake_datadir)) - self.env_info.AUTOMAKE_DATADIR = automake_datadir + # tracing using m4 on Windows returns Windows paths => use cygpath to convert to unix paths + replace_in_file(self, path.join(self.source_path, "bin", "aclocal.in"), + " $map_traced_defs{$arg1} = $file;", + " $file = `cygpath -u $file`;\n" + " $file =~ s/^\\s+|\\s+$//g;\n" + " $map_traced_defs{$arg1} = $file;") - automake_libdir = tools.unix_path(self._automake_libdir) - self.output.info("Setting AUTOMAKE_LIBDIR to {}".format(automake_libdir)) - self.env_info.AUTOMAKE_LIBDIR = automake_libdir + _ = self._autotools() - automake_perllibdir = tools.unix_path(self._automake_libdir) - self.output.info("Setting AUTOMAKE_PERLLIBDIR to {}".format(automake_perllibdir)) - self.env_info.AUTOMAKE_PERLLIBDIR = automake_perllibdir + def package(self): + autotools = self._autotools() + # KB-H013 we're packaging an application, place everything under bin + autotools.install(args=[f"DESTDIR={unix_path(self, path.join(self.package_folder, 'bin'))}"]) - automake = tools.unix_path(os.path.join(self.package_folder, "bin", "automake" + bin_ext)) - self.output.info("Setting AUTOMAKE to {}".format(automake)) - self.env_info.AUTOMAKE = automake + copy(self, "COPYING*", src=self.source_folder, dst=path.join(self.package_folder, "licenses")) + rmdir(self, path.join(self._datarootdir, "info")) + rmdir(self, path.join(self._datarootdir, "man")) + rmdir(self, path.join(self._datarootdir, "doc")) - self.output.info("Append M4 include directories to AUTOMAKE_CONAN_INCLUDES environment variable") + def _set_env(self, var_name, var_path): + self.output.info(f"Setting {var_name} to {var_path}") + self.buildenv_info.define_path(var_name, var_path) + setattr(self.env_info, var_name, unix_path(self, var_path)) - self.user_info.compile = os.path.join(self._automake_libdir, "compile") - self.user_info.ar_lib = os.path.join(self._automake_libdir, "ar-lib") + def package_info(self): + # KB-H013 we're packaging an application, hence the nested bin + bin_dir = path.join(self.package_folder, "bin", "bin") + self.output.info(f"Appending PATH environment variable:: {bin_dir}") + self.buildenv_info.prepend_path("PATH", bin_dir) + self.env_info.PATH.append(bin_dir) + + for var in [("ACLOCAL", path.join(self.package_folder, "bin", "aclocal")), + ("AUTOMAKE_DATADIR", self._datarootdir), + ("AUTOMAKE_LIBDIR", self._automake_libdir), + ("AUTOMAKE_PERLLIBDIR", self._automake_libdir), + ("AUTOMAKE", path.join(self.package_folder, "bin", "automake"))]: + self._set_env(*var) + + compile_bin = path.join(self._automake_libdir, "compile") + self.output.info(f"Define path to `compile` binary in user_info as: {compile_bin}") + self.user_info.compile = compile_bin + compile_conf_key = "user.automake:compile" + self.output.info(f"Defining path to `compile` binary in configuration as `{compile_conf_key}` with value: {compile_bin}") + self.conf_info.define(compile_conf_key, compile_bin) + + ar_lib_bin = path.join(self._automake_libdir, "ar-lib") + self.output.info(f"Define path to `ar_lib` binary in user_info as: {ar_lib_bin}") + self.user_info.ar_lib = ar_lib_bin + ar_lib_conf_key = "user.automake:ar-lib" + self.output.info(f"Defining path to `ar-lib` binary in configuration as `{ar_lib_conf_key}` with value: {ar_lib_bin}") + self.conf_info.define(ar_lib_conf_key, ar_lib_bin) diff --git a/recipes/automake/all/test_package/Makefile.am b/recipes/automake/all/test_package/Makefile.am deleted file mode 100644 index 655db7f1876cb..0000000000000 --- a/recipes/automake/all/test_package/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -# @configure_input@ - -bin_PROGRAMS = test_package -test_package_SOURCES = test_package.cpp diff --git a/recipes/automake/all/test_package/conanfile.py b/recipes/automake/all/test_package/conanfile.py index 8362800620a5a..27cee6b4a0618 100644 --- a/recipes/automake/all/test_package/conanfile.py +++ b/recipes/automake/all/test_package/conanfile.py @@ -1,89 +1,29 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conan.tools.microsoft import is_msvc -from contextlib import contextmanager -import os -import shutil +from os import environ -required_conan_version = ">=1.45.0" +from conan import ConanFile +from conan.tools.build import can_run + +required_conan_version = ">=1.50.0" class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - exports_sources = "configure.ac", "Makefile.am", "test_package_1.c", "test_package.cpp" - # DON'T COPY extra.m4 TO BUILD FOLDER!!! + generators = "VirtualBuildEnv" test_type = "explicit" + win_bash = True @property def _settings_build(self): return getattr(self, "settings_build", self.settings) - def requirements(self): - self.requires(self.tested_reference_str) - 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") - - @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 - - _default_cc = { - "gcc": "gcc", - "clang": "clang", - "Visual Studio": "cl -nologo", - "apple-clang": "clang", - } - - @property - def _system_cc(self): - system_cc = os.environ.get("CC", None) - if not system_cc: - system_cc = self._default_cc.get(str(self.settings.compiler)) - return system_cc - - @property - def _user_info(self): - return getattr(self, "user_info_build", self.deps_user_info) - - def _build_scripts(self): - """Test compile script of automake""" - compile_script = self._user_info["automake"].compile - ar_script = self._user_info["automake"].ar_lib - assert os.path.isfile(ar_script) - assert os.path.isfile(compile_script) - - if self._system_cc: - with tools.vcvars(self) if is_msvc(self) else tools.no_op(): - self.run("{} {} test_package_1.c -o script_test".format(tools.unix_path(compile_script), self._system_cc), win_bash=tools.os_info.is_windows) - - def _build_autotools(self): - """Test autoreconf + configure + make""" - with tools.environment_append({"AUTOMAKE_CONAN_INCLUDES": [tools.unix_path(self.source_folder)]}): - self.run("{} -fiv".format(os.environ["AUTORECONF"]), 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) - autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - with self._build_context(): - autotools.configure() - autotools.make() + self.tool_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not environ.get("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") def build(self): - for src in self.exports_sources: - shutil.copy(os.path.join(self.source_folder, src), self.build_folder) - - self._build_scripts() - self._build_autotools() + pass def test(self): - if self._system_cc: - if not tools.cross_building(self): - self.run(os.path.join(".", "script_test"), run_environment=True) - - if not tools.cross_building(self): - self.run(os.path.join(".", "test_package"), run_environment=True) + if can_run(self): + self.run("automake --version", run_environment=True, env="conanbuild", win_bash=self.settings.os == "Windows") diff --git a/recipes/automake/all/test_package/configure.ac b/recipes/automake/all/test_package/configure.ac deleted file mode 100644 index 8a7ae1dc34e7f..0000000000000 --- a/recipes/automake/all/test_package/configure.ac +++ /dev/null @@ -1,28 +0,0 @@ -AC_PREREQ([2.69]) -AC_INIT([test_package], [1.0]) -AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) - -# Safety checks in case user overwritten --srcdir -AC_CONFIG_SRCDIR([test_package.cpp]) - -AC_CANONICAL_HOST - -# Test includes of extra including directories using conan -AUTOMAKE_TEST_PACKAGE_PREREQ([1.0]) -AUTOMAKE_TEST_PACKAGE_HELLO([argument1], [argument2], [...], [last argument]) - -AC_CONFIG_HEADER([config.h]) - -# Check for CC and CXX compiler -AC_PROG_CC -AC_PROG_CXX -## We can add more checks in this section -# -## Tells automake to create a Makefile -## See https://www.gnu.org/software/automake/manual/html_node/Requirements.html -AC_CONFIG_FILES([Makefile]) -# -## Generate the output -AC_OUTPUT -# diff --git a/recipes/automake/all/test_package/extra.m4 b/recipes/automake/all/test_package/extra.m4 deleted file mode 100644 index 69c85f5ac945d..0000000000000 --- a/recipes/automake/all/test_package/extra.m4 +++ /dev/null @@ -1,14 +0,0 @@ -dnl This file contains a macro to test adding extra include dirs using conan - -AC_DEFUN([AUTOMAKE_TEST_PACKAGE_PREREQ],[ - m4_define([CONAN_MACRO_VERSION], [1.3]) - m4_if(m4_version_compare(CONAN_MACRO_VERSION, [$1]), - -1, - [m4_fatal([extra.m4 version $1 or higher is required, but ]CONAN_MACRO_VERSION[ found])] - ) -])dnl AUTOMAKE_TEST_PACKAGE_PREREQ - -AC_DEFUN([AUTOMAKE_TEST_PACKAGE_HELLO],[ - echo "Hello world from the extra.m4 script!" - echo "My args were: $*" -])dnl diff --git a/recipes/automake/all/test_package/test_package.cpp b/recipes/automake/all/test_package/test_package.cpp deleted file mode 100644 index cd8c2f27c3587..0000000000000 --- a/recipes/automake/all/test_package/test_package.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "config.h" - -#include -#include - -int main(int argc, char** argv) { - std::cout << "test_package.cpp: " << "hello world from " PACKAGE_NAME "!\n"; - return EXIT_SUCCESS; -} diff --git a/recipes/automake/all/test_package/test_package_1.c b/recipes/automake/all/test_package/test_package_1.c deleted file mode 100644 index 9aaff6c18e30d..0000000000000 --- a/recipes/automake/all/test_package/test_package_1.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int main() { - puts("test_package.c says 'Hello World'!\n"); - return EXIT_SUCCESS; -}