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

[automake] conan ready v2 #12898

Closed
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dc309dc
Added support for conan v2
jellespijker Sep 5, 2022
1c3140e
Don't use unix_path for setting variable
Sep 5, 2022
8af95df
Fix wrong setattr call
Sep 5, 2022
f50f40a
partial revert simplified test_package
jellespijker Sep 7, 2022
efb2026
use real-life test_package scenario
jellespijker Sep 7, 2022
05d9d10
use define or define_path depending on context
jellespijker Sep 7, 2022
e82180c
modernized test_package
jellespijker Sep 7, 2022
082b4ec
fix setattr call
jellespijker Sep 7, 2022
9c76ee1
fix subsystems on Windows
jellespijker Sep 8, 2022
1a1da0e
Use exe extension for bins
jellespijker Sep 9, 2022
a973261
Cleaned up code
jellespijker Sep 11, 2022
de8b1ce
Removed etxra.m4
jellespijker Sep 11, 2022
ebac519
fixed paths to compile, ar-lib and added install-sh
Sep 12, 2022
2a57057
Use conanbuild env as scope for testing
jellespijker Sep 13, 2022
7f7dd66
Convert Path to string in conf_info and env_info
jellespijker Sep 13, 2022
74ffd60
Merge branch 'conan-io:master' into CURA-9575_automake_conan_v2
jellespijker Sep 13, 2022
54476a8
set win_bash during the configure stage
jellespijker Sep 15, 2022
488e8ad
workaround for Unix paths not being set in win_bash env
Sep 15, 2022
0acf8e0
Revert "workaround for Unix paths not being set in win_bash env"
jellespijker Sep 15, 2022
e113728
Merge branch 'conan-io:master' into CURA-9575_automake_conan_v2
jellespijker Sep 21, 2022
6829fcd
Merge branch 'conan-io:master' into CURA-9575_automake_conan_v2
jellespijker Oct 16, 2022
0abf603
move conf key from tools to user space
jellespijker Oct 16, 2022
7a780b2
use *_folder in favor of *_path
jellespijker Oct 16, 2022
bdfa9ad
reuse test_package source files
jellespijker Oct 16, 2022
51ca852
Reformat windows path
Oct 16, 2022
b5d8452
Merge branch 'conan-io:master' into CURA-9575_automake_conan_v2
jellespijker Oct 23, 2022
7fcccd1
use export_conandata_patches
jellespijker Oct 23, 2022
303355e
Use src folder as name for consistency
jellespijker Oct 23, 2022
070119f
Removed unused conf_info values
jellespijker Oct 23, 2022
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
60 changes: 20 additions & 40 deletions recipes/automake/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
247 changes: 143 additions & 104 deletions recipes/automake/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,140 +1,179 @@
from conans import AutoToolsBuildEnvironment, ConanFile, tools
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 apply_conandata_patches, copy, get, replace_in_file, rmdir
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path
from conan.tools.scm import Version

required_conan_version = ">=1.51.3"


class AutomakeConan(ConanFile):
name = "automake"
description = "Automake is a tool for automatically generating Makefile.in files compliant with the GNU Coding Standards."
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/automake/"
description = "Automake is a tool for automatically generating Makefile.in files compliant with the GNU Coding Standards."
topics = ("conan", "automake", "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 _version_major_minor(self):
[major, minor, _] = self.version.split(".", 2)
return '{}.{}'.format(major, minor)

@property
def _settings_build(self):
# TODO: Remove for Conan v2
return getattr(self, "settings_build", self.settings)

def export_sources(self):
for p in self.conan_data.get("patches", {}).get(self.version, []):
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder)

def configure(self):
del self.settings.compiler.cppstd
del self.settings.compiler.libcxx
self.win_bash = self._settings_build.os == "Windows"
try:
del self.settings.compiler.libcxx # for plain C projects only
except ValueError:
pass
try:
del self.settings.compiler.cppstd # for plain C projects only
except ValueError:
pass

def layout(self):
basic_layout(self, src_folder="automake")

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.requires("m4/1.4.19")

def package_id(self):
del self.info.settings.arch
del self.info.settings.compiler
del self.info.settings.build_type
try:
del self.info.settings.arch
except ValueError:
pass
try:
del self.info.settings.compiler
except ValueError:
pass
try:
del self.info.settings.build_type
except ValueError:
pass

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
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")

@property
def _datarootdir(self):
return os.path.join(self.package_folder, "res")
def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def generate(self):
tc = AutotoolsToolchain(self)
tc.configure_args.extend([
"--datarootdir=${prefix}/res",
])

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}")
tc.generate()

deps = AutotoolsDeps(self)
deps.generate()

ms = VirtualBuildEnv(self)
ms.generate(scope="build")

@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)
def build(self):
apply_conandata_patches(self)
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;")

def build(self):
self._patch_files()
autotools = self._configure_autotools()
replace_in_file(self, path.join(self.source_folder, "bin", "aclocal.in"),
" $map_traced_defs{$arg1} = $file;",
" $file = `cygpath -u $file`;\n"
" $file =~ s/^\\s+|\\s+$//g;\n"
" $map_traced_defs{$arg1} = $file;")

autotools = Autotools(self)
autotools.configure()
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"))
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

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")
copy(self, "COPYING*", src=self.source_folder, dst=path.join(self.package_folder, "licenses"))
for sub_path in ("info", "man", "doc"):
rmdir(self, path.join(self.package_folder, "res", sub_path))

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))
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)

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

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

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

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

self.output.info("Append M4 include directories to AUTOMAKE_CONAN_INCLUDES environment variable")

self.user_info.compile = os.path.join(self._automake_libdir, "compile")
self.user_info.ar_lib = os.path.join(self._automake_libdir, "ar-lib")
dataroot_path = path.join(self.package_folder, "res")
self.output.info(f"Defining AUTOMAKE_DATADIR environment variable: {dataroot_path}")
self.env_info.AUTOMAKE_DATADIR = dataroot_path
self.buildenv_info.define_path("AUTOMAKE_DATADIR", dataroot_path)

version = Version(self.version)
automake_dataroot_path = path.join(dataroot_path, f"automake-{version.major}.{version.minor}")
self.output.info(f"Defining AUTOMAKE_LIBDIR environment variable: {automake_dataroot_path}")
self.env_info.AUTOMAKE_LIBDIR = automake_dataroot_path
self.buildenv_info.define_path("AUTOMAKE_LIBDIR", automake_dataroot_path)

self.output.info(f"Defining AUTOMAKE_PERLLIBDIR environment variable: {automake_dataroot_path}")
self.env_info.AUTOMAKE_PERLLIBDIR = automake_dataroot_path
self.buildenv_info.define_path("AUTOMAKE_PERLLIBDIR", automake_dataroot_path)

aclocal_bin = path.join(bin_path, "aclocal")
self.output.info(f"Defining ACLOCAL environment variable: {aclocal_bin}")
self.env_info.ACLOCAL = aclocal_bin
self.buildenv_info.define_path("ACLOCAL", aclocal_bin)

aclocal_bin_conf_key = "user.automake:aclocal"
self.output.info(f"Defining path to aclocal binary in configuration as `{aclocal_bin_conf_key}` with value: {aclocal_bin}")
self.conf_info.define(aclocal_bin_conf_key, aclocal_bin)

automake_bin = path.join(bin_path, "automake")
self.output.info(f"Defining AUTOMAKE environment variable: {automake_bin}")
self.env_info.AUTOMAKE = automake_bin
self.buildenv_info.define_path("AUTOMAKE", automake_bin)

automake_bin_conf_key = "user.automake:automake"
self.output.info(f"Defining path to automake binary in configuration as `{automake_bin_conf_key}` with value: {automake_bin}")
self.conf_info.define(automake_bin_conf_key, automake_bin)

compile_bin = path.join(automake_dataroot_path, "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(automake_dataroot_path, "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)

install_sh_bin = path.join(automake_dataroot_path, "install-sh")
self.output.info(f"Define path to install_sh binary in user_info as: {install_sh_bin}")
self.user_info.install_sh = install_sh_bin
install_sh_conf_key = "user.automake:install-sh"
self.output.info(f"Defining path to install_sh binary in configuration as `{install_sh_conf_key}` with value: {install_sh_bin}")
self.conf_info.define(install_sh_conf_key, install_sh_bin)
Loading