-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
msys2: Conan 2.0 compatibility tweaks #14686
Changes from all commits
59e130a
cb4c332
66de1e8
30ecd01
656d687
95c3980
ecd8e49
5640aa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration, ConanException | ||
from conan.tools.files import chdir, get, replace_in_file | ||
from conan.tools.files import chdir, get, replace_in_file, copy | ||
from conan.tools.layout import basic_layout | ||
import fnmatch | ||
import os | ||
import shutil | ||
import subprocess | ||
import errno | ||
import ctypes | ||
|
||
try: | ||
import ctypes | ||
except ImportError: | ||
pass | ||
except ValueError: | ||
pass | ||
|
||
required_conan_version = ">=1.47.0" | ||
|
||
required_conan_version = ">=1.55.0" | ||
|
||
class lock: | ||
def __init__(self): | ||
|
@@ -38,7 +32,6 @@ def close(self): | |
|
||
__del__ = close | ||
|
||
|
||
class MSYS2Conan(ConanFile): | ||
name = "msys2" | ||
description = "MSYS2 is a software distro and building platform for Windows" | ||
|
@@ -53,11 +46,13 @@ class MSYS2Conan(ConanFile): | |
"exclude_files": ["ANY"], | ||
"packages": ["ANY"], | ||
"additional_packages": [None, "ANY"], | ||
"no_kill": [True, False] | ||
} | ||
default_options = { | ||
"exclude_files": "*/link.exe", | ||
"packages": "base-devel,binutils,gcc", | ||
"additional_packages": None, | ||
"no_kill": False, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this option should be removed from package id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops! I for this was not resolved 🙈 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
short_paths = True | ||
|
@@ -68,9 +63,16 @@ def validate(self): | |
if self.settings.arch != "x86_64": | ||
raise ConanInvalidConfiguration("Only Windows x64 supported") | ||
|
||
def configure(self): | ||
self.settings.rm_safe("compiler.libcxx") | ||
self.settings.rm_safe("compiler.cppstd") | ||
|
||
Comment on lines
+66
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's useless and confusing. There is no compiler in settings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @SpaceIm, |
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def source(self): | ||
# sources are different per configuration - do download in build | ||
pass | ||
get(self, **self.conan_data["sources"][self.version], | ||
destination=self.source_folder, strip_root=False) # Preserve tarball root dir (msys64/) | ||
|
||
def _update_pacman(self): | ||
with chdir(self, os.path.join(self._msys_dir, "usr", "bin")): | ||
|
@@ -90,6 +92,8 @@ def _update_pacman(self): | |
|
||
# https://github.com/msys2/MSYS2-packages/issues/1966 | ||
def _kill_pacman(self): | ||
if self.options.no_kill: | ||
return | ||
if (self.settings.os == "Windows"): | ||
taskkill_exe = os.path.join(os.environ.get('SystemRoot'), 'system32', 'taskkill.exe') | ||
|
||
|
@@ -98,7 +102,7 @@ def _kill_pacman(self): | |
out = subprocess.PIPE | ||
err = subprocess.STDOUT | ||
else: | ||
out = open(os.devnull, 'w') | ||
out = open(os.devnull, 'w', encoding='UTF-8') | ||
err = subprocess.PIPE | ||
|
||
if os.path.exists(taskkill_exe): | ||
|
@@ -114,16 +118,14 @@ def _kill_pacman(self): | |
proc.wait() | ||
except OSError as e: | ||
if e.errno == errno.ENOENT: | ||
raise ConanException("Cannot kill pacman") | ||
raise ConanException("Cannot kill pacman") from e | ||
|
||
@property | ||
def _msys_dir(self): | ||
subdir = "msys64" | ||
return os.path.join(self.package_folder, "bin", subdir) | ||
subdir = "msys64" # top-level directoy in tarball | ||
return os.path.join(self.source_folder, subdir) | ||
|
||
def build(self): | ||
get(self, **self.conan_data["sources"][self.version], | ||
destination=os.path.join(self.package_folder, "bin")) | ||
with lock(): | ||
self._do_build() | ||
|
||
|
@@ -150,7 +152,7 @@ def _do_build(self): | |
if not os.path.isdir(tmp_dir): | ||
os.makedirs(tmp_dir) | ||
tmp_name = os.path.join(tmp_dir, 'dummy') | ||
with open(tmp_name, 'a'): | ||
with open(tmp_name, 'a', encoding='UTF-8'): | ||
os.utime(tmp_name, None) | ||
|
||
# Prepend the PKG_CONFIG_PATH environment variable with an eventual PKG_CONFIG_PATH environment variable | ||
|
@@ -161,13 +163,14 @@ def package(self): | |
excludes = None | ||
if self.options.exclude_files: | ||
excludes = tuple(str(self.options.exclude_files).split(",")) | ||
#self.copy("*", dst="bin", src=self._msys_dir, excludes=excludes) | ||
for exclude in excludes: | ||
for root, _, filenames in os.walk(self._msys_dir): | ||
for filename in filenames: | ||
fullname = os.path.join(root, filename) | ||
if fnmatch.fnmatch(fullname, exclude): | ||
os.unlink(fullname) | ||
# See https://github.com/conan-io/conan-center-index/blob/master/docs/error_knowledge_base.md#kb-h013-default-package-layout | ||
copy(self, "*", dst=os.path.join(self.package_folder, "bin", "msys64"), src=self._msys_dir, excludes=excludes) | ||
shutil.copytree(os.path.join(self._msys_dir, "usr", "share", "licenses"), | ||
os.path.join(self.package_folder, "licenses")) | ||
|
||
|
@@ -176,7 +179,7 @@ def package_info(self): | |
self.cpp_info.includedirs = [] | ||
self.cpp_info.resdirs = [] | ||
|
||
msys_root = self._msys_dir | ||
msys_root = os.path.join(self.package_folder, "bin", "msys64") | ||
msys_bin = os.path.join(msys_root, "usr", "bin") | ||
self.cpp_info.bindirs.append(msys_bin) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
min conan version is 1.53.0 with these unecessary rm_safe, and without it's 1.47.0