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

pixman: patch in build() instead of source() + bump msys2 + del fPIC if shared + fix hooks #3225

Merged
merged 11 commits into from
Oct 20, 2020
63 changes: 34 additions & 29 deletions recipes/pixman/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration
import os
import glob


class PixmanConan(ConanFile):
Expand All @@ -17,40 +16,49 @@ class PixmanConan(ConanFile):
_autotools = None

@property
def _includedir(self):
return os.path.join("include", "pixman-1")
def _source_subfolder(self):
return "source_subfolder"

@property
def _folder(self):
return "{}-{}".format(self.name, self.version)
def _includedir(self):
return os.path.join("include", "pixman-1")

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.settings.os == 'Windows':
del self.options.fPIC
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("pixman can only be built as a static library on Windows")

def build_requirements(self):
if tools.os_info.is_windows:
if "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != 'msys2':
self.build_requires("msys2/20190524")

def configure(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("pixman can only built as static library for Windows")
self.build_requires("msys2/20200517")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename(self.name + "-" + self.version, self._source_subfolder)

if self.settings.os == 'Macos':
def _patch_sources(self):
if self.settings.compiler == "Visual Studio":
tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.win32.common"),
"-MDd ", "-{} ".format(str(self.settings.compiler.runtime)))
tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.win32.common"),
"-MD ", "-{} ".format(str(self.settings.compiler.runtime)))
if self.settings.os == "Macos":
# https://lists.freedesktop.org/archives/pixman/2014-November/003461.html
test_makefile = os.path.join(self._folder, 'test', 'Makefile.in')
test_makefile = os.path.join(self._source_subfolder, "test", "Makefile.in")
tools.replace_in_file(test_makefile,
'region_test_OBJECTS = region-test.$(OBJEXT)',
'region_test_OBJECTS = region-test.$(OBJEXT) utils.$(OBJEXT)')
"region_test_OBJECTS = region-test.$(OBJEXT)",
"region_test_OBJECTS = region-test.$(OBJEXT) utils.$(OBJEXT)")
tools.replace_in_file(test_makefile,
'scaling_helpers_test_OBJECTS = scaling-helpers-test.$(OBJEXT)',
'scaling_helpers_test_OBJECTS = scaling-helpers-test.$(OBJEXT) utils.$(OBJEXT)')
"scaling_helpers_test_OBJECTS = scaling-helpers-test.$(OBJEXT)",
"scaling_helpers_test_OBJECTS = scaling-helpers-test.$(OBJEXT) utils.$(OBJEXT)")

def _configure_autotools(self):
if not self._autotools:
Expand All @@ -60,10 +68,11 @@ def _configure_autotools(self):
else:
args.extend(["--enable-static", "--disable-shared"])
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
self._autotools.configure(configure_dir=self._folder, args=args)
self._autotools.configure(configure_dir=self._source_subfolder, args=args)
return self._autotools

def build(self):
self._patch_sources()
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self.settings):
make_vars = {
Expand All @@ -72,12 +81,8 @@ def build(self):
"SSSE3": "on",
"CFG": str(self.settings.build_type).lower(),
}
tools.replace_in_file(os.path.join(self._folder, 'Makefile.win32.common'),
'-MDd ', '-%s ' % str(self.settings.compiler.runtime))
tools.replace_in_file(os.path.join(self._folder, 'Makefile.win32.common'),
'-MD ', '-%s ' % str(self.settings.compiler.runtime))
var_args = " ".join("{}={}".format(k, v) for k, v in make_vars.items())
self.run("make -C {}/pixman -f Makefile.win32 {}".format(self._folder, var_args),
self.run("make -C {}/pixman -f Makefile.win32 {}".format(self._source_subfolder, var_args),
win_bash=True)
else:
autotools = self._configure_autotools()
Expand All @@ -91,11 +96,11 @@ def package(self):
else:
autotools = self._configure_autotools()
autotools.install()
la = os.path.join(self.package_folder, "lib", "libpixman-1.la")
if os.path.isfile(la):
os.unlink(la)
self.copy(os.path.join(self._folder, 'COPYING'), dst='licenses')
tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))
tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, I think you forgot to convert these to double quotes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt it's needed, only adds additional noise

la = os.path.join(self.package_folder, "lib", "libpixman-1.la")
if os.path.isfile(la):
os.unlink(la)
self.copy(os.path.join(self._source_subfolder, 'COPYING'), dst='licenses')

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
Expand Down
2 changes: 1 addition & 1 deletion recipes/pixman/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
Expand Down