Skip to content
Open
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
29 changes: 22 additions & 7 deletions extensions/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
load("@score_bazel_cpp_toolchains//packages:version_matrix.bzl", "VERSION_MATRIX")
load("@score_bazel_cpp_toolchains//rules:common.bzl", "SDP_VERSION_MAPPING")
load("@score_bazel_cpp_toolchains//rules:gcc.bzl", "gcc_toolchain")
Expand Down Expand Up @@ -54,6 +55,11 @@ _attrs_sdp = {
default = "",
doc = "Url to the toolchain archive.",
),
"path": attr.string(
mandatory = False,
default = "",
doc = "Path to the local toolchain archive.",
),
}

# GCC interface API for toolchain tag class
Expand Down Expand Up @@ -188,6 +194,7 @@ def _get_packages(tags):
"sha256": tag.sha256,
"strip_prefix": tag.strip_prefix,
"url": tag.url,
"path": tag.path,
})
return packages

Expand Down Expand Up @@ -304,6 +311,7 @@ def _create_and_link_sdp(toolchain_info):
"sha256": matrix["sha256"],
"strip_prefix": matrix["strip_prefix"],
"url": matrix["url"],
"path": "",
}

def _resolve_identifier(toolchain_info):
Expand Down Expand Up @@ -385,13 +393,20 @@ def _impl(mctx):
"""
toolchains, archives = _get_info(mctx)
for archive_info in archives:
http_archive(
name = archive_info["name"],
urls = [archive_info["url"]],
build_file = archive_info["build_file"],
sha256 = archive_info["sha256"],
strip_prefix = archive_info["strip_prefix"],
)
if archive_info["path"] != "":
new_local_repository(
name = archive_info["name"],
build_file = archive_info["build_file"],
path = archive_info["path"],
)
else:
http_archive(
name = archive_info["name"],
urls = [archive_info["url"]],
build_file = archive_info["build_file"],
sha256 = archive_info["sha256"],
strip_prefix = archive_info["strip_prefix"],
)

for toolchain_info in toolchains:
gcc_toolchain(
Expand Down
7 changes: 7 additions & 0 deletions tests/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ build:x86_64-linux-autosd10 --extra_toolchains=@score_autosd_10_toolchain//:x86_
build:aarch64-linux-ebclfsa --config=shared
build:aarch64-linux-ebclfsa --platforms=@score_bazel_platforms//:aarch64-linux-sdk_0.1.0-ebclfsa
build:aarch64-linux-ebclfsa --extra_toolchains=@score_ebclfsa_toolchain//:aarch64-linux-sdk_0.1.0-ebclfsa

# -------------------------------------------------------------------------------
# Config dedicated to local toolchain testing CPU:x86_64 and OS:linux
# -------------------------------------------------------------------------------
# build:x86_64-linux-local --config=shared
# build:x86_64-linux-local --host_platform=@score_bazel_platforms//:x86_64-linux-gcc_15.3.0-posix
# build:x86_64-linux-local --extra_toolchains=@score_gcc_toolchain_local//:x86_64-linux-gcc_15.3.0
23 changes: 23 additions & 0 deletions tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0")
# *******************************************************************************
bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "score_bazel_platforms", version = "0.1.2")
git_override(
module_name = "score_bazel_platforms",
commit = "6c45a8f2a973fe396c392f727d9dae510692eb88",
remote = "https://github.com/eclipse-score/bazel_platforms.git",
)

# *******************************************************************************
# C++ Rules for Bazel
Expand Down Expand Up @@ -91,6 +96,22 @@ gcc.toolchain(
version = "12.2.0",
)

# *******************************************************************************
# Setting default GCC - local (CPU:x86_64|OS:Linux|V:12.2.0|ES:posix)
# *******************************************************************************
# gcc.sdp(
# name = "gcc_local_pkg",
# build_file = "@score_bazel_cpp_toolchains//packages/linux/x86_64/gcc/12.2.0:gcc.BUILD",
# path = "<PUT_YOUR_LOCAL_PATH_HERE>",
# )
# gcc.toolchain(
# name = "score_gcc_toolchain_local",
# target_cpu = "x86_64",
# target_os = "linux",
# sdp_to_link = "gcc_local_pkg",
# version = "15.3.0",
# )

# *******************************************************************************
# Setting default GCC (CPU:aarch64|OS:Linux|V:12.2.0|ES:posix)
# *******************************************************************************
Expand Down Expand Up @@ -179,6 +200,8 @@ use_repo(
"score_qcc_arm_toolchain_pkg",
"score_qcc_toolchain",
"score_qcc_toolchain_pkg",
# "score_gcc_toolchain_local",
# "gcc_local_pkg",
)

# *******************************************************************************
Expand Down
5 changes: 1 addition & 4 deletions tests/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading