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

depot_tools: migrate to Conan v2 #18982

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion recipes/depot_tools/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"cci.20201009":
url: "https://chromium.googlesource.com/chromium/tools/depot_tools.git/+archive/b073999c6f90103a36a923e63ae8cf7a5c9c6c8c.tar.gz"
patches:
"cci.20201009":
- patch_file: "patches/001-use-system-python.patch"

Check warning on line 8 in recipes/depot_tools/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/001-use- ... ^ (line: 8)
base_path: "source_subfolder"
114 changes: 64 additions & 50 deletions recipes/depot_tools/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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):
"""
Expand All @@ -30,63 +39,68 @@
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):

Check warning on line 42 in recipes/depot_tools/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused variable 'dirs'
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)
os.remove(symlink)
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)
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
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"
15 changes: 13 additions & 2 deletions recipes/depot_tools/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
7 changes: 7 additions & 0 deletions recipes/depot_tools/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)