From c728c322adb6ee22f6d21040ea48f683c69afdf0 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Thu, 5 Dec 2024 15:57:33 +0100 Subject: [PATCH] gn: add support to macos x86_64 and fix cross compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Abril Rincón Blanco --- recipes/gn/all/conanfile.py | 35 ++---------------------- recipes/gn/all/test_package/conanfile.py | 6 ++-- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/recipes/gn/all/conanfile.py b/recipes/gn/all/conanfile.py index b7c257685f..0d2157c4b5 100644 --- a/recipes/gn/all/conanfile.py +++ b/recipes/gn/all/conanfile.py @@ -2,10 +2,8 @@ import os import shutil import sys import textwrap -import time from conan import ConanFile -from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os, XCRun from conan.tools.build import check_min_cppstd from conan.tools.env import VirtualBuildEnv, Environment @@ -14,7 +12,7 @@ from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, VCVars from conan.tools.scm import Version -required_conan_version = ">=1.47.0" +required_conan_version = ">=2.0.9" class GnConan(ConanFile): @@ -36,36 +34,13 @@ class GnConan(ConanFile): @property def _min_cppstd(self): - if self.version == "cci.20210429": + if Version(self.version) == "cci.20210429": return 17 else: return 20 - @property - def _minimum_compiler_version(self): - if self._min_cppstd == 17: - return { - "Visual Studio": 15, - "msvc": 191, - "gcc": 7, - "clang": 4, - "apple-clang": 10, - }.get(str(self.settings.compiler)) - else: - return { - "gcc": "11", - "clang": "12", - "apple-clang": "15", - "msvc": "192", - "Visual Studio": "16", - }.get(str(self.settings.compiler)) - def validate_build(self): - if self.settings.compiler.cppstd: - check_min_cppstd(self, self._min_cppstd) - if self._minimum_compiler_version and Version(self.settings.compiler.version) < self._minimum_compiler_version: - raise ConanInvalidConfiguration(f"gn requires a compiler supporting C++{self._min_cppstd}") - + check_min_cppstd(self, self._min_cppstd) def build_requirements(self): # FIXME: add cpython build requirements for `build/gen.py`. @@ -168,7 +143,3 @@ class GnConan(ConanFile): self.cpp_info.frameworkdirs = [] self.cpp_info.libdirs = [] self.cpp_info.resdirs = [] - - bin_path = os.path.join(self.package_folder, "bin") - self.output.info(f"Appending PATH environment variable: {bin_path}") - self.env_info.PATH.append(bin_path) diff --git a/recipes/gn/all/test_package/conanfile.py b/recipes/gn/all/test_package/conanfile.py index 4a3175e525..86e73805a0 100644 --- a/recipes/gn/all/test_package/conanfile.py +++ b/recipes/gn/all/test_package/conanfile.py @@ -13,8 +13,10 @@ class TestPackageConan(ConanFile): generators = "VCVars" test_type = "explicit" + def requirements(self): + self.requires(self.tested_reference_str) + def build_requirements(self): - self.tool_requires(self.tested_reference_str) self.tool_requires("ninja/1.11.1") def layout(self): @@ -47,7 +49,7 @@ class TestPackageConan(ConanFile): rel_bindir, f'--args="target_os=\\"{self._target_os}\\" target_cpu=\\"{self._target_cpu}\\""', ] - self.run("gn gen " + " ".join(gn_args)) + self.run("gn gen " + " ".join(gn_args), env="conanrun") self.run(f"ninja -v -j{os.cpu_count()} -C {rel_bindir}") def test(self):