mirror of
https://github.com/bazel-contrib/rules_foreign_cc
synced 2024-11-28 08:43:26 +00:00
118 lines
3.6 KiB
Python
118 lines
3.6 KiB
Python
"""
|
|
Defines repositories and register toolchains for versions of the tools built
|
|
from source
|
|
"""
|
|
|
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
|
|
|
_ALL_CONTENT = """\
|
|
filegroup(
|
|
name = "all_srcs",
|
|
srcs = glob(["**"]),
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
"""
|
|
|
|
# buildifier: disable=unnamed-macro
|
|
def built_toolchains(cmake_version, make_version, ninja_version):
|
|
"""Register toolchains for built tools that will be built from source"""
|
|
_cmake_toolchain(cmake_version)
|
|
_make_toolchain(make_version)
|
|
_ninja_toolchain(ninja_version)
|
|
|
|
def _cmake_toolchain(version):
|
|
native.register_toolchains(
|
|
"@rules_foreign_cc//toolchains:built_cmake_toolchain",
|
|
)
|
|
if "3.20.1" == version:
|
|
maybe(
|
|
http_archive,
|
|
name = "cmake_src",
|
|
build_file_content = _ALL_CONTENT,
|
|
strip_prefix = "cmake-3.20.1",
|
|
urls = [
|
|
"https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1.tar.gz",
|
|
],
|
|
)
|
|
return
|
|
|
|
if "3.20.0" == version:
|
|
maybe(
|
|
http_archive,
|
|
name = "cmake_src",
|
|
build_file_content = _ALL_CONTENT,
|
|
sha256 = "9c06b2ddf7c337e31d8201f6ebcd3bba86a9a033976a9aee207fe0c6971f4755",
|
|
strip_prefix = "cmake-3.20.0",
|
|
urls = [
|
|
"https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0.tar.gz",
|
|
],
|
|
)
|
|
return
|
|
|
|
if "3.19.7" == version:
|
|
maybe(
|
|
http_archive,
|
|
name = "cmake_src",
|
|
build_file_content = _ALL_CONTENT,
|
|
sha256 = "58a15f0d56a0afccc3cc5371234fce73fcc6c8f9dbd775d898e510b83175588e",
|
|
strip_prefix = "cmake-3.19.7",
|
|
urls = [
|
|
"https://github.com/Kitware/CMake/releases/download/v3.19.7/cmake-3.19.7.tar.gz",
|
|
],
|
|
)
|
|
return
|
|
|
|
if "3.19.6" == version:
|
|
maybe(
|
|
http_archive,
|
|
name = "cmake_src",
|
|
build_file_content = _ALL_CONTENT,
|
|
sha256 = "ec87ab67c45f47c4285f204280c5cde48e1c920cfcfed1555b27fb3b1a1d20ba",
|
|
strip_prefix = "cmake-3.19.6",
|
|
urls = [
|
|
"https://github.com/Kitware/CMake/releases/download/v3.19.6/cmake-3.19.6.tar.gz",
|
|
],
|
|
)
|
|
return
|
|
|
|
fail("Unsupported cmake version: " + str(version))
|
|
|
|
def _make_toolchain(version):
|
|
native.register_toolchains(
|
|
"@rules_foreign_cc//toolchains:built_make_toolchain",
|
|
)
|
|
if version == "4.3":
|
|
maybe(
|
|
http_archive,
|
|
name = "gnumake_src",
|
|
build_file_content = _ALL_CONTENT,
|
|
sha256 = "e05fdde47c5f7ca45cb697e973894ff4f5d79e13b750ed57d7b66d8defc78e19",
|
|
strip_prefix = "make-4.3",
|
|
urls = [
|
|
"http://ftpmirror.gnu.org/gnu/make/make-4.3.tar.gz",
|
|
],
|
|
)
|
|
return
|
|
|
|
fail("Unsupported make version: " + str(version))
|
|
|
|
def _ninja_toolchain(version):
|
|
native.register_toolchains(
|
|
"@rules_foreign_cc//toolchains:built_ninja_toolchain",
|
|
)
|
|
if version == "1.10.2":
|
|
maybe(
|
|
http_archive,
|
|
name = "ninja_build_src",
|
|
build_file_content = _ALL_CONTENT,
|
|
sha256 = "ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed",
|
|
strip_prefix = "ninja-1.10.2",
|
|
urls = [
|
|
"https://github.com/ninja-build/ninja/archive/v1.10.2.tar.gz",
|
|
],
|
|
)
|
|
return
|
|
|
|
fail("Unsupported ninja version: " + str(version))
|