diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6c3a316 Binary files /dev/null and b/.DS_Store differ diff --git a/.bazelrc b/.bazelrc index acc86ba..e678b90 100644 --- a/.bazelrc +++ b/.bazelrc @@ -14,6 +14,94 @@ common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ common --registry=https://bcr.bazel.build +build --java_language_version=17 +build --tool_java_language_version=17 +build --java_runtime_version=remotejdk_17 +build --tool_java_runtime_version=remotejdk_17 +build --credential_helper="*.qnx.com=%workspace%/.github/tools/qnx_credential_helper.py" + +#Baselibs flags +build --@score_baselibs//score/json:base_library=nlohmann +build --@score_baselibs//score/mw/log/flags:KRemote_Logging=False + +# Clippy linting (enabled by default) +build --aspects=@score_rust_policies//clippy:linters.bzl%clippy_strict +build --output_groups=+rules_lint_human +build:lint --@aspect_rules_lint//lint:fail_on_violation=true + +test --test_output=errors + + +# Target configuration for CPU:x86-64|OS:Linux build (do not use it in case of system toolchains!) +#build:x86_64-linux --config=_bl_stub +#build:x86_64-linux --config=_bl_toolchain_common +build:x86_64-linux --config=_common +build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix +build:x86_64-linux --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0-posix +build:x86_64-linux --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu +test:x86_64-linux --config=_common + +# Target configuration for CPU:AArch64|OS:Linux build (do not use it in case of system toolchains!) +#build:aarch64-linux --config=_bl_stub +#build:aarch64-linux --config=_bl_toolchain_common +build:aarch64-linux --config=_common +build:aarch64-linux --platforms=@score_bazel_platforms//:aarch64-linux-gcc_12.2.0-posix +build:aarch64-linux --extra_toolchains=@score_gcc_aarch64_toolchain//:aarch64-linux-gcc_12.2.0-posix +test:aarch64-linux --config=_common + + +# Target configuration for CPU:x86-64|OS:QNX build (do not use it in case of system toolchains!) +#build:x86_64-qnx --config=_bl_stub +#build:x86_64-qnx --config=_bl_toolchain_common +build:x86_64-qnx --config=_common +build:x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix +build:x86_64-qnx --extra_toolchains=@score_qcc_x86_64_toolchain//:x86_64-qnx-sdp_8.0.0-posix +test:x86_64-qnx --config=_common + +# Target configuration for CPU:AArch64|OS:QNX build (do not use it in case of system toolchains!) +#build:aarch64-qnx --config=_bl_stub +#build:aarch64-qnx --config=_bl_toolchain_common +build:aarch64-qnx --config=_common +build:aarch64-qnx --incompatible_strict_action_env +build:aarch64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix +build:aarch64-qnx --extra_toolchains=@score_qcc_aarch64_toolchain//:aarch64-qnx-sdp_8.0.0-posix +test:aarch64-qnx --config=_common + +# Target configuration for CPU:AArch64|OS:QNX build with Ferrocene Rust toolchain (do not use it in case of system toolchains!) +build:per-arm64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_aarch64_unknown_nto_qnx800 + +coverage --features=coverage +coverage --combined_report=lcov +coverage --cache_test_results=no + +# Sanitizer configuration for C++ +test:asan_ubsan_lsan --features=asan +test:asan_ubsan_lsan --features=ubsan +test:asan_ubsan_lsan --features=lsan +test:asan_ubsan_lsan --copt -g3 +test:asan_ubsan_lsan --platform_suffix=asan_ubsan_lsan +test:asan_ubsan_lsan --test_env=ASAN_OPTIONS="exitcode=55 allow_addr2line=1 verbosity=1 coverage=1 check_initialization_order=1 detect_stack_use_after_return=1 print_stats=1 halt_on_error=1 allocator_may_return_null=1 detect_leaks=1" +test:asan_ubsan_lsan --test_env=UBSAN_OPTIONS="exitcode=55 allow_addr2line=1 verbosity=1 coverage=1 print_stacktrace=1 halt_on_error=1" + +# ------------------------------------------------------------------------------- +# Ferrocene Rust coverage config +# ------------------------------------------------------------------------------- +build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Cinstrument-coverage +build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Clink-dead-code +build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Ccodegen-units=1 +build:ferrocene-coverage --@rules_rust//rust/settings:extra_rustc_flag=-Cdebuginfo=2 +build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Cinstrument-coverage +build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Clink-dead-code +build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Ccodegen-units=1 +build:ferrocene-coverage --@rules_rust//rust/settings:extra_exec_rustc_flag=-Cdebuginfo=2 +test:ferrocene-coverage --run_under=@score_tooling//coverage:llvm_profile_wrapper + +# ------------------------------------------------------------------------------- +# Import local user workspace file, if exists +# ------------------------------------------------------------------------------- +try-import %workspace%/user.bazelrc + + # Build stamping for version info build --workspace_status_command=$(pwd)/bazel_stamp_vars.sh @@ -26,10 +114,3 @@ build:_common --cxxopt=-Wno-error=deprecated-declarations # Host platform build configuration build:host --config=_common - -build:x86_64-qnx --config=_common -build:x86_64-qnx --noexperimental_merged_skyframe_analysis_execution -build:x86_64-qnx --incompatible_enable_cc_toolchain_resolution -build:x86_64-qnx --incompatible_strict_action_env -build:x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx -build:x86_64-qnx --extra_toolchains=@toolchains_qnx_qcc//:qcc_x86_64 diff --git a/.bazelrc.user b/.bazelrc.user new file mode 100644 index 0000000..30580b3 --- /dev/null +++ b/.bazelrc.user @@ -0,0 +1 @@ +build --action_env=APE_NO_MODIFY_SELF=1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e88d473..b76cbf8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,4 +1,16 @@ { "name": "eclipse-s-core", - "image": "ghcr.io/eclipse-score/devcontainer:v1.1.0" -} + "image": "ghcr.io/eclipse-score/devcontainer:v1.2.0", + "runArgs": [ + "--dns=8.8.8.8", + "--dns=8.8.4.4", + "--privileged" + ], + "capAdd": [ + "SYS_PTRACE" + ] // NOTE: APE (Actually Portable Executable) binaries used by Bazel may not work + // in Docker Desktop on macOS/Windows due to linuxkit kernel incompatibility. + // If you experience "assimilate" segfaults: + // - Use WSL2 with native Docker (not Docker Desktop) + // - Run Bazel on the host system instead + // - Rely on CI for format checks} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 930c42b..0a55ada 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,19 +13,23 @@ name: Scrample Build on: - pull_request_target: + pull_request: types: [opened, reopened, synchronize] merge_group: types: [checks_requested] jobs: qnx-build: + strategy: + fail-fast: false + matrix: + bazel-config: [x86_64-qnx, aarch64-qnx] uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@main permissions: contents: read pull-requests: read with: - bazel-target: "//src:scrample" - bazel-config: "x86_64-qnx" + bazel-target: "//score/..." + bazel-config: ${{ matrix.bazel-config }} credential-helper: ".github/tools/qnx_credential_helper.py" environment-name: "workflow-approval" secrets: diff --git a/.github/workflows/debug-qnx-helper.yml b/.github/workflows/debug-qnx-helper.yml index d71dcef..dc17248 100644 --- a/.github/workflows/debug-qnx-helper.yml +++ b/.github/workflows/debug-qnx-helper.yml @@ -45,7 +45,7 @@ jobs: chmod +x "${CRED_HELPER}" - PAYLOAD='{"uri": "https://fusion.qnx.com/8/79858/installation.tgz"}' + PAYLOAD='{"uri": "https://fusion.qnx.com/6/85936/installation_qnx_803_260203.tar.xz?tid=3631642_wE_0220075214&ending=installation_qnx_803_260203.tar.xz"}' echo "Running helper with timeout 30s..." START=$(date +%s) diff --git a/.github/workflows/release_verification.yml b/.github/workflows/release_verification.yml index d6fd014..bca5fb9 100644 --- a/.github/workflows/release_verification.yml +++ b/.github/workflows/release_verification.yml @@ -40,8 +40,8 @@ jobs: SCORE_QNX_USER: ${{ secrets.SCORE_QNX_USER }} SCORE_QNX_PASSWORD: ${{ secrets.SCORE_QNX_PASSWORD }} run: | - bazel build --config x86_64-qnx --credential_helper=*.qnx.com=${{ github.workspace }}/.github/tools/qnx_credential_helper.py -- \ - //src:scrample + bazel build --config=x86_64-qnx --credential_helper=*.qnx.com=${{ github.workspace }}/.github/tools/qnx_credential_helper.py -- \ + //score/src:scrample - name: Cleanup QNX License if: always() run: rm -rf /opt/score_qnx diff --git a/BUILD b/BUILD index 9b5e377..cbad380 100644 --- a/BUILD +++ b/BUILD @@ -27,9 +27,8 @@ copyright_checker( name = "copyright", srcs = [ "feo/ad-demo", + "score", "scorex", - "src", - "tests", "//:BUILD", "//:MODULE.bazel", ], diff --git a/MODULE.bazel b/MODULE.bazel index 1323a4c..b2f733c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,11 +12,12 @@ # ******************************************************************************* module( name = "score_scrample", - version = "0.1.0", + version = "0.0.0", + compatibility_level = 0, ) # Configure and register the python toolchain. -bazel_dep(name = "rules_python", version = "1.4.1") +bazel_dep(name = "rules_python", version = "1.8.3") PYTHON_VERSION = "3.12" @@ -27,28 +28,67 @@ python.toolchain( ) use_repo(python, "python_versions") -# Configure the target toolchain. -bazel_dep(name = "score_toolchains_qnx", version = "0.0.2", dev_dependency = True) -qnx = use_extension("@score_toolchains_qnx//:extensions.bzl", "toolchains_qnx", dev_dependency = True) -qnx.sdp( - sha256 = "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63", - strip_prefix = "installation", - url = "https://www.qnx.com/download/download/79858/installation.tgz", +## Configure the C++ toolchain + +bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.2.2", dev_dependency = True) + +gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc", dev_dependency = True) +gcc.toolchain( + name = "score_gcc_x86_64_toolchain", + target_cpu = "x86_64", + target_os = "linux", + use_default_package = True, + version = "12.2.0", +) +gcc.toolchain( + name = "score_gcc_aarch64_toolchain", + target_cpu = "aarch64", + target_os = "linux", + use_default_package = True, + version = "12.2.0", +) +gcc.toolchain( + name = "score_qcc_x86_64_toolchain", + sdp_version = "8.0.0", + target_cpu = "x86_64", + target_os = "qnx", + use_default_package = True, + version = "12.2.0", +) +gcc.toolchain( + name = "score_qcc_aarch64_toolchain", + sdp_version = "8.0.0", + target_cpu = "aarch64", + target_os = "qnx", + use_default_package = True, + version = "12.2.0", +) +use_repo( + gcc, + "score_gcc_aarch64_toolchain", + "score_gcc_x86_64_toolchain", + "score_qcc_aarch64_toolchain", + "score_qcc_x86_64_toolchain", ) -use_repo(qnx, "toolchains_qnx_sdp") -use_repo(qnx, "toolchains_qnx_qcc") -# register_toolchains("@toolchains_qnx_qcc//:qcc_x86_64") # Add GoogleTest dependency -bazel_dep(name = "googletest", version = "1.17.0") +bazel_dep(name = "googletest", version = "1.17.0.bcr.2") +bazel_dep(name = "google_benchmark", version = "1.9.5") + +# rust +bazel_dep(name = "rules_rust", version = "0.67.0") +git_override( + module_name = "rules_rust", + commit = "2b171a7376e69cb1207eced1f66904ce4ae0c819", + remote = "https://github.com/pawelrutkaq/rules_rust.git", # To be fixed once rule_rust is in score bazel registry +) + +# Shared Rust policies (Clippy config, etc.), overridden locally during development. +bazel_dep(name = "score_rust_policies", version = "0.0.5", dev_dependency = True) -# Add Rust rules for Rust tests -bazel_dep(name = "rules_rust", version = "0.61.0") -rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") -rust.toolchain(edition = "2021") # Add boost dependency bazel_dep(name = "rules_boost", repo_name = "com_github_nelhage_rules_boost") @@ -61,27 +101,30 @@ archive_override( bazel_dep(name = "boost.program_options", version = "1.87.0") # C/C++ rules for Bazel -bazel_dep(name = "rules_cc", version = "0.2.1") +bazel_dep(name = "rules_cc", version = "0.2.16") # tooling -bazel_dep(name = "score_tooling", version = "1.0.5") -bazel_dep(name = "score_rust_policies", version = "0.0.3") -bazel_dep(name = "aspect_rules_lint", version = "1.5.3") +bazel_dep(name = "score_tooling", version = "1.1.2") +bazel_dep(name = "aspect_rules_lint", version = "2.0.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2") #docs-as-code -bazel_dep(name = "score_docs_as_code", version = "2.3.3") -bazel_dep(name = "score_process", version = "1.4.2") -bazel_dep(name = "score_baselibs", version = "0.1.3") -bazel_dep(name = "score_communication", version = "0.1.1") -bazel_dep(name = "platforms", version = "1.0.0") -bazel_dep(name = "score_bazel_platforms", version = "0.0.2") -bazel_dep(name = "score_logging", version = "0.0.3") +bazel_dep(name = "score_process", version = "1.4.3") +bazel_dep(name = "score_baselibs", version = "0.2.4") git_override( - module_name = "score_logging", - commit = "9ed6a88cab10a81bf6b0813712cbd7b9fc7e44c5", - remote = "https://github.com/eclipse-score/logging.git", + module_name = "score_baselibs", + commit = "6951cd2a3045fb7a053acf203833a17704c22ccf", + remote = "https://github.com/eclipse-score/baselibs.git", ) +bazel_dep(name = "score_communication", version = "0.1.2") +bazel_dep(name = "platforms", version = "1.0.0") +bazel_dep(name = "score_bazel_platforms", version = "0.0.4") +bazel_dep(name = "score_logging", version = "0.1.0") +#git_override( +# module_name = "score_logging", +# commit = "9ed6a88cab10a81bf6b0813712cbd7b9fc7e44c5", +# remote = "https://github.com/eclipse-score/logging.git", +#) # TRLC dependency for requirements traceability bazel_dep(name = "trlc", version = "0.0.0") @@ -144,18 +187,10 @@ crate.from_cargo( ) use_repo(crate, "ad-demo-local-crates") -# Override feo's dependency on score_docs_as_code to use 2.3.3 -single_version_override( - module_name = "score_docs_as_code", - version = "2.3.3", -) +bazel_dep(name = "score_docs_as_code", version = "3.0.0") + +bazel_dep(name = "score_feo", version = "1.0.5") -bazel_dep(name = "feo", version = "1.0.1") -git_override( - module_name = "feo", - commit = "05702d0a386daf23912c26ccb2b35b584d3a9e8c", - remote = "https://github.com/eclipse-score/feo.git", -) pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.parse( diff --git a/README.md b/README.md index 847f380..9248fd3 100644 --- a/README.md +++ b/README.md @@ -49,12 +49,12 @@ SCRAMPLE consists of two operational modes: ### Standard Build (Host Platform) ```bash -bazel build --config=host //src:scrample +bazel build --config=host //score/src:scrample ``` ### QNX Cross-Compilation ```bash -bazel build --config=x86_64-qnx //src:scrample +bazel build --config=x86_64-qnx //score/src:scrample ``` ### Build All Tests @@ -192,12 +192,12 @@ The project includes example tests demonstrating the testing infrastructure: Run all tests: ```bash -bazel test --config=host //tests/... +bazel test --config=host //score/tests/... ``` Run all tests and format checks: ```bash -bazel test --config=host //tests/... //:format.check +bazel test --config=host //score/tests/... //:format.check ``` ## Contributing diff --git a/cicd-workflows b/cicd-workflows new file mode 160000 index 0000000..773e90a --- /dev/null +++ b/cicd-workflows @@ -0,0 +1 @@ +Subproject commit 773e90a525ba9dd552412961f8057f5de40135a7 diff --git a/examples/BUILD b/examples/BUILD index 012dd54..aee1f2f 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -4,5 +4,9 @@ filegroup( srcs = [ "Cargo.lock", ], + tags = ["no-clippy"], + target_compatible_with = [ + "@platforms//os:linux", + ], visibility = ["//visibility:public"], ) diff --git a/feo/.DS_Store b/feo/.DS_Store new file mode 100644 index 0000000..f135fc0 Binary files /dev/null and b/feo/.DS_Store differ diff --git a/feo/ad-demo/BUILD.bazel b/feo/ad-demo/BUILD.bazel index b2e4d07..3d3017c 100644 --- a/feo/ad-demo/BUILD.bazel +++ b/feo/ad-demo/BUILD.bazel @@ -31,6 +31,9 @@ rust_library( ], crate_name = "ad_demo", data = ["src/assets/gps_route.mcap"], + target_compatible_with = [ + "@platforms//os:linux", + ], visibility = ["//visibility:public"], deps = [ "@ad-demo-local-crates//:camino", @@ -56,6 +59,9 @@ rust_binary( srcs = [ "src/agents/primary.rs", ], + target_compatible_with = [ + "@platforms//os:linux", + ], visibility = ["//visibility:public"], deps = [ ":activities_lib", @@ -72,6 +78,9 @@ rust_binary( srcs = [ "src/agents/secondary.rs", ], + target_compatible_with = [ + "@platforms//os:linux", + ], visibility = ["//visibility:public"], deps = [ ":activities_lib", diff --git a/feo/ad-demo/lichtblick-com/BUILD.bazel b/feo/ad-demo/lichtblick-com/BUILD.bazel index 14a1f76..7638ffb 100644 --- a/feo/ad-demo/lichtblick-com/BUILD.bazel +++ b/feo/ad-demo/lichtblick-com/BUILD.bazel @@ -18,12 +18,22 @@ compile_pip_requirements( name = "requirements", requirements_in = "requirements.in", requirements_txt = "requirements_lock.txt", + tags = [ + "manual", + "no-clippy", + ], + target_compatible_with = [ + "@platforms//os:linux", + ], ) py_binary( name = "foxglove_ws_server", srcs = ["foxglove_ws_server.py"], main = "foxglove_ws_server.py", + target_compatible_with = [ + "@platforms//os:linux", + ], visibility = ["//visibility:public"], deps = [ requirement("foxglove_websocket"), diff --git a/score/BUILD b/score/BUILD new file mode 100644 index 0000000..1cda3c9 --- /dev/null +++ b/score/BUILD @@ -0,0 +1,15 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +# Scrample - Score Example Application +# This directory contains the main source code and tests diff --git a/src/BUILD b/score/src/BUILD similarity index 100% rename from src/BUILD rename to score/src/BUILD diff --git a/src/assert_handler.cpp b/score/src/assert_handler.cpp similarity index 100% rename from src/assert_handler.cpp rename to score/src/assert_handler.cpp diff --git a/src/assert_handler.h b/score/src/assert_handler.h similarity index 100% rename from src/assert_handler.h rename to score/src/assert_handler.h diff --git a/src/datatype.cpp b/score/src/datatype.cpp similarity index 100% rename from src/datatype.cpp rename to score/src/datatype.cpp diff --git a/src/datatype.h b/score/src/datatype.h similarity index 100% rename from src/datatype.h rename to score/src/datatype.h diff --git a/src/etc/logging.json b/score/src/etc/logging.json similarity index 100% rename from src/etc/logging.json rename to score/src/etc/logging.json diff --git a/src/etc/mw_com_config.json b/score/src/etc/mw_com_config.json similarity index 100% rename from src/etc/mw_com_config.json rename to score/src/etc/mw_com_config.json diff --git a/src/main.cpp b/score/src/main.cpp similarity index 100% rename from src/main.cpp rename to score/src/main.cpp diff --git a/src/sample_sender_receiver.cpp b/score/src/sample_sender_receiver.cpp similarity index 100% rename from src/sample_sender_receiver.cpp rename to score/src/sample_sender_receiver.cpp diff --git a/src/sample_sender_receiver.h b/score/src/sample_sender_receiver.h similarity index 100% rename from src/sample_sender_receiver.h rename to score/src/sample_sender_receiver.h diff --git a/tests/cpp/BUILD b/score/tests/cpp/BUILD similarity index 100% rename from tests/cpp/BUILD rename to score/tests/cpp/BUILD diff --git a/tests/cpp/test_main.cpp b/score/tests/cpp/test_main.cpp similarity index 100% rename from tests/cpp/test_main.cpp rename to score/tests/cpp/test_main.cpp diff --git a/score/tests/rust/BUILD b/score/tests/rust/BUILD new file mode 100644 index 0000000..711361f --- /dev/null +++ b/score/tests/rust/BUILD @@ -0,0 +1,21 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* +load("@rules_rust//rust:defs.bzl", "rust_test") + +rust_test( + name = "rust_hello_test", + srcs = ["test_main.rs"], + target_compatible_with = [ + "@platforms//os:linux", + ], +) diff --git a/tests/rust/test_main.rs b/score/tests/rust/test_main.rs similarity index 100% rename from tests/rust/test_main.rs rename to score/tests/rust/test_main.rs diff --git a/tests/rust/BUILD b/tests/rust/BUILD index 828a001..711361f 100644 --- a/tests/rust/BUILD +++ b/tests/rust/BUILD @@ -15,4 +15,7 @@ load("@rules_rust//rust:defs.bzl", "rust_test") rust_test( name = "rust_hello_test", srcs = ["test_main.rs"], + target_compatible_with = [ + "@platforms//os:linux", + ], )