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

M4 Conan 2.0 compatibility #14544

Merged
merged 13 commits into from
Jan 27, 2023
Merged
22 changes: 12 additions & 10 deletions recipes/m4/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
from conan.tools.microsoft import is_msvc, unix_path
from conan.tools.scm import Version
import os
import shutil

required_conan_version = ">=1.52.0"
required_conan_version = ">=1.55.0"


class M4Conan(ConanFile):
name = "m4"
package_type = "application"
description = "GNU M4 is an implementation of the traditional Unix macro processor"
topics = ("macro", "preprocessor")
homepage = "https://www.gnu.org/software/m4/"
Expand All @@ -34,9 +36,9 @@ def package_id(self):

def build_requirements(self):
if self._settings_build.os == "Windows":
if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool):
self.tool_requires("msys2/cci.latest")
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")

def source(self):
get(self, **self.conan_data["sources"][self.version],
Expand Down Expand Up @@ -87,11 +89,12 @@ def generate(self):

def _patch_sources(self):
apply_conandata_patches(self)
# dummy file for configure
help2man = os.path.join(self.source_folder, "help2man")
save(self, help2man, "#!/usr/bin/env bash\n:")
if os.name == "posix":
os.chmod(help2man, os.stat(help2man).st_mode | 0o111)
if shutil.which("help2man") == None:
# dummy file for configure
help2man = os.path.join(self.source_folder, "help2man")
save(self, help2man, "#!/usr/bin/env bash\n:")
if os.name == "posix":
os.chmod(help2man, os.stat(help2man).st_mode | 0o111)

def build(self):
self._patch_sources()
Expand All @@ -102,8 +105,7 @@ def build(self):
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
# TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed
autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"])
autotools.install()
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
Expand Down
2 changes: 1 addition & 1 deletion recipes/m4/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ def test(self):
self.run(f"m4 -R {self.source_folder}/frozen.m4f {self.source_folder}/test.m4")

output = StringIO()
self.run(f"m4 -P {self._m4_input_path}", output=output)
self.run(f"m4 -P {self._m4_input_path}", output)
assert "Harry, Jr. met Sally" in output.getvalue()