-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#17698) bazel: update to Conan v2, add v6.2.0
* bazel: update to Conan v2, add v6.2.0 * bazel: Fix an error in conandata.yml * bazel: Drop test_v1_package
- Loading branch information
Showing
4 changed files
with
112 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,43 @@ | ||
sources: | ||
"6.2.0": | ||
license: | ||
url: "https://raw.githubusercontent.com/bazelbuild/bazel/6.2.0/LICENSE" | ||
sha256: "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30" | ||
Macos: | ||
x86_64: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/6.2.0/bazel-6.2.0-darwin-x86_64" | ||
sha256: "d2356012843ce3a2fbba89f88191673a6ad2f7716cc46ad43ec1bcee78d36b44" | ||
armv8: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/6.2.0/bazel-6.2.0-darwin-arm64" | ||
sha256: "482957a15c34eb43b1d1ae5e7623444e4783a04d4c618d7c518fe7b3dbf75512" | ||
Linux: | ||
x86_64: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/6.2.0/bazel-6.2.0-linux-x86_64" | ||
sha256: "3d11c26fb9ba12c833844450bb90165b176e8a19cb5cf5923f3cec855837f17c" | ||
armv8: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/6.2.0/bazel-6.2.0-linux-arm64" | ||
sha256: "16e41fe8fb791ffb9835643435e4828384a1890b0f916fd84b750fa01f783807" | ||
Windows: | ||
x86_64: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/6.2.0/bazel-6.2.0-windows-x86_64.exe" | ||
sha256: "3d119e934ffb26910fcbd44dbc5973761480f58d3a06722cb84a90e16d8c5727" | ||
armv8: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/6.2.0/bazel-6.2.0-windows-arm64.exe" | ||
sha256: "3c23fccd3815933452c859e8482864598b6903d3143f9f18589915bf2c0dd2d4" | ||
|
||
"4.0.0": | ||
- url: "https://raw.githubusercontent.com/bazelbuild/bazel/4.0.0/LICENSE" | ||
sha256: cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 | ||
- url: "https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-darwin-x86_64" | ||
sha256: "349f3c9dd24191369c1073c57cc1386fc3c2d4ad7d44135c3d873c9dc67fae1f" | ||
- url: "https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-linux-x86_64" | ||
sha256: "7bee349a626281fc8b8d04a7a0b0358492712377400ab12533aeb39c2eb2b901" | ||
- url: "https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-windows-x86_64.exe" | ||
sha256: "43930bbbc8b5d618884ee8145e1ec181760bf9eea42d16217a30381d176e4cf6" | ||
license: | ||
url: "https://raw.githubusercontent.com/bazelbuild/bazel/4.0.0/LICENSE" | ||
sha256: "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30" | ||
Macos: | ||
x86_64: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-darwin-x86_64" | ||
sha256: "349f3c9dd24191369c1073c57cc1386fc3c2d4ad7d44135c3d873c9dc67fae1f" | ||
Linux: | ||
x86_64: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-linux-x86_64" | ||
sha256: "7bee349a626281fc8b8d04a7a0b0358492712377400ab12533aeb39c2eb2b901" | ||
Windows: | ||
x86_64: | ||
url: "https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-windows-x86_64.exe" | ||
sha256: "43930bbbc8b5d618884ee8145e1ec181760bf9eea42d16217a30381d176e4cf6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,86 @@ | ||
from conans import ConanFile, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.files import copy, rename, download | ||
|
||
required_conan_version = ">=1.47.0" | ||
|
||
|
||
class BazelConan(ConanFile): | ||
name = "bazel" | ||
package_type = "application" | ||
description = "Bazel is a fast, scalable, multi-language and extensible build system." | ||
license = "Apache-2.0" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://bazel.build/" | ||
topics = ("test", "build", "automation") | ||
settings = "os", "arch" | ||
no_copy_source = True | ||
topics = ("test", "build", "automation", "pre-built") | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
@property | ||
def _program_suffix(self): | ||
return ".exe" if self.settings.os == "Windows" else "" | ||
def layout(self): | ||
pass | ||
|
||
def _chmod_plus_x(self, name): | ||
os.chmod(name, os.stat(name).st_mode | 0o111) | ||
def package_id(self): | ||
del self.info.settings.compiler | ||
del self.info.settings.build_type | ||
|
||
@property | ||
def _bazel_filename(self): | ||
platform = "darwin" if self.settings.os == "Macos" else str(self.settings.os).lower() | ||
return "bazel-{}-{}-{}{}".format(self.version, platform, self.settings.arch, self._program_suffix) | ||
def _binary_info(self): | ||
os = str(self.settings.os) | ||
arch = str(self.settings.arch) | ||
return self.conan_data["sources"][self.version][os].get(arch) | ||
|
||
def validate(self): | ||
if self.settings.arch != "x86_64": | ||
raise ConanInvalidConfiguration("Only amd64 is supported for this package.") | ||
if self.settings.os not in ["Linux", "Macos", "Windows"]: | ||
raise ConanInvalidConfiguration("Only Linux, Windows and OSX are supported for this package.") | ||
if self._binary_info is None: | ||
raise ConanInvalidConfiguration( | ||
f"{self.settings.arch} architecture on {self.settings.os} is not supported for this package." | ||
) | ||
|
||
def source(self): | ||
pass | ||
|
||
@property | ||
def _bazel_filename(self): | ||
return self._binary_info["url"].rsplit("/")[-1] | ||
|
||
def build(self): | ||
for source in self.conan_data["sources"][self.version]: | ||
url = source["url"] | ||
filename = url[url.rfind("/") + 1:] | ||
if filename in ["LICENSE", self._bazel_filename]: | ||
tools.download(url, filename) | ||
tools.check_sha256(filename, source["sha256"]) | ||
download(self, **self._binary_info, filename=self._bazel_filename) | ||
download(self, **self.conan_data["sources"][self.version]["license"], filename="LICENSE") | ||
|
||
@property | ||
def _program_suffix(self): | ||
return ".exe" if self.settings.os == "Windows" else "" | ||
|
||
@staticmethod | ||
def _chmod_plus_x(name): | ||
os.chmod(name, os.stat(name).st_mode | 0o111) | ||
|
||
def package(self): | ||
self.copy(pattern="LICENSE", dst="licenses") | ||
self.copy(pattern=self._bazel_filename, dst="bin") | ||
copy( | ||
self, | ||
pattern="LICENSE", | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
src=self.source_folder, | ||
) | ||
copy( | ||
self, | ||
pattern=self._bazel_filename, | ||
dst=os.path.join(self.package_folder, "bin"), | ||
src=self.source_folder, | ||
) | ||
old_target_filename = os.path.join(self.package_folder, "bin", self._bazel_filename) | ||
new_target_filename = os.path.join(self.package_folder, "bin", "bazel" + self._program_suffix) | ||
tools.rename(old_target_filename, new_target_filename) | ||
rename(self, old_target_filename, new_target_filename) | ||
self._chmod_plus_x(new_target_filename) | ||
|
||
def package_info(self): | ||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info("Appending PATH environment variable with : {0}".format(bin_path)) | ||
self.env_info.path.append(bin_path) | ||
self.cpp_info.frameworkdirs = [] | ||
self.cpp_info.libdirs = [] | ||
self.cpp_info.resdirs = [] | ||
self.cpp_info.includedirs = [] | ||
|
||
# TODO: Legacy, to be removed on Conan 2.0 | ||
bin_folder = os.path.join(self.package_folder, "bin") | ||
self.env_info.PATH.append(bin_folder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
from conans import ConanFile | ||
from conan import ConanFile | ||
|
||
|
||
class TestPackage(ConanFile): | ||
settings = "os", "arch" | ||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "VirtualBuildEnv" | ||
test_type = "explicit" | ||
|
||
def test(self): | ||
self.run("bazel --version", run_environment=True) | ||
def build_requirements(self): | ||
self.tool_requires(self.tested_reference_str) | ||
|
||
def test(self): | ||
self.run("bazel --version") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
versions: | ||
"6.2.0": | ||
folder: all | ||
"4.0.0": | ||
folder: all |