From 79156fe20f4a10071cc9a985642d056a769fdae0 Mon Sep 17 00:00:00 2001 From: Nikola Radakovic Date: Tue, 10 Feb 2026 23:13:53 +0000 Subject: [PATCH] Enable new toolchain for AutoSD The new toolchain comes with set of requirements which we now updated so that toolchain definition can be made based on selected constraints. Also several new input arguments have been added. - sdk_version - use_base_constraints_only --- MODULE.bazel | 4 +- examples/.bazelrc | 65 +++--- examples/BUILD | 8 +- examples/MODULE.bazel | 80 ++++---- examples/test.sh | 23 +++ extensions/gcc.bzl | 245 ++++++++++++++--------- packages/linux/aarch64/autosd/10.0/BUILD | 2 +- packages/linux/aarch64/gcc/12.2.0/BUILD | 2 +- packages/linux/x86_64/autosd/10.0/BUILD | 2 +- packages/linux/x86_64/gcc/12.2.0/BUILD | 2 +- packages/version_matrix.bzl | 144 +++++++------ rules/common.bzl | 4 +- rules/gcc.bzl | 101 ++++++---- templates/BUILD.template | 6 +- 14 files changed, 403 insertions(+), 285 deletions(-) create mode 100755 examples/test.sh diff --git a/MODULE.bazel b/MODULE.bazel index 4bb76fa..f1e0e7f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,7 +13,7 @@ module( name = "score_bazel_cpp_toolchains", - version = "0.2.2", + version = "0.3.0", compatibility_level = 0, ) @@ -26,7 +26,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1") # Constraint values for specifying platforms and toolchains # ******************************************************************************* bazel_dep(name = "platforms", version = "1.0.0") -bazel_dep(name = "score_bazel_platforms", version = "0.0.2") +bazel_dep(name = "score_bazel_platforms", version = "0.1.0") # ******************************************************************************* # C++ Rules for Bazel diff --git a/examples/.bazelrc b/examples/.bazelrc index ee241d5..975a32e 100644 --- a/examples/.bazelrc +++ b/examples/.bazelrc @@ -18,60 +18,53 @@ common --registry=https://bcr.bazel.build # Shared configuration for simple test execution build:shared --incompatible_strict_action_env build:shared --sandbox_writable_path=/var/tmp -build:shared --host_platform=@score_bazel_platforms//:x86_64-linux # ------------------------------------------------------------------------------- -# Config dedicated to host platform CPU:x86_64 and OS:Linux +# Different toolchain configuration for x86_64-linux (host) # ------------------------------------------------------------------------------- -build:x86_64-linux --config=shared -build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix +build:host_config_1 --config=shared +build:host_config_1 --host_platform=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix +build:host_config_1 --extra_toolchains=@score_gcc_toolchain//:x86_64-linux-gcc_12.2.0 +build:host_config_1 --host_features=use_pthread # ------------------------------------------------------------------------------- -# Different toolchain configuration for x86_64-linux +# Different toolchain configuration for x86_64-linux (host) # ------------------------------------------------------------------------------- -build:host_config_1 --config=x86_64-linux -build:host_config_1 --extra_toolchains=@score_gcc_toolchain//:x86_64-linux-gcc_12.2.0-posix -build:host_config_1 --features=use_pthread +build:host_config_2 --config=shared +build:host_config_2 --host_platform=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix +build:host_config_2 --extra_toolchains=@my_toolchain//:x86_64-linux-gcc_12.2.0 # ------------------------------------------------------------------------------- -# Different toolchain configuration for x86_64-linux +# Different toolchain configuration for x86_64-linux (host) # ------------------------------------------------------------------------------- -build:host_config_2 --config=x86_64-linux -build:host_config_2 --extra_toolchains=@my_toolchain//:x86_64-linux-gcc_12.2.0-posix +build:host_config_3 --config=shared +build:host_config_3 --host_platform=@score_bazel_platforms//:x86_64-linux +build:host_config_3 --extra_toolchains=@score_gcc_toolchain_bp//:x86_64-linux # ------------------------------------------------------------------------------- -# Config dedicated to target platform CPU:aarch64 and OS:linux +# Toolchain configuration for x86_64-qnx (target) # ------------------------------------------------------------------------------- -build:aarch64-linux --config=shared -build:aarch64-linux --platforms=@score_bazel_platforms//:aarch64-linux-gcc_12.2.0-posix +build:target_config_1 --config=host_config_1 +build:target_config_1 --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix +build:target_config_1 --extra_toolchains=@score_qcc_toolchain//:x86_64-qnx-sdp_8.0.0 # ------------------------------------------------------------------------------- -# Different toolchain configuration for aarch64-linux +# Toolchain configuration for aarch64-qnx (target) # ------------------------------------------------------------------------------- -build:target_config_3 --config=aarch64-linux -build:target_config_3 --extra_toolchains=@score_aarch64_gcc_toolchain//:aarch64-linux-gcc_12.2.0-posix - - -# ------------------------------------------------------------------------------- -# Config dedicated to target platform CPU:x86_64 and OS:QNX -# ------------------------------------------------------------------------------- -build:x86_64-qnx --config=shared -build:x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix - -# ------------------------------------------------------------------------------- -# Different toolchain configuration for x86_64-qnx -# ------------------------------------------------------------------------------- -build:target_config_1 --config=x86_64-qnx -build:target_config_1 --extra_toolchains=@score_qcc_toolchain//:x86_64-qnx-sdp_8.0.0-posix +build:target_config_2 --config=host_config_1 +build:target_config_2 --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix +build:target_config_2 --extra_toolchains=@score_qcc_arm_toolchain//:aarch64-qnx-sdp_8.0.0 # ------------------------------------------------------------------------------- -# Config dedicated to target platform CPU:aarch64 and OS:QNX +# Toolchain configuration for aarch64-linux (target) # ------------------------------------------------------------------------------- -build:aarch64-qnx --config=shared -build:aarch64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix +build:target_config_3 --config=host_config_1 +build:target_config_3 --platforms=@score_bazel_platforms//:aarch64-linux-gcc_12.2.0-posix +build:target_config_3 --extra_toolchains=@score_aarch64_gcc_toolchain//:aarch64-linux-gcc_12.2.0 # ------------------------------------------------------------------------------- -# Different toolchain configuration for aarch64-qnx +# Toolchain configuration for aarch64-linux (target) # ------------------------------------------------------------------------------- -build:target_config_2 --config=aarch64-qnx -build:target_config_2 --extra_toolchains=@score_qcc_arm_toolchain//:aarch64-qnx-sdp_8.0.0-posix +build:target_config_4 --config=host_config_1 +build:target_config_4 --platforms=@score_bazel_platforms//:x86_64-linux-autosd10 +build:target_config_4 --extra_toolchains=@score_autosd_10_toolchain//:x86_64-linux-autosd10 diff --git a/examples/BUILD b/examples/BUILD index 64ff781..92232d3 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -13,7 +13,7 @@ """Small C++ CLI application for sanity testing""" -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "cc_shared_library") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_shared_library", "cc_test") cc_binary( name = "main_cpp", @@ -34,8 +34,8 @@ cc_library( cc_test( name = "math_lib_test", srcs = ["math_lib_test.cpp"], - deps = [":math_lib"], linkstatic = True, + deps = [":math_lib"], ) cc_shared_library( @@ -47,9 +47,9 @@ cc_shared_library( cc_test( name = "math_lib_dyn_test", srcs = ["math_lib_test.cpp"], - deps = [":math_lib"], dynamic_deps = [":math_lib_shared"], linkstatic = False, + deps = [":math_lib"], ) cc_test( @@ -59,5 +59,5 @@ cc_test( deps = [ "@googletest//:gtest", "@googletest//:gtest_main", - ] + ], ) diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 3aadc2e..c9a958d 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -25,7 +25,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.2") # Constraint values for specifying platforms and toolchains # ******************************************************************************* bazel_dep(name = "platforms", version = "1.0.0") -bazel_dep(name = "score_bazel_platforms", version = "0.0.4") +bazel_dep(name = "score_bazel_platforms", version = "0.1.0") # ******************************************************************************* # C++ Rules for Bazel @@ -38,7 +38,7 @@ bazel_dep(name = "googletest", version = "1.17.0") # ******************************************************************************* bazel_dep( name = "score_bazel_cpp_toolchains", - version = "0.2.0", + version = "0.3.0", ) local_path_override( module_name = "score_bazel_cpp_toolchains", @@ -60,11 +60,23 @@ gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc", de # Setting default GCC (CPU:x86_64|OS:Linux|V:12.2.0|ES:posix) # ******************************************************************************* gcc.toolchain( - name = "score_gcc_toolchain", + name = "score_gcc_toolchain_bp", target_cpu = "x86_64", target_os = "linux", + use_default_package = True, version = "12.2.0", + use_base_constraints_only = True, +) + +# ******************************************************************************* +# Setting default GCC (CPU:x86_64|OS:Linux|V:12.2.0|ES:posix) +# ******************************************************************************* +gcc.toolchain( + name = "score_gcc_toolchain", + target_cpu = "x86_64", + target_os = "linux", use_default_package = True, + version = "12.2.0", ) # ******************************************************************************* @@ -74,29 +86,29 @@ gcc.toolchain( name = "score_aarch64_gcc_toolchain", target_cpu = "aarch64", target_os = "linux", - version = "12.2.0", use_default_package = True, -) + version = "12.2.0", +) # ******************************************************************************* # Setting custom GCC (CPU:x86_64|OS:Linux|V:12.2.0|ES:posix) # ******************************************************************************* gcc.sdp( name = "my_toolchain_pkg", - url = "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/0.0.1/x86_64-unknown-linux-gnu_gcc12.tar.gz", - strip_prefix = "x86_64-unknown-linux-gnu", - sha256 = "457f5f20f57528033cb840d708b507050d711ae93e009388847e113b11bf3600", build_file = "@score_bazel_cpp_toolchains//packages/linux/x86_64/gcc/12.2.0:gcc.BUILD", + sha256 = "457f5f20f57528033cb840d708b507050d711ae93e009388847e113b11bf3600", + strip_prefix = "x86_64-unknown-linux-gnu", + url = "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/0.0.1/x86_64-unknown-linux-gnu_gcc12.tar.gz", ) gcc.toolchain( name = "my_toolchain", + extra_link_flags = [ + "-lpthread", + ], sdp_to_link = "my_toolchain_pkg", - target_os = "linux", target_cpu = "x86_64", + target_os = "linux", version = "12.2.0", - extra_link_flags = [ - "-lpthread", - ] ) # ******************************************************************************* @@ -104,10 +116,9 @@ gcc.toolchain( # ******************************************************************************* gcc.toolchain( name = "score_qcc_toolchain", + sdp_version = "8.0.0", target_cpu = "x86_64", target_os = "qnx", - sdp_version = "8.0.0", - version = "12.2.0", use_default_package = True, ) @@ -116,42 +127,39 @@ gcc.toolchain( # ******************************************************************************* gcc.toolchain( name = "score_qcc_arm_toolchain", + sdp_version = "8.0.0", target_cpu = "aarch64", target_os = "qnx", - sdp_version = "8.0.0", - version = "12.2.0", use_default_package = True, ) -# TODO: Not yet supported -# ******************************************************************************* -# Setting local host GCC (CPU:x86_64|OS:Linux|V:unknown|ES:host) -# ******************************************************************************* -# gcc.toolchain( -# name = "score_system_toolchain", -# target_cpu = "x86_64", -# target_os = "linux", -# use_system_toolchain = True, -# ) - # ******************************************************************************* -# Setting AutoSD 10 GCC (CPU:x86_64|OS:Linux|V:autosd-10.0|ES:autosd) +# Setting AutoSD 10 GCC (CPU:x86_64|OS:Linux|ES:autosd10) # ******************************************************************************* gcc.toolchain( name = "score_autosd_10_toolchain", + runtime_ecosystem = "autosd10", target_cpu = "x86_64", target_os = "linux", - runtime_ecosystem = "autosd", - version = "autosd-10.0", use_default_package = True, -) +) use_repo( gcc, - "score_gcc_toolchain", - "score_aarch64_gcc_toolchain", "my_toolchain", - "score_qcc_toolchain", - "score_qcc_arm_toolchain", + "score_gcc_toolchain_bp", + "score_aarch64_gcc_toolchain", "score_autosd_10_toolchain", -) \ No newline at end of file + "score_gcc_toolchain", + "score_qcc_arm_toolchain", + "score_qcc_toolchain", +) + +# register_toolchains( +# "@score_gcc_toolchain//:x86_64-linux-gcc_12.2.0", +# "@my_toolchain//:x86_64-linux-gcc_12.2.0", +# "@score_qcc_toolchain//:x86_64-qnx-sdp_8.0.0", +# "@score_qcc_arm_toolchain//:aarch64-qnx-sdp_8.0.0", +# "@score_aarch64_gcc_toolchain//:aarch64-linux-gcc_12.2.0", +# "@score_autosd_10_toolchain//:x86_64-linux-autosd10", +# ) diff --git a/examples/test.sh b/examples/test.sh new file mode 100755 index 0000000..271af03 --- /dev/null +++ b/examples/test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +echo -e "Testing 'host_config_1' ..." +bazel test --config host_config_1 //:math_lib_test +bazel clean --expunge +echo -e "Testing 'host_config_2' ..." +bazel test --config host_config_2 //:math_lib_test +bazel clean --expunge +echo -e "Testing 'host_config_3' ..." +bazel test --config host_config_3 //:math_lib_test +bazel clean --expunge +echo -e "Testing 'target_config_1' ..." +bazel build --config target_config_1 //:main_cpp +bazel clean --expunge +echo -e "Testing 'target_config_2' ..." +bazel build --config target_config_2 //:main_cpp +bazel clean --expunge +echo -e "Testing 'target_config_3' ..." +bazel build --config target_config_3 //:main_cpp +bazel clean --expunge +echo -e "Testing 'target_config_4' ..." +bazel build --config target_config_4 //:main_cpp +bazel clean --expunge \ No newline at end of file diff --git a/extensions/gcc.bzl b/extensions/gcc.bzl index 2373a32..1959812 100644 --- a/extensions/gcc.bzl +++ b/extensions/gcc.bzl @@ -13,61 +13,103 @@ """ Module extension for setting up GCC toolchains in Bazel. """ + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@score_bazel_cpp_toolchains//packages:version_matrix.bzl", "VERSION_MATRIX") load("@score_bazel_cpp_toolchains//rules:gcc.bzl", "gcc_toolchain") # GCC interface API for archive tag class _attrs_sdp = { - "name": attr.string( - default = "", - doc = "package name of toolchain, default set to toolchain toolchain name + `_pkg`.", - ), "build_file": attr.label( mandatory = False, default = None, doc = "The path to the BUILD file of selected archive.", ), - "url": attr.string( + "name": attr.string( + default = "", + doc = "package name of toolchain, default set to toolchain toolchain name + `_pkg`.", + ), + "sha256": attr.string( mandatory = False, default = "", - doc = "Url to the toolchain archive." + doc = "Checksum of the archive.", ), "strip_prefix": attr.string( mandatory = False, default = "", - doc = "Strip prefix from toolchain archive.", + doc = "Strip prefix from toolchain archive.", ), - "sha256": attr.string( + "url": attr.string( mandatory = False, default = "", - doc = "Checksum of the archive." + doc = "Url to the toolchain archive.", ), } # GCC interface API for toolchain tag class _attrs_tc = { + "extra_c_compile_flags": attr.string_list( + mandatory = False, + default = [], + doc = "List of additional flags to be passed to C compiler.", + ), + "extra_compile_flags": attr.string_list( + mandatory = False, + default = [], + doc = "List of additional flags to be passed to compiler.", + ), + "extra_cxx_compile_flags": attr.string_list( + mandatory = False, + default = [], + doc = "List of additional flags to be passed to C++ compiler.", + ), + "extra_link_flags": attr.string_list( + mandatory = False, + default = [], + doc = "List of additional flags to be passed to linker.", + ), + "license_info_url": attr.string( + default = "", + mandatory = False, + doc = "URL of the QNX license server.", + ), + "license_info_variable": attr.string( + default = "", + mandatory = False, + doc = "QNX License info variable.", + ), + "license_path": attr.string( + default = "/opt/score_qnx/license/licenses", + mandatory = False, + doc = "Path to the shared license file.", + ), "name": attr.string( mandatory = True, doc = "Toolchain repo name, default set to `score_gcc_toolchain`.", ), + "use_base_constraints_only": attr.bool( + default = False, + doc = "Experimental. Attribute for flag toolchain creation to use only base platform constraints. Limits toolchain registration to 1 per base platform definition.", + ), + "runtime_ecosystem": attr.string( + default = "", + mandatory = False, + doc = "Attribute for identifing the system-level runtime environment a binary or target is built to run in.", + ), + "sdk_version": attr.string( + default = "", + mandatory = False, + doc = "SDK version info variable.", + ), "sdp_to_link": attr.string( mandatory = False, default = "", doc = "Name of the toolchain package to be linked with this toolchain, default set to toolchain name + `_pkg`.", ), - "use_default_package": attr.bool( - default = False, - doc = "Whether to use the default package from the version matrix, default set to False.", - ), - "use_system_toolchain": attr.bool( - default = False, - doc = "TBD", - ), - "runtime_ecosystem": attr.string( - default = "posix", + "sdp_version": attr.string( + default = "", mandatory = False, - doc = "TBD", + doc = "Version of the SDP package.", ), "target_cpu": attr.string( mandatory = True, @@ -85,51 +127,20 @@ _attrs_tc = { ], doc = "Target platform OS", ), - "version": attr.string( - default = "", - mandatory = False, - doc = "Version of the GCC toolchain.", + "use_default_package": attr.bool( + default = False, + doc = "Whether to use the default package from the version matrix, default set to False.", ), - "license_info_url": attr.string( - default = "", - mandatory = False, - doc = "URL of the QNX license server.", + "use_system_toolchain": attr.bool( + default = False, + doc = "TBD", ), - "license_info_variable": attr.string( + "version": attr.string( default = "", mandatory = False, - doc = "QNX License info variable.", - ), - "sdp_version": attr.string( - default = "8.0.0", - mandatory = False, - doc = "Version of the SDP package.", - ), - "license_path": attr.string( - default = "/opt/score_qnx/license/licenses", - mandatory = False, - doc = "Path to the shared license file.", - ), - "extra_compile_flags": attr.string_list( - mandatory = False, - default = [], - doc = "List of additional flags to be passed to compiler.", - ), - "extra_c_compile_flags": attr.string_list( - mandatory = False, - default = [], - doc = "List of additional flags to be passed to C compiler.", - ), - "extra_cxx_compile_flags": attr.string_list( - mandatory = False, - default = [], - doc = "List of additional flags to be passed to C++ compiler.", - ), - "extra_link_flags": attr.string_list( - mandatory = False, - default = [], - doc = "List of additional flags to be passed to linker.", + doc = "Version of the GCC toolchain.", ), + } def _get_packages(tags): @@ -141,15 +152,15 @@ def _get_packages(tags): Returns: dict: A dictionary with archive information. """ - packages = [] + packages = [] for tag in tags: packages.append({ + "build_file": tag.build_file, "name": tag.name, - "url": tag.url, - "strip_prefix": tag.strip_prefix, "sha256": tag.sha256, - "build_file": tag.build_file, - }) + "strip_prefix": tag.strip_prefix, + "url": tag.url, + }) return packages def _get_toolchains(tags): @@ -157,76 +168,101 @@ def _get_toolchains(tags): Args: tags: A list of tags containing toolchain information. - + Returns: dict: A dictionary with toolchain information. """ toolchains = [] for tag in tags: toolchain = { + "cc_toolchain_config": "@score_bazel_cpp_toolchains//templates/{}:cc_toolchain_config.bzl.template".format(tag.target_os), + "cc_toolchain_flags": "@score_bazel_cpp_toolchains//templates/{}:cc_toolchain_flags.bzl.template".format(tag.target_os), + "gcc_version": tag.version, "name": tag.name, - "tc_cpu": tag.target_cpu, - "tc_os": tag.target_os, - "tc_family": "gcc", # TODO: it can be llvm, check if we need to pull it in common - "tc_version": tag.version, + "use_base_constraints_only": tag.use_base_constraints_only, + "sdk_version": tag.sdk_version, "sdp_to_link": tag.sdp_to_link, - "use_default_package": tag.use_default_package, - "use_system_toolchain": tag.use_system_toolchain, - "tc_extra_compile_flags": tag.extra_compile_flags, + "sdp_version": tag.sdp_version, + "tc_cpu": tag.target_cpu, "tc_extra_c_compile_flags": tag.extra_c_compile_flags, + "tc_extra_compile_flags": tag.extra_compile_flags, "tc_extra_cxx_compile_flags": tag.extra_cxx_compile_flags, "tc_extra_link_flags": tag.extra_link_flags, - "sdp_version": tag.sdp_version, - "tc_license_info_variable": tag.license_info_variable, "tc_license_info_url": tag.license_info_url, + "tc_license_info_variable": tag.license_info_variable, "tc_license_path": tag.license_path, + "tc_os": tag.target_os, "tc_runtime_ecosystem": tag.runtime_ecosystem, - "cc_toolchain_config": "@score_bazel_cpp_toolchains//templates/{}:cc_toolchain_config.bzl.template".format(tag.target_os), - "cc_toolchain_flags": "@score_bazel_cpp_toolchains//templates/{}:cc_toolchain_flags.bzl.template".format(tag.target_os), + "use_default_package": tag.use_default_package, + "use_system_toolchain": tag.use_system_toolchain, } toolchains.append(toolchain) return toolchains def _create_and_link_sdp(toolchain_info): - """ TODO: Write docstring + """ Create new archive based on information provided in extension. + + Args: + toolchain_info: A dict of holding toolchain information. + + Returns: + dict: A dict with archive information. """ pkg_name = "{}_pkg".format(toolchain_info["name"]) - identifier = "gcc" - version = toolchain_info["tc_version"] - if toolchain_info["tc_os"] == "qnx": - identifier = "sdp" - version = toolchain_info["sdp_version"] - matrix_key = "{cpu}-{os}-{identifier}-{version}".format( + + matrix_key = "{cpu}-{os}{identifier}{runtime_es}".format( cpu = toolchain_info["tc_cpu"], os = toolchain_info["tc_os"], - identifier = identifier, - version = version, + identifier = "-{}".format(toolchain_info["tc_identifier"]) if toolchain_info["tc_identifier"] != "" else "", + runtime_es = "-{}".format(toolchain_info["tc_runtime_ecosystem"]) if toolchain_info["tc_runtime_ecosystem"] != "" else "", ) matrix = VERSION_MATRIX[matrix_key] toolchain_info["sdp_to_link"] = pkg_name + # TODO: Put this in separate function so that we can easy extend it (if needed). if "extra_c_compile_flags" in matrix and not toolchain_info["tc_extra_c_compile_flags"]: toolchain_info["tc_extra_c_compile_flags"] = matrix["extra_c_compile_flags"] if "extra_cxx_compile_flags" in matrix and not toolchain_info["tc_extra_cxx_compile_flags"]: toolchain_info["tc_extra_cxx_compile_flags"] = matrix["extra_cxx_compile_flags"] if "extra_link_flags" in matrix and not toolchain_info["tc_extra_link_flags"]: toolchain_info["tc_extra_link_flags"] = matrix["extra_link_flags"] + if "gcc_version" in matrix and not toolchain_info["gcc_version"]: + toolchain_info["gcc_version"] = matrix["gcc_version"] return { + "build_file": matrix["build_file"], "name": pkg_name, - "url": matrix["url"], - "strip_prefix": matrix["strip_prefix"], "sha256": matrix["sha256"], - "build_file": matrix["build_file"], + "strip_prefix": matrix["strip_prefix"], + "url": matrix["url"], } +def _resolve_identifier(toolchain_info): + """ Create new archive based on information provided in extension. + + Args: + toolchain_info: A dict of holding toolchain information. + + Returns: + dict: A dict with archive information. + """ + identifier = "gcc" + version = toolchain_info["gcc_version"] + if toolchain_info["sdk_version"] != "": + identifier = "sdk" + version = toolchain_info["sdk_version"] + elif toolchain_info["sdp_version"] != "": + identifier = "sdp" + version = toolchain_info["sdp_version"] + + return "{}_{}".format(identifier, version) + def _get_info(mctx): """Gets raw info from module ctx about toolchain properties. Args: mctx: A bazel object holding module information. - family: An identifier that holds the driver type (gcc, qcc or llvm). - + Returns: list: A list of dictionaries with toolchain and archive information. """ @@ -236,10 +272,16 @@ def _get_info(mctx): fail("Only the root module can use the 'gcc' extension!") root = mod - toolchains = _get_toolchains(mod.tags.toolchain) - packages = _get_packages(mod.tags.sdp) + toolchains = _get_toolchains(root.tags.toolchain) + packages = _get_packages(root.tags.sdp) for tc in toolchains: + if tc["sdp_version"] != "" or tc["sdk_version"] != "" or tc["gcc_version"] != "": + identifier = _resolve_identifier(tc) + tc.update({"tc_identifier":"{}".format(identifier)}) + else: + tc.update({"tc_identifier":""}) + # need to be sure not to link package in case of system toolchain. if tc["use_system_toolchain"]: continue @@ -276,27 +318,30 @@ def _impl(mctx): license_info_variable = toolchain_info["tc_license_info_variable"], license_info_value = toolchain_info["tc_license_info_url"], license_path = toolchain_info["tc_license_path"], + sdk_version = toolchain_info["sdk_version"], sdp_version = toolchain_info["sdp_version"], tc_cpu = toolchain_info["tc_cpu"], + tc_identifier = toolchain_info["tc_identifier"], tc_os = toolchain_info["tc_os"], tc_pkg_repo = toolchain_info["sdp_to_link"], tc_system_toolchain = toolchain_info["use_system_toolchain"], tc_runtime_ecosystem = toolchain_info["tc_runtime_ecosystem"], - gcc_version = toolchain_info["tc_version"], + gcc_version = toolchain_info["gcc_version"], cc_toolchain_config = toolchain_info["cc_toolchain_config"], cc_toolchain_flags = toolchain_info["cc_toolchain_flags"], + use_base_constraints_only = toolchain_info["use_base_constraints_only"] ) gcc = module_extension( implementation = _impl, tag_classes = { - "toolchain": tag_class( - attrs = _attrs_tc, - doc = "Toolchain configuration parameters that define toolchain." - ), "sdp": tag_class( attrs = _attrs_sdp, doc = "Software Development Package (short sdp) is tarball holding binaries of toolchain.", ), - } -) \ No newline at end of file + "toolchain": tag_class( + attrs = _attrs_tc, + doc = "Toolchain configuration parameters that define toolchain.", + ), + }, +) diff --git a/packages/linux/aarch64/autosd/10.0/BUILD b/packages/linux/aarch64/autosd/10.0/BUILD index 3f98d7c..c9126ba 100644 --- a/packages/linux/aarch64/autosd/10.0/BUILD +++ b/packages/linux/aarch64/autosd/10.0/BUILD @@ -13,4 +13,4 @@ exports_files([ "autosd.BUILD", -]) \ No newline at end of file +]) diff --git a/packages/linux/aarch64/gcc/12.2.0/BUILD b/packages/linux/aarch64/gcc/12.2.0/BUILD index fecdade..6e19dcb 100644 --- a/packages/linux/aarch64/gcc/12.2.0/BUILD +++ b/packages/linux/aarch64/gcc/12.2.0/BUILD @@ -13,4 +13,4 @@ exports_files([ "gcc.BUILD", -]) \ No newline at end of file +]) diff --git a/packages/linux/x86_64/autosd/10.0/BUILD b/packages/linux/x86_64/autosd/10.0/BUILD index 3f98d7c..c9126ba 100644 --- a/packages/linux/x86_64/autosd/10.0/BUILD +++ b/packages/linux/x86_64/autosd/10.0/BUILD @@ -13,4 +13,4 @@ exports_files([ "autosd.BUILD", -]) \ No newline at end of file +]) diff --git a/packages/linux/x86_64/gcc/12.2.0/BUILD b/packages/linux/x86_64/gcc/12.2.0/BUILD index fecdade..6e19dcb 100644 --- a/packages/linux/x86_64/gcc/12.2.0/BUILD +++ b/packages/linux/x86_64/gcc/12.2.0/BUILD @@ -13,4 +13,4 @@ exports_files([ "gcc.BUILD", -]) \ No newline at end of file +]) diff --git a/packages/version_matrix.bzl b/packages/version_matrix.bzl index 4fcc587..666466e 100644 --- a/packages/version_matrix.bzl +++ b/packages/version_matrix.bzl @@ -15,92 +15,120 @@ """ VERSION_MATRIX = { - "aarch64-linux-gcc-12.2.0": { - "url": "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/v0.0.4/aarch64-unknown-linux-gnu_gcc12.tar.gz", + "aarch64-linux-gcc_12.2.0": { "build_file": "@score_bazel_cpp_toolchains//packages/linux/aarch64/gcc/12.2.0:gcc.BUILD", - "strip_prefix": "aarch64-unknown-linux-gnu", "sha256": "7279b1adb50361b21f5266b001980b6febb35fa8d83170901196b9edae3f06d9", + "strip_prefix": "aarch64-unknown-linux-gnu", + "url": "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/v0.0.4/aarch64-unknown-linux-gnu_gcc12.tar.gz", }, - "aarch64-qnx-sdp-8.0.0": { - "url": "https://www.qnx.com/download/download/79858/installation.tgz", - "build_file": "@score_bazel_cpp_toolchains//packages/qnx/aarch64/sdp/8.0.0:sdp.BUILD", - "strip_prefix": "installation", - "sha256": "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63", - }, - "x86_64-linux-gcc-12.2.0": { - "url": "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/v0.0.4/x86_64-unknown-linux-gnu_gcc12.tar.gz", - "build_file": "@score_bazel_cpp_toolchains//packages/linux/x86_64/gcc/12.2.0:gcc.BUILD", - "strip_prefix": "x86_64-unknown-linux-gnu", - "sha256": "e9b9a7a63a5f8271b76d6e2057906b95c7a244e4931a8e10edeaa241e9f7c11e", - }, - "x86_64-qnx-sdp-8.0.0": { - "url": "https://www.qnx.com/download/download/79858/installation.tgz", - "build_file": "@score_bazel_cpp_toolchains//packages/qnx/x86_64/sdp/8.0.0:sdp.BUILD", - "strip_prefix": "installation", - "sha256": "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63", - }, - "x86_64-linux-gcc-autosd-10.0": { - "url": "https://github.com/eclipse-score/inc_os_autosd/releases/download/continuous/autosd-toolchain-x86_64.tar.gz", - "build_file": "@score_bazel_cpp_toolchains//packages/linux/x86_64/autosd/10.0:autosd.BUILD", - "strip_prefix": "sysroot", - "sha256": "525dcca237dfdff3d6c8f3650a0db77a93638141e8c91252544b37447ef9108c", + "aarch64-linux-autosd10": { + "build_file": "@score_bazel_cpp_toolchains//packages/linux/aarch64/autosd/10.0:autosd.BUILD", "extra_c_compile_flags": [ "-nostdinc", - "-isystem", "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14/include", - "-isystem", "external/%{toolchain_pkg}%/usr/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/lib/gcc/aarch64-redhat-linux/14/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/include", ], "extra_cxx_compile_flags": [ "-nostdinc++", - "-isystem", "external/%{toolchain_pkg}%/usr/include/c++/14", - "-isystem", "external/%{toolchain_pkg}%/usr/include/c++/14/x86_64-redhat-linux", - "-isystem", "external/%{toolchain_pkg}%/usr/include/c++/14/backward", + "-isystem", + "external/%{toolchain_pkg}%/usr/include/c++/14", + "-isystem", + "external/%{toolchain_pkg}%/usr/include/c++/14/aarch64-redhat-linux", + "-isystem", + "external/%{toolchain_pkg}%/usr/include/c++/14/backward", "-nostdinc", - "-isystem", "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14/include", - "-isystem", "external/%{toolchain_pkg}%/usr/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/lib/gcc/aarch64-redhat-linux/14/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/include", ], "extra_link_flags": [ - "-B", "external/%{toolchain_pkg}%/usr/bin", - "-L", "external/%{toolchain_pkg}%/lib64", - "-L", "external/%{toolchain_pkg}%/lib", - "-L", "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14", - "-L", "external/%{toolchain_pkg}%/usr/lib64", - "-L", "external/%{toolchain_pkg}%/usr/lib", + "-B", + "external/%{toolchain_pkg}%/usr/bin", + "-L", + "external/%{toolchain_pkg}%/lib64", + "-L", + "external/%{toolchain_pkg}%/lib", + "-L", + "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14", + "-L", + "external/%{toolchain_pkg}%/usr/lib64", + "-L", + "external/%{toolchain_pkg}%/usr/lib", "-lm", "-ldl", "-lrt", "-lstdc++", ], - }, - "aarch64-linux-gcc-autosd-10.0": { - "url": "https://github.com/eclipse-score/inc_os_autosd/releases/download/continuous/autosd-toolchain-aarch64.tar.gz", - "build_file": "@score_bazel_cpp_toolchains//packages/linux/aarch64/autosd/10.0:autosd.BUILD", - "strip_prefix": "sysroot", "sha256": "8d70f31588f864e680db05b1e8053fe93655897af646335c48c2ea5bd6578947", + "strip_prefix": "sysroot", + "url": "https://github.com/eclipse-score/inc_os_autosd/releases/download/continuous/autosd-toolchain-aarch64.tar.gz", + }, + "aarch64-qnx-sdp_8.0.0": { + "build_file": "@score_bazel_cpp_toolchains//packages/qnx/aarch64/sdp/8.0.0:sdp.BUILD", + "sha256": "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63", + "strip_prefix": "installation", + "url": "https://www.qnx.com/download/download/79858/installation.tgz", + "gcc_version": "12.2.0", + }, + "x86_64-linux-gcc_12.2.0": { + "build_file": "@score_bazel_cpp_toolchains//packages/linux/x86_64/gcc/12.2.0:gcc.BUILD", + "sha256": "e9b9a7a63a5f8271b76d6e2057906b95c7a244e4931a8e10edeaa241e9f7c11e", + "strip_prefix": "x86_64-unknown-linux-gnu", + "url": "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/v0.0.4/x86_64-unknown-linux-gnu_gcc12.tar.gz", + }, + "x86_64-linux-autosd10": { + "build_file": "@score_bazel_cpp_toolchains//packages/linux/x86_64/autosd/10.0:autosd.BUILD", "extra_c_compile_flags": [ "-nostdinc", - "-isystem", "external/%{toolchain_pkg}%/usr/lib/gcc/aarch64-redhat-linux/14/include", - "-isystem", "external/%{toolchain_pkg}%/usr/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/include", ], "extra_cxx_compile_flags": [ "-nostdinc++", - "-isystem", "external/%{toolchain_pkg}%/usr/include/c++/14", - "-isystem", "external/%{toolchain_pkg}%/usr/include/c++/14/aarch64-redhat-linux", - "-isystem", "external/%{toolchain_pkg}%/usr/include/c++/14/backward", + "-isystem", + "external/%{toolchain_pkg}%/usr/include/c++/14", + "-isystem", + "external/%{toolchain_pkg}%/usr/include/c++/14/x86_64-redhat-linux", + "-isystem", + "external/%{toolchain_pkg}%/usr/include/c++/14/backward", "-nostdinc", - "-isystem", "external/%{toolchain_pkg}%/usr/lib/gcc/aarch64-redhat-linux/14/include", - "-isystem", "external/%{toolchain_pkg}%/usr/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14/include", + "-isystem", + "external/%{toolchain_pkg}%/usr/include", ], "extra_link_flags": [ - "-B", "external/%{toolchain_pkg}%/usr/bin", - "-L", "external/%{toolchain_pkg}%/lib64", - "-L", "external/%{toolchain_pkg}%/lib", - "-L", "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14", - "-L", "external/%{toolchain_pkg}%/usr/lib64", - "-L", "external/%{toolchain_pkg}%/usr/lib", + "-B", + "external/%{toolchain_pkg}%/usr/bin", + "-L", + "external/%{toolchain_pkg}%/lib64", + "-L", + "external/%{toolchain_pkg}%/lib", + "-L", + "external/%{toolchain_pkg}%/usr/lib/gcc/x86_64-redhat-linux/14", + "-L", + "external/%{toolchain_pkg}%/usr/lib64", + "-L", + "external/%{toolchain_pkg}%/usr/lib", "-lm", "-ldl", "-lrt", "-lstdc++", ], + "sha256": "525dcca237dfdff3d6c8f3650a0db77a93638141e8c91252544b37447ef9108c", + "strip_prefix": "sysroot", + "url": "https://github.com/eclipse-score/inc_os_autosd/releases/download/continuous/autosd-toolchain-x86_64.tar.gz", + }, + "x86_64-qnx-sdp_8.0.0": { + "build_file": "@score_bazel_cpp_toolchains//packages/qnx/x86_64/sdp/8.0.0:sdp.BUILD", + "sha256": "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63", + "strip_prefix": "installation", + "url": "https://www.qnx.com/download/download/79858/installation.tgz", + "gcc_version": "12.2.0", }, -} \ No newline at end of file +} diff --git a/rules/common.bzl b/rules/common.bzl index f4ff574..03b5396 100644 --- a/rules/common.bzl +++ b/rules/common.bzl @@ -42,6 +42,6 @@ def get_flag_group(flags): return [ flag_group( flags = flags, - ) + ), ] - return [] \ No newline at end of file + return [] diff --git a/rules/gcc.bzl b/rules/gcc.bzl index 69263f8..4666bfd 100644 --- a/rules/gcc.bzl +++ b/rules/gcc.bzl @@ -17,7 +17,14 @@ load("@score_bazel_cpp_toolchains//rules:common.bzl", "get_flag_groups") def dict_union(x, y): - """ TODO: Write docstrings + """ Helper function to merge 2 dict + + Args: + x: The 1st dict + y: The 2nd dict + + Returns: + z: Merged dict """ z = {} z.update(x) @@ -25,7 +32,7 @@ def dict_union(x, y): return z def _get_cc_config_linux(rctx): - """ TODO: Write docstring + """ Write configuration invocation function for Linux. """ return """ filegroup( @@ -55,7 +62,7 @@ cc_toolchain_config( ) def _get_cc_config_qnx(rctx): - """ TODO: Write docstring + """ Write configuration invocation function for QNX. """ return """ filegroup( @@ -90,9 +97,7 @@ def _impl(rctx): Args: rctx: The repository context. """ - tc_identifier = "gcc_{}".format(rctx.attr.gcc_version) - if rctx.attr.tc_os == "qnx": - tc_identifier = "sdp_{}".format(rctx.attr.sdp_version) + tc_identifier = rctx.attr.tc_identifier if rctx.attr.tc_os == "qnx": cc_toolchain_config = _get_cc_config_qnx(rctx) @@ -101,17 +106,33 @@ def _impl(rctx): else: fail("Unsupported OS detected!") + tc_identifier_short_1 = "" + tc_identifier_long_1 = "[]" + tc_identifier_short_2 = "" + tc_identifier_long_2 = "[]" + if not rctx.attr.use_base_constraints_only: + if tc_identifier != "": + tc_identifier_short_1 = "-{}".format(tc_identifier) + tc_identifier_long_1 = "[\"@score_bazel_platforms//version:{}\"]".format(tc_identifier) + if rctx.attr.tc_runtime_ecosystem != "": + tc_identifier_short_2 = "-{}".format(rctx.attr.tc_runtime_ecosystem) + tc_identifier_long_2 = "[\"@score_bazel_platforms//runtime_es:{}\"]".format(rctx.attr.tc_runtime_ecosystem) + rctx.template( "BUILD", rctx.attr._cc_toolchain_build, { "%{cc_toolchain_config}": cc_toolchain_config, - "%{tc_pkg_repo}": rctx.attr.tc_pkg_repo, "%{tc_cpu}": rctx.attr.tc_cpu, + "%{tc_identifier}": tc_identifier, "%{tc_os}": rctx.attr.tc_os, - "%{tc_version}": rctx.attr.gcc_version, - "%{tc_identifier}": tc_identifier, + "%{tc_pkg_repo}": rctx.attr.tc_pkg_repo, "%{tc_runtime_es}": rctx.attr.tc_runtime_ecosystem, + "%{tc_version}": rctx.attr.gcc_version, + "%{tc_identifier_short_1}": tc_identifier_short_1, + "%{tc_identifier_short_2}": tc_identifier_short_2, + "%{tc_identifier_long_1}": tc_identifier_long_1, + "%{tc_identifier_long_2}": tc_identifier_long_2, }, ) @@ -136,30 +157,29 @@ def _impl(rctx): extra_cxx_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_cxx_compile_flags)) extra_link_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_link_flags)) - template_dict = { - "%{tc_version}": rctx.attr.gcc_version, - "%{tc_identifier}": "gcc", - "%{tc_cpu}": "aarch64le" if rctx.attr.tc_cpu == "aarch64" else rctx.attr.tc_cpu, - "%{tc_runtime_es}": rctx.attr.tc_runtime_ecosystem, - "%{extra_compile_flags_switch}": "True" if len(rctx.attr.extra_compile_flags) else "False", - "%{extra_compile_flags}":extra_compile_flags, "%{extra_c_compile_flags_switch}": "True" if len(rctx.attr.extra_c_compile_flags) else "False", "%{extra_c_compile_flags}": extra_c_compile_flags, + "%{extra_compile_flags_switch}": "True" if len(rctx.attr.extra_compile_flags) else "False", + "%{extra_compile_flags}": extra_compile_flags, "%{extra_cxx_compile_flags_switch}": "True" if len(rctx.attr.extra_cxx_compile_flags) else "False", "%{extra_cxx_compile_flags}": extra_cxx_compile_flags, "%{extra_link_flags_switch}": "True" if len(rctx.attr.extra_link_flags) else "False", "%{extra_link_flags}": extra_link_flags, + "%{tc_cpu}": "aarch64le" if rctx.attr.tc_cpu == "aarch64" else rctx.attr.tc_cpu, + "%{tc_identifier}": "gcc", + "%{tc_runtime_es}": rctx.attr.tc_runtime_ecosystem, + "%{tc_version}": rctx.attr.gcc_version, } if rctx.attr.tc_os == "qnx": extra_template_dict = { - "%{tc_cpu_cxx}": "aarch64le" if rctx.attr.tc_cpu == "aarch64" else rctx.attr.tc_cpu, - "%{sdp_version}": rctx.attr.sdp_version, + "%{license_info_value}": rctx.attr.license_info_value, + "%{license_info_variable}": rctx.attr.license_info_variable, "%{license_path}": rctx.attr.license_path, + "%{sdp_version}": rctx.attr.sdp_version, + "%{tc_cpu_cxx}": "aarch64le" if rctx.attr.tc_cpu == "aarch64" else rctx.attr.tc_cpu, "%{use_license_info}": "False" if rctx.attr.license_info_value == "" else "True", - "%{license_info_variable}": rctx.attr.license_info_variable, - "%{license_info_value}": rctx.attr.license_info_value, } template_dict = dict_union(template_dict, extra_template_dict) @@ -176,7 +196,7 @@ def _impl(rctx): ) if rctx.attr.tc_os == "linux": - # There is an issue with gcov and cc_toolchain config. + # There is an issue with gcov and cc_toolchain config. # See: https://github.com/bazelbuild/rules_cc/issues/351 rctx.template( "gcov_wrapper", @@ -192,32 +212,35 @@ def _impl(rctx): gcc_toolchain = repository_rule( implementation = _impl, attrs = { - "tc_pkg_repo": attr.string(doc="The label name of toolchain tarbal."), - "tc_cpu": attr.string(doc="Target platform CPU."), - "tc_os": attr.string(doc="Target platform OS."), - "gcc_version": attr.string(doc="GCC version number"), - "extra_compile_flags": attr.string_list(doc="Extra/Additional compile flags."), - "extra_c_compile_flags": attr.string_list(doc="Extra/Additional C-specific compile flags."), - "extra_cxx_compile_flags": attr.string_list(doc="Extra/Additional C++-specific compile flags."), - "extra_link_flags": attr.string_list(doc="Extra/Additional link flags."), - "sdp_version": attr.string(doc="SDP version number"), - "license_path": attr.string(doc="Lincese path"), - "license_info_variable": attr.string(doc="License info variable name (custom settings)"), - "license_info_value": attr.string(doc="License info value (custom settings)"), - "tc_runtime_ecosystem": attr.string(doc="Runtime ecosystem."), - "tc_system_toolchain": attr.bool(doc="Boolean flag to state if this is a system toolchain"), "cc_toolchain_config": attr.label( doc = "Path to the cc_config.bzl template file.", ), "cc_toolchain_flags": attr.label( doc = "Path to the Bazel BUILD file template for the toolchain.", ), + "extra_c_compile_flags": attr.string_list(doc = "Extra/Additional C-specific compile flags."), + "extra_compile_flags": attr.string_list(doc = "Extra/Additional compile flags."), + "extra_cxx_compile_flags": attr.string_list(doc = "Extra/Additional C++-specific compile flags."), + "extra_link_flags": attr.string_list(doc = "Extra/Additional link flags."), + "gcc_version": attr.string(doc = "GCC version string"), + "use_base_constraints_only": attr.bool(doc="Boolean flag to state only base constraints should be used for toolchain compatibility definition"), + "license_info_value": attr.string(doc = "License info value (custom settings)"), + "license_info_variable": attr.string(doc = "License info variable name (custom settings)"), + "license_path": attr.string(doc = "Lincese path"), + "sdk_version": attr.string(doc = "SDP version string"), + "sdp_version": attr.string(doc = "SDP version string"), + "tc_cpu": attr.string(doc = "Target platform CPU."), + "tc_identifier": attr.string(doc = "Constraint to be used for toolchain definition (e.g. gcc_12.2.0)."), + "tc_os": attr.string(doc = "Target platform OS."), + "tc_pkg_repo": attr.string(doc = "The label name of toolchain tarbal."), + "tc_runtime_ecosystem": attr.string(doc = "Runtime ecosystem."), + "tc_system_toolchain": attr.bool(doc = "Boolean flag to state if this is a system toolchain"), + "_cc_gcov_wrapper_script": attr.label( + default = "@score_bazel_cpp_toolchains//templates/linux:cc_gcov_wrapper.template", + ), "_cc_toolchain_build": attr.label( default = "@score_bazel_cpp_toolchains//templates:BUILD.template", doc = "Path to the Bazel BUILD file template for the toolchain.", ), - "_cc_gcov_wrapper_script": attr.label( - default = "@score_bazel_cpp_toolchains//templates/linux:cc_gcov_wrapper.template", - ) }, -) \ No newline at end of file +) diff --git a/templates/BUILD.template b/templates/BUILD.template index fbfad1b..b7548da 100644 --- a/templates/BUILD.template +++ b/templates/BUILD.template @@ -38,7 +38,7 @@ cc_toolchain( ) toolchain( - name = "%{tc_cpu}-%{tc_os}-%{tc_identifier}-%{tc_runtime_es}", + name = "%{tc_cpu}-%{tc_os}%{tc_identifier_short_1}%{tc_identifier_short_2}", exec_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", @@ -46,9 +46,7 @@ toolchain( target_compatible_with = [ "@platforms//cpu:%{tc_cpu}", "@platforms//os:%{tc_os}", - "@score_bazel_platforms//runtime_es:%{tc_runtime_es}", - "@score_bazel_platforms//version:%{tc_identifier}", - ], + ] + %{tc_identifier_long_1} + %{tc_identifier_long_2}, toolchain = ":cc_toolchain", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", visibility = [