Skip to content

Commit

Permalink
(conan-io#15358) automake: fix cpp_info.resdirs & more conan v2 stuff
Browse files Browse the repository at this point in the history
* fix cpp_info.resdirs

* more conan v2 stuff & define win_bash on Windows

* cleanup a little bit more

* add autotools topic
  • Loading branch information
SpaceIm authored and franramirez688 committed Jan 20, 2023
1 parent 5ca124c commit 1678aec
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions recipes/automake/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.scm import Version

required_conan_version = ">=1.53.0"

Expand All @@ -15,56 +16,43 @@ class AutomakeConan(ConanFile):
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")
topics = ("autotools", "configure", "build")
license = ("GPL-2.0-or-later", "GPL-3.0-or-later")
settings = "os", "arch", "compiler", "build_type"

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

def export_sources(self):
export_conandata_patches(self)

def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

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

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 self.conf.get("tools.microsoft.bash:path", check_type=str):
self.win_bash = True
self.build_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 source(self):
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, "res")
def build_requirements(self):
if hasattr(self, "settings_build"):
self.tool_requires("autoconf/2.71")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")

@property
def _automake_libdir(self):
return os.path.join(self._datarootdir, "automake-{}".format(self._version_major_minor))
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
Expand All @@ -74,7 +62,6 @@ def generate(self):
tc.configure_args.extend([
"--datarootdir=${prefix}/res",
])

tc.generate()

def _patch_sources(self):
Expand All @@ -88,7 +75,7 @@ def _patch_sources(self):
" $file =~ s/^\\s+|\\s+$//g;\n"
" $map_traced_defs{$arg1} = $file;")
# handle relative paths during aclocal.m4 creation
replace_in_file(self, ac_local_in, "$map{$m} eq $map_traced_defs{$m}",
replace_in_file(self, ac_local_in, "$map{$m} eq $map_traced_defs{$m}",
"abs_path($map{$m}) eq abs_path($map_traced_defs{$m})")

def build(self):
Expand All @@ -97,6 +84,10 @@ def build(self):
autotools.configure()
autotools.make()

@property
def _datarootdir(self):
return os.path.join(self.package_folder, "res")

def package(self):
autotools = Autotools(self)
autotools.install()
Expand All @@ -115,9 +106,15 @@ def package(self):
continue
os.rename(fullpath, fullpath + ".exe")

@property
def _automake_libdir(self):
ver = Version(self.version)
return os.path.join(self._datarootdir, f"automake-{ver.major}.{ver.minor}")

def package_info(self):
self.cpp_info.libdirs = []
self.cpp_info.includedirs = []
self.cpp_info.resdirs = ["res"]

# For consumers with new integrations (Conan 1 and 2 compatible):
compile_wrapper = os.path.join(self._automake_libdir, "compile")
Expand All @@ -128,6 +125,4 @@ def package_info(self):
# For legacy Conan 1.x consumers only:
self.user_info.compile = compile_wrapper
self.user_info.ar_lib = lib_wrapper
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)
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))

0 comments on commit 1678aec

Please sign in to comment.