Skip to content
Draft
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
65 changes: 29 additions & 36 deletions examples/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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_host
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
8 changes: 4 additions & 4 deletions examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -59,5 +59,5 @@ cc_test(
deps = [
"@googletest//:gtest",
"@googletest//:gtest_main",
]
],
)
80 changes: 46 additions & 34 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ bazel_dep(name = "bazel_skylib", version = "1.8.2")
# *******************************************************************************
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "score_bazel_platforms", version = "0.0.4")
local_path_override(
module_name = "score_bazel_platforms",
path = "../../bazel_platforms",
)

# *******************************************************************************
# C++ Rules for Bazel
Expand Down Expand Up @@ -60,11 +64,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",
)

# *******************************************************************************
Expand All @@ -74,40 +90,39 @@ 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",
]
)

# *******************************************************************************
# Setting GCC (CPU:x86_64|OS:QNX|version(sdp):8.0.0|ES:posix)
# *******************************************************************************
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,
)

Expand All @@ -116,42 +131,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",
)
"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",
# )
23 changes: 23 additions & 0 deletions examples/test.sh
Original file line number Diff line number Diff line change
@@ -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
echo -e "Testing 'host_config_2' ..."
bazel test --config host_config_2 //:math_lib_test
bazel clean
echo -e "Testing 'host_config_3' ..."
bazel test --config host_config_3 //:math_lib_test
bazel clean
echo -e "Testing 'target_config_1' ..."
bazel build --config target_config_1 //:main_cpp
bazel clean
echo -e "Testing 'target_config_2' ..."
bazel build --config target_config_2 //:main_cpp
bazel clean
echo -e "Testing 'target_config_3' ..."
bazel build --config target_config_3 //:main_cpp
bazel clean
echo -e "Testing 'target_config_4' ..."
bazel build --config target_config_4 //:main_cpp
bazel clean
Loading