Skip to content

Commit 7998225

Browse files
authored
Enable new toolchain for AutoSD (#31)
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
1 parent 7da1729 commit 7998225

14 files changed

Lines changed: 403 additions & 285 deletions

File tree

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
module(
1515
name = "score_bazel_cpp_toolchains",
16-
version = "0.2.2",
16+
version = "0.3.0",
1717
compatibility_level = 0,
1818
)
1919

@@ -26,7 +26,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1")
2626
# Constraint values for specifying platforms and toolchains
2727
# *******************************************************************************
2828
bazel_dep(name = "platforms", version = "1.0.0")
29-
bazel_dep(name = "score_bazel_platforms", version = "0.0.2")
29+
bazel_dep(name = "score_bazel_platforms", version = "0.1.0")
3030

3131
# *******************************************************************************
3232
# C++ Rules for Bazel

examples/.bazelrc

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,53 @@ common --registry=https://bcr.bazel.build
1818
# Shared configuration for simple test execution
1919
build:shared --incompatible_strict_action_env
2020
build:shared --sandbox_writable_path=/var/tmp
21-
build:shared --host_platform=@score_bazel_platforms//:x86_64-linux
2221

2322
# -------------------------------------------------------------------------------
24-
# Config dedicated to host platform CPU:x86_64 and OS:Linux
23+
# Different toolchain configuration for x86_64-linux (host)
2524
# -------------------------------------------------------------------------------
26-
build:x86_64-linux --config=shared
27-
build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix
25+
build:host_config_1 --config=shared
26+
build:host_config_1 --host_platform=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix
27+
build:host_config_1 --extra_toolchains=@score_gcc_toolchain//:x86_64-linux-gcc_12.2.0
28+
build:host_config_1 --host_features=use_pthread
2829

2930
# -------------------------------------------------------------------------------
30-
# Different toolchain configuration for x86_64-linux
31+
# Different toolchain configuration for x86_64-linux (host)
3132
# -------------------------------------------------------------------------------
32-
build:host_config_1 --config=x86_64-linux
33-
build:host_config_1 --extra_toolchains=@score_gcc_toolchain//:x86_64-linux-gcc_12.2.0-posix
34-
build:host_config_1 --features=use_pthread
33+
build:host_config_2 --config=shared
34+
build:host_config_2 --host_platform=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix
35+
build:host_config_2 --extra_toolchains=@my_toolchain//:x86_64-linux-gcc_12.2.0
3536

3637
# -------------------------------------------------------------------------------
37-
# Different toolchain configuration for x86_64-linux
38+
# Different toolchain configuration for x86_64-linux (host)
3839
# -------------------------------------------------------------------------------
39-
build:host_config_2 --config=x86_64-linux
40-
build:host_config_2 --extra_toolchains=@my_toolchain//:x86_64-linux-gcc_12.2.0-posix
40+
build:host_config_3 --config=shared
41+
build:host_config_3 --host_platform=@score_bazel_platforms//:x86_64-linux
42+
build:host_config_3 --extra_toolchains=@score_gcc_toolchain_bp//:x86_64-linux
4143

4244
# -------------------------------------------------------------------------------
43-
# Config dedicated to target platform CPU:aarch64 and OS:linux
45+
# Toolchain configuration for x86_64-qnx (target)
4446
# -------------------------------------------------------------------------------
45-
build:aarch64-linux --config=shared
46-
build:aarch64-linux --platforms=@score_bazel_platforms//:aarch64-linux-gcc_12.2.0-posix
47+
build:target_config_1 --config=host_config_1
48+
build:target_config_1 --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix
49+
build:target_config_1 --extra_toolchains=@score_qcc_toolchain//:x86_64-qnx-sdp_8.0.0
4750

4851
# -------------------------------------------------------------------------------
49-
# Different toolchain configuration for aarch64-linux
52+
# Toolchain configuration for aarch64-qnx (target)
5053
# -------------------------------------------------------------------------------
51-
build:target_config_3 --config=aarch64-linux
52-
build:target_config_3 --extra_toolchains=@score_aarch64_gcc_toolchain//:aarch64-linux-gcc_12.2.0-posix
53-
54-
55-
# -------------------------------------------------------------------------------
56-
# Config dedicated to target platform CPU:x86_64 and OS:QNX
57-
# -------------------------------------------------------------------------------
58-
build:x86_64-qnx --config=shared
59-
build:x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix
60-
61-
# -------------------------------------------------------------------------------
62-
# Different toolchain configuration for x86_64-qnx
63-
# -------------------------------------------------------------------------------
64-
build:target_config_1 --config=x86_64-qnx
65-
build:target_config_1 --extra_toolchains=@score_qcc_toolchain//:x86_64-qnx-sdp_8.0.0-posix
54+
build:target_config_2 --config=host_config_1
55+
build:target_config_2 --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix
56+
build:target_config_2 --extra_toolchains=@score_qcc_arm_toolchain//:aarch64-qnx-sdp_8.0.0
6657

6758
# -------------------------------------------------------------------------------
68-
# Config dedicated to target platform CPU:aarch64 and OS:QNX
59+
# Toolchain configuration for aarch64-linux (target)
6960
# -------------------------------------------------------------------------------
70-
build:aarch64-qnx --config=shared
71-
build:aarch64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix
61+
build:target_config_3 --config=host_config_1
62+
build:target_config_3 --platforms=@score_bazel_platforms//:aarch64-linux-gcc_12.2.0-posix
63+
build:target_config_3 --extra_toolchains=@score_aarch64_gcc_toolchain//:aarch64-linux-gcc_12.2.0
7264

7365
# -------------------------------------------------------------------------------
74-
# Different toolchain configuration for aarch64-qnx
66+
# Toolchain configuration for aarch64-linux (target)
7567
# -------------------------------------------------------------------------------
76-
build:target_config_2 --config=aarch64-qnx
77-
build:target_config_2 --extra_toolchains=@score_qcc_arm_toolchain//:aarch64-qnx-sdp_8.0.0-posix
68+
build:target_config_4 --config=host_config_1
69+
build:target_config_4 --platforms=@score_bazel_platforms//:x86_64-linux-autosd10
70+
build:target_config_4 --extra_toolchains=@score_autosd_10_toolchain//:x86_64-linux-autosd10

examples/BUILD

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
"""Small C++ CLI application for sanity testing"""
1515

16-
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "cc_shared_library")
16+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_shared_library", "cc_test")
1717

1818
cc_binary(
1919
name = "main_cpp",
@@ -34,8 +34,8 @@ cc_library(
3434
cc_test(
3535
name = "math_lib_test",
3636
srcs = ["math_lib_test.cpp"],
37-
deps = [":math_lib"],
3837
linkstatic = True,
38+
deps = [":math_lib"],
3939
)
4040

4141
cc_shared_library(
@@ -47,9 +47,9 @@ cc_shared_library(
4747
cc_test(
4848
name = "math_lib_dyn_test",
4949
srcs = ["math_lib_test.cpp"],
50-
deps = [":math_lib"],
5150
dynamic_deps = [":math_lib_shared"],
5251
linkstatic = False,
52+
deps = [":math_lib"],
5353
)
5454

5555
cc_test(
@@ -59,5 +59,5 @@ cc_test(
5959
deps = [
6060
"@googletest//:gtest",
6161
"@googletest//:gtest_main",
62-
]
62+
],
6363
)

examples/MODULE.bazel

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bazel_dep(name = "bazel_skylib", version = "1.8.2")
2525
# Constraint values for specifying platforms and toolchains
2626
# *******************************************************************************
2727
bazel_dep(name = "platforms", version = "1.0.0")
28-
bazel_dep(name = "score_bazel_platforms", version = "0.0.4")
28+
bazel_dep(name = "score_bazel_platforms", version = "0.1.0")
2929

3030
# *******************************************************************************
3131
# C++ Rules for Bazel
@@ -38,7 +38,7 @@ bazel_dep(name = "googletest", version = "1.17.0")
3838
# *******************************************************************************
3939
bazel_dep(
4040
name = "score_bazel_cpp_toolchains",
41-
version = "0.2.0",
41+
version = "0.3.0",
4242
)
4343
local_path_override(
4444
module_name = "score_bazel_cpp_toolchains",
@@ -60,11 +60,23 @@ gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc", de
6060
# Setting default GCC (CPU:x86_64|OS:Linux|V:12.2.0|ES:posix)
6161
# *******************************************************************************
6262
gcc.toolchain(
63-
name = "score_gcc_toolchain",
63+
name = "score_gcc_toolchain_bp",
6464
target_cpu = "x86_64",
6565
target_os = "linux",
66+
use_default_package = True,
6667
version = "12.2.0",
68+
use_base_constraints_only = True,
69+
)
70+
71+
# *******************************************************************************
72+
# Setting default GCC (CPU:x86_64|OS:Linux|V:12.2.0|ES:posix)
73+
# *******************************************************************************
74+
gcc.toolchain(
75+
name = "score_gcc_toolchain",
76+
target_cpu = "x86_64",
77+
target_os = "linux",
6778
use_default_package = True,
79+
version = "12.2.0",
6880
)
6981

7082
# *******************************************************************************
@@ -74,40 +86,39 @@ gcc.toolchain(
7486
name = "score_aarch64_gcc_toolchain",
7587
target_cpu = "aarch64",
7688
target_os = "linux",
77-
version = "12.2.0",
7889
use_default_package = True,
79-
)
90+
version = "12.2.0",
91+
)
8092

8193
# *******************************************************************************
8294
# Setting custom GCC (CPU:x86_64|OS:Linux|V:12.2.0|ES:posix)
8395
# *******************************************************************************
8496
gcc.sdp(
8597
name = "my_toolchain_pkg",
86-
url = "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/0.0.1/x86_64-unknown-linux-gnu_gcc12.tar.gz",
87-
strip_prefix = "x86_64-unknown-linux-gnu",
88-
sha256 = "457f5f20f57528033cb840d708b507050d711ae93e009388847e113b11bf3600",
8998
build_file = "@score_bazel_cpp_toolchains//packages/linux/x86_64/gcc/12.2.0:gcc.BUILD",
99+
sha256 = "457f5f20f57528033cb840d708b507050d711ae93e009388847e113b11bf3600",
100+
strip_prefix = "x86_64-unknown-linux-gnu",
101+
url = "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/0.0.1/x86_64-unknown-linux-gnu_gcc12.tar.gz",
90102
)
91103
gcc.toolchain(
92104
name = "my_toolchain",
105+
extra_link_flags = [
106+
"-lpthread",
107+
],
93108
sdp_to_link = "my_toolchain_pkg",
94-
target_os = "linux",
95109
target_cpu = "x86_64",
110+
target_os = "linux",
96111
version = "12.2.0",
97-
extra_link_flags = [
98-
"-lpthread",
99-
]
100112
)
101113

102114
# *******************************************************************************
103115
# Setting GCC (CPU:x86_64|OS:QNX|version(sdp):8.0.0|ES:posix)
104116
# *******************************************************************************
105117
gcc.toolchain(
106118
name = "score_qcc_toolchain",
119+
sdp_version = "8.0.0",
107120
target_cpu = "x86_64",
108121
target_os = "qnx",
109-
sdp_version = "8.0.0",
110-
version = "12.2.0",
111122
use_default_package = True,
112123
)
113124

@@ -116,42 +127,39 @@ gcc.toolchain(
116127
# *******************************************************************************
117128
gcc.toolchain(
118129
name = "score_qcc_arm_toolchain",
130+
sdp_version = "8.0.0",
119131
target_cpu = "aarch64",
120132
target_os = "qnx",
121-
sdp_version = "8.0.0",
122-
version = "12.2.0",
123133
use_default_package = True,
124134
)
125135

126-
# TODO: Not yet supported
127-
# *******************************************************************************
128-
# Setting local host GCC (CPU:x86_64|OS:Linux|V:unknown|ES:host)
129-
# *******************************************************************************
130-
# gcc.toolchain(
131-
# name = "score_system_toolchain",
132-
# target_cpu = "x86_64",
133-
# target_os = "linux",
134-
# use_system_toolchain = True,
135-
# )
136-
137136
# *******************************************************************************
138-
# Setting AutoSD 10 GCC (CPU:x86_64|OS:Linux|V:autosd-10.0|ES:autosd)
137+
# Setting AutoSD 10 GCC (CPU:x86_64|OS:Linux|ES:autosd10)
139138
# *******************************************************************************
140139
gcc.toolchain(
141140
name = "score_autosd_10_toolchain",
141+
runtime_ecosystem = "autosd10",
142142
target_cpu = "x86_64",
143143
target_os = "linux",
144-
runtime_ecosystem = "autosd",
145-
version = "autosd-10.0",
146144
use_default_package = True,
147-
)
145+
)
148146

149147
use_repo(
150148
gcc,
151-
"score_gcc_toolchain",
152-
"score_aarch64_gcc_toolchain",
153149
"my_toolchain",
154-
"score_qcc_toolchain",
155-
"score_qcc_arm_toolchain",
150+
"score_gcc_toolchain_bp",
151+
"score_aarch64_gcc_toolchain",
156152
"score_autosd_10_toolchain",
157-
)
153+
"score_gcc_toolchain",
154+
"score_qcc_arm_toolchain",
155+
"score_qcc_toolchain",
156+
)
157+
158+
# register_toolchains(
159+
# "@score_gcc_toolchain//:x86_64-linux-gcc_12.2.0",
160+
# "@my_toolchain//:x86_64-linux-gcc_12.2.0",
161+
# "@score_qcc_toolchain//:x86_64-qnx-sdp_8.0.0",
162+
# "@score_qcc_arm_toolchain//:aarch64-qnx-sdp_8.0.0",
163+
# "@score_aarch64_gcc_toolchain//:aarch64-linux-gcc_12.2.0",
164+
# "@score_autosd_10_toolchain//:x86_64-linux-autosd10",
165+
# )

examples/test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "Testing 'host_config_1' ..."
4+
bazel test --config host_config_1 //:math_lib_test
5+
bazel clean --expunge
6+
echo -e "Testing 'host_config_2' ..."
7+
bazel test --config host_config_2 //:math_lib_test
8+
bazel clean --expunge
9+
echo -e "Testing 'host_config_3' ..."
10+
bazel test --config host_config_3 //:math_lib_test
11+
bazel clean --expunge
12+
echo -e "Testing 'target_config_1' ..."
13+
bazel build --config target_config_1 //:main_cpp
14+
bazel clean --expunge
15+
echo -e "Testing 'target_config_2' ..."
16+
bazel build --config target_config_2 //:main_cpp
17+
bazel clean --expunge
18+
echo -e "Testing 'target_config_3' ..."
19+
bazel build --config target_config_3 //:main_cpp
20+
bazel clean --expunge
21+
echo -e "Testing 'target_config_4' ..."
22+
bazel build --config target_config_4 //:main_cpp
23+
bazel clean --expunge

0 commit comments

Comments
 (0)