Skip to content

Commit

Permalink
(conan-io#5599) libsafec: fix MinGW + resolve build requires conflicts
Browse files Browse the repository at this point in the history
* no os.rename

* fix versions conflicts in build requirements

* fix build for mingw

also use a more standard layout for autotools recipes
  • Loading branch information
SpaceIm authored and madebr committed Jun 21, 2021
1 parent 27f1ede commit 3cd7ff0
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions recipes/libsafec/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import glob
import os

from conans import AutoToolsBuildEnvironment, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.29.1"
required_conan_version = ">=1.33.0"


class LibSafeCConan(ConanFile):
Expand All @@ -20,11 +18,12 @@ class LibSafeCConan(ConanFile):
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

build_requires = "autoconf/2.69", "libtool/2.4.6"
exports_sources = "patches/*"
_autotools = None

__autotools = None
_source_subfolder = "source_subfolder"
@property
def _source_subfolder(self):
return "source_subfolder"

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -50,40 +49,42 @@ def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob.glob("safeclib-*")[0]
os.rename(extracted_dir, self._source_subfolder)
def build_requirements(self):
self.build_requires("libtool/2.4.6")
if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")

@property
def _autotools(self):
if self.__autotools is None:
self.__autotools = AutoToolsBuildEnvironment(self)
return self.__autotools
def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _autotools_configure(self):
def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
if self.options.shared:
args = ["--enable-shared", "--disable-static"]
else:
args = ["--disable-shared", "--enable-static"]
args.extend(["--disable-doc", "--disable-Werror"])
if self.settings.build_type in ("Debug", "RelWithDebInfo"):
args.append("--enable-debug")
self._autotools.configure(args=args)
self._autotools.configure(configure_dir=self._source_subfolder, args=args)
return self._autotools

def build(self):
with tools.chdir(self._source_subfolder):
self.run("autoreconf -fiv", run_environment=True)
self._autotools_configure()
self._autotools.make()
self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
win_bash=tools.os_info.is_windows, run_environment=True)
autotools = self._configure_autotools()
autotools.make()

def package(self):
with tools.chdir(self._source_subfolder):
self._autotools.install()
self.copy("COPYING", src=self._source_subfolder, dst="licenses")
with tools.chdir(os.path.join(self.package_folder, "lib")):
tools.rmdir("pkgconfig")
tools.remove_files_by_mask(".", "*.la")
autotools = self._configure_autotools()
autotools.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")

def package_info(self):
self.cpp_info.includedirs.append(os.path.join("include", "libsafec"))
Expand Down

0 comments on commit 3cd7ff0

Please sign in to comment.