Skip to content
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
20 changes: 10 additions & 10 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,17 @@ gcc.toolchain(
# use_system_toolchain = True,
# )

# TODO: Not yet supported
# *******************************************************************************
# Setting AutoSD GCC (CPU:x86_64|OS:Linux|V:unknown|ES:autosd)
# Setting AutoSD 10 GCC (CPU:x86_64|OS:Linux|V:autosd-10.0|ES:autosd)
# *******************************************************************************
# gcc.toolchain(
# name = "score_autosd_9_toolchain",
# target_cpu = "x86_64",
# target_os = "linux",
# runtime_ecosystem = "autosd",
# version = "9",
# use_system_toolchain = True,
# )
gcc.toolchain(
name = "score_autosd_10_toolchain",
target_cpu = "x86_64",
target_os = "linux",
runtime_ecosystem = "autosd",
version = "autosd-10.0",
use_default_package = True,
)

use_repo(
gcc,
Expand All @@ -159,4 +158,5 @@ use_repo(
"my_toolchain",
"score_qcc_toolchain",
"score_qcc_arm_toolchain",
"score_autosd_10_toolchain",
)
22 changes: 22 additions & 0 deletions extensions/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ _attrs_tc = {
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 = [],
Expand Down Expand Up @@ -163,6 +173,8 @@ def _get_toolchains(tags):
"use_default_package": tag.use_default_package,
"use_system_toolchain": tag.use_system_toolchain,
"tc_extra_compile_flags": tag.extra_compile_flags,
"tc_extra_c_compile_flags": tag.extra_c_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,
Expand Down Expand Up @@ -192,6 +204,14 @@ def _create_and_link_sdp(toolchain_info):
)
matrix = VERSION_MATRIX[matrix_key]
toolchain_info["sdp_to_link"] = pkg_name

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"]

return {
"name": pkg_name,
"url": matrix["url"],
Expand Down Expand Up @@ -250,6 +270,8 @@ def _impl(mctx):
gcc_toolchain(
name = toolchain_info["name"],
extra_compile_flags = toolchain_info["tc_extra_compile_flags"],
extra_c_compile_flags = toolchain_info["tc_extra_c_compile_flags"],
extra_cxx_compile_flags = toolchain_info["tc_extra_cxx_compile_flags"],
extra_link_flags = toolchain_info["tc_extra_link_flags"],
license_info_variable = toolchain_info["tc_license_info_variable"],
license_info_value = toolchain_info["tc_license_info_url"],
Expand Down
16 changes: 16 additions & 0 deletions packages/linux/aarch64/autosd/10.0/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

exports_files([
"autosd.BUILD",
])
61 changes: 61 additions & 0 deletions packages/linux/aarch64/autosd/10.0/autosd.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Build file for AutoSD 10 GCC toolchain package"""

package(default_visibility = ["//visibility:public"])

filegroup(
name = "all_files",
srcs = glob(["*/**/*"]),
)

filegroup(
name = "bin",
srcs = ["usr/bin"],
)

filegroup(
name = "ar",
srcs = ["usr/bin/ar"],
)

filegroup(
name = "cc",
srcs = ["usr/bin/gcc"],
)

filegroup(
name = "gcov",
srcs = ["usr/bin/gcov"],
)

filegroup(
name = "cxx",
srcs = ["usr/bin/g++"],
)

filegroup(
name = "strip",
srcs = ["usr/bin/strip"],
)

# The sysroot for AutoSD is the entire extracted directory
# since it contains usr/ and lib64/ at the root
filegroup(
name = "sysroot_dir",
srcs = glob([
"usr/**",
"lib64/**",
]),
)
16 changes: 16 additions & 0 deletions packages/linux/x86_64/autosd/10.0/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

exports_files([
"autosd.BUILD",
])
71 changes: 71 additions & 0 deletions packages/linux/x86_64/autosd/10.0/autosd.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Build file for AutoSD 10 GCC toolchain package"""

package(default_visibility = ["//visibility:public"])

filegroup(
name = "all_files",
srcs = glob(["*/**/*"]),
)

filegroup(
name = "bin",
srcs = ["usr/bin"],
)

filegroup(
name = "ar",
srcs = ["usr/bin/ar"],
)

filegroup(
name = "cc",
srcs = ["usr/bin/gcc"],
)

filegroup(
name = "gcov",
srcs = ["usr/bin/gcov"],
)

filegroup(
name = "cxx",
srcs = ["usr/bin/g++"],
)

filegroup(
name = "strip",
srcs = ["usr/bin/strip"],
)

# The sysroot for AutoSD is the entire extracted directory
# since it contains usr/ and lib64/ at the root
filegroup(
name = "sysroot_dir",
srcs = ["."],
)

# Builtin include directories for the compiler
# List directory paths directly (like QNX does)
filegroup(
name = "cxx_builtin_include_directories",
srcs = [
"usr/lib/gcc/x86_64-redhat-linux/14/include",
"usr/include",
"usr/include/c++/14",
"usr/include/c++/14/x86_64-redhat-linux",
"usr/include/c++/14/backward",
],
)
52 changes: 52 additions & 0 deletions packages/version_matrix.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,56 @@ VERSION_MATRIX = {
"strip_prefix": "installation",
"sha256": "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63",
},
"x86_64-linux-gcc-autosd-10.0": {
"url": "https://github.com/eclipse-score/inc_os_autosd/releases/download/v0.1.0/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": "472e312711efab98022b14f2af288d47e1891674eaf9ab6a0a8dec60cae0ac75",
"extra_c_compile_flags": [
"-nostdinc",
"-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/x86_64-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",
],
"extra_link_flags": [
"-lm",
"-ldl",
"-lrt",
"-lstdc++",
],
},
"aarch64-linux-gcc-autosd-10.0": {
"url": "https://github.com/eclipse-score/inc_os_autosd/releases/download/v0.1.0/autosd-toolchain-aarch64.tar.gz",
"build_file": "@score_bazel_cpp_toolchains//packages/linux/aarch64/autosd/10.0:autosd.BUILD",
"strip_prefix": "sysroot",
"sha256": "b5128954339b9ace240de36233f910966c4760f70e4d4f2772033b3cb8d4ae22",
"extra_c_compile_flags": [
"-nostdinc",
"-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/aarch64-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",
],
"extra_link_flags": [
"-lm",
"-ldl",
"-lrt",
"-lstdc++",
],
},
}
28 changes: 26 additions & 2 deletions rules/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,26 @@ def _impl(rctx):
},
)

extra_compile_flags = get_flag_groups(rctx.attr.extra_compile_flags)
extra_link_flags = get_flag_groups(rctx.attr.extra_link_flags)
# Get canonical repository name for the toolchain package
# In bzlmod, repos created by module extensions follow the pattern: module++extension+repo_name
# Get our own canonical name (e.g., "score_bazel_cpp_toolchains++gcc+score_autosd_10_toolchain")
# and replace our repo name with the package repo name
my_canonical_name = rctx.name
if "++" in my_canonical_name:
parts = my_canonical_name.rsplit("+", 1)
prefix = parts[0] + "+"
canonical_pkg_name = prefix + rctx.attr.tc_pkg_repo
else:
canonical_pkg_name = rctx.attr.tc_pkg_repo

# Replace %{toolchain_pkg}% placeholder in extra flags with canonical name
def replace_placeholder(flags):
return [flag.replace("%{toolchain_pkg}%", canonical_pkg_name) for flag in flags]

extra_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_compile_flags))
extra_c_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_c_compile_flags))
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 = {
Expand All @@ -126,6 +144,10 @@ def _impl(rctx):
"%{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_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,
}
Expand Down Expand Up @@ -175,6 +197,8 @@ gcc_toolchain = repository_rule(
"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"),
Expand Down
Loading