diff --git a/recipes/depot_tools/all/conandata.yml b/recipes/depot_tools/all/conandata.yml index 76dffe6ab4ef4..ab4c55cfe78ae 100644 --- a/recipes/depot_tools/all/conandata.yml +++ b/recipes/depot_tools/all/conandata.yml @@ -6,4 +6,3 @@ sources: patches: "cci.20201009": - patch_file: "patches/001-use-system-python.patch" - base_path: "source_subfolder" diff --git a/recipes/depot_tools/all/conanfile.py b/recipes/depot_tools/all/conanfile.py index 45bfe37d78533..a56140f75a3c9 100644 --- a/recipes/depot_tools/all/conanfile.py +++ b/recipes/depot_tools/all/conanfile.py @@ -1,24 +1,33 @@ import os import shutil -from conans import ConanFile, tools + +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +from conan.tools.layout import basic_layout + +required_conan_version = ">=1.52.0" class DepotToolsConan(ConanFile): name = "depot_tools" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://chromium.googlesource.com/chromium/tools/depot_tools" description = "Tools for working with Chromium development." - topics = ("depot_tools", "chromium") license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://chromium.googlesource.com/chromium/tools/depot_tools" + topics = ("chromium", "pre-built") + + package_type = "application" + settings = "os", "arch", "compiler", "build_type" short_paths = True - no_copy_source = True - settings = "os", "arch", "build_type", "compiler" - exports_sources = ["patches/**"] + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") - @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + def package_id(self): + self.info.clear() def _dereference_symlinks(self): """ @@ -30,7 +39,7 @@ def _dereference_symlinks(self): if self.settings.os != "Windows": return - for root, dirs, files in os.walk(self._source_subfolder): + for root, dirs, files in os.walk(self.source_folder): symlinks = [os.path.join(root, f) for f in files if os.path.islink(os.path.join(root, f))] for symlink in symlinks: dest = os.readlink(symlink) @@ -38,55 +47,60 @@ def _dereference_symlinks(self): shutil.copy(os.path.join(root, dest), symlink, follow_symlinks=False) self.output.info("Replaced symlink '%s' with its destination file '%s'" % (symlink, dest)) - def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder) + def build(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) self._dereference_symlinks() - - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="bin", src=self._source_subfolder) - self._fix_permissions() + apply_conandata_patches(self) def _fix_permissions(self): + if self.settings.os == "Windows": + return def chmod_plus_x(name): os.chmod(name, os.stat(name).st_mode | 0o111) - if self.settings.os != "Windows": - for root, _, files in os.walk(self.package_folder): - for file_it in files: - filename = os.path.join(root, file_it) - with open(filename, 'rb') as f: - sig = f.read(4) - if type(sig) is str: - sig = [ord(s) for s in sig] - if len(sig) >= 2 and sig[0] == 0x23 and sig[1] == 0x21: - self.output.info('chmod on script file %s' % file_it) - chmod_plus_x(filename) - elif sig == [0x7F, 0x45, 0x4C, 0x46]: - self.output.info('chmod on ELF file %s' % file_it) - chmod_plus_x(filename) - elif \ - sig == [0xCA, 0xFE, 0xBA, 0xBE] or \ - sig == [0xBE, 0xBA, 0xFE, 0xCA] or \ - sig == [0xFE, 0xED, 0xFA, 0xCF] or \ - sig == [0xCF, 0xFA, 0xED, 0xFE] or \ - sig == [0xFE, 0xED, 0xFA, 0xCE] or \ - sig == [0xCE, 0xFA, 0xED, 0xFE]: - self.output.info('chmod on Mach-O file %s' % file_it) - chmod_plus_x(filename) + for root, _, files in os.walk(self.package_folder): + for file_it in files: + filename = os.path.join(root, file_it) + with open(filename, "rb") as f: + sig = tuple(f.read(4)) + if len(sig) >= 2 and sig[0] == 0x23 and sig[1] == 0x21: + self.output.info(f"chmod on script file {file_it}") + chmod_plus_x(filename) + elif sig == (0x7F, 0x45, 0x4C, 0x46): + self.output.info(f"chmod on ELF file {file_it}") + chmod_plus_x(filename) + elif sig in [ + (0xCA, 0xFE, 0xBA, 0xBE), + (0xBE, 0xBA, 0xFE, 0xCA), + (0xFE, 0xED, 0xFA, 0xCF), + (0xCF, 0xFA, 0xED, 0xFE), + (0xFE, 0xED, 0xFA, 0xCE), + (0xCE, 0xFA, 0xED, 0xFE), + ]: + self.output.info(f"chmod on Mach-O file {file_it}") + chmod_plus_x(filename) - def package_id(self): - del self.info.settings.arch - del self.info.settings.build_type - del self.info.settings.compiler + def package(self): + copy(self, "LICENSE", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder) + copy(self, "*", + dst=os.path.join(self.package_folder, "bin"), + src=self.source_folder) + self._fix_permissions() def package_info(self): + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.includedirs = [] + + self.runenv_info.define("DEPOT_TOOLS_UPDATE", "0") + self.buildenv_info.define("DEPOT_TOOLS_UPDATE", "0") + + # TODO: Legacy, to be removed on Conan 2.0 bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.output.info(f"Appending PATH env var with : {bin_path}") self.env_info.PATH.append(bin_path) - self.env_info.DEPOT_TOOLS_UPDATE = "0" diff --git a/recipes/depot_tools/all/test_package/conanfile.py b/recipes/depot_tools/all/test_package/conanfile.py index 38bf21d14dbee..4315ef29254a7 100644 --- a/recipes/depot_tools/all/test_package/conanfile.py +++ b/recipes/depot_tools/all/test_package/conanfile.py @@ -1,7 +1,18 @@ -from conans import ConanFile +from conan import ConanFile +from conan.tools.cmake import cmake_layout class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + def test(self): # cit: Chrome Infrastructure CLI - self.run("cit --help", run_environment=True) + self.run("cit --help") diff --git a/recipes/depot_tools/all/test_v1_package/conanfile.py b/recipes/depot_tools/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38bf21d14dbee --- /dev/null +++ b/recipes/depot_tools/all/test_v1_package/conanfile.py @@ -0,0 +1,7 @@ +from conans import ConanFile + + +class TestPackageConan(ConanFile): + def test(self): + # cit: Chrome Infrastructure CLI + self.run("cit --help", run_environment=True)