From 32abf22969081a7c4a97733cf6d1b88b9e0c9d55 Mon Sep 17 00:00:00 2001 From: Anton Krivoborodov <63401640+antonkri@users.noreply.github.com> Date: Sun, 24 May 2026 11:15:33 +0000 Subject: [PATCH] refactor: scrample app --- .bazelrc | 16 +- .github/workflows/build-cli.yml | 77 --- .github/workflows/build.yml | 37 +- .github/workflows/debug-qnx-helper.yml | 57 --- .github/workflows/release_verification.yml | 78 +-- BUILD | 7 +- MODULE.bazel | 149 ++---- README.md | 199 +++----- .../point.bazelrc.tmpl => config/BUILD | 28 +- config/logging.json | 7 + docs/scrample/index.rst | 103 +++- feo/ad-demo/BUILD.bazel | 84 ---- feo/ad-demo/Cargo.lock | 415 ---------------- feo/ad-demo/Cargo.toml | 10 - feo/ad-demo/README.md | 40 -- feo/ad-demo/lichtblick-com/BUILD.bazel | 31 -- feo/ad-demo/lichtblick-com/README.md | 14 - .../lichtblick-com/foxglove_ws_server.py | 154 ------ feo/ad-demo/lichtblick-com/requirements.in | 1 - .../lichtblick-com/requirements_lock.txt | 81 --- .../src/activities/application_config.rs | 117 ----- feo/ad-demo/src/activities/camera_activity.rs | 66 --- feo/ad-demo/src/activities/common.rs | 43 -- feo/ad-demo/src/activities/mcap_activity.rs | 126 ----- feo/ad-demo/src/activities/messages.rs | 45 -- feo/ad-demo/src/activities/mod.rs | 21 - feo/ad-demo/src/activities/render_activity.rs | 77 --- feo/ad-demo/src/agents/primary.rs | 88 ---- feo/ad-demo/src/agents/secondary.rs | 56 --- feo/ad-demo/src/assets/gps_route.mcap | Bin 24327 -> 0 bytes feo/ad-demo/src/lib.rs | 17 - scorex/BUILD.bazel | 93 ---- scorex/README.md | 178 ------- scorex/cmd/BUILD.bazel | 31 -- scorex/cmd/init.go | 450 ----------------- scorex/cmd/root.go | 65 --- scorex/cmd/version.go | 35 -- scorex/distribution/homebrew/scorex.rb | 39 -- scorex/distribution/install.sh | 100 ---- scorex/distribution/scoop/scorex.json | 23 - scorex/go.mod | 10 - scorex/go.sum | 10 - scorex/internal/config/BUILD.bazel | 30 -- scorex/internal/config/config.go | 8 - scorex/internal/config/known_good.go | 14 - scorex/internal/config/module_presets.go | 132 ----- scorex/internal/config/module_presets.json | 18 - scorex/internal/config/project_config.go | 42 -- scorex/internal/model/BUILD.bazel | 23 - scorex/internal/model/known_good.go | 10 - scorex/internal/model/module.go | 8 - scorex/internal/projectinit/BUILD.bazel | 21 - scorex/internal/projectinit/service.go | 14 - scorex/internal/service/knowngood/BUILD.bazel | 21 - scorex/internal/service/knowngood/loader.go | 47 -- scorex/internal/service/module/BUILD.bazel | 21 - scorex/internal/service/module/resolver.go | 97 ---- .../internal/service/projectinit/BUILD.bazel | 27 - .../internal/service/projectinit/service.go | 94 ---- scorex/internal/service/skeleton/BUILD.bazel | 27 - scorex/internal/service/skeleton/generator.go | 133 ----- .../internal/service/skeleton/properties.go | 14 - scorex/internal/skeleton/BUILD.bazel | 24 - scorex/internal/skeleton/generator.go | 8 - scorex/internal/skeleton/properties.go | 6 - scorex/internal/templates/BUILD.bazel | 47 -- .../templates/application/daal_app/BUILD.tmpl | 0 .../application/daal_app/MODULE.bazel.tmpl | 41 -- .../daal_app/point.bazelversion.tmpl | 1 - .../point.devcontainer/devcontainer.json.tmpl | 6 - .../prepare_workspace.sh.tmpl | 18 - .../application/daal_app/src/BUILD.tmpl | 29 -- .../daal_app/src/hello_world_app.hpp.tmpl | 47 -- .../application/daal_app/src/main.cpp.tmpl | 62 --- .../templates/application/feo_app/BUILD.tmpl | 0 .../application/feo_app/MODULE.bazel.tmpl | 52 -- .../application/feo_app/point.bazelrc.tmpl | 15 - .../feo_app/point.bazelversion.tmpl | 1 - .../point.devcontainer/devcontainer.json.tmpl | 6 - .../prepare_workspace.sh.tmpl | 18 - .../feo_app/src/hello_world.rs.tmpl | 30 -- scorex/internal/templates/fs.go | 7 - scorex/internal/templates/module/BUILD.tmpl | 0 .../templates/module/MODULE.bazel.tmpl | 38 -- .../templates/module/point.bazelrc.tmpl | 15 - .../templates/module/point.bazelversion.tmpl | 1 - .../point.devcontainer/devcontainer.json.tmpl | 6 - .../prepare_workspace.sh.tmpl | 18 - .../templates/module/src/main.cpp.tmpl | 20 - scorex/internal/utils/BUILD.bazel | 28 -- scorex/internal/utils/module_resolver.go | 16 - scorex/internal/utils/skeleton_properties.go | 6 - scorex/main.go | 19 - src/BUILD | 57 --- src/assert_handler.cpp | 70 --- src/assert_handler.h | 24 - src/datatype.cpp | 14 - src/datatype.h | 306 ------------ src/etc/logging.json | 8 - src/etc/mw_com_config.json | 63 --- src/main.cpp | 131 ----- src/sample_sender_receiver.cpp | 464 ------------------ src/sample_sender_receiver.h | 55 --- .../module/src/BUILD.tmpl => src_cpp/BUILD | 40 +- src_cpp/main.cpp | 43 ++ .../feo_app/src/BUILD.tmpl => src_rust/BUILD | 74 +-- src_rust/main.rs | 31 ++ 107 files changed, 459 insertions(+), 5585 deletions(-) delete mode 100644 .github/workflows/build-cli.yml delete mode 100644 .github/workflows/debug-qnx-helper.yml rename scorex/internal/templates/application/daal_app/point.bazelrc.tmpl => config/BUILD (71%) mode change 100755 => 100644 create mode 100644 config/logging.json delete mode 100644 feo/ad-demo/BUILD.bazel delete mode 100644 feo/ad-demo/Cargo.lock delete mode 100644 feo/ad-demo/Cargo.toml delete mode 100644 feo/ad-demo/README.md delete mode 100644 feo/ad-demo/lichtblick-com/BUILD.bazel delete mode 100644 feo/ad-demo/lichtblick-com/README.md delete mode 100644 feo/ad-demo/lichtblick-com/foxglove_ws_server.py delete mode 100644 feo/ad-demo/lichtblick-com/requirements.in delete mode 100644 feo/ad-demo/lichtblick-com/requirements_lock.txt delete mode 100644 feo/ad-demo/src/activities/application_config.rs delete mode 100644 feo/ad-demo/src/activities/camera_activity.rs delete mode 100644 feo/ad-demo/src/activities/common.rs delete mode 100644 feo/ad-demo/src/activities/mcap_activity.rs delete mode 100644 feo/ad-demo/src/activities/messages.rs delete mode 100644 feo/ad-demo/src/activities/mod.rs delete mode 100644 feo/ad-demo/src/activities/render_activity.rs delete mode 100644 feo/ad-demo/src/agents/primary.rs delete mode 100644 feo/ad-demo/src/agents/secondary.rs delete mode 100644 feo/ad-demo/src/assets/gps_route.mcap delete mode 100644 feo/ad-demo/src/lib.rs delete mode 100644 scorex/BUILD.bazel delete mode 100644 scorex/README.md delete mode 100644 scorex/cmd/BUILD.bazel delete mode 100644 scorex/cmd/init.go delete mode 100644 scorex/cmd/root.go delete mode 100644 scorex/cmd/version.go delete mode 100644 scorex/distribution/homebrew/scorex.rb delete mode 100755 scorex/distribution/install.sh delete mode 100644 scorex/distribution/scoop/scorex.json delete mode 100644 scorex/go.mod delete mode 100644 scorex/go.sum delete mode 100644 scorex/internal/config/BUILD.bazel delete mode 100644 scorex/internal/config/config.go delete mode 100644 scorex/internal/config/known_good.go delete mode 100644 scorex/internal/config/module_presets.go delete mode 100644 scorex/internal/config/module_presets.json delete mode 100644 scorex/internal/config/project_config.go delete mode 100644 scorex/internal/model/BUILD.bazel delete mode 100644 scorex/internal/model/known_good.go delete mode 100644 scorex/internal/model/module.go delete mode 100644 scorex/internal/projectinit/BUILD.bazel delete mode 100644 scorex/internal/projectinit/service.go delete mode 100644 scorex/internal/service/knowngood/BUILD.bazel delete mode 100644 scorex/internal/service/knowngood/loader.go delete mode 100644 scorex/internal/service/module/BUILD.bazel delete mode 100644 scorex/internal/service/module/resolver.go delete mode 100644 scorex/internal/service/projectinit/BUILD.bazel delete mode 100644 scorex/internal/service/projectinit/service.go delete mode 100644 scorex/internal/service/skeleton/BUILD.bazel delete mode 100644 scorex/internal/service/skeleton/generator.go delete mode 100644 scorex/internal/service/skeleton/properties.go delete mode 100644 scorex/internal/skeleton/BUILD.bazel delete mode 100644 scorex/internal/skeleton/generator.go delete mode 100644 scorex/internal/skeleton/properties.go delete mode 100644 scorex/internal/templates/BUILD.bazel delete mode 100644 scorex/internal/templates/application/daal_app/BUILD.tmpl delete mode 100644 scorex/internal/templates/application/daal_app/MODULE.bazel.tmpl delete mode 100644 scorex/internal/templates/application/daal_app/point.bazelversion.tmpl delete mode 100644 scorex/internal/templates/application/daal_app/point.devcontainer/devcontainer.json.tmpl delete mode 100644 scorex/internal/templates/application/daal_app/point.devcontainer/prepare_workspace.sh.tmpl delete mode 100644 scorex/internal/templates/application/daal_app/src/BUILD.tmpl delete mode 100644 scorex/internal/templates/application/daal_app/src/hello_world_app.hpp.tmpl delete mode 100644 scorex/internal/templates/application/daal_app/src/main.cpp.tmpl delete mode 100644 scorex/internal/templates/application/feo_app/BUILD.tmpl delete mode 100644 scorex/internal/templates/application/feo_app/MODULE.bazel.tmpl delete mode 100644 scorex/internal/templates/application/feo_app/point.bazelrc.tmpl delete mode 100644 scorex/internal/templates/application/feo_app/point.bazelversion.tmpl delete mode 100644 scorex/internal/templates/application/feo_app/point.devcontainer/devcontainer.json.tmpl delete mode 100644 scorex/internal/templates/application/feo_app/point.devcontainer/prepare_workspace.sh.tmpl delete mode 100644 scorex/internal/templates/application/feo_app/src/hello_world.rs.tmpl delete mode 100644 scorex/internal/templates/fs.go delete mode 100644 scorex/internal/templates/module/BUILD.tmpl delete mode 100644 scorex/internal/templates/module/MODULE.bazel.tmpl delete mode 100644 scorex/internal/templates/module/point.bazelrc.tmpl delete mode 100644 scorex/internal/templates/module/point.bazelversion.tmpl delete mode 100644 scorex/internal/templates/module/point.devcontainer/devcontainer.json.tmpl delete mode 100644 scorex/internal/templates/module/point.devcontainer/prepare_workspace.sh.tmpl delete mode 100644 scorex/internal/templates/module/src/main.cpp.tmpl delete mode 100644 scorex/internal/utils/BUILD.bazel delete mode 100644 scorex/internal/utils/module_resolver.go delete mode 100644 scorex/internal/utils/skeleton_properties.go delete mode 100644 scorex/main.go delete mode 100644 src/BUILD delete mode 100644 src/assert_handler.cpp delete mode 100644 src/assert_handler.h delete mode 100644 src/datatype.cpp delete mode 100644 src/datatype.h delete mode 100644 src/etc/logging.json delete mode 100644 src/etc/mw_com_config.json delete mode 100644 src/main.cpp delete mode 100644 src/sample_sender_receiver.cpp delete mode 100644 src/sample_sender_receiver.h rename scorex/internal/templates/module/src/BUILD.tmpl => src_cpp/BUILD (81%) create mode 100644 src_cpp/main.cpp rename scorex/internal/templates/application/feo_app/src/BUILD.tmpl => src_rust/BUILD (55%) create mode 100644 src_rust/main.rs diff --git a/.bazelrc b/.bazelrc index acc86ba..0020f34 100644 --- a/.bazelrc +++ b/.bazelrc @@ -14,13 +14,18 @@ common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ common --registry=https://bcr.bazel.build +# Ferrocene must be the common compiler for HOST to ensure metadata +# compatibility for proc macro crates (same as score_baselibs_rust) +common --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0 +common --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu + +common --@score_baselibs//score/memory/shared/flags:use_typedshmd=False +common --@score_baselibs//score/mw/log/flags:KRemote_Logging=False + # Build stamping for version info build --workspace_status_command=$(pwd)/bazel_stamp_vars.sh -build:_common --@score_baselibs//score/mw/log/flags:KRemote_Logging=False build:_common --@score_baselibs//score/json:base_library=nlohmann -build:_common --@score_baselibs//score/memory/shared/flags:use_typedshmd=False -build:_common --@score_communication//score/mw/com/flags:tracing_library=stub build:_common --cxxopt=-Wno-error=mismatched-new-delete build:_common --cxxopt=-Wno-error=deprecated-declarations @@ -31,5 +36,6 @@ 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 +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 +build:x86_64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_pc_nto_qnx800 diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml deleted file mode 100644 index e9d4206..0000000 --- a/.github/workflows/build-cli.yml +++ /dev/null @@ -1,77 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* -name: Scrample Build CLI -on: - pull_request: - types: [opened, reopened, synchronize] - merge_group: - types: [checks_requested] -jobs: - gazelle-and-go-build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.9.0 - with: - bazelisk-cache: true - disk-cache: ${{ github.workflow }} - repository-cache: true - - - name: Run Gazelle - run: bazel run //:gazelle - - - name: Set version - id: version - run: | - # Get short commit SHA - SHORT_SHA=$(git rev-parse --short HEAD) - # Create version string - if [ "${{ github.event_name }}" == "pull_request" ]; then - VERSION="pr-${{ github.event.pull_request.number }}-${SHORT_SHA}" - else - VERSION="${SHORT_SHA}" - fi - echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - echo "Building version: ${VERSION}" - - - name: Build scorex for Linux (x86_64) - run: VERSION=${{ steps.version.outputs.VERSION }} bazel build //scorex:scorex_linux_amd64 - - - name: Copy Linux binary - run: | - mkdir -p artifacts - cp bazel-bin/scorex/scorex_linux_amd64_/scorex_linux_amd64 artifacts/scorex-linux-x86_64 - - - name: Build scorex for macOS (Apple Silicon) - run: VERSION=${{ steps.version.outputs.VERSION }} bazel build //scorex:scorex_darwin_arm64 - - - name: Copy macOS binary - run: cp bazel-bin/scorex/scorex_darwin_arm64_/scorex_darwin_arm64 artifacts/scorex-macos-arm64 - - - name: Build scorex for Windows (x86_64) - run: VERSION=${{ steps.version.outputs.VERSION }} bazel build //scorex:scorex_windows_amd64 - - - name: Copy Windows binary - run: cp bazel-bin/scorex/scorex_windows_amd64_/scorex_windows_amd64.exe artifacts/scorex-windows-x86_64.exe - - - name: Upload CLI artifacts - uses: actions/upload-artifact@v4 - with: - name: scorex-cli-${{ steps.version.outputs.VERSION }} - path: artifacts/ - if-no-files-found: error diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d457d61..7a9edb2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,18 +13,49 @@ name: Scrample Build on: - pull_request_target: + pull_request: types: [opened, reopened, synchronize] merge_group: types: [checks_requested] jobs: - qnx-build: + cpp-host-build: + uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 + permissions: + contents: read + pull-requests: read + with: + bazel-target: "build --config=host //src_cpp:scrample_cpp" + + cpp-qnx-build: + uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 + permissions: + contents: read + pull-requests: read + with: + bazel-target: "//src_cpp:scrample_cpp" + bazel-config: "x86_64-qnx" + credential-helper: ".github/tools/qnx_credential_helper.py" + environment-name: "workflow-approval" + secrets: + score-qnx-license: ${{ secrets.SCORE_QNX_LICENSE }} + score-qnx-user: ${{ secrets.SCORE_QNX_USER }} + score-qnx-password: ${{ secrets.SCORE_QNX_PASSWORD }} + + rust-host-build: + uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 + permissions: + contents: read + pull-requests: read + with: + bazel-target: "build --config=host //src_rust:scrample_rust" + + rust-qnx-build: uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 permissions: contents: read pull-requests: read with: - bazel-target: "//src:scrample" + bazel-target: "//src_rust:scrample_rust" bazel-config: "x86_64-qnx" credential-helper: ".github/tools/qnx_credential_helper.py" environment-name: "workflow-approval" diff --git a/.github/workflows/debug-qnx-helper.yml b/.github/workflows/debug-qnx-helper.yml deleted file mode 100644 index d71dcef..0000000 --- a/.github/workflows/debug-qnx-helper.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Debug QNX helper - -on: - workflow_dispatch: - -jobs: - debug-helper: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.2.2 - - - name: Check QNX secrets presence - env: - SCORE_QNX_LICENSE: ${{ secrets.SCORE_QNX_LICENSE }} - SCORE_QNX_USER: ${{ secrets.SCORE_QNX_USER }} - SCORE_QNX_PASSWORD: ${{ secrets.SCORE_QNX_PASSWORD }} - run: | - set -euo pipefail - for var in SCORE_QNX_LICENSE SCORE_QNX_USER SCORE_QNX_PASSWORD; do - if [ -z "${!var:-}" ]; then - echo "::error::$var is NOT set (or empty)" - else - echo "$var is set (non-empty)" - fi - done - - - name: Check connectivity to QNX endpoints - run: | - set -euo pipefail - echo "Testing www.qnx.com..." - curl -vI --max-time 15 https://www.qnx.com || echo "www.qnx.com failed" - - echo "Testing fusion.qnx.com..." - curl -vI --max-time 15 https://fusion.qnx.com || echo "fusion.qnx.com failed" - - - name: Run qnx_credential_helper.py directly - env: - SCORE_QNX_USER: ${{ secrets.SCORE_QNX_USER }} - SCORE_QNX_PASSWORD: ${{ secrets.SCORE_QNX_PASSWORD }} - run: | - set -euo pipefail - CRED_HELPER="${GITHUB_WORKSPACE}/.github/tools/qnx_credential_helper.py" - echo "Using helper at: ${CRED_HELPER}" - ls -l "${CRED_HELPER}" - - chmod +x "${CRED_HELPER}" - - PAYLOAD='{"uri": "https://fusion.qnx.com/8/79858/installation.tgz"}' - - echo "Running helper with timeout 30s..." - START=$(date +%s) - OUT="$(timeout 30s "${CRED_HELPER}" <<< "${PAYLOAD}")" || { - echo "::error::Helper failed or timed out (exit $?)" - exit 1 - } - END=$(date +%s) - echo "Helper finished, runtime: $((END-START))s, output length: ${#OUT}" diff --git a/.github/workflows/release_verification.yml b/.github/workflows/release_verification.yml index d6fd014..88d9326 100644 --- a/.github/workflows/release_verification.yml +++ b/.github/workflows/release_verification.yml @@ -11,45 +11,67 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -name: release verification for scrample (with host toolchain GCC12.2) +name: release verification for scrample on: push: tags: - - 'v*' # Triggers on version tags like v1.0.0 - - 'release-*' # Triggers on release tags like release-1.0.0 + - 'v*' + - 'release-*' permissions: contents: write jobs: - build_target: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4.2.2 - - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.9.1 - - name: Setup QNX License - env: - SCORE_QNX_LICENSE: ${{ secrets.SCORE_QNX_LICENSE }} - run: | - mkdir -p /opt/score_qnx/license - echo "${SCORE_QNX_LICENSE}" | base64 --decode > /opt/score_qnx/license/licenses - - name: Bazel build scrample with qnx toolchain - env: - 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 - - name: Cleanup QNX License - if: always() - run: rm -rf /opt/score_qnx + cpp-host-build: + uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 + permissions: + contents: read + pull-requests: read + with: + bazel-target: "build --config=host //src_cpp:scrample_cpp" + + cpp-qnx-build: + uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 + permissions: + contents: read + pull-requests: read + with: + bazel-target: "//src_cpp:scrample_cpp" + bazel-config: "x86_64-qnx" + credential-helper: ".github/tools/qnx_credential_helper.py" + environment-name: "workflow-approval" + secrets: + score-qnx-license: ${{ secrets.SCORE_QNX_LICENSE }} + score-qnx-user: ${{ secrets.SCORE_QNX_USER }} + score-qnx-password: ${{ secrets.SCORE_QNX_PASSWORD }} + + rust-host-build: + uses: eclipse-score/cicd-workflows/.github/workflows/tests.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 + permissions: + contents: read + pull-requests: read + with: + bazel-target: "build --config=host //src_rust:scrample_rust" + + rust-qnx-build: + uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0 + permissions: + contents: read + pull-requests: read + with: + bazel-target: "//src_rust:scrample_rust" + bazel-config: "x86_64-qnx" + credential-helper: ".github/tools/qnx_credential_helper.py" + environment-name: "workflow-approval" + secrets: + score-qnx-license: ${{ secrets.SCORE_QNX_LICENSE }} + score-qnx-user: ${{ secrets.SCORE_QNX_USER }} + score-qnx-password: ${{ secrets.SCORE_QNX_PASSWORD }} release_verification: runs-on: ubuntu-latest - needs: [build_target] - if: always() && (needs.build_target.result == 'failure') + needs: [cpp-host-build, cpp-qnx-build, rust-host-build, rust-qnx-build] + if: always() && contains(needs.*.result, 'failure') steps: - name: Remove release and tag (if exists) uses: nikhilbadyal/ghaction-rm-releases@v0.7.0 diff --git a/BUILD b/BUILD index 9b5e377..b4ceaee 100644 --- a/BUILD +++ b/BUILD @@ -11,13 +11,10 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -load("@bazel_gazelle//:def.bzl", "gazelle") load("@score_docs_as_code//:docs.bzl", "docs") load("@score_tooling//:defs.bzl", "copyright_checker", "dash_license_checker", "setup_starpls", "use_format_targets") load("//:project_config.bzl", "PROJECT_CONFIG") -gazelle(name = "gazelle") - setup_starpls( name = "starpls_server", visibility = ["//visibility:public"], @@ -26,9 +23,7 @@ setup_starpls( copyright_checker( name = "copyright", srcs = [ - "feo/ad-demo", - "scorex", - "src", + "src_cpp", "tests", "//:BUILD", "//:MODULE.bazel", diff --git a/MODULE.bazel b/MODULE.bazel index 1323a4c..2297707 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -27,19 +27,35 @@ 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", +# C++ and QNX toolchains (same setup as score_baselibs / score_baselibs_rust) +bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.5.1", 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_qcc_x86_64_toolchain", + sdp_version = "8.0.0", + target_cpu = "x86_64", + target_os = "qnx", + use_default_package = True, + version = "12.2.0", +) +use_repo( + gcc, + "score_gcc_x86_64_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") +# Ferrocene Rust toolchains (QNX cross-compilation support) +# score_toolchains_rust already declares ferrocene_x86_64_pc_nto_qnx800 internally; +# the toolchain alias is accessible at @score_toolchains_rust//toolchains/ferrocene:... +bazel_dep(name = "score_toolchains_rust", version = "0.9.1", dev_dependency = True) # Add GoogleTest dependency bazel_dep(name = "googletest", version = "1.17.0") @@ -48,41 +64,34 @@ bazel_dep(name = "googletest", version = "1.17.0") 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") -archive_override( - module_name = "rules_boost", - strip_prefix = "rules_boost-master", - urls = ["https://github.com/nelhage/rules_boost/archive/refs/heads/master.tar.gz"], +rust.toolchain( + edition = "2021", + versions = ["1.90.0"], ) -bazel_dep(name = "boost.program_options", version = "1.87.0") - # C/C++ rules for Bazel bazel_dep(name = "rules_cc", version = "0.2.1") # tooling -bazel_dep(name = "score_tooling", version = "1.0.5") +bazel_dep(name = "score_tooling", version = "1.1.2") bazel_dep(name = "score_rust_policies", version = "0.0.3") bazel_dep(name = "aspect_rules_lint", version = "1.5.3") 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") -git_override( - module_name = "score_logging", - commit = "9ed6a88cab10a81bf6b0813712cbd7b9fc7e44c5", - remote = "https://github.com/eclipse-score/logging.git", +bazel_dep(name = "score_docs_as_code", version = "4.0.3") +single_version_override( + module_name = "score_docs_as_code", + version = "4.0.3", ) +bazel_dep(name = "score_process", version = "1.5.4") +bazel_dep(name = "platforms", version = "1.0.0") +bazel_dep(name = "score_bazel_platforms", version = "0.1.2") +bazel_dep(name = "score_baselibs", version = "0.2.7") +bazel_dep(name = "score_baselibs_rust", version = "0.1.2") +bazel_dep(name = "score_logging", version = "0.2.1") + # TRLC dependency for requirements traceability bazel_dep(name = "trlc", version = "0.0.0") git_override( @@ -90,77 +99,3 @@ git_override( commit = "ede35c4411d41abe42b8f19e78f8989ff79ad3d8", remote = "https://github.com/bmw-software-engineering/trlc.git", ) - -bazel_dep(name = "rules_go", version = "0.59.0") -bazel_dep(name = "gazelle", version = "0.42.0", repo_name = "bazel_gazelle") - -go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk", dev_dependency = True) -go_sdk.download( - name = "go_sdk", - version = "1.23.5", -) -go_sdk.download( - name = "go_linux_amd64", - goarch = "amd64", - goos = "linux", - version = "1.23.5", -) -go_sdk.download( - name = "go_darwin_arm64", - goarch = "arm64", - goos = "darwin", - version = "1.23.5", -) -go_sdk.download( - name = "go_windows_amd64", - goarch = "amd64", - goos = "windows", - version = "1.23.5", -) -go_sdk.download( - name = "go_darwin_amd64", - goarch = "amd64", - goos = "darwin", - version = "1.23.5", -) - -go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") -go_deps.from_file(go_mod = "//scorex:go.mod") -use_repo( - go_deps, - "com_github_spf13_cobra", -) - -#### Following section for Feo framework examples ### -bazel_dep(name = "score_crates", version = "0.0.6") - -crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") -crate.from_cargo( - name = "ad-demo-local-crates", - cargo_lockfile = "//feo/ad-demo:Cargo.lock", - manifests = [ - "//feo/ad-demo:Cargo.toml", - ], -) -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 = "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( - hub_name = "lichtblick_com_pypi", - python_version = "3.12", - requirements_lock = "//feo/ad-demo/lichtblick-com:requirements_lock.txt", -) -use_repo(pip, "lichtblick_com_pypi") diff --git a/README.md b/README.md index 847f380..080aa22 100644 --- a/README.md +++ b/README.md @@ -3,158 +3,113 @@ [![Build Status](https://github.com/eclipse-score/scrample/actions/workflows/build.yml/badge.svg)](https://github.com/eclipse-score/scrample/actions/workflows/build.yml) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -**SCRAMPLE** (S-CORE + Sample) is a demonstration application showcasing the inter-process communication (IPC) capabilities of the [Eclipse S-CORE](https://projects.eclipse.org/projects/automotive.score) platform for Software Defined Vehicles (SDVs). +**SCRAMPLE** (S-CORE + Sample) is a demonstration application showcasing the logging capabilities of the [Eclipse S-CORE](https://projects.eclipse.org/projects/automotive.score) platform for Software Defined Vehicles (SDVs). ## Overview -This application demonstrates a producer-consumer pattern using S-CORE's middleware communication layer. It illustrates: - -- **Event-based communication** using the S-CORE middleware (`score::mw::com`) -- **Shared memory IPC** for high-performance data transfer between processes -- **Type-safe serialization** of complex automotive data structures -- **Skeleton-Proxy pattern** following AUTOSAR Adaptive Platform concepts - -The sample exchanges `MapApiLanesStamped` messages containing lane information data structures, simulating real-world automotive HD map data exchange scenarios. - -## Architecture - -SCRAMPLE consists of two operational modes: - -### Skeleton (Publisher/Server) -- Offers a service instance identified by `score/MapApiLanesStamped` -- Generates and publishes lane data samples at a configurable cycle rate -- Populates complex nested data structures with randomized values -- Computes hash values for data integrity verification - -### Proxy (Subscriber/Client) -- Discovers and connects to the skeleton service -- Subscribes to receive lane data events -- Validates received samples for ordering and data integrity -- Supports both event-driven callbacks and polling modes +SCRAMPLE provides two minimal "Hello World" applications — one in C++ and one in Rust — that both use the S-CORE `mw::log` logging library. They share a common logging configuration and produce identical output, demonstrating how to integrate `mw::log` in both languages. ## Prerequisites - **Bazel** 8.3.0 or higher (see `.bazelversion`) - **QNX SDP** (for cross-compilation to QNX targets) - **C++17** compatible compiler -- **Rust toolchain** (automatically managed by Bazel for Rust tests) +- **Rust toolchain** (automatically managed by Bazel via Ferrocene) - **Dependencies** (automatically managed via Bazel): - S-CORE Base Libraries (`score_baselibs`) - - S-CORE Communication (`score_communication`) - - Boost.Program_Options - - GoogleTest (for C++ tests) - - Rust toolchain (for Rust tests) + - S-CORE Logging (`score_logging`) + - S-CORE Base Libraries Rust (`score_baselibs_rust`) -## Building +## Toolchains -### Standard Build (Host Platform) -```bash -bazel build --config=host //src:scrample -``` +SCRAMPLE uses the same toolchain setup as the other S-CORE modules. -### QNX Cross-Compilation -```bash -bazel build --config=x86_64-qnx //src:scrample -``` +### C++ Toolchains -### Build All Tests -```bash -bazel test --config=host //tests/... -``` +Toolchains are provided by [`score_bazel_cpp_toolchains`](https://github.com/eclipse-score/bazel_cpp_toolchains) via the `gcc` Bzlmod extension: -**Note:** Always use a build configuration (`--config=host` or `--config=x86_64-qnx`) to ensure proper dependency settings. +| Toolchain | Target | Used for | +|---|---|---| +| `score_gcc_x86_64_toolchain` | x86_64 Linux (GCC 12.2.0) | `--config=host` builds | +| `score_qcc_x86_64_toolchain` | x86_64 QNX SDP 8.0.0 | `--config=x86_64-qnx` builds | -## Running +### Rust Toolchains + +Rust toolchains are provided by [`score_toolchains_rust`](https://github.com/eclipse-score/toolchains_rust), which bundles pre-built [Ferrocene](https://ferrous-systems.com/ferrocene/) toolchains: + +| Toolchain | Target | Used for | +|---|---|---| +| `ferrocene_x86_64_unknown_linux_gnu` | x86_64 Linux | Host builds + proc macro compilation | +| `ferrocene_x86_64_pc_nto_qnx800` | x86_64 QNX Neutrino 8.0.0 | `--config=x86_64-qnx` Rust builds | -After building with `--config=host`, the binary will be in `bazel-bin/src/scrample`. +The Ferrocene Linux toolchain is registered as a `common` toolchain so that proc macro crates (compiled on the host) and QNX target crates share the same compiler metadata format, which is required for cross-compilation compatibility. -### Quick Start (Two Terminals) +### Key `.bazelrc` Flags -To see the IPC communication in action, open two terminals: +| Flag | Purpose | +|---|---| +| `--@score_baselibs//score/memory/shared/flags:use_typedshmd=False` | Disables proprietary Shared Memory Data Router (not available in public CI) | +| `--@score_baselibs//score/mw/log/flags:KRemote_Logging=False` | Disables remote logging backend (not needed for this demo) | -**Terminal 1 - Start Skeleton (Publisher):** +## Building + +### Build the C++ app ```bash -./bazel-bin/src/scrample \ - --mode skeleton \ - --cycle-time 1000 \ - --num-cycles 10 \ - --service_instance_manifest src/etc/mw_com_config.json +bazel build --config=host //src_cpp:scrample_cpp ``` -**Terminal 2 - Start Proxy (Subscriber):** +### Build the Rust app ```bash -./bazel-bin/src/scrample \ - --mode proxy \ - --cycle-time 500 \ - --num-cycles 20 \ - --service_instance_manifest src/etc/mw_com_config.json +bazel build --config=host //src_rust:scrample_rust ``` -You should see the proxy discover the skeleton service, subscribe, and receive `MapApiLanesStamped` samples. The proxy validates data integrity and ordering for each received sample. - -### Start Skeleton (Publisher) +### Build both apps ```bash -./bazel-bin/src/scrample \ - --mode skeleton \ - --cycle-time 1000 \ - --num-cycles 10 \ - --service_instance_manifest src/etc/mw_com_config.json +bazel build --config=host //src_cpp:scrample_cpp //src_rust:scrample_rust ``` -### Start Proxy (Subscriber) +### QNX Cross-Compilation ```bash -./bazel-bin/src/scrample \ - --mode proxy \ - --cycle-time 500 \ - --num-cycles 20 \ - --service_instance_manifest src/etc/mw_com_config.json +bazel build --config=x86_64-qnx //src_cpp:scrample_cpp +bazel build --config=x86_64-qnx //src_rust:scrample_rust ``` -### Command-Line Options +**Note:** Always use a build configuration (`--config=host` or `--config=x86_64-qnx`) to ensure proper dependency settings. -| Option | Description | Required | -|--------|-------------|----------| -| `--mode, -m` | Operation mode: `skeleton`/`send` or `proxy`/`recv` | Yes | -| `--cycle-time, -t` | Cycle time in milliseconds for sending/polling | Yes | -| `--num-cycles, -n` | Number of cycles to execute (0 = infinite) | Yes | -| `--service_instance_manifest, -s` | Path to communication config JSON | Optional | -| `--disable-hash-check, -d` | Skip sample hash validation in proxy mode | Optional | +## Running -## Configuration +After building with `--config=host`: -The communication behavior is configured via `src/etc/mw_com_config.json`: +### C++ app +```bash +./bazel-bin/src_cpp/scrample_cpp +``` -- Service type definitions and bindings -- Event definitions with IDs -- Instance-specific configuration (shared memory settings, subscriber limits) -- ASIL level and process ID restrictions +### Rust app +```bash +./bazel-bin/src_rust/scrample_rust +``` + +Both apps produce the same log output to the console: +``` +2026/05/22 12:00:00.0000000 00000000 000 ECU1 SCRM scra log info verbose 1 Hello from SCRAMPLE! +``` ## Project Structure ``` scrample/ -├── src/ -│ ├── main.cpp # Entry point and CLI argument parsing -│ ├── sample_sender_receiver.cpp # Core skeleton/proxy logic -│ ├── datatype.h # Data type definitions -│ ├── assert_handler.cpp # Custom assertion handling -│ └── etc/ -│ ├── mw_com_config.json # Communication configuration -│ └── logging.json # Logging configuration -├── tests/ -│ ├── cpp/ # C++ unit tests (GoogleTest) -│ └── rust/ # Rust tests -├── scorex/ # CLI tool for generating S-CORE projects -│ ├── main.go # Entry point -│ ├── cmd/ # Cobra CLI commands -│ ├── internal/ # Internal packages -│ └── README.md # scorex documentation -├── docs/ # Sphinx documentation -└── BUILD # Bazel build definitions +├── src_cpp/ +│ ├── main.cpp # C++ app using score::mw::log +│ └── BUILD +├── src_rust/ +│ ├── main.rs # Rust app using score_log + score_log_bridge +│ └── BUILD +├── config/ +│ └── logging.json # Shared logging configuration (console, kInfo) +└── BUILD # Bazel build definitions ``` -**For information about the scorex CLI tool, see [scorex/README.md](scorex/README.md).** - ## Development ### Code Formatting @@ -175,30 +130,7 @@ Verify copyright headers are present: bazel run //:copyright.check ``` -### Build Documentation -Build Sphinx documentation: -```bash -bazel build //:docs -``` - -**Note:** Formatting and documentation commands don't require `--config` flags. - -## Testing - -The project includes example tests demonstrating the testing infrastructure: - -- **C++ Tests**: GoogleTest-based unit tests in `tests/cpp/` -- **Rust Tests**: Rust test framework in `tests/rust/` - -Run all tests: -```bash -bazel test --config=host //tests/... -``` - -Run all tests and format checks: -```bash -bazel test --config=host //tests/... //:format.check -``` +**Note:** Formatting commands don't require `--config` flags. ## Contributing @@ -251,12 +183,13 @@ QNX cross-compilation requires: - QNX SDP installation and license - Proper credential setup (see `.github/workflows/build.yml` for CI example) +The required `score_baselibs` feature flags (`use_typedshmd=False`, `KRemote_Logging=False`) are already configured in `.bazelrc` and apply automatically. + ## Roadmap Future extensions planned for SCRAMPLE: - Additional S-CORE platform module demonstrations - - [FEO demo application](feo/ad-demo/README.md) - More complex communication patterns - Performance benchmarking utilities - Integration with other S-CORE components diff --git a/scorex/internal/templates/application/daal_app/point.bazelrc.tmpl b/config/BUILD old mode 100755 new mode 100644 similarity index 71% rename from scorex/internal/templates/application/daal_app/point.bazelrc.tmpl rename to config/BUILD index f693141..bb99b2c --- a/scorex/internal/templates/application/daal_app/point.bazelrc.tmpl +++ b/config/BUILD @@ -1,15 +1,13 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* - -common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ -common --registry=https://bcr.bazel.build +# ******************************************************************************* +# Copyright (c) 2026 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(["logging.json"]) diff --git a/config/logging.json b/config/logging.json new file mode 100644 index 0000000..9b4394b --- /dev/null +++ b/config/logging.json @@ -0,0 +1,7 @@ +{ + "appId": "SCRM", + "appDesc": "SCRAMPLE Rust App", + "logMode": "kConsole", + "logLevel": "kVerbose", + "logLevelThresholdConsole": "kInfo" +} diff --git a/docs/scrample/index.rst b/docs/scrample/index.rst index 3c392cd..2917cad 100644 --- a/docs/scrample/index.rst +++ b/docs/scrample/index.rst @@ -15,4 +15,105 @@ Scrample example ============================= -Welcome to scrample application! \ No newline at end of file +Welcome to the SCRAMPLE application! + +Overview +-------- + +**SCRAMPLE** (S-CORE + Sample) is a minimal demonstration application for the +`Eclipse S-CORE `_ platform. +It provides two equivalent "Hello World" apps — one written in **C++** and one in **Rust** — +that both use the S-CORE ``mw::log`` logging library to emit a single log message to the console. + +The goal of SCRAMPLE is to show how to set up a minimal Bazel workspace that integrates +S-CORE dependencies and produces a working logging application in either language. + +Applications +------------ + +C++ application (``//src_cpp:scrample_cpp``) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The C++ app uses the ``score::mw::log`` API from ``@score_logging//score/mw/log``. +It locates the shared logging configuration at runtime via the ``MW_LOG_CONFIG_FILE`` +environment variable, resolved from Bazel runfiles: + +.. code-block:: cpp + + #include "score/mw/log/logging.h" + + int main() + { + // logging configuration is loaded from config/logging.json via MW_LOG_CONFIG_FILE + score::mw::log::LogInfo("scrample") << "Hello from SCRAMPLE!"; + return 0; + } + +Rust application (``//src_rust:scrample_rust``) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Rust app uses the ``score_log`` crate together with the ``score_log_bridge`` crate, +which bridges the Rust logging facade to the underlying ``mw::log`` C++ backend. +The path to the shared logging configuration is resolved from Bazel runfiles at startup: + +.. code-block:: rust + + use score_log::info; + use score_log_bridge::ScoreLogBridgeBuilder; + + fn main() { + // logging configuration is loaded from config/logging.json via runfiles + ScoreLogBridgeBuilder::new() + .context("scrample") + .config(config_path) + .set_as_default_logger(); + info!("Hello from SCRAMPLE!"); + } + +Shared Logging Configuration +----------------------------- + +Both apps share the same ``config/logging.json`` file, which configures ``mw::log`` +to write to the console at ``kInfo`` level or above: + +.. code-block:: json + + { + "appId": "SCRM", + "appDesc": "SCRAMPLE App", + "logMode": "kConsole", + "logLevel": "kVerbose", + "logLevelThresholdConsole": "kInfo" + } + +Building +-------- + +Build both apps for the host platform: + +.. code-block:: bash + + bazel build --config=host //src_cpp:scrample_cpp //src_rust:scrample_rust + +Cross-compile for QNX: + +.. code-block:: bash + + bazel build --config=x86_64-qnx //src_cpp:scrample_cpp + bazel build --config=x86_64-qnx //src_rust:scrample_rust + +Running +------- + +After a successful host build, run either app directly: + +.. code-block:: bash + + ./bazel-bin/src_cpp/scrample_cpp + ./bazel-bin/src_rust/scrample_rust + +Both produce output in the following format: + +.. code-block:: text + + 2026/05/22 12:00:00.0000000 00000000 000 ECU1 SCRM scra log info verbose 1 Hello from SCRAMPLE! \ No newline at end of file diff --git a/feo/ad-demo/BUILD.bazel b/feo/ad-demo/BUILD.bazel deleted file mode 100644 index b2e4d07..0000000 --- a/feo/ad-demo/BUILD.bazel +++ /dev/null @@ -1,84 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_binary", "rust_library") - -rust_library( - name = "activities_lib", - srcs = [ - "src/activities/application_config.rs", - "src/activities/camera_activity.rs", - "src/activities/common.rs", - "src/activities/mcap_activity.rs", - "src/activities/messages.rs", - "src/activities/mod.rs", - "src/activities/render_activity.rs", - "src/lib.rs", - ], - crate_features = [ - "com_iox2", - "signalling_relayed_tcp", - ], - crate_name = "ad_demo", - data = ["src/assets/gps_route.mcap"], - visibility = ["//visibility:public"], - deps = [ - "@ad-demo-local-crates//:camino", - "@ad-demo-local-crates//:mcap", - "@ad-demo-local-crates//:memmap2", - "@feo//feo:libfeo_rust", - "@feo//feo-com:libfeo_com_rust", - "@feo//feo-log:libfeo_log_rust", - "@feo//feo-logger:libfeo_logger_rust", - "@feo//feo-time:libfeo_time_rust", - "@feo//feo-tracing:libfeo_tracing_rust", - "@score_crates//:anyhow", - "@score_crates//:postcard", - "@score_crates//:rand", - "@score_crates//:serde", - "@score_crates//:serde_json", - "@score_crates//:tracing", - ], -) - -rust_binary( - name = "agent_primary", - srcs = [ - "src/agents/primary.rs", - ], - visibility = ["//visibility:public"], - deps = [ - ":activities_lib", - "@feo//feo:libfeo_rust", - "@feo//feo-log:libfeo_log_rust", - "@feo//feo-logger:libfeo_logger_rust", - "@feo//feo-time:libfeo_time_rust", - "@feo//feo-tracing:libfeo_tracing_rust", - ], -) - -rust_binary( - name = "agent_secondary", - srcs = [ - "src/agents/secondary.rs", - ], - visibility = ["//visibility:public"], - deps = [ - ":activities_lib", - "@feo//feo:libfeo_rust", - "@feo//feo-log:libfeo_log_rust", - "@feo//feo-logger:libfeo_logger_rust", - "@feo//feo-time:libfeo_time_rust", - "@feo//feo-tracing:libfeo_tracing_rust", - ], -) diff --git a/feo/ad-demo/Cargo.lock b/feo/ad-demo/Cargo.lock deleted file mode 100644 index 03024ba..0000000 --- a/feo/ad-demo/Cargo.lock +++ /dev/null @@ -1,415 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "ad-demo-local-crates" -version = "0.0.1" -dependencies = [ - "camino", - "mcap", - "memmap2", -] - -[[package]] -name = "array-init" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" - -[[package]] -name = "bimap" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" - -[[package]] -name = "binrw" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8318fda24dc135cdd838f57a2b5ccb6e8f04ff6b6c65528c4bd9b5fcdc5cf6" -dependencies = [ - "array-init", - "binrw_derive", - "bytemuck", -] - -[[package]] -name = "binrw_derive" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db0832bed83248115532dfb25af54fae1c83d67a2e4e3e2f591c13062e372e7e" -dependencies = [ - "either", - "owo-colors", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "bytemuck" -version = "1.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "camino" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609" - -[[package]] -name = "cc" -version = "1.2.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" -dependencies = [ - "find-msvc-tools", - "jobserver", - "libc", - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" - -[[package]] -name = "crc32fast" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "darling" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "syn 2.0.110", -] - -[[package]] -name = "darling_macro" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.110", -] - -[[package]] -name = "either" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" - -[[package]] -name = "enumset" -version = "1.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b07a8dfbbbfc0064c0a6bdf9edcf966de6b1c33ce344bdeca3b41615452634" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43e744e4ea338060faee68ed933e46e722fb7f3617e722a5772d7e856d8b3ce" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.110", -] - -[[package]] -name = "find-msvc-tools" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasip2", -] - -[[package]] -name = "hermit-abi" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "jobserver" -version = "0.1.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" -dependencies = [ - "getrandom", - "libc", -] - -[[package]] -name = "libc" -version = "0.2.177" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" - -[[package]] -name = "log" -version = "0.4.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" - -[[package]] -name = "lz4" -version = "1.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20b523e860d03443e98350ceaac5e71c6ba89aea7d960769ec3ce37f4de5af4" -dependencies = [ - "lz4-sys", -] - -[[package]] -name = "lz4-sys" -version = "1.11.1+lz4-1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "mcap" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3ca583fed649ed7cd8c976b59422996472c6b08067308443e0b60c56e0a4ca" -dependencies = [ - "bimap", - "binrw", - "byteorder", - "crc32fast", - "enumset", - "log", - "lz4", - "num_cpus", - "paste", - "static_assertions", - "thiserror", - "zstd", -] - -[[package]] -name = "memmap2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744133e4a0e0a658e1374cf3bf8e415c4052a15a111acd372764c55b4177d490" -dependencies = [ - "libc", -] - -[[package]] -name = "num_cpus" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "pkg-config" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - -[[package]] -name = "proc-macro2" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.110" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.110", -] - -[[package]] -name = "unicode-ident" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" - -[[package]] -name = "wasip2" -version = "1.0.1+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" -dependencies = [ - "wit-bindgen", -] - -[[package]] -name = "wit-bindgen" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" - -[[package]] -name = "zstd" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "7.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" -dependencies = [ - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.16+zstd.1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/feo/ad-demo/Cargo.toml b/feo/ad-demo/Cargo.toml deleted file mode 100644 index b1125d3..0000000 --- a/feo/ad-demo/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "ad-demo-local-crates" -version = "0.0.1" -edition = "2024" - -[dependencies] -# crate dependencies specific to ad-demo and not available in @score_crates -mcap = "0.23.4" -camino = "1.2.1" -memmap2 = "0.9.9" diff --git a/feo/ad-demo/README.md b/feo/ad-demo/README.md deleted file mode 100644 index 36f6fd3..0000000 --- a/feo/ad-demo/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# AD (Autonomous Driving) Demo using FEO Framework - -### Activities overview in ad-demo FEO (Fixed Execution Order) application -This [FEO](https://eclipse-score.github.io/score/main/features/frameworks/feo/index.html#) application contains three activities to demonstrate activity and topic creation, define their dependencies and how they communicate: -1. **Camera** - Simulates a camera sensor generating person detection data with fake object count, car count, obstacle distance and outputs as **CameraImage** topic message. -2. **SceneRender** - This activity simulates processing of camera images and extracting fake lane distance information to create enhanced scene data on top of Camera data. This activity commuincates with Camera activity to receive CameraImage topic and outputs **Scene** topic message. -3. **Mcap** - This activity reads GPS route data from an MCAP file and publishes to a TCP server for visualization in Lichtblick via Foxglove WebSocket Server. This activity is standalone and neither does commuincate with any other activity nor outputs any message. -This application tries to demostrate the basic usage of FEO framework. - -### First time setup -1. Follow the steps mentioned here: https://code.visualstudio.com/docs/languages/rust - 1. It gives all the required steps to get started with rust on linux - 1. Install [rustup](https://www.rust-lang.org/tools/install) in your system - 1. These are the set of available [components](https://rust-lang.github.io/rustup/concepts/components.html) once you install rustup in your system: - 1. Install [rust analyzer extension](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) for Rust lint and debug and support -1. So that rust analyzer works with the rust intelligence since you have a bazel project with minimal cargo.toml. You need to have a `rust_project.json` so that your rust code intelligence works properly. Run the following, from project root, to generate it: - 1. `bazelisk run @rules_rust//tools/rust_analyzer:gen_rust_project -- //feo/ad-demo/...` - 1. _Tip_ : Run it every time you would update the project or reorganize it. - -### Running ad-demo application -1. Run **agent_primary** (one terminal) : - 1. `bazelisk run //feo/ad-demo:agent_primary 2000` - 1. The FEO application cycles every 2000 milliseconds. - 1. This will run the Camera and Environment Renderer activity -2. Run **agent_secondary** (another terminal) : - 1. `bazelisk run //feo/ad-demo:agent_secondary` - 1. This will run Mcap activity - 1. Now, you can see in the logs the interaction between Camera and SceneRender activity, whereas MCap activity is independent to any of them. - 1. Camera and SceneRender logs are visible in previous terminal whereas MCap logs are visible in this terminal. -3. Run [foxglove websocket server script (in yet another terminal)](lichtblick-com/README.md). - 1. `bazelisk run //feo/ad-demo/lichtblick-com:foxglove_ws_server` - 1. Pleae check out the [Readme](lichtblick-com/README.md) for your first run. -1. Now open [Lichtblick](https://github.com/Lichtblick-Suite/lichtblick/releases) and - 1. Go to "Open connection" → "Foxglove WebSocket" - 1. Enter: `ws://localhost:8765` - 1. usually this is default and already exists - 1. if hosted on remote machine Enter: `ws://:8765` - 1. Now open [map panel](https://lichtblick-suite.github.io/docs/docs/visualization/message-schemas/location-fix) and listen to topic name **/gps/fix**. - 1. you can also open [raw message panel](https://lichtblick-suite.github.io/docs/docs/visualization/panels/raw-messages-panel) and listen to topic name **/gps/fix** - to see the lat long. - 1. **You should be able to see that the location (latitude, longitude) message from Mcap activity in FEO application is visible in map panel coming via foxglove webserver.** diff --git a/feo/ad-demo/lichtblick-com/BUILD.bazel b/feo/ad-demo/lichtblick-com/BUILD.bazel deleted file mode 100644 index 14a1f76..0000000 --- a/feo/ad-demo/lichtblick-com/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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("@lichtblick_com_pypi//:requirements.bzl", "requirement") -load("@rules_python//python:defs.bzl", "py_binary") -load("@rules_python//python:pip.bzl", "compile_pip_requirements") - -compile_pip_requirements( - name = "requirements", - requirements_in = "requirements.in", - requirements_txt = "requirements_lock.txt", -) - -py_binary( - name = "foxglove_ws_server", - srcs = ["foxglove_ws_server.py"], - main = "foxglove_ws_server.py", - visibility = ["//visibility:public"], - deps = [ - requirement("foxglove_websocket"), - ], -) diff --git a/feo/ad-demo/lichtblick-com/README.md b/feo/ad-demo/lichtblick-com/README.md deleted file mode 100644 index 6156481..0000000 --- a/feo/ad-demo/lichtblick-com/README.md +++ /dev/null @@ -1,14 +0,0 @@ -### Steps to run the foxglove websocket server script -1. **For first run only**: - 1. `bazelisk run //feo/ad-demo/lichtblick-com:requirements.update` - 1. It will use [requirements file](requirements.in) to create [requirements lock file](requirements_lock.txt) to install required packages in the pip environment. - 1. you can always test if the requirements are up to date for your copy - 1. `bazelisk test //feo/ad-demo/lichtblick-com:requirements_test` -1. **In one terminal**: run the FoxGloveServer & TCP server on localhost - 1. `bazelisk run //feo/ad-demo/lichtblick-com:foxglove_ws_server` - 1. By default this runs the web socket server and tcp server on localhost - 1. To run the server on some other machine or remote host, use the ip of the remote machine: - 1. `bazelisk run //feo/ad-demo/lichtblick-com:foxglove_ws_server ` - 1. This will run the python binary target (the servers) on a bazel environment which isolates it from the sytem - similar to python virtual environment. -1. **In other terminals**: [Start the primary and secondary agents in other terminals to run the FEO application](../README.md#running). - 1. This message will then be forwarded via the foxglove web socket server to lichtblick with topic name **/gps/fix** in the **messaging schema format [locationfix](https://lichtblick-suite.github.io/docs/docs/visualization/message-schemas/location-fix)**. diff --git a/feo/ad-demo/lichtblick-com/foxglove_ws_server.py b/feo/ad-demo/lichtblick-com/foxglove_ws_server.py deleted file mode 100644 index edbe421..0000000 --- a/feo/ad-demo/lichtblick-com/foxglove_ws_server.py +++ /dev/null @@ -1,154 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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 -# ******************************************************************************* -import asyncio -import json -import time -import argparse -from foxglove_websocket import run_cancellable -from foxglove_websocket.server import FoxgloveServer, FoxgloveServerListener -from foxglove_websocket.types import ChannelId - -LOCALHOST = "127.0.0.1" -TCP_PORT = 9001 - -""" -TCP listener that receives Json messages and forwards them to Foxglove channel -""" - - -async def tcp_listener(foxglove_server: FoxgloveServer, channel_id: ChannelId): - async def handle_client(reader, writer): - address = writer.get_extra_info("peername") - print(f"TCP connection opened at : {address}") - - try: - while True: - data = await reader.readline() - if not data: - break - - tcp_message = data.decode("utf-8").strip() - if tcp_message: - message_fxg = json.loads(tcp_message) - # covariance to just make location more visible in Lichtblick - message_fxg.update( - { - "position_covariance": [ - 700, - 0.0, - 0.0, - 0.0, - 700, - 0.0, - 0.0, - 0.0, - 700, - ], - "position_covariance_type": 2, - }, - ) - - print(f"Received TCP message: {message_fxg}") - - await foxglove_server.send_message( - channel_id, - time.time_ns(), - json.dumps(message_fxg).encode("utf8"), - ) - except Exception as e: - print(f"Error in TCP client: {e}") - finally: - writer.close() - await writer.wait_closed() - print(f"TCP connection closed at : {address}") - - tcp_server = await asyncio.start_server(handle_client, LOCALHOST, TCP_PORT) - - tcp_address = tcp_server.sockets[0].getsockname() - print(f"TCP server listening on {tcp_address}") - - async with tcp_server: - await tcp_server.serve_forever() - - -""" -Main function to start Foxglove server and TCP listener -""" - - -async def main(host): - class Listener(FoxgloveServerListener): - async def on_subscribe(self, server: FoxgloveServer, channel_id: ChannelId): - print("First client subscribed to", channel_id) - - async def on_unsubscribe(self, server: FoxgloveServer, channel_id: ChannelId): - print("Last client unsubscribed from", channel_id) - - async with FoxgloveServer( - host, - 8765, - "foxglove server", - supported_encodings=["json"], - ) as server: - server.set_listener(Listener()) - channel_id = await server.add_channel( - { - "topic": "/gps/fix", - "encoding": "json", - "schemaName": "foxglove.LocationFix", - "schema": json.dumps( - { - "type": "object", - "properties": { - "altitude": {"type": "number"}, - "latitude": {"type": "number"}, - "longitude": {"type": "number"}, - "position_covariance": { - "type": "array", - "items": {"type": "number"}, - "minItems": 9, - "maxItems": 9, - }, - "position_covariance_type": {"type": "integer"}, - }, - "required": ["latitude", "longitude"], - } - ), - "schemaEncoding": "jsonschema", - } - ) - - tcp_task = asyncio.create_task(tcp_listener(server, channel_id)) - - try: - await asyncio.Event().wait() - finally: - tcp_task.cancel() - try: - await tcp_task - except asyncio.CancelledError: - pass - print("TCP server closed.") - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument( - "host", - type=str, - nargs="?", - default=LOCALHOST, - help="Host the server in this machine. If not provided, defaults to localhost", - ) - args = parser.parse_args() - run_cancellable(main(args.host)) diff --git a/feo/ad-demo/lichtblick-com/requirements.in b/feo/ad-demo/lichtblick-com/requirements.in deleted file mode 100644 index ff2df4f..0000000 --- a/feo/ad-demo/lichtblick-com/requirements.in +++ /dev/null @@ -1 +0,0 @@ -foxglove-websocket>=0.1.4 diff --git a/feo/ad-demo/lichtblick-com/requirements_lock.txt b/feo/ad-demo/lichtblick-com/requirements_lock.txt deleted file mode 100644 index 0ef8c73..0000000 --- a/feo/ad-demo/lichtblick-com/requirements_lock.txt +++ /dev/null @@ -1,81 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# bazel run //feo/ad-demo/lichtblick-com:requirements.update -# -foxglove-websocket==0.1.4 \ - --hash=sha256:2ec8936982e478d103dd90268a572599fc0cce45a4ab95490d5bc31f7c8a8af8 \ - --hash=sha256:772e24e2c98bdfc704df53f7177c8ff5bab0abc4dac59a91463aca16debdd83a - # via -r feo/ad-demo/lichtblick-com/requirements.in -websockets==15.0.1 \ - --hash=sha256:0701bc3cfcb9164d04a14b149fd74be7347a530ad3bbf15ab2c678a2cd3dd9a2 \ - --hash=sha256:0a34631031a8f05657e8e90903e656959234f3a04552259458aac0b0f9ae6fd9 \ - --hash=sha256:0af68c55afbd5f07986df82831c7bff04846928ea8d1fd7f30052638788bc9b5 \ - --hash=sha256:0c9e74d766f2818bb95f84c25be4dea09841ac0f734d1966f415e4edfc4ef1c3 \ - --hash=sha256:0f3c1e2ab208db911594ae5b4f79addeb3501604a165019dd221c0bdcabe4db8 \ - --hash=sha256:0fdfe3e2a29e4db3659dbd5bbf04560cea53dd9610273917799f1cde46aa725e \ - --hash=sha256:1009ee0c7739c08a0cd59de430d6de452a55e42d6b522de7aa15e6f67db0b8e1 \ - --hash=sha256:1234d4ef35db82f5446dca8e35a7da7964d02c127b095e172e54397fb6a6c256 \ - --hash=sha256:16b6c1b3e57799b9d38427dda63edcbe4926352c47cf88588c0be4ace18dac85 \ - --hash=sha256:2034693ad3097d5355bfdacfffcbd3ef5694f9718ab7f29c29689a9eae841880 \ - --hash=sha256:21c1fa28a6a7e3cbdc171c694398b6df4744613ce9b36b1a498e816787e28123 \ - --hash=sha256:229cf1d3ca6c1804400b0a9790dc66528e08a6a1feec0d5040e8b9eb14422375 \ - --hash=sha256:27ccee0071a0e75d22cb35849b1db43f2ecd3e161041ac1ee9d2352ddf72f065 \ - --hash=sha256:363c6f671b761efcb30608d24925a382497c12c506b51661883c3e22337265ed \ - --hash=sha256:39c1fec2c11dc8d89bba6b2bf1556af381611a173ac2b511cf7231622058af41 \ - --hash=sha256:3b1ac0d3e594bf121308112697cf4b32be538fb1444468fb0a6ae4feebc83411 \ - --hash=sha256:3be571a8b5afed347da347bfcf27ba12b069d9d7f42cb8c7028b5e98bbb12597 \ - --hash=sha256:3c714d2fc58b5ca3e285461a4cc0c9a66bd0e24c5da9911e30158286c9b5be7f \ - --hash=sha256:3d00075aa65772e7ce9e990cab3ff1de702aa09be3940d1dc88d5abf1ab8a09c \ - --hash=sha256:3e90baa811a5d73f3ca0bcbf32064d663ed81318ab225ee4f427ad4e26e5aff3 \ - --hash=sha256:47819cea040f31d670cc8d324bb6435c6f133b8c7a19ec3d61634e62f8d8f9eb \ - --hash=sha256:47b099e1f4fbc95b701b6e85768e1fcdaf1630f3cbe4765fa216596f12310e2e \ - --hash=sha256:4a9fac8e469d04ce6c25bb2610dc535235bd4aa14996b4e6dbebf5e007eba5ee \ - --hash=sha256:4b826973a4a2ae47ba357e4e82fa44a463b8f168e1ca775ac64521442b19e87f \ - --hash=sha256:4c2529b320eb9e35af0fa3016c187dffb84a3ecc572bcee7c3ce302bfeba52bf \ - --hash=sha256:54479983bd5fb469c38f2f5c7e3a24f9a4e70594cd68cd1fa6b9340dadaff7cf \ - --hash=sha256:558d023b3df0bffe50a04e710bc87742de35060580a293c2a984299ed83bc4e4 \ - --hash=sha256:5756779642579d902eed757b21b0164cd6fe338506a8083eb58af5c372e39d9a \ - --hash=sha256:592f1a9fe869c778694f0aa806ba0374e97648ab57936f092fd9d87f8bc03665 \ - --hash=sha256:595b6c3969023ecf9041b2936ac3827e4623bfa3ccf007575f04c5a6aa318c22 \ - --hash=sha256:5a939de6b7b4e18ca683218320fc67ea886038265fd1ed30173f5ce3f8e85675 \ - --hash=sha256:5d54b09eba2bada6011aea5375542a157637b91029687eb4fdb2dab11059c1b4 \ - --hash=sha256:5df592cd503496351d6dc14f7cdad49f268d8e618f80dce0cd5a36b93c3fc08d \ - --hash=sha256:5f4c04ead5aed67c8a1a20491d54cdfba5884507a48dd798ecaf13c74c4489f5 \ - --hash=sha256:64dee438fed052b52e4f98f76c5790513235efaa1ef7f3f2192c392cd7c91b65 \ - --hash=sha256:66dd88c918e3287efc22409d426c8f729688d89a0c587c88971a0faa2c2f3792 \ - --hash=sha256:678999709e68425ae2593acf2e3ebcbcf2e69885a5ee78f9eb80e6e371f1bf57 \ - --hash=sha256:67f2b6de947f8c757db2db9c71527933ad0019737ec374a8a6be9a956786aaf9 \ - --hash=sha256:693f0192126df6c2327cce3baa7c06f2a117575e32ab2308f7f8216c29d9e2e3 \ - --hash=sha256:746ee8dba912cd6fc889a8147168991d50ed70447bf18bcda7039f7d2e3d9151 \ - --hash=sha256:756c56e867a90fb00177d530dca4b097dd753cde348448a1012ed6c5131f8b7d \ - --hash=sha256:76d1f20b1c7a2fa82367e04982e708723ba0e7b8d43aa643d3dcd404d74f1475 \ - --hash=sha256:7f493881579c90fc262d9cdbaa05a6b54b3811c2f300766748db79f098db9940 \ - --hash=sha256:823c248b690b2fd9303ba00c4f66cd5e2d8c3ba4aa968b2779be9532a4dad431 \ - --hash=sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee \ - --hash=sha256:8dd8327c795b3e3f219760fa603dcae1dcc148172290a8ab15158cf85a953413 \ - --hash=sha256:8fdc51055e6ff4adeb88d58a11042ec9a5eae317a0a53d12c062c8a8865909e8 \ - --hash=sha256:a625e06551975f4b7ea7102bc43895b90742746797e2e14b70ed61c43a90f09b \ - --hash=sha256:abdc0c6c8c648b4805c5eacd131910d2a7f6455dfd3becab248ef108e89ab16a \ - --hash=sha256:ac017dd64572e5c3bd01939121e4d16cf30e5d7e110a119399cf3133b63ad054 \ - --hash=sha256:ac1e5c9054fe23226fb11e05a6e630837f074174c4c2f0fe442996112a6de4fb \ - --hash=sha256:ac60e3b188ec7574cb761b08d50fcedf9d77f1530352db4eef1707fe9dee7205 \ - --hash=sha256:b359ed09954d7c18bbc1680f380c7301f92c60bf924171629c5db97febb12f04 \ - --hash=sha256:b7643a03db5c95c799b89b31c036d5f27eeb4d259c798e878d6937d71832b1e4 \ - --hash=sha256:ba9e56e8ceeeedb2e080147ba85ffcd5cd0711b89576b83784d8605a7df455fa \ - --hash=sha256:c338ffa0520bdb12fbc527265235639fb76e7bc7faafbb93f6ba80d9c06578a9 \ - --hash=sha256:cad21560da69f4ce7658ca2cb83138fb4cf695a2ba3e475e0559e05991aa8122 \ - --hash=sha256:d08eb4c2b7d6c41da6ca0600c077e93f5adcfd979cd777d747e9ee624556da4b \ - --hash=sha256:d50fd1ee42388dcfb2b3676132c78116490976f1300da28eb629272d5d93e905 \ - --hash=sha256:d591f8de75824cbb7acad4e05d2d710484f15f29d4a915092675ad3456f11770 \ - --hash=sha256:d5f6b181bb38171a8ad1d6aa58a67a6aa9d4b38d0f8c5f496b9e42561dfc62fe \ - --hash=sha256:d63efaa0cd96cf0c5fe4d581521d9fa87744540d4bc999ae6e08595a1014b45b \ - --hash=sha256:d99e5546bf73dbad5bf3547174cd6cb8ba7273062a23808ffea025ecb1cf8562 \ - --hash=sha256:e09473f095a819042ecb2ab9465aee615bd9c2028e4ef7d933600a8401c79561 \ - --hash=sha256:e8b56bdcdb4505c8078cb6c7157d9811a85790f2f2b3632c7d1462ab5783d215 \ - --hash=sha256:ee443ef070bb3b6ed74514f5efaa37a252af57c90eb33b956d35c8e9c10a1931 \ - --hash=sha256:f29d80eb9a9263b8d109135351caf568cc3f80b9928bccde535c235de55c22d9 \ - --hash=sha256:f7a866fbc1e97b5c617ee4116daaa09b722101d4a3c170c787450ba409f9736f \ - --hash=sha256:fcd5cf9e305d7b8338754470cf69cf81f420459dbae8a3b40cee57417f4614a7 - # via foxglove-websocket diff --git a/feo/ad-demo/src/activities/application_config.rs b/feo/ad-demo/src/activities/application_config.rs deleted file mode 100644 index c102e2a..0000000 --- a/feo/ad-demo/src/activities/application_config.rs +++ /dev/null @@ -1,117 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -use crate::activities::common::*; - -use crate::activities::camera_activity::Camera; -use crate::activities::mcap_activity::Mcap; -use crate::activities::render_activity::SceneRender; - -use core::net::{IpAddr, Ipv4Addr, SocketAddr}; -use feo::activity::{ActivityBuilder, ActivityIdAndBuilder}; -use feo::ids::{ActivityId, AgentId, WorkerId}; -use feo::topicspec::{Direction, TopicSpecification}; -use feo_com::interface::ComBackend; -use std::collections::HashMap; -use std::path::{Path, PathBuf}; - -pub type WorkerAssignment = (WorkerId, Vec<(ActivityId, Box)>); - -pub type ActivityDependencies = HashMap>; - -pub const COM_BACKEND: ComBackend = ComBackend::Iox2; - -pub const BIND_ADDR: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8081); -pub const BIND_ADDR2: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8082); - -pub const TOPIC_INFERRED_SCENE: &str = "feo/com/vehicle/inferred/scene"; -pub const TOPIC_CAMERA_FRONT: &str = "feo/com/vehicle/camera/front"; - -/// Just for demonstration purposes, currently we dont use recorders. -pub const MAX_ADDITIONAL_SUBSCRIBERS: usize = 2; - -pub fn socket_paths() -> (PathBuf, PathBuf) { - ( - Path::new("/tmp/feo_listener1.socket").to_owned(), - Path::new("/tmp/feo_listener2.socket").to_owned(), - ) -} - -pub fn agent_assignments() -> HashMap)>> { - let worker_40: WorkerAssignment = ( - 40.into(), - vec![ - (0.into(), Box::new(|id| Camera::build(id, TOPIC_CAMERA_FRONT))), - ( - 1.into(), - Box::new(|id| SceneRender::build(id, TOPIC_CAMERA_FRONT, TOPIC_INFERRED_SCENE)), - ), - ], - ); - let worker_41: WorkerAssignment = (41.into(), vec![(2.into(), Box::new(|id| Mcap::build(id)))]); - - let assignment = [(100.into(), vec![worker_40]), (101.into(), vec![worker_41])] - .into_iter() - .collect(); - - assignment -} - -pub fn activity_dependencies() -> ActivityDependencies { - let dependencies = [(0.into(), vec![]), (1.into(), vec![0.into()]), (2.into(), vec![])]; - - dependencies.into() -} - -pub fn topic_dependencies<'a>() -> Vec> { - use Direction::*; - - vec![ - TopicSpecification::new::(TOPIC_CAMERA_FRONT, vec![(0.into(), Outgoing), (1.into(), Incoming)]), - TopicSpecification::new::(TOPIC_INFERRED_SCENE, vec![(1.into(), Outgoing)]), - ] -} - -pub fn worker_agent_map() -> HashMap { - agent_assignments() - .iter() - .flat_map(|(agent_id, worker_activity_map)| { - worker_activity_map - .iter() - .map(move |(worker_id, _)| (*worker_id, *agent_id)) - }) - .collect() -} - -pub fn agent_assignments_ids() -> HashMap)>> { - agent_assignments() - .into_iter() - .map(|(agent_id, worker_activity_map)| { - ( - agent_id, - worker_activity_map - .into_iter() - .map(|(worker_id, activity_and_builder)| { - ( - worker_id, - activity_and_builder - .into_iter() - .map(|(activity_id, _)| activity_id) - .collect(), - ) - }) - .collect(), - ) - }) - .collect() -} diff --git a/feo/ad-demo/src/activities/camera_activity.rs b/feo/ad-demo/src/activities/camera_activity.rs deleted file mode 100644 index 16b4f91..0000000 --- a/feo/ad-demo/src/activities/camera_activity.rs +++ /dev/null @@ -1,66 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -use crate::activities::common::*; - -/// Camera activity -/// -/// This activity emulates a camera generating a [CameraImage]. -#[derive(Debug)] -pub struct Camera { - activity_id: ActivityId, - output_image: Box>, -} - -impl Camera { - pub fn build(activity_id: ActivityId, image_topic: &str) -> Box { - Box::new(Self { - activity_id, - output_image: activity_output(image_topic), - }) - } - - fn get_image(&mut self) -> CameraImage { - let mut rnd_generator = rand::rng(); - - CameraImage { - num_people: rnd_generator.random_range(0..20), - num_cars: rnd_generator.random_range(0..7), - obstacle_distance: rnd_generator.random_range(20.0..50.0), - } - } -} - -impl Activity for Camera { - fn id(&self) -> ActivityId { - self.activity_id - } - - #[instrument(name = "Camera startup")] - fn startup(&mut self) {} - - #[instrument(name = "Camera")] - fn step(&mut self) { - debug!("Stepping Camera"); - - if let Ok(camera) = self.output_image.write_uninit() { - let image = self.get_image(); - debug!("Sending image: {image:?}"); - let camera = camera.write_payload(image); - camera.send().unwrap(); - } - } - - #[instrument(name = "Camera shutdown")] - fn shutdown(&mut self) {} -} diff --git a/feo/ad-demo/src/activities/common.rs b/feo/ad-demo/src/activities/common.rs deleted file mode 100644 index b425a48..0000000 --- a/feo/ad-demo/src/activities/common.rs +++ /dev/null @@ -1,43 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -/// common imports for activities and config -pub(in crate::activities) use crate::activities::messages::{CameraImage, Scene}; - -pub(in crate::activities) use core::fmt; -pub(in crate::activities) use rand::Rng; - -pub(in crate::activities) use feo::activity::Activity; -pub(in crate::activities) use feo::ids::ActivityId; -pub(in crate::activities) use feo_com::interface::{ActivityInput, ActivityOutput}; -pub(in crate::activities) use feo_log::debug; -pub(in crate::activities) use feo_tracing::instrument; - -// imports specific to this file -use feo_com::iox2::{Iox2Input, Iox2Output}; - -/// Create an activity input. -pub(in crate::activities) fn activity_input(topic: &str) -> Box> -where - T: fmt::Debug + 'static, -{ - return Box::new(Iox2Input::new(topic)); -} - -/// Create an activity output. -pub(in crate::activities) fn activity_output(topic: &str) -> Box> -where - T: fmt::Debug + 'static, -{ - return Box::new(Iox2Output::new(topic)); -} diff --git a/feo/ad-demo/src/activities/mcap_activity.rs b/feo/ad-demo/src/activities/mcap_activity.rs deleted file mode 100644 index ffaf3ee..0000000 --- a/feo/ad-demo/src/activities/mcap_activity.rs +++ /dev/null @@ -1,126 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -use crate::activities::common::*; - -use anyhow::{Context, Result}; -use camino::Utf8Path; -use mcap::MessageStream; -use memmap2::Mmap; -use serde_json; -use serde_json::Value; -use std::fs; - -/// Mcap activity -/// -/// This activity reads mcap msgs in Mcap file and publish it to tcp server, -/// to be forwarded to lichtblick via foxglove websocket server. -pub struct Mcap { - activity_id: ActivityId, - message_stream: MessageStream<'static>, -} - -impl fmt::Debug for Mcap { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Mcap") - .field("activity_id", &self.activity_id) - .field("message_stream", &"") - .finish() - } -} - -impl Mcap { - fn map_mcap>(p: P) -> Result { - let path = p.as_ref(); - debug!("Opening Mcap file at path: {}", path); - let file = fs::File::open(path).context("Couldn't open MCAP file at")?; - unsafe { Mmap::map(&file) }.context("Couldn't map MCAP file") - } - - pub fn build(activity_id: ActivityId) -> Box { - let mcap_to_map = Self::map_mcap("feo/ad-demo/src/assets/gps_route.mcap").expect("Could not open MCAP file"); - let static_slice: &'static [u8] = Box::leak(mcap_to_map.to_vec().into_boxed_slice()); - let message_stream = MessageStream::new(static_slice).expect("Failed to create MessageStream"); - Box::new(Self { - activity_id, - message_stream, - }) - } - - fn get_single_msg(&mut self) -> Result> { - match self.message_stream.next() { - Some(Ok(message)) => { - let data_json = serde_json::from_slice(&message.data).context("Failed to convert msg data as JSON")?; - - debug!("single mcap message data: {}", data_json); - - Ok(Some(data_json)) - }, - Some(Err(e)) => { - debug!("Error reading MCAP message: {}", e); - Ok(None) - }, - None => { - debug!("No more messages in MCAP file"); - Ok(None) - }, - } - } - - fn send_tcp_msg(&mut self, msg: &str) { - use std::io::Write; - use std::net::{Shutdown, TcpStream}; - if let Ok(mut stream) = TcpStream::connect("127.0.0.1:9001") { - debug!("Connected to the tcp server!"); - - let _ = stream.write(msg.as_bytes()); - - debug!("Message sent to the TCP server!"); - - let _ = stream.shutdown(Shutdown::Both); - } else { - debug!("Couldn't connect to tcp server..."); - } - } -} - -impl Activity for Mcap { - fn id(&self) -> ActivityId { - self.activity_id - } - - #[instrument(name = "Mcap startup")] - fn startup(&mut self) { - debug!("Mcap Startup"); - } - - #[instrument(name = "Mcap")] - fn step(&mut self) { - debug!("Stepping Mcap"); - - if let Ok(Some(mcap_msg_json)) = self.get_single_msg() { - let compact_json = serde_json::to_string(&mcap_msg_json).expect("failed to stringify Json"); - - debug!("Read Mcap message: {compact_json:?}"); - self.send_tcp_msg(&compact_json); - } else { - debug!("No message in mcap left."); - self.send_tcp_msg("No message in mcap left"); - } - } - - #[instrument(name = "Mcap shutdown")] - fn shutdown(&mut self) { - debug!("Mcap Shutdown"); - } -} diff --git a/feo/ad-demo/src/activities/messages.rs b/feo/ad-demo/src/activities/messages.rs deleted file mode 100644 index 8495b77..0000000 --- a/feo/ad-demo/src/activities/messages.rs +++ /dev/null @@ -1,45 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -/// Messages -/// -/// This module contains the definition of messages -/// to be used within this application. -use postcard::experimental::max_size::MaxSize; -use serde::{Deserialize, Serialize}; - -/// Camera image -/// -/// Fake camera frame with number of detected people and cars, -/// and distance to the closest obstacle. -#[derive(Serialize, Deserialize, MaxSize, Debug, Default)] -#[repr(C)] -pub struct CameraImage { - pub num_people: usize, - pub num_cars: usize, - pub obstacle_distance: f64, -} - -/// Scene -/// -/// Fake inferred scene with number of detected people and cars, -/// distance to the closest obstacle, and distances to left and right lane. -#[derive(Serialize, Deserialize, MaxSize, Debug, Default)] -#[repr(C)] -pub struct Scene { - pub num_people: usize, - pub num_cars: usize, - pub obstacle_distance: f64, - pub distance_left_lane: f64, - pub distance_right_lane: f64, -} diff --git a/feo/ad-demo/src/activities/mod.rs b/feo/ad-demo/src/activities/mod.rs deleted file mode 100644 index 0e06adf..0000000 --- a/feo/ad-demo/src/activities/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -/// Module declarations for activities, messages, and config -pub(in crate::activities) mod camera_activity; -pub(in crate::activities) mod common; -pub(in crate::activities) mod mcap_activity; -pub(in crate::activities) mod messages; -pub(in crate::activities) mod render_activity; - -pub mod application_config; diff --git a/feo/ad-demo/src/activities/render_activity.rs b/feo/ad-demo/src/activities/render_activity.rs deleted file mode 100644 index a9a69b8..0000000 --- a/feo/ad-demo/src/activities/render_activity.rs +++ /dev/null @@ -1,77 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -use crate::activities::common::*; -use crate::activities::messages::{CameraImage, Scene}; - -/// Scene render activity -/// -/// This activity emulates rendering a scene from a [CameraImage] which can be rendered to a display. -#[derive(Debug)] -pub struct SceneRender { - activity_id: ActivityId, - input_image: Box>, - output_scene: Box>, -} - -impl SceneRender { - pub fn build(activity_id: ActivityId, image_topic: &str, scene_topic: &str) -> Box { - Box::new(Self { - activity_id, - input_image: activity_input(image_topic), - output_scene: activity_output(scene_topic), - }) - } -} - -impl Activity for SceneRender { - fn id(&self) -> ActivityId { - self.activity_id - } - - #[instrument(name = "SceneRender startup")] - fn startup(&mut self) {} - - #[instrument(name = "SceneRender")] - fn step(&mut self) { - debug!("Stepping SceneRender"); - - let received_image = self.input_image.read(); - let output_scene = self.output_scene.write_uninit(); - - if let (Ok(received_image), Ok(output_scene)) = (received_image, output_scene) { - debug!("Received image: {:?}", *received_image); - - let mut rnd_generator = rand::rng(); - - let op_scene = Scene { - num_people: received_image.num_people, - num_cars: received_image.num_cars, - obstacle_distance: received_image.obstacle_distance, - distance_left_lane: rnd_generator.random_range(10.0..50.0), - distance_right_lane: rnd_generator.random_range(10.0..50.0), - }; - - debug!("Sending scene: {op_scene:?}"); - - let send_output_scene = output_scene.write_payload(op_scene); - - send_output_scene.send().unwrap(); - - debug!("Rendering scene"); - } - } - - #[instrument(name = "SceneRender shutdown")] - fn shutdown(&mut self) {} -} diff --git a/feo/ad-demo/src/agents/primary.rs b/feo/ad-demo/src/agents/primary.rs deleted file mode 100644 index bb0f4d4..0000000 --- a/feo/ad-demo/src/agents/primary.rs +++ /dev/null @@ -1,88 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -use feo::agent::com_init::initialize_com_primary; -use feo::agent::relayed::primary::{Primary, PrimaryConfig}; -use feo::agent::NodeAddress; -use feo::ids::{ActivityId, AgentId, WorkerId}; -use feo_log::{info, LevelFilter}; -use feo_time::Duration; -use std::collections::HashMap; - -use ad_demo::activities::application_config::{ - activity_dependencies, agent_assignments, agent_assignments_ids, topic_dependencies, worker_agent_map, BIND_ADDR, - BIND_ADDR2, COM_BACKEND, MAX_ADDITIONAL_SUBSCRIBERS, -}; - -const AGENT_ID: AgentId = AgentId::new(100); -const DEFAULT_FEO_CYCLE_TIME: Duration = Duration::from_secs(5); - -/// Primary agent for the ad-demo FEO application. -fn main() { - feo_logger::init(LevelFilter::Debug, true, true); - feo_tracing::init(feo_tracing::LevelFilter::TRACE); - - info!("Starting primary agent {AGENT_ID}"); - - // Initialize topics. Make it alive until application runs. - let _topic_guards = initialize_com_primary( - COM_BACKEND, - AGENT_ID, - topic_dependencies(), - &agent_assignments_ids(), - MAX_ADDITIONAL_SUBSCRIBERS, - ); - - let mut primary_agent = Primary::new(generate_primary_config()); - - primary_agent.run().unwrap() -} - -fn get_cycle_time_from_args() -> Duration { - let args: Vec = std::env::args().collect(); - - args.get(1) - .and_then(|argument| argument.parse::().ok()) - .map(Duration::from_millis) - .unwrap_or(DEFAULT_FEO_CYCLE_TIME) -} - -fn generate_primary_config() -> PrimaryConfig { - let activity_worker_map: HashMap = agent_assignments() - .values() - .flat_map(|worker_activity_builder| { - worker_activity_builder - .iter() - .flat_map(move |(worker_id, activity_id_builder_vec)| { - activity_id_builder_vec - .iter() - .map(|(activity_id, _)| (*activity_id, *worker_id)) - }) - }) - .collect(); - - let with_no_recorders: Vec = vec![]; - - PrimaryConfig { - cycle_time: get_cycle_time_from_args(), - activity_dependencies: activity_dependencies(), - recorder_ids: with_no_recorders, - worker_assignments: agent_assignments().remove(&AGENT_ID).unwrap(), - timeout: Duration::from_secs(10), - bind_address_senders: NodeAddress::Tcp(BIND_ADDR), - bind_address_receivers: NodeAddress::Tcp(BIND_ADDR2), - id: AGENT_ID, - worker_agent_map: worker_agent_map(), - activity_worker_map, - } -} diff --git a/feo/ad-demo/src/agents/secondary.rs b/feo/ad-demo/src/agents/secondary.rs deleted file mode 100644 index fffd74f..0000000 --- a/feo/ad-demo/src/agents/secondary.rs +++ /dev/null @@ -1,56 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -use ad_demo::activities::application_config::{ - agent_assignments, agent_assignments_ids, topic_dependencies, BIND_ADDR, BIND_ADDR2, COM_BACKEND, -}; -use core::time::Duration; -use feo::agent::com_init::initialize_com_secondary; -use feo::agent::relayed::secondary::{Secondary, SecondaryConfig}; -use feo::agent::NodeAddress; -use feo::ids::ActivityId; -use feo::ids::AgentId; -use feo_log::{info, LevelFilter}; -use std::collections::HashSet; - -/// One Secondary agent for the ad-demo FEO application. -fn main() { - feo_logger::init(LevelFilter::Debug, true, true); - feo_tracing::init(feo_tracing::LevelFilter::TRACE); - - let secondary_agent_id = AgentId::new(101); - - let config = SecondaryConfig { - id: secondary_agent_id, - worker_assignments: agent_assignments().remove(&secondary_agent_id).unwrap(), - timeout: Duration::from_secs(10), - bind_address_senders: NodeAddress::Tcp(BIND_ADDR), - bind_address_receivers: NodeAddress::Tcp(BIND_ADDR2), - }; - - let local_activities: HashSet = agent_assignments_ids() - .remove(&secondary_agent_id) - .unwrap() - .iter() - .flat_map(|(_, activity_ids)| activity_ids.iter()) - .copied() - .collect(); - - // Initialize topics. Make it alive until application runs. - let _topic_guards = initialize_com_secondary(COM_BACKEND, topic_dependencies(), &local_activities); - - info!("Starting secondary agent {}", secondary_agent_id); - - let secondary_agent = Secondary::new(config); - secondary_agent.run(); -} diff --git a/feo/ad-demo/src/assets/gps_route.mcap b/feo/ad-demo/src/assets/gps_route.mcap deleted file mode 100644 index 2d1667b37b2a6849d25fc5246380b8c4ff0e9f56..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24327 zcmaLfcRZDU;QxPnWbeIKSs7)|h>*-kpm#c|IKHbUR30oj83Bbwde?Q@AWR|M#FlF5dC?cJ^@RcC)v= z!!0Q;EiOUCCX5zFY!@F+-($wvDpu5;xyNiQi2FYS`<*xA1jwZTFK>sfGyk=xTh1OA zf`G#SH%C0>q7F6nO0D~a>|oi5f})4(cBp0eoX4+ zTNV*I890%bF%?|3ZLIsO?edr}SKCQX#H#GpZv7`bMS_3$asy7AQ^4#E-%#E@3CwTUw0sD$%0Xo0NY~JUdd9!sjnLkC><5Q~eJGGWO+W}wR zD!qHLSNyd<#i*F|Q^L)pfkKiTyXM`*NF1Y!9gC-;^qS6+kwx(+|N1~1MqRx-_UZ{W z1J?G#xGT@rv$zG)Iz^|%9z3CnU(Z?N@l>CVo?&>qVO8%Akow%$0cUQEI^Nd8C8BYCGyxNmIGBH0a>^St+cu(?b4^FW6 z?SI0e*rSmxrwlUVbkom)?4=CryOi$&9Nd^fS7!U4*$}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z?fcsofFD7pVc0Js-i5Z=HU~D~M0=t5G~jCJ9f6O)q+ICU(RoS>u@iKZl@@Rhw88H% zU|w#tXGwVh918tK1o{78$o++`?LDWBSb+!a{cP_5XF{tVRRixqlVz>}8}p+5xFp{t z#C6b*2d)8=@u9nmQx32*v^3rXa1Zox9*quSUVgOilhp?ffle8T1^x_e<@N?xUI6U{ zNN{u!XF{W|DE9Y;@Z7e_DT`aoV+2eSJ9)Jf0W->YO7CHFw|N9lh|M&Qx%m3@u*}?A#?*HjY zuE6?#Wy0w7{OE=M-t7u11F8RJa9{r4FYgXt`kj&neRq7U^?#S(PjLTdA&9g2ZxKM# x|Fe+Qp^N(eUP!jk#r%ISr?jr2SN-pW;(srA;MoEWc-LUS*z(|I9QyM2{||Y{s*V5v diff --git a/feo/ad-demo/src/lib.rs b/feo/ad-demo/src/lib.rs deleted file mode 100644 index c7fd114..0000000 --- a/feo/ad-demo/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -// ******************************************************************************* -// Copyright (c) 2026 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 -// -// -// SPDX-License-Identifier: Apache-2.0 -// ******************************************************************************* - -#![deny(clippy::std_instead_of_core)] - -/// share activity dependencies between primary and secondary agents -pub mod activities; diff --git a/scorex/BUILD.bazel b/scorex/BUILD.bazel deleted file mode 100644 index b0ec8d0..0000000 --- a/scorex/BUILD.bazel +++ /dev/null @@ -1,93 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_binary", "go_library") - -# gazelle:prefix scorex -exports_files( - [ - "go.mod", - "go.sum", - ], - visibility = ["//visibility:public"], -) - -go_library( - name = "scorex_lib", - srcs = ["main.go"], - importpath = "scorex", - visibility = ["//visibility:private"], - deps = ["//scorex/cmd"], -) - -go_binary( - name = "scorex", - embed = [":scorex_lib"], - visibility = ["//visibility:public"], - x_defs = { - "scorex/cmd.Version": "{STABLE_VERSION}", - "scorex/cmd.GitCommit": "{STABLE_GIT_COMMIT}", - "scorex/cmd.BuildDate": "{STABLE_BUILD_DATE}", - }, -) - -go_binary( - name = "scorex_linux_amd64", - embed = [":scorex_lib"], - goarch = "amd64", - goos = "linux", - visibility = ["//visibility:public"], - x_defs = { - "scorex/cmd.Version": "{STABLE_VERSION}", - "scorex/cmd.GitCommit": "{STABLE_GIT_COMMIT}", - "scorex/cmd.BuildDate": "{STABLE_BUILD_DATE}", - }, -) - -go_binary( - name = "scorex_darwin_arm64", - embed = [":scorex_lib"], - goarch = "arm64", - goos = "darwin", - visibility = ["//visibility:public"], - x_defs = { - "scorex/cmd.Version": "{STABLE_VERSION}", - "scorex/cmd.GitCommit": "{STABLE_GIT_COMMIT}", - "scorex/cmd.BuildDate": "{STABLE_BUILD_DATE}", - }, -) - -go_binary( - name = "scorex_windows_amd64", - embed = [":scorex_lib"], - goarch = "amd64", - goos = "windows", - visibility = ["//visibility:public"], - x_defs = { - "scorex/cmd.Version": "{STABLE_VERSION}", - "scorex/cmd.GitCommit": "{STABLE_GIT_COMMIT}", - "scorex/cmd.BuildDate": "{STABLE_BUILD_DATE}", - }, -) - -go_binary( - name = "scorex_darwin_amd64", - embed = [":scorex_lib"], - goarch = "amd64", - goos = "darwin", - visibility = ["//visibility:public"], - x_defs = { - "scorex/cmd.Version": "{STABLE_VERSION}", - "scorex/cmd.GitCommit": "{STABLE_GIT_COMMIT}", - "scorex/cmd.BuildDate": "{STABLE_BUILD_DATE}", - }, -) diff --git a/scorex/README.md b/scorex/README.md deleted file mode 100644 index 6918902..0000000 --- a/scorex/README.md +++ /dev/null @@ -1,178 +0,0 @@ -
- -```text -|=================================| -| ___ ___ ___ _ __ _____ __ | -| / __|/ __/ _ \| '__/ _ \ \/ / | -| \__ \ (_| (_) | | | __/> < | -| |___/\___\___/|_| \___/_/\_\ | -| | -|=================================| -``` - -
- -# scorex - -`scorex` is a small CLI helper for generating S-CORE skeleton applications. - -It is implemented in Go in [scorex/main.go](scorex/main.go) and uses Cobra for its CLI in -[scorex/cmd/root.go](scorex/cmd/root.go) and [scorex/cmd/init.go](scorex/cmd/init.go). - -## Features - -- Generate a new S-CORE Bazel project skeleton -- Pre-wire `MODULE.bazel`, `.bazelrc`, `.bazelversion`, `BUILD`, and `src/main.cpp` -- Use a central `known_good.json` to pin module versions and commits - -The project layout and files are rendered from the templates in -[scorex/cmd/templates/application](scorex/cmd/templates/application). - -## Installation - -From the repository root: - -```sh -cd scorex -go mod tidy -go build ./... -``` - -This creates a `scorex` binary in the `scorex/` directory. - -## Usage - -Show help: - -```sh -./scorex --help -``` - -Generate a new S-CORE project (example): - -```sh -./scorex init \ - --module score_baselibs \ - --module score_communication \ - --name my_score_app \ - --dir . \ - --bazel-version 8.3.0 -``` - -This will create `./my_score_app` with: - -- `MODULE.bazel` -- `.bazelrc` -- `.bazelversion` -- `BUILD` -- `src/BUILD` -- `src/main.cpp` - -## Options - -The `init` command (see [scorex/cmd/init.go](scorex/cmd/init.go)) supports: - -- `--module` (repeatable): S-CORE modules to include, e.g. `score_communication` -- `--name`: Name of the generated project (default: `score_app`) -- `--dir`: Target directory where the project is created (default: current directory) -- `--known-good-url`: URL or file path to `known_good.json` -- `--bazel-version`: Bazel version written into `.bazelversion` (default: `8.3.0`) - -## Distribution - -The `scorex` CLI is distributed through multiple package managers for easy installation across different platforms. - -### Installation Methods - -#### macOS & Linux - Homebrew - -```bash -# Add the tap (once a tap repository is created) -brew tap eclipse-score/tap - -# Install scorex -brew install scorex -``` - -#### Windows - Scoop - -```bash -# Add the bucket (once a bucket repository is created) -scoop bucket add eclipse-score https://github.com/eclipse-score/scoop-bucket - -# Install scorex -scoop install scorex -``` - -#### Universal - Install Script - -**macOS & Linux:** -```bash -curl -sSL https://raw.githubusercontent.com/eclipse-score/score_scrample/main/scorex/distribution/install.sh | sh -``` - -#### Manual Download - -Download the appropriate binary for your platform from the [releases page](https://github.com/eclipse-score/score_scrample/releases): - -- **Linux (x86_64)**: `scorex-VERSION-linux-x86_64.tar.gz` -- **macOS (Apple Silicon)**: `scorex-VERSION-macos-arm64.tar.gz` -- **macOS (Intel)**: `scorex-VERSION-macos-x86_64.tar.gz` -- **Windows (x86_64)**: `scorex-VERSION-windows-x86_64.zip` - -Extract and move to a directory in your PATH. - -### For Maintainers - -#### Publishing a New Release - -1. Create and push a new version tag: - ```bash - git tag v1.0.0 - git push origin v1.0.0 - ``` - -2. GitHub Actions will automatically: - - Build binaries for all platforms - - Create compressed archives - - Generate checksums - - Create a GitHub release - -3. Update package manifests: - - **Homebrew Formula** (`distribution/homebrew/scorex.rb`): - - Update version number - - Update SHA256 checksums from `checksums.txt` in the release - - **Scoop Manifest** (`distribution/scoop/scorex.json`): - - Update version number - - Update SHA256 hash from `checksums.txt` - -4. Commit and push updated manifests to respective repositories: - - Homebrew: Create/update tap repository at `eclipse-score/homebrew-tap` - - Scoop: Create/update bucket repository at `eclipse-score/scoop-bucket` - -#### Setting Up Package Repositories - -**Homebrew Tap:** -1. Create repository: `https://github.com/eclipse-score/homebrew-tap` -2. Add `distribution/homebrew/scorex.rb` to the repository root or `Formula/` directory -3. Users can then install with: `brew install eclipse-score/tap/scorex` - -**Scoop Bucket:** -1. Create repository: `https://github.com/eclipse-score/scoop-bucket` -2. Add `distribution/scoop/scorex.json` to the `bucket/` directory -3. Users can then install with: `scoop bucket add eclipse-score ` then `scoop install scorex` - -#### Updating Checksums - -After each release, download `checksums.txt` from the GitHub release and update: - -```bash -# Example for version 1.0.0 -curl -sL https://github.com/eclipse-score/score_scrample/releases/download/v1.0.0/checksums.txt - -# Update the SHA256 values in: -# - distribution/homebrew/scorex.rb -# - distribution/scoop/scorex.json -``` diff --git a/scorex/cmd/BUILD.bazel b/scorex/cmd/BUILD.bazel deleted file mode 100644 index 003e18f..0000000 --- a/scorex/cmd/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "cmd", - srcs = [ - "init.go", - "root.go", - "version.go", - ], - importpath = "scorex/cmd", - visibility = ["//visibility:public"], - deps = [ - "//scorex/internal/config", - "//scorex/internal/model", - "//scorex/internal/service/knowngood", - "//scorex/internal/service/projectinit", - "@com_github_spf13_cobra//:cobra", - ], -) diff --git a/scorex/cmd/init.go b/scorex/cmd/init.go deleted file mode 100644 index 7f9d226..0000000 --- a/scorex/cmd/init.go +++ /dev/null @@ -1,450 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ -package cmd - -import ( - "bufio" - "fmt" - "io" - "os" - "slices" - "sort" - "strconv" - "strings" - - "github.com/spf13/cobra" - "scorex/internal/config" - "scorex/internal/model" - "scorex/internal/service/knowngood" - "scorex/internal/service/projectinit" -) - -type initOptions struct { - Modules []string - TargetDir string - Name string - KnownGoodURL string - BazelVersion string - ProjectType string // Application|Module - AppType string // daal|feo - IncludeDevcontainer bool - ModulePreset string -} - -var initOpts = initOptions{} - -// initCmd represents the init command -var initCmd = &cobra.Command{ - Use: "init", - Short: "Generates an S-CORE skeleton application", - Long: `Generates a new S-CORE project with selected modules.`, - RunE: func(cmd *cobra.Command, args []string) error { - if err := config.ValidateModulePresetUsage(initOpts.Modules, initOpts.ModulePreset); err != nil { - return err - } - - if err := validateInitOptions(initOpts); err != nil { - return err - } - - if len(initOpts.Modules) == 0 { - if initOpts.ModulePreset != "" { - if err := applyPresetNonInteractive(&initOpts); err != nil { - return err - } - return runInit(initOpts) - } - return runInitInteractive(&initOpts) - } - return runInit(initOpts) - }, -} - -func init() { - rootCmd.AddCommand(initCmd) - - initOpts.ProjectType = "Application" - initOpts.AppType = "daal" - - initCmd.Flags().StringSliceVar(&initOpts.Modules, "module", nil, "S-CORE Module(s), e.g.: score_communication, score_baselibs") - initCmd.Flags().StringVar(&initOpts.Name, "name", config.DefaultProjectName, "name of the generated project") - initCmd.Flags().StringVar(&initOpts.TargetDir, "dir", config.DefaultTargetDir, "targetdirectory of the generated project") - initCmd.Flags().StringVar( - &initOpts.KnownGoodURL, - "known-good-url", - config.DefaultKnownGoodURL, - "URL or path to known_good.json", - ) - initCmd.Flags().StringVar(&initOpts.BazelVersion, "bazel-version", config.DefaultBazelVersion, "bazel version to be used in project") - initCmd.Flags().StringVar(&initOpts.ProjectType, "project-type", initOpts.ProjectType, "project type: Application or Module") - initCmd.Flags().StringVar(&initOpts.AppType, "app-type", initOpts.AppType, "application type (for Application projects): daal or feo") - initCmd.Flags().BoolVar(&initOpts.IncludeDevcontainer, "devcontainer", false, "include a .devcontainer folder") - initCmd.Flags().StringVar(&initOpts.ModulePreset, "module-preset", "", "use a predefined module preset (e.g. feo-standard, daal-standard)") -} - -func runInit(opts initOptions) error { - piOpts := projectinit.Options{ - Modules: opts.Modules, - TargetDir: opts.TargetDir, - Name: opts.Name, - KnownGoodURL: opts.KnownGoodURL, - BazelVersion: opts.BazelVersion, - ProjectType: opts.ProjectType, - AppType: opts.AppType, - IncludeDevcontainer: opts.IncludeDevcontainer, - } - - result, err := projectinit.Run(piOpts) - if err != nil { - return err - } - - fmt.Println("Generating skeleton in", result.TargetDir, "with modules:", result.SelectedModules) - return nil -} - -func runInitInteractive(opts *initOptions) error { - reader := bufio.NewReader(os.Stdin) - - appChar := "a" - moduleChar := "m" - - // project type - fmt.Printf("Project type (%s = application, %s = module): ", appChar, moduleChar) - v, err := readLine(reader) - if err != nil { - return err - } - v = strings.ToLower(v) - - switch v { - case "", appChar: // Default: application - opts.ProjectType = "Application" - case moduleChar: - opts.ProjectType = "Module" - default: - return fmt.Errorf("invalid project type %q (use %s or %s)", v, appChar, moduleChar) - } - - // application type (nur bei Application) - if opts.ProjectType == "Application" { - feoChar := "f" - daalChar := "d" - - fmt.Printf("Application type (%s = FEO, %s = DAAL): ", feoChar, daalChar) - v, err := readLine(reader) - if err != nil { - return err - } - v = strings.ToLower(v) - - switch v { - case "", daalChar: // Default: DAAL - opts.AppType = "daal" - case feoChar: - opts.AppType = "feo" - default: - return fmt.Errorf("invalid application type %q (use %s or %s)", v, feoChar, daalChar) - } - } - - // project name - fmt.Printf("Project name [%s]: ", opts.Name) - if v, err := readLine(reader); err != nil { - return err - } else if v != "" { - opts.Name = v - } - - // target directory - fmt.Printf("Target directory [%s]: ", opts.TargetDir) - if v, err := readLine(reader); err != nil { - return err - } else if v != "" { - opts.TargetDir = v - } - - // devcontainer - devcontainer, err := confirm(reader, "Use .devcontainer?") - if err != nil { - return err - } else { - opts.IncludeDevcontainer = devcontainer - } - - // load known-good - kg, err := knowngood.Load(opts.KnownGoodURL) - if err != nil { - return fmt.Errorf("error loading known_good.json: %w", err) - } - - // presets (optional) - if err := applyPresetInteractive(reader, opts, kg.Modules); err != nil { - return err - } - if len(opts.Modules) > 0 { - if err := validateInitOptions(*opts); err != nil { - return err - } - return runInit(*opts) - } - - // choose modules - modules, err := promptModules(reader, kg.Modules) - if err != nil { - return err - } - if len(modules) == 0 { - return fmt.Errorf("no modules selected") - } - opts.Modules = modules - - if err := validateInitOptions(*opts); err != nil { - return err - } - return runInit(*opts) -} - -func applyPresetNonInteractive(opts *initOptions) error { - all, err := config.LoadModulePresets() - if err != nil { - return err - } - p, ok := config.FindModulePreset(all, opts.ModulePreset) - if !ok { - return fmt.Errorf("unknown --module-preset %q (known: %s)", opts.ModulePreset, strings.Join(config.KnownPresetIDs(all), ", ")) - } - if p.ProjectType != "" && p.ProjectType != opts.ProjectType { - return fmt.Errorf("module preset %q is not applicable to project type %q", p.ID, opts.ProjectType) - } - if p.AppType != "" && p.AppType != opts.AppType { - return fmt.Errorf("module preset %q is not applicable to app type %q", p.ID, opts.AppType) - } - if len(p.Modules) == 0 { - return fmt.Errorf("module preset %q has no modules", p.ID) - } - opts.Modules = append([]string(nil), p.Modules...) - return nil -} - -func applyPresetInteractive(reader *bufio.Reader, opts *initOptions, known map[string]model.ModuleInfo) error { - all, err := config.LoadModulePresets() - if err != nil { - return err - } - applicable := config.ApplicableModulePresets(all, opts.ProjectType, opts.AppType) - if len(applicable) == 0 { - return nil - } - - fmt.Println("\nModule presets:") - fmt.Println(" [0] Custom (select manually)") - for i, p := range applicable { - fmt.Printf(" [%d] %s (%s)\n", i+1, p.Label, p.ID) - } - fmt.Print("Select preset [0]: ") - - v, err := readLine(reader) - if err != nil { - return err - } - v = strings.TrimSpace(v) - if v == "" { - v = "0" - } - - idx, err := strconv.Atoi(v) - if err != nil || idx < 0 || idx > len(applicable) { - return fmt.Errorf("invalid preset selection: %q", v) - } - if idx == 0 { - return nil - } - - preset := applicable[idx-1] - if len(preset.Modules) == 0 { - return fmt.Errorf("selected preset %q has no modules", preset.ID) - } - - opts.Modules = append([]string(nil), preset.Modules...) - - addMore, err := confirm(reader, "Add more modules on top of the preset?") - if err != nil { - return err - } - if !addMore { - return nil - } - - extra, err := promptModules(reader, known) - if err != nil { - return err - } - opts.Modules = mergeUnique(opts.Modules, extra) - return nil -} - -func mergeUnique(a, b []string) []string { - seen := make(map[string]struct{}, len(a)+len(b)) - out := make([]string, 0, len(a)+len(b)) - for _, s := range a { - if s == "" { - continue - } - if _, ok := seen[s]; ok { - continue - } - seen[s] = struct{}{} - out = append(out, s) - } - for _, s := range b { - if s == "" { - continue - } - if _, ok := seen[s]; ok { - continue - } - seen[s] = struct{}{} - out = append(out, s) - } - return out -} - -func validateInitOptions(opts initOptions) error { - validProjectTypes := []string{"Application", "Module"} - if opts.ProjectType == "" { - return fmt.Errorf("--project-type must be set (Application or Module)") - } - if !slices.Contains(validProjectTypes, opts.ProjectType) { - return fmt.Errorf("invalid --project-type %q (use Application or Module)", opts.ProjectType) - } - - if opts.ProjectType == "Application" { - validAppTypes := []string{"daal", "feo"} - if opts.AppType == "" { - return fmt.Errorf("--app-type must be set for Application projects (daal or feo)") - } - if !slices.Contains(validAppTypes, opts.AppType) { - return fmt.Errorf("invalid --app-type %q (use daal or feo)", opts.AppType) - } - } - - if opts.Name == "" { - return fmt.Errorf("--name must be set") - } - if opts.TargetDir == "" { - return fmt.Errorf("--dir must be set") - } - if opts.KnownGoodURL == "" { - return fmt.Errorf("--known-good-url must be set") - } - if opts.BazelVersion == "" { - return fmt.Errorf("--bazel-version must be set") - } - - return nil -} - -func readLine(r *bufio.Reader) (string, error) { - line, err := r.ReadString('\n') - if err != nil && err != io.EOF { - return "", err - } - return strings.TrimSpace(line), nil -} - -func promptModules(r *bufio.Reader, known map[string]model.ModuleInfo) ([]string, error) { - if len(known) == 0 { - return nil, fmt.Errorf("no modules in known_good.json") - } - - // sorted list of module names - names := make([]string, 0, len(known)) - for n := range known { - names = append(names, n) - } - sort.Strings(names) - - fmt.Println("\nAvailable S-CORE modules:") - for i, n := range names { - fmt.Printf(" [%d] %s\n", i+1, n) - } - fmt.Print("Select modules (comma-separated indices or names, e.g. 1,3 or score_foo): ") - - sel, err := readLine(r) - if err != nil { - return nil, err - } - if sel == "" { - return nil, nil - } - - parts := strings.Split(sel, ",") - var result []string - seen := make(map[string]struct{}) - for _, p := range parts { - p = strings.TrimSpace(p) - if p == "" { - continue - } - - // Either an index into the known-good list, or a module name. - if idx, err := strconv.Atoi(p); err == nil { - if idx < 1 || idx > len(names) { - return nil, fmt.Errorf("invalid module index: %q", p) - } - name := names[idx-1] - if _, ok := seen[name]; !ok { - result = append(result, name) - seen[name] = struct{}{} - } - continue - } - - // Treat as module name. - name := p - if _, ok := known[name]; !ok { - ok, err := confirm(r, fmt.Sprintf("Module %q is not in known_good.json. Add anyway?", name)) - if err != nil { - return nil, err - } - if !ok { - continue - } - } - if _, ok := seen[name]; !ok { - result = append(result, name) - seen[name] = struct{}{} - } - } - return result, nil -} - -func confirm(r *bufio.Reader, prompt string) (bool, error) { - for { - fmt.Printf("%s (y/N): ", prompt) - v, err := readLine(r) - if err != nil { - return false, err - } - v = strings.TrimSpace(strings.ToLower(v)) - switch v { - case "", "n", "no": - return false, nil - case "y", "yes": - return true, nil - default: - // keep asking - } - } -} diff --git a/scorex/cmd/root.go b/scorex/cmd/root.go deleted file mode 100644 index c504e50..0000000 --- a/scorex/cmd/root.go +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ -package cmd - -import ( - "os" - - "github.com/spf13/cobra" -) - -// Version information, set via ldflags during build -var ( - Version = "dev" - GitCommit = "unknown" - BuildDate = "unknown" -) - -// rootCmd represents the base command when called without any subcommands -var rootCmd = &cobra.Command{ - Use: "scorex", - Short: "CLI for creating S-CORE skeleton projects", - Long: ` - -|=================================| -| ___ ___ ___ _ __ _____ __ | -| / __|/ __/ _ \| '__/ _ \ \/ / | -| \__ \ (_| (_) | | | __/> < | -| |___/\___\___/|_| \___/_/\_\ | -| | -|=================================| - -Welcome to scorex - a cli for S-CORE development! -`, -} - -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() { - err := rootCmd.Execute() - if err != nil { - os.Exit(1) - } -} - -func init() { - // Here you will define your flags and configuration settings. - // Cobra supports persistent flags, which, if defined here, - // will be global for your application. - - // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.scorex.yaml)") - - // Cobra also supports local flags, which will only run - // when this action is called directly. - rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") -} diff --git a/scorex/cmd/version.go b/scorex/cmd/version.go deleted file mode 100644 index b53f2c1..0000000 --- a/scorex/cmd/version.go +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ -package cmd - -import ( - "fmt" - - "github.com/spf13/cobra" -) - -// versionCmd represents the version command -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Print the version information", - Long: `Display version information for scorex CLI including version, git commit, and build date.`, - Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("scorex version %s\n", Version) - fmt.Printf("Git commit: %s\n", GitCommit) - fmt.Printf("Build date: %s\n", BuildDate) - }, -} - -func init() { - rootCmd.AddCommand(versionCmd) -} diff --git a/scorex/distribution/homebrew/scorex.rb b/scorex/distribution/homebrew/scorex.rb deleted file mode 100644 index 8cc6d54..0000000 --- a/scorex/distribution/homebrew/scorex.rb +++ /dev/null @@ -1,39 +0,0 @@ -class Scorex < Formula - desc "CLI for creating S-CORE skeleton projects" - homepage "https://github.com/eclipse-score/score_scrample" - version "0.1.0" - license "Apache-2.0" - - on_macos do - if Hardware::CPU.arm? - url "https://github.com/eclipse-score/score_scrample/releases/download/v#{version}/scorex-#{version}-macos-arm64.tar.gz" - sha256 "REPLACE_WITH_ACTUAL_SHA256_ARM64" - else - url "https://github.com/eclipse-score/score_scrample/releases/download/v#{version}/scorex-#{version}-macos-x86_64.tar.gz" - sha256 "REPLACE_WITH_ACTUAL_SHA256_X86_64" - end - end - - on_linux do - if Hardware::CPU.intel? - url "https://github.com/eclipse-score/score_scrample/releases/download/v#{version}/scorex-#{version}-linux-x86_64.tar.gz" - sha256 "REPLACE_WITH_ACTUAL_SHA256_LINUX" - end - end - - def install - if OS.mac? - if Hardware::CPU.arm? - bin.install "scorex-macos-arm64" => "scorex" - else - bin.install "scorex-macos-x86_64" => "scorex" - end - elsif OS.linux? - bin.install "scorex-linux-x86_64" => "scorex" - end - end - - test do - system "#{bin}/scorex", "version" - end -end diff --git a/scorex/distribution/install.sh b/scorex/distribution/install.sh deleted file mode 100755 index f941b60..0000000 --- a/scorex/distribution/install.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -# ******************************************************************************* -# 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 -# ******************************************************************************* -# -# scorex installer script -# Usage: curl -sSL https://raw.githubusercontent.com/eclipse-score/score_scrample/main/scorex/distribution/install.sh | sh -# - -set -e - -REPO="eclipse-score/score_scrample" -INSTALL_DIR="${SCOREX_INSTALL_DIR:-$HOME/.local/bin}" - -# Detect OS and architecture -detect_platform() { - OS=$(uname -s) - ARCH=$(uname -m) - - case "$OS" in - Linux) - case "$ARCH" in - x86_64) PLATFORM="linux-x86_64" ;; - *) echo "Unsupported architecture: $ARCH"; exit 1 ;; - esac - ;; - Darwin) - case "$ARCH" in - arm64) PLATFORM="macos-arm64" ;; - x86_64) PLATFORM="macos-x86_64" ;; - *) echo "Unsupported architecture: $ARCH"; exit 1 ;; - esac - ;; - *) - echo "Unsupported OS: $OS" - exit 1 - ;; - esac -} - -# Get latest release version -get_latest_version() { - VERSION=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') - if [ -z "$VERSION" ]; then - echo "Error: Could not fetch latest version" - exit 1 - fi - echo "Latest version: $VERSION" -} - -# Download and install -install_scorex() { - echo "Detecting platform..." - detect_platform - echo "Platform: $PLATFORM" - - echo "Fetching latest version..." - get_latest_version - - DOWNLOAD_URL="https://github.com/$REPO/releases/download/v$VERSION/scorex-$VERSION-$PLATFORM.tar.gz" - TEMP_DIR=$(mktemp -d) - - echo "Downloading scorex from $DOWNLOAD_URL..." - curl -sL "$DOWNLOAD_URL" | tar -xz -C "$TEMP_DIR" - - echo "Installing to $INSTALL_DIR..." - mkdir -p "$INSTALL_DIR" - - # Find the binary in temp dir - BINARY=$(find "$TEMP_DIR" -name "scorex-*" -type f | head -n 1) - if [ -z "$BINARY" ]; then - echo "Error: Binary not found in download" - rm -rf "$TEMP_DIR" - exit 1 - fi - - mv "$BINARY" "$INSTALL_DIR/scorex" - chmod +x "$INSTALL_DIR/scorex" - - rm -rf "$TEMP_DIR" - - echo "" - echo "✓ scorex $VERSION installed successfully!" - echo "" - echo "Make sure $INSTALL_DIR is in your PATH:" - echo " export PATH=\"$INSTALL_DIR:\$PATH\"" - echo "" - echo "Run 'scorex --help' to get started." -} - -install_scorex diff --git a/scorex/distribution/scoop/scorex.json b/scorex/distribution/scoop/scorex.json deleted file mode 100644 index d677207..0000000 --- a/scorex/distribution/scoop/scorex.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "version": "0.1.0", - "description": "CLI for creating S-CORE skeleton projects", - "homepage": "https://github.com/eclipse-score/score_scrample", - "license": "Apache-2.0", - "architecture": { - "64bit": { - "url": "https://github.com/eclipse-score/score_scrample/releases/download/v0.1.0/scorex-0.1.0-windows-x86_64.zip", - "hash": "REPLACE_WITH_ACTUAL_SHA256", - "bin": "scorex-windows-x86_64.exe" - } - }, - "checkver": { - "github": "https://github.com/eclipse-score/score_scrample" - }, - "autoupdate": { - "architecture": { - "64bit": { - "url": "https://github.com/eclipse-score/score_scrample/releases/download/v$version/scorex-$version-windows-x86_64.zip" - } - } - } -} diff --git a/scorex/go.mod b/scorex/go.mod deleted file mode 100644 index 55ccc8c..0000000 --- a/scorex/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module scorex - -go 1.23 - -require github.com/spf13/cobra v1.10.2 - -require ( - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/spf13/pflag v1.0.9 // indirect -) diff --git a/scorex/go.sum b/scorex/go.sum deleted file mode 100644 index a6ee3e0..0000000 --- a/scorex/go.sum +++ /dev/null @@ -1,10 +0,0 @@ -github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= -github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= -github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= -github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= -github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/scorex/internal/config/BUILD.bazel b/scorex/internal/config/BUILD.bazel deleted file mode 100644 index 3f27b2b..0000000 --- a/scorex/internal/config/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "config", - srcs = [ - "config.go", - "known_good.go", - "module_presets.go", - "project_config.go", - ], - embedsrcs = ["module_presets.json"], - importpath = "scorex/internal/config", - visibility = ["//scorex:__subpackages__"], - deps = [ - "//scorex/internal/model", - "//scorex/internal/service/knowngood", - ], -) diff --git a/scorex/internal/config/config.go b/scorex/internal/config/config.go deleted file mode 100644 index 97a7ea7..0000000 --- a/scorex/internal/config/config.go +++ /dev/null @@ -1,8 +0,0 @@ -package config - -const ( - DefaultProjectName = "score_app" - DefaultTargetDir = "." - DefaultKnownGoodURL = "https://raw.githubusercontent.com/eclipse-score/reference_integration/main/known_good.json" - DefaultBazelVersion = "8.3.0" -) diff --git a/scorex/internal/config/known_good.go b/scorex/internal/config/known_good.go deleted file mode 100644 index 48ec666..0000000 --- a/scorex/internal/config/known_good.go +++ /dev/null @@ -1,14 +0,0 @@ -package config - -import ( - "scorex/internal/model" - "scorex/internal/service/knowngood" -) - -// Deprecated: use scorex/internal/model.KnownGood and scorex/internal/service/knowngood.Load. -type KnownGood = model.KnownGood - -// Deprecated: use scorex/internal/service/knowngood.Load. -func LoadKnownGood(urlOrPath string) (*KnownGood, error) { - return knowngood.Load(urlOrPath) -} diff --git a/scorex/internal/config/module_presets.go b/scorex/internal/config/module_presets.go deleted file mode 100644 index 4f226d2..0000000 --- a/scorex/internal/config/module_presets.go +++ /dev/null @@ -1,132 +0,0 @@ -package config - -import ( - _ "embed" - "encoding/json" - "fmt" - "slices" - "strings" -) - -type ModulePreset struct { - ID string `json:"id"` - Label string `json:"label"` - ProjectType string `json:"projectType,omitempty"` - AppType string `json:"appType,omitempty"` - Modules []string `json:"modules"` -} - -type modulePresetFile struct { - Presets []ModulePreset `json:"presets"` -} - -//go:embed module_presets.json -var modulePresetsJSON []byte - -func LoadModulePresets() ([]ModulePreset, error) { - var f modulePresetFile - if err := json.Unmarshal(modulePresetsJSON, &f); err != nil { - return nil, fmt.Errorf("parsing embedded module presets: %w", err) - } - - seen := make(map[string]struct{}, len(f.Presets)) - for i := range f.Presets { - p := &f.Presets[i] - p.ID = strings.TrimSpace(p.ID) - p.Label = strings.TrimSpace(p.Label) - p.ProjectType = strings.TrimSpace(p.ProjectType) - p.AppType = strings.TrimSpace(p.AppType) - - if p.ID == "" { - return nil, fmt.Errorf("module preset missing id") - } - if _, ok := seen[p.ID]; ok { - return nil, fmt.Errorf("duplicate module preset id %q", p.ID) - } - seen[p.ID] = struct{}{} - - if p.Label == "" { - p.Label = p.ID - } - - // Normalize module names to the score_ prefix (consistent with module resolver). - for j := range p.Modules { - p.Modules[j] = normalizeModuleName(p.Modules[j]) - } - p.Modules = dedupeStrings(p.Modules) - } - - return f.Presets, nil -} - -func ApplicableModulePresets(all []ModulePreset, projectType, appType string) []ModulePreset { - var out []ModulePreset - for _, p := range all { - if p.ProjectType != "" && p.ProjectType != projectType { - continue - } - if p.AppType != "" && p.AppType != appType { - continue - } - out = append(out, p) - } - return out -} - -func FindModulePreset(all []ModulePreset, id string) (ModulePreset, bool) { - id = strings.TrimSpace(id) - for _, p := range all { - if p.ID == id { - return p, true - } - } - return ModulePreset{}, false -} - -func normalizeModuleName(name string) string { - name = strings.TrimSpace(name) - if name == "" { - return "" - } - if strings.HasPrefix(name, "score_") { - return name - } - return "score_" + name -} - -func dedupeStrings(in []string) []string { - seen := make(map[string]struct{}, len(in)) - out := make([]string, 0, len(in)) - for _, s := range in { - s = strings.TrimSpace(s) - if s == "" { - continue - } - if _, ok := seen[s]; ok { - continue - } - seen[s] = struct{}{} - out = append(out, s) - } - // Preserve stable output order: first occurrence wins. - return out -} - -func ValidateModulePresetUsage(modules []string, presetID string) error { - if presetID == "" { - return nil - } - if len(modules) > 0 { - return fmt.Errorf("--module and --module-preset are mutually exclusive") - } - return nil -} - -func KnownPresetIDs(all []ModulePreset) []string { - ids := make([]string, 0, len(all)) - for _, p := range all { - ids = append(ids, p.ID) - } - slices.Sort(ids) - return ids -} diff --git a/scorex/internal/config/module_presets.json b/scorex/internal/config/module_presets.json deleted file mode 100644 index 5f1d4e4..0000000 --- a/scorex/internal/config/module_presets.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "presets": [ - { - "id": "feo-standard", - "label": "FEO app (standard)", - "projectType": "Application", - "appType": "feo", - "modules": ["score_baselibs", "score_communication", "score_docs_as_code", "score_feo"] - }, - { - "id": "daal-standard", - "label": "DAAL app (standard)", - "projectType": "Application", - "appType": "daal", - "modules": ["score_baselibs", "score_communication", "score_inc_daal"] - } - ] -} diff --git a/scorex/internal/config/project_config.go b/scorex/internal/config/project_config.go deleted file mode 100644 index c0b676c..0000000 --- a/scorex/internal/config/project_config.go +++ /dev/null @@ -1,42 +0,0 @@ -package config - -import ( - "encoding/json" - "os" - "path/filepath" -) - -type ProjectConfig struct { - ProjectName string `json:"project_name"` - Template string `json:"template"` - BazelVersion string `json:"bazel_version"` - KnownGoodURL string `json:"known_good_url"` - Modules []string `json:"modules"` -} - -const DefaultConfigFileName = "scorex.json" - -func WriteProjectConfig(dir string, cfg *ProjectConfig) error { - if err := os.MkdirAll(dir, 0o755); err != nil { - return err - } - data, err := json.MarshalIndent(cfg, "", " ") - if err != nil { - return err - } - path := filepath.Join(dir, DefaultConfigFileName) - return os.WriteFile(path, data, 0o644) -} - -func ReadProjectConfig(dir string) (*ProjectConfig, error) { - path := filepath.Join(dir, DefaultConfigFileName) - data, err := os.ReadFile(path) - if err != nil { - return nil, err - } - var cfg ProjectConfig - if err := json.Unmarshal(data, &cfg); err != nil { - return nil, err - } - return &cfg, nil -} diff --git a/scorex/internal/model/BUILD.bazel b/scorex/internal/model/BUILD.bazel deleted file mode 100644 index 42f49a1..0000000 --- a/scorex/internal/model/BUILD.bazel +++ /dev/null @@ -1,23 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "model", - srcs = [ - "known_good.go", - "module.go", - ], - importpath = "scorex/internal/model", - visibility = ["//scorex:__subpackages__"], -) diff --git a/scorex/internal/model/known_good.go b/scorex/internal/model/known_good.go deleted file mode 100644 index 069c5ce..0000000 --- a/scorex/internal/model/known_good.go +++ /dev/null @@ -1,10 +0,0 @@ -package model - -// KnownGood represents the structure of known_good.json. -type KnownGood struct { - Timestamp string `json:"timestamp"` - Modules map[string]ModuleInfo `json:"modules"` - ManifestSHA256 string `json:"manifest_sha256"` - Suite string `json:"suite"` - DurationS int `json:"duration_s"` -} diff --git a/scorex/internal/model/module.go b/scorex/internal/model/module.go deleted file mode 100644 index 1f5e718..0000000 --- a/scorex/internal/model/module.go +++ /dev/null @@ -1,8 +0,0 @@ -package model - -type ModuleInfo struct { - Version string `json:"version"` - Hash string `json:"hash"` - Repo string `json:"repo"` - Branch string `json:"branch,omitempty"` -} diff --git a/scorex/internal/projectinit/BUILD.bazel b/scorex/internal/projectinit/BUILD.bazel deleted file mode 100644 index 1f06f1b..0000000 --- a/scorex/internal/projectinit/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "projectinit", - srcs = ["service.go"], - importpath = "scorex/internal/projectinit", - visibility = ["//scorex:__subpackages__"], - deps = ["//scorex/internal/service/projectinit"], -) diff --git a/scorex/internal/projectinit/service.go b/scorex/internal/projectinit/service.go deleted file mode 100644 index 3fbfc7f..0000000 --- a/scorex/internal/projectinit/service.go +++ /dev/null @@ -1,14 +0,0 @@ -package projectinit - -import serviceprojectinit "scorex/internal/service/projectinit" - -// Deprecated: use scorex/internal/service/projectinit.Options. -type Options = serviceprojectinit.Options - -// Deprecated: use scorex/internal/service/projectinit.Result. -type Result = serviceprojectinit.Result - -// Deprecated: use scorex/internal/service/projectinit.Run. -func Run(opts Options) (*Result, error) { - return serviceprojectinit.Run(opts) -} diff --git a/scorex/internal/service/knowngood/BUILD.bazel b/scorex/internal/service/knowngood/BUILD.bazel deleted file mode 100644 index 2991785..0000000 --- a/scorex/internal/service/knowngood/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "knowngood", - srcs = ["loader.go"], - importpath = "scorex/internal/service/knowngood", - visibility = ["//scorex:__subpackages__"], - deps = ["//scorex/internal/model"], -) diff --git a/scorex/internal/service/knowngood/loader.go b/scorex/internal/service/knowngood/loader.go deleted file mode 100644 index 54161aa..0000000 --- a/scorex/internal/service/knowngood/loader.go +++ /dev/null @@ -1,47 +0,0 @@ -package knowngood - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - "os" - "strings" - - "scorex/internal/model" -) - -// Load loads a KnownGood specification from a local file or HTTP(S) URL. -func Load(urlOrPath string) (*model.KnownGood, error) { - var data []byte - var err error - - if strings.HasPrefix(urlOrPath, "http://") || strings.HasPrefix(urlOrPath, "https://") { - resp, err := http.Get(urlOrPath) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("HTTP %s", resp.Status) - } - - data, err = io.ReadAll(resp.Body) - if err != nil { - return nil, err - } - } else { - data, err = os.ReadFile(urlOrPath) - if err != nil { - return nil, err - } - } - - var kg model.KnownGood - if err := json.Unmarshal(data, &kg); err != nil { - return nil, err - } - - return &kg, nil -} diff --git a/scorex/internal/service/module/BUILD.bazel b/scorex/internal/service/module/BUILD.bazel deleted file mode 100644 index 5a89ddf..0000000 --- a/scorex/internal/service/module/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "module", - srcs = ["resolver.go"], - importpath = "scorex/internal/service/module", - visibility = ["//scorex:__subpackages__"], - deps = ["//scorex/internal/model"], -) diff --git a/scorex/internal/service/module/resolver.go b/scorex/internal/service/module/resolver.go deleted file mode 100644 index dbc8d6a..0000000 --- a/scorex/internal/service/module/resolver.go +++ /dev/null @@ -1,97 +0,0 @@ -package module - -import ( - "encoding/json" - "fmt" - "net/http" - "strings" - "time" - - "scorex/internal/model" -) - -// ResolveModuleWithFallback tries to resolve a module from knownGood. -// If not present, it falls back to GitHub "latest release" for the given repo name. -func ResolveModuleWithFallback( - name string, - knownGood map[string]model.ModuleInfo, -) (model.ModuleInfo, error) { - if mi, ok := knownGood[name]; ok { - return mi, nil - } - - repoName := strings.TrimPrefix(name, "score_") - - // Fallback: neuester Commit auf main von GitHub - latestCommit, err := fetchLatestGithubMainCommit("eclipse-score", repoName) - if err != nil { - return model.ModuleInfo{}, fmt.Errorf( - "module %q not in known_good and GitHub lookup failed: %w", - name, err, - ) - } - - mi := model.ModuleInfo{ - Version: "0.1.0", //TODO get correct version number - Hash: latestCommit, - Repo: fmt.Sprintf("https://github.com/eclipse-score/%s.git", repoName), - Branch: "main", - } - - return mi, nil -} - -// ResolveModules resolves a list of module names against the known-good set, -// automatically prefixing names with "score_" when missing and falling back -// to GitHub if a module is not present in known_good. -func ResolveModules( - modules []string, - knownGood map[string]model.ModuleInfo, -) (map[string]model.ModuleInfo, error) { - selected := make(map[string]model.ModuleInfo, len(modules)) - - for _, name := range modules { - moduleName := name - if !strings.HasPrefix(moduleName, "score_") { - moduleName = "score_" + moduleName - } - - mi, err := ResolveModuleWithFallback(moduleName, knownGood) - if err != nil { - return nil, fmt.Errorf("resolving module %q failed: %w", moduleName, err) - } - selected[moduleName] = mi - } - - return selected, nil -} - -func fetchLatestGithubMainCommit(owner, repo string) (string, error) { - url := fmt.Sprintf("https://api.github.com/repos/%s/%s/commits/main", owner, repo) - - client := http.Client{ - Timeout: 5 * time.Second, - } - - resp, err := client.Get(url) - if err != nil { - return "", err - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return "", fmt.Errorf("unexpected status %d from GitHub", resp.StatusCode) - } - - var payload struct { - SHA string `json:"sha"` - } - if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil { - return "", err - } - - if payload.SHA == "" { - return "", fmt.Errorf("no sha in GitHub response") - } - return payload.SHA, nil -} diff --git a/scorex/internal/service/projectinit/BUILD.bazel b/scorex/internal/service/projectinit/BUILD.bazel deleted file mode 100644 index 1d63e5f..0000000 --- a/scorex/internal/service/projectinit/BUILD.bazel +++ /dev/null @@ -1,27 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "projectinit", - srcs = ["service.go"], - importpath = "scorex/internal/service/projectinit", - visibility = ["//scorex:__subpackages__"], - deps = [ - "//scorex/internal/config", - "//scorex/internal/model", - "//scorex/internal/service/knowngood", - "//scorex/internal/service/module", - "//scorex/internal/service/skeleton", - ], -) diff --git a/scorex/internal/service/projectinit/service.go b/scorex/internal/service/projectinit/service.go deleted file mode 100644 index 2db9d68..0000000 --- a/scorex/internal/service/projectinit/service.go +++ /dev/null @@ -1,94 +0,0 @@ -package projectinit - -import ( - "fmt" - "path/filepath" - - "scorex/internal/config" - "scorex/internal/model" - "scorex/internal/service/knowngood" - "scorex/internal/service/module" - "scorex/internal/service/skeleton" -) - -// Options represents all inputs required to initialize a new project. -type Options struct { - Modules []string - TargetDir string - Name string - KnownGoodURL string - BazelVersion string - ProjectType string // "Application" or "Module" - AppType string // "feo" or "daal" - IncludeDevcontainer bool -} - -// Result contains information about the generated project. -type Result struct { - TargetDir string - SelectedModules map[string]model.ModuleInfo -} - -// Run performs the full project initialization flow based on the provided options. -func Run(opts Options) (*Result, error) { - if len(opts.Modules) == 0 { - return nil, fmt.Errorf("at least one module must be set") - } - - kg, err := knowngood.Load(opts.KnownGoodURL) - if err != nil { - return nil, fmt.Errorf("error loading known_good.json: %w", err) - } - - selected, err := module.ResolveModules(opts.Modules, kg.Modules) - if err != nil { - return nil, err - } - - targetDir := filepath.Join(opts.TargetDir, opts.Name) - - props := skeleton.Properties{ - ProjectName: opts.Name, - SelectedModules: selected, - BazelVersion: opts.BazelVersion, - TargetDir: targetDir, - IsApplication: opts.ProjectType == "Application", - UseFeo: opts.AppType == "feo", - IncludeDevcontainer: opts.IncludeDevcontainer, - } - - if err := skeleton.Generate(props); err != nil { - return nil, err - } - - cfg := &config.ProjectConfig{ - ProjectName: opts.Name, - Template: templateFor(opts.ProjectType, opts.AppType), - BazelVersion: opts.BazelVersion, - KnownGoodURL: opts.KnownGoodURL, - Modules: opts.Modules, - } - - if err := config.WriteProjectConfig(targetDir, cfg); err != nil { - return nil, fmt.Errorf("writing scorex config: %w", err) - } - - return &Result{ - TargetDir: targetDir, - SelectedModules: selected, - }, nil -} - -func templateFor(projectType, appType string) string { - if projectType != "Application" { - return "module" - } - switch appType { - case "feo": - return "feo_app" - case "daal", "": - return "daal_app" - default: - return "daal_app" - } -} diff --git a/scorex/internal/service/skeleton/BUILD.bazel b/scorex/internal/service/skeleton/BUILD.bazel deleted file mode 100644 index c5637b0..0000000 --- a/scorex/internal/service/skeleton/BUILD.bazel +++ /dev/null @@ -1,27 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "skeleton", - srcs = [ - "generator.go", - "properties.go", - ], - importpath = "scorex/internal/service/skeleton", - visibility = ["//scorex:__subpackages__"], - deps = [ - "//scorex/internal/model", - "//scorex/internal/templates", - ], -) diff --git a/scorex/internal/service/skeleton/generator.go b/scorex/internal/service/skeleton/generator.go deleted file mode 100644 index 20befcc..0000000 --- a/scorex/internal/service/skeleton/generator.go +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ -package skeleton - -import ( - "io/fs" - "os" - "path/filepath" - "strings" - "text/template" - - templatesfs "scorex/internal/templates" -) - -type moduleTemplateData struct { - ProjectName string - SelectedModules map[string]any - BazelVersion string -} - -func renderTemplate(tmplPath, dstPath string, data any) error { - if err := os.MkdirAll(filepath.Dir(dstPath), 0o755); err != nil { - return err - } - - t, err := template.ParseFS(templatesfs.FS, tmplPath) - if err != nil { - return err - } - - f, err := os.Create(dstPath) - if err != nil { - return err - } - defer f.Close() - - return t.Execute(f, data) -} - -func undotifyPath(rel string) string { - // Work in slash-form, rewrite each segment, then convert back. - parts := strings.Split(filepath.ToSlash(rel), "/") - for i, p := range parts { - if strings.HasPrefix(p, "point.") { - parts[i] = "." + strings.TrimPrefix(p, "point.") - } - } - return filepath.FromSlash(strings.Join(parts, "/")) -} - -// Generate creates a project skeleton based on the provided properties. -func Generate(props Properties) error { - targetDir := props.TargetDir - - if err := os.MkdirAll(targetDir, 0o755); err != nil { - return err - } - - data := moduleTemplateData{ - ProjectName: props.ProjectName, - SelectedModules: toAnyMap(props.SelectedModules), - BazelVersion: props.BazelVersion, - } - - templatePath := "module" - - if props.IsApplication { - if props.UseFeo { - templatePath = filepath.Join("application", "feo_app") - } else { - templatePath = filepath.Join("application", "daal_app") - } - } - - err := fs.WalkDir(templatesfs.FS, templatePath, func(path string, d fs.DirEntry, err error) error { - if err != nil { - return err - } - if d.IsDir() { - return nil - } - if !strings.HasSuffix(path, ".tmpl") { - return nil - } - - rel, err := filepath.Rel(templatePath, path) - if err != nil { - return err - } - - // Optional: only include .devcontainer when requested. - slashRel := filepath.ToSlash(rel) - if !props.IncludeDevcontainer && strings.HasPrefix(slashRel, "point.devcontainer/") { - return nil - } - - outRel := strings.TrimSuffix(rel, ".tmpl") - outRel = undotifyPath(outRel) - - base := filepath.Base(outRel) - if strings.HasPrefix(base, "point.") { - dir := filepath.Dir(outRel) - base = "." + strings.TrimPrefix(base, "point.") - outRel = filepath.Join(dir, base) - } - - dstPath := filepath.Join(targetDir, outRel) - return renderTemplate(path, dstPath, data) - }) - if err != nil { - return err - } - - return nil -} - -func toAnyMap[T any](in map[string]T) map[string]any { - out := make(map[string]any, len(in)) - for k, v := range in { - out[k] = v - } - return out -} diff --git a/scorex/internal/service/skeleton/properties.go b/scorex/internal/service/skeleton/properties.go deleted file mode 100644 index e00b5d2..0000000 --- a/scorex/internal/service/skeleton/properties.go +++ /dev/null @@ -1,14 +0,0 @@ -package skeleton - -import "scorex/internal/model" - -// Properties holds all data required to render a project skeleton. -type Properties struct { - ProjectName string - SelectedModules map[string]model.ModuleInfo - BazelVersion string - TargetDir string - IsApplication bool - UseFeo bool - IncludeDevcontainer bool -} diff --git a/scorex/internal/skeleton/BUILD.bazel b/scorex/internal/skeleton/BUILD.bazel deleted file mode 100644 index 65fa0b0..0000000 --- a/scorex/internal/skeleton/BUILD.bazel +++ /dev/null @@ -1,24 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "skeleton", - srcs = [ - "generator.go", - "properties.go", - ], - importpath = "scorex/internal/skeleton", - visibility = ["//scorex:__subpackages__"], - deps = ["//scorex/internal/service/skeleton"], -) diff --git a/scorex/internal/skeleton/generator.go b/scorex/internal/skeleton/generator.go deleted file mode 100644 index 7bc5bc1..0000000 --- a/scorex/internal/skeleton/generator.go +++ /dev/null @@ -1,8 +0,0 @@ -package skeleton - -import serviceskeleton "scorex/internal/service/skeleton" - -// Deprecated: use scorex/internal/service/skeleton.Generate. -func Generate(props Properties) error { - return serviceskeleton.Generate(props) -} diff --git a/scorex/internal/skeleton/properties.go b/scorex/internal/skeleton/properties.go deleted file mode 100644 index 1574288..0000000 --- a/scorex/internal/skeleton/properties.go +++ /dev/null @@ -1,6 +0,0 @@ -package skeleton - -import serviceskeleton "scorex/internal/service/skeleton" - -// Deprecated: use scorex/internal/service/skeleton.Properties. -type Properties = serviceskeleton.Properties diff --git a/scorex/internal/templates/BUILD.bazel b/scorex/internal/templates/BUILD.bazel deleted file mode 100644 index 54ffcf6..0000000 --- a/scorex/internal/templates/BUILD.bazel +++ /dev/null @@ -1,47 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "templates", - srcs = ["fs.go"], - embedsrcs = [ - "application/daal_app/BUILD.tmpl", - "application/daal_app/MODULE.bazel.tmpl", - "application/daal_app/point.bazelrc.tmpl", - "application/daal_app/point.bazelversion.tmpl", - "application/daal_app/point.devcontainer/devcontainer.json.tmpl", - "application/daal_app/point.devcontainer/prepare_workspace.sh.tmpl", - "application/daal_app/src/BUILD.tmpl", - "application/daal_app/src/hello_world_app.hpp.tmpl", - "application/daal_app/src/main.cpp.tmpl", - "application/feo_app/BUILD.tmpl", - "application/feo_app/MODULE.bazel.tmpl", - "application/feo_app/point.bazelrc.tmpl", - "application/feo_app/point.bazelversion.tmpl", - "application/feo_app/point.devcontainer/devcontainer.json.tmpl", - "application/feo_app/point.devcontainer/prepare_workspace.sh.tmpl", - "application/feo_app/src/BUILD.tmpl", - "application/feo_app/src/hello_world.rs.tmpl", - "module/BUILD.tmpl", - "module/MODULE.bazel.tmpl", - "module/point.bazelrc.tmpl", - "module/point.bazelversion.tmpl", - "module/point.devcontainer/devcontainer.json.tmpl", - "module/point.devcontainer/prepare_workspace.sh.tmpl", - "module/src/BUILD.tmpl", - "module/src/main.cpp.tmpl", - ], - importpath = "scorex/internal/templates", - visibility = ["//scorex:__subpackages__"], -) diff --git a/scorex/internal/templates/application/daal_app/BUILD.tmpl b/scorex/internal/templates/application/daal_app/BUILD.tmpl deleted file mode 100644 index e69de29..0000000 diff --git a/scorex/internal/templates/application/daal_app/MODULE.bazel.tmpl b/scorex/internal/templates/application/daal_app/MODULE.bazel.tmpl deleted file mode 100644 index 20bdd00..0000000 --- a/scorex/internal/templates/application/daal_app/MODULE.bazel.tmpl +++ /dev/null @@ -1,41 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* -module( - name = "{{ .ProjectName }}", - version = "0.0.1", -) - -bazel_dep(name = "trlc") -git_override( - module_name = "trlc", - remote = "https://github.com/bmw-software-engineering/trlc.git", - commit = "650b51a47264a4f232b3341f473527710fc32669", # trlc-2.0.2 release -) - -# C/C++ rules for Bazel -bazel_dep(name = "rules_cc", version = "0.2.1") - -{{ range $name, $m := .SelectedModules }} -# {{ $name }} -bazel_dep( - name = "{{ $name }}", - version = "{{ $m.Version }}", -) - -git_override( - module_name = "{{ $name }}", - remote = "{{ $m.Repo }}", - commit = "{{ $m.Hash }}", -) - -{{ end }} \ No newline at end of file diff --git a/scorex/internal/templates/application/daal_app/point.bazelversion.tmpl b/scorex/internal/templates/application/daal_app/point.bazelversion.tmpl deleted file mode 100644 index 3905b2b..0000000 --- a/scorex/internal/templates/application/daal_app/point.bazelversion.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{ .BazelVersion }} diff --git a/scorex/internal/templates/application/daal_app/point.devcontainer/devcontainer.json.tmpl b/scorex/internal/templates/application/daal_app/point.devcontainer/devcontainer.json.tmpl deleted file mode 100644 index cfef9e4..0000000 --- a/scorex/internal/templates/application/daal_app/point.devcontainer/devcontainer.json.tmpl +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "eclipse-s-core", - "image": "ghcr.io/eclipse-score/devcontainer:v1.1.0", - "postCreateCommand": "bash .devcontainer/prepare_workspace.sh", - "postStartCommand": "ssh-keygen -f '/home/vscode/.ssh/known_hosts' -R '[localhost]:2222' || true" -} diff --git a/scorex/internal/templates/application/daal_app/point.devcontainer/prepare_workspace.sh.tmpl b/scorex/internal/templates/application/daal_app/point.devcontainer/prepare_workspace.sh.tmpl deleted file mode 100644 index 0da37bc..0000000 --- a/scorex/internal/templates/application/daal_app/point.devcontainer/prepare_workspace.sh.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Install pipx -sudo apt update -sudo apt install -y pipx - -# Install gita -pipx install gita - -# Enable bash autocompletion for gita -echo "eval \"\$(register-python-argcomplete gita -s bash)\"" >> ~/.bashrc - -# Set GITA_PROJECT_HOME environment variable -echo "export GITA_PROJECT_HOME=$(pwd)/.gita" >> ~/.bashrc -GITA_PROJECT_HOME=$(pwd)/.gita -mkdir -p "$GITA_PROJECT_HOME" -export GITA_PROJECT_HOME \ No newline at end of file diff --git a/scorex/internal/templates/application/daal_app/src/BUILD.tmpl b/scorex/internal/templates/application/daal_app/src/BUILD.tmpl deleted file mode 100644 index 38bb2cd..0000000 --- a/scorex/internal/templates/application/daal_app/src/BUILD.tmpl +++ /dev/null @@ -1,29 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* - -cc_binary( - name = "af_hello_world", - srcs = [ - "hello_world_app.hpp", - "main.cpp", - ], - deps = [ - "@score_inc_daal//src:daal_app_executor_builder", - "@score_inc_daal//src:daal_app_handler_singleshot", - "@score_inc_daal//src:daal_checkpoint", - "@score_inc_daal//src:daal_logger", - "@score_inc_daal//src:daal_os_helper", - "@score_inc_daal//src:daal_trigger", - "@score_inc_daal//src:dummy_execution_environment", - ], -) \ No newline at end of file diff --git a/scorex/internal/templates/application/daal_app/src/hello_world_app.hpp.tmpl b/scorex/internal/templates/application/daal_app/src/hello_world_app.hpp.tmpl deleted file mode 100644 index ce07c7d..0000000 --- a/scorex/internal/templates/application/daal_app/src/hello_world_app.hpp.tmpl +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ - -#include "daal/af/app_base/safe_application_base.hpp" -#include "daal/log/logger.hpp" - -namespace daal { -namespace {{ .ProjectName }} { - -class HelloWorldApp : public daal::af::app_base::SafeApplicationBase { - public: - HelloWorldApp() : logger_(std::make_shared("APP")) { logger_->AddDefaultSinks(); }; - ~HelloWorldApp() override = default; - - daal::af::app_base::MethodState OnInitialize() override { return daal::af::app_base::MethodState::kSuccessful; } - - daal::af::app_base::MethodState OnStart() override { return daal::af::app_base::MethodState::kSuccessful; } - - daal::af::app_base::MethodState Step() override { - static unsigned int cycle_counter = 0; - - logger_->Info("step #{}", cycle_counter); - cycle_counter++; - - return daal::af::app_base::MethodState::kSuccessful; - } - - daal::af::app_base::MethodState OnStop() override { return daal::af::app_base::MethodState::kSuccessful; } - - daal::af::app_base::MethodState OnTerminate() override { return daal::af::app_base::MethodState::kSuccessful; } - - private: - std::shared_ptr logger_; -}; - -} // namespace {{ .ProjectName }} -} // namespace daal diff --git a/scorex/internal/templates/application/daal_app/src/main.cpp.tmpl b/scorex/internal/templates/application/daal_app/src/main.cpp.tmpl deleted file mode 100644 index 5902e77..0000000 --- a/scorex/internal/templates/application/daal_app/src/main.cpp.tmpl +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ - -#include - -#include "daal/af/app_handler/details/single_shot_app_handler.hpp" -#include "daal/af/checkpoint/details/checkpoint_container.hpp" -#include "daal/af/env/details/dummy_exec_env.hpp" -#include "daal/af/exe/builder/executor_builder.hpp" -#include "daal/af/os/details/posix_helper_impl.hpp" -#include "daal/af/trigger/details/trigger_impl.hpp" -#include "daal/log/logger.hpp" -#include "hello_world_app.hpp" -using namespace std::chrono_literals; - -int main() { - auto logger = std::make_shared("MAIN"); - logger->AddDefaultSinks(); - - logger->Info("Starting DAAL hello-world application"); - - // (1) create the application - // (2) create the application handler (SingleShotAppHandler => we can run only one application) - auto my_app = std::make_shared(); - std::unique_ptr app_handler = - std::make_unique(my_app); - - // (3) create the executor with environment, scheduling/trigger and optional checkpoints - // here: a dummy environment, the AppHandler is called every 100ms and no checkpoints - auto exe = daal::af::exe::ExecutorBuilder() - .SetExecutionEnvironment(std::make_unique()) - .SetPosixHelper(std::make_unique()) - .SetTrigger(std::make_unique(500ms)) - .SetCheckpointContainer(std::make_unique()) - .Start() - .End() - .Build(); - - // (4) finalize the initialization of the exectuor - exe->Init(); - exe->SetApplicationHandler(std::move(app_handler)); - - // (5) run the executor (= application) until it's terminated - bool ret = exe->Run(); - if (ret) { - logger->Info("Application finished successfully"); - } else { - logger->Error("Application finished with an error"); - } - - return ret ? 0 : -1; -} diff --git a/scorex/internal/templates/application/feo_app/BUILD.tmpl b/scorex/internal/templates/application/feo_app/BUILD.tmpl deleted file mode 100644 index e69de29..0000000 diff --git a/scorex/internal/templates/application/feo_app/MODULE.bazel.tmpl b/scorex/internal/templates/application/feo_app/MODULE.bazel.tmpl deleted file mode 100644 index da914ac..0000000 --- a/scorex/internal/templates/application/feo_app/MODULE.bazel.tmpl +++ /dev/null @@ -1,52 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* -module( - name = "{{ .ProjectName }}", - version = "0.0.1", -) - -bazel_dep(name = "rules_boost", repo_name = "com_github_nelhage_rules_boost") -archive_override( - module_name = "rules_boost", - strip_prefix = "rules_boost-master", - urls = ["https://github.com/nelhage/rules_boost/archive/refs/heads/master.tar.gz"], -) - -# Rust rules for Bazel -bazel_dep(name = "rules_rust", version = "0.67.0") -bazel_dep(name = "rules_rust_prost", version = "0.67.0") - -# C/C++ rules for Bazel -bazel_dep(name = "rules_cc", version = "0.2.8") - -bazel_dep(name = "trlc") -git_override( - module_name = "trlc", - remote = "https://github.com/bmw-software-engineering/trlc.git", - commit = "650b51a47264a4f232b3341f473527710fc32669", # trlc-2.0.2 release -) - -{{ range $name, $m := .SelectedModules }} -# {{ $name }} -bazel_dep( - name = "{{ $name }}", - version = "{{ $m.Version }}", -) - -git_override( - module_name = "{{ $name }}", - remote = "{{ $m.Repo }}", - commit = "{{ $m.Hash }}", -) - -{{ end }} \ No newline at end of file diff --git a/scorex/internal/templates/application/feo_app/point.bazelrc.tmpl b/scorex/internal/templates/application/feo_app/point.bazelrc.tmpl deleted file mode 100644 index f693141..0000000 --- a/scorex/internal/templates/application/feo_app/point.bazelrc.tmpl +++ /dev/null @@ -1,15 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* - -common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ -common --registry=https://bcr.bazel.build diff --git a/scorex/internal/templates/application/feo_app/point.bazelversion.tmpl b/scorex/internal/templates/application/feo_app/point.bazelversion.tmpl deleted file mode 100644 index 3905b2b..0000000 --- a/scorex/internal/templates/application/feo_app/point.bazelversion.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{ .BazelVersion }} diff --git a/scorex/internal/templates/application/feo_app/point.devcontainer/devcontainer.json.tmpl b/scorex/internal/templates/application/feo_app/point.devcontainer/devcontainer.json.tmpl deleted file mode 100644 index cfef9e4..0000000 --- a/scorex/internal/templates/application/feo_app/point.devcontainer/devcontainer.json.tmpl +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "eclipse-s-core", - "image": "ghcr.io/eclipse-score/devcontainer:v1.1.0", - "postCreateCommand": "bash .devcontainer/prepare_workspace.sh", - "postStartCommand": "ssh-keygen -f '/home/vscode/.ssh/known_hosts' -R '[localhost]:2222' || true" -} diff --git a/scorex/internal/templates/application/feo_app/point.devcontainer/prepare_workspace.sh.tmpl b/scorex/internal/templates/application/feo_app/point.devcontainer/prepare_workspace.sh.tmpl deleted file mode 100644 index 0da37bc..0000000 --- a/scorex/internal/templates/application/feo_app/point.devcontainer/prepare_workspace.sh.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Install pipx -sudo apt update -sudo apt install -y pipx - -# Install gita -pipx install gita - -# Enable bash autocompletion for gita -echo "eval \"\$(register-python-argcomplete gita -s bash)\"" >> ~/.bashrc - -# Set GITA_PROJECT_HOME environment variable -echo "export GITA_PROJECT_HOME=$(pwd)/.gita" >> ~/.bashrc -GITA_PROJECT_HOME=$(pwd)/.gita -mkdir -p "$GITA_PROJECT_HOME" -export GITA_PROJECT_HOME \ No newline at end of file diff --git a/scorex/internal/templates/application/feo_app/src/hello_world.rs.tmpl b/scorex/internal/templates/application/feo_app/src/hello_world.rs.tmpl deleted file mode 100644 index ed08113..0000000 --- a/scorex/internal/templates/application/feo_app/src/hello_world.rs.tmpl +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * 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 - ********************************************************************************/ - -use feo::ids::AgentId; -use feo_log::{info, LevelFilter}; -use feo_time::Duration; - -const AGENT_ID: AgentId = AgentId::new(100); -const DEFAULT_FEO_CYCLE_TIME: Duration = Duration::from_secs(1); - -fn main() { - // initialize logging & tracing - feo_logger::init(LevelFilter::Info, true, true); - feo_tracing::init(feo_tracing::LevelFilter::INFO); - - info!( - "Hello FEO from agent {AGENT_ID}, default cycle time = {:?}", - DEFAULT_FEO_CYCLE_TIME - ); -} \ No newline at end of file diff --git a/scorex/internal/templates/fs.go b/scorex/internal/templates/fs.go deleted file mode 100644 index 444ce65..0000000 --- a/scorex/internal/templates/fs.go +++ /dev/null @@ -1,7 +0,0 @@ -package templates - -import "embed" - -// FS embeds all template files under internal/templates. -//go:embed application/** module/** -var FS embed.FS diff --git a/scorex/internal/templates/module/BUILD.tmpl b/scorex/internal/templates/module/BUILD.tmpl deleted file mode 100644 index e69de29..0000000 diff --git a/scorex/internal/templates/module/MODULE.bazel.tmpl b/scorex/internal/templates/module/MODULE.bazel.tmpl deleted file mode 100644 index ea0378a..0000000 --- a/scorex/internal/templates/module/MODULE.bazel.tmpl +++ /dev/null @@ -1,38 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* -module( - name = "{{ .ProjectName }}", - version = "0.0.1", -) - -bazel_dep(name = "rules_cc", version = "0.0.9") - -bazel_dep(name = "trlc") -git_override( - module_name = "trlc", - remote = "https://github.com/bmw-software-engineering/trlc.git", - commit = "650b51a47264a4f232b3341f473527710fc32669", # trlc-2.0.2 release -) - -{{ range $name, $m := .SelectedModules }} -bazel_dep( - name = "{{ $name }}", - version = "{{ $m.Version }}", -) - -git_override( - module_name = "{{ $name }}", - remote = "{{ $m.Repo }}", - commit = "{{ $m.Hash }}", -) -{{ end }} diff --git a/scorex/internal/templates/module/point.bazelrc.tmpl b/scorex/internal/templates/module/point.bazelrc.tmpl deleted file mode 100644 index f693141..0000000 --- a/scorex/internal/templates/module/point.bazelrc.tmpl +++ /dev/null @@ -1,15 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* - -common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ -common --registry=https://bcr.bazel.build diff --git a/scorex/internal/templates/module/point.bazelversion.tmpl b/scorex/internal/templates/module/point.bazelversion.tmpl deleted file mode 100644 index 3905b2b..0000000 --- a/scorex/internal/templates/module/point.bazelversion.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{ .BazelVersion }} diff --git a/scorex/internal/templates/module/point.devcontainer/devcontainer.json.tmpl b/scorex/internal/templates/module/point.devcontainer/devcontainer.json.tmpl deleted file mode 100644 index cfef9e4..0000000 --- a/scorex/internal/templates/module/point.devcontainer/devcontainer.json.tmpl +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "eclipse-s-core", - "image": "ghcr.io/eclipse-score/devcontainer:v1.1.0", - "postCreateCommand": "bash .devcontainer/prepare_workspace.sh", - "postStartCommand": "ssh-keygen -f '/home/vscode/.ssh/known_hosts' -R '[localhost]:2222' || true" -} diff --git a/scorex/internal/templates/module/point.devcontainer/prepare_workspace.sh.tmpl b/scorex/internal/templates/module/point.devcontainer/prepare_workspace.sh.tmpl deleted file mode 100644 index 0da37bc..0000000 --- a/scorex/internal/templates/module/point.devcontainer/prepare_workspace.sh.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Install pipx -sudo apt update -sudo apt install -y pipx - -# Install gita -pipx install gita - -# Enable bash autocompletion for gita -echo "eval \"\$(register-python-argcomplete gita -s bash)\"" >> ~/.bashrc - -# Set GITA_PROJECT_HOME environment variable -echo "export GITA_PROJECT_HOME=$(pwd)/.gita" >> ~/.bashrc -GITA_PROJECT_HOME=$(pwd)/.gita -mkdir -p "$GITA_PROJECT_HOME" -export GITA_PROJECT_HOME \ No newline at end of file diff --git a/scorex/internal/templates/module/src/main.cpp.tmpl b/scorex/internal/templates/module/src/main.cpp.tmpl deleted file mode 100644 index 98e1250..0000000 --- a/scorex/internal/templates/module/src/main.cpp.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ -#include -#include - -int main() -{ - std::cout << "Hello World!" << std::endl; - return 0; -} diff --git a/scorex/internal/utils/BUILD.bazel b/scorex/internal/utils/BUILD.bazel deleted file mode 100644 index 5b2b315..0000000 --- a/scorex/internal/utils/BUILD.bazel +++ /dev/null @@ -1,28 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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_go//go:def.bzl", "go_library") - -go_library( - name = "utils", - srcs = [ - "module_resolver.go", - "skeleton_properties.go", - ], - importpath = "scorex/internal/utils", - visibility = ["//scorex:__subpackages__"], - deps = [ - "//scorex/internal/model", - "//scorex/internal/service/module", - "//scorex/internal/service/skeleton", - ], -) diff --git a/scorex/internal/utils/module_resolver.go b/scorex/internal/utils/module_resolver.go deleted file mode 100644 index f301d23..0000000 --- a/scorex/internal/utils/module_resolver.go +++ /dev/null @@ -1,16 +0,0 @@ -package utils - -import ( - "scorex/internal/model" - "scorex/internal/service/module" -) - -// Deprecated: use scorex/internal/service/module.ResolveModuleWithFallback. -func ResolveModuleWithFallback(name string, knownGood map[string]model.ModuleInfo) (model.ModuleInfo, error) { - return module.ResolveModuleWithFallback(name, knownGood) -} - -// Deprecated: use scorex/internal/service/module.ResolveModules. -func ResolveModules(modules []string, knownGood map[string]model.ModuleInfo) (map[string]model.ModuleInfo, error) { - return module.ResolveModules(modules, knownGood) -} \ No newline at end of file diff --git a/scorex/internal/utils/skeleton_properties.go b/scorex/internal/utils/skeleton_properties.go deleted file mode 100644 index a58a8e4..0000000 --- a/scorex/internal/utils/skeleton_properties.go +++ /dev/null @@ -1,6 +0,0 @@ -package utils - -import "scorex/internal/service/skeleton" - -// Deprecated: use scorex/internal/service/skeleton.Properties. -type SkeletonProperties = skeleton.Properties \ No newline at end of file diff --git a/scorex/main.go b/scorex/main.go deleted file mode 100644 index 9a6ef68..0000000 --- a/scorex/main.go +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************** -* 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 -********************************************************************************/ -package main - -import "scorex/cmd" - -func main() { - cmd.Execute() -} diff --git a/src/BUILD b/src/BUILD deleted file mode 100644 index 6180746..0000000 --- a/src/BUILD +++ /dev/null @@ -1,57 +0,0 @@ -# ******************************************************************************* -# 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 -# ******************************************************************************* -cc_binary( - name = "scrample", - srcs = [ - "assert_handler.cpp", - "assert_handler.h", - "main.cpp", - ], - visibility = ["//visibility:public"], - deps = [ - ":sample_sender_receiver", - "@boost.program_options", - "@score_baselibs//score/language/futurecpp", - "@score_communication//score/mw/com", - "@score_logging//score/mw/log", - ], -) - -cc_library( - name = "sample_sender_receiver", - srcs = [ - "sample_sender_receiver.cpp", - ], - hdrs = [ - "sample_sender_receiver.h", - ], - deps = [ - ":datatype", - "@score_baselibs//score/mw/log:frontend", - "@score_communication//score/mw/com", - ], -) - -cc_library( - name = "datatype", - srcs = [ - "datatype.cpp", - ], - hdrs = [ - "datatype.h", - ], - deps = [ - "@score_baselibs//score/language/futurecpp", - "@score_communication//score/mw/com", - ], -) diff --git a/src/assert_handler.cpp b/src/assert_handler.cpp deleted file mode 100644 index 0c8c3c5..0000000 --- a/src/assert_handler.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 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 - ********************************************************************************/ - -#include "assert_handler.h" - -#include "score/mw/log/logging.h" - -#include -#include -#include -#include -#include - -namespace score::mw::com -{ - -namespace -{ - -void assert_handler(const score::cpp::handler_parameters& params) -{ - std::cerr << "Assertion \"" << params.condition << "\" failed"; - if (params.message != nullptr) - { - std::cerr << ": " << params.message; - } - std::cerr << " (" << params.file << ':' << params.line << ")" << std::endl; - std::cerr.flush(); - - score::mw::log::LogFatal("AsHa") << params.condition << params.message << params.file << params.line; - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - - const char* const no_abort = std::getenv("ASSERT_NO_CORE"); - if (no_abort != nullptr) - { - std::cerr << "Would not coredump on \"" << no_abort << "\"" << std::endl; - if (std::strcmp(no_abort, params.condition) == 0) - { - std::cerr << "... matched." << std::endl; - std::cerr.flush(); - std::quick_exit(1); - } - std::cerr << "... not matched." << std::endl; - } - std::cerr.flush(); -} - -} // namespace - -void SetupAssertHandler() -{ - score::cpp::set_assertion_handler(assert_handler); - // in addition, delay the calls to std::terminate() till the datarouter is able to read the logs - std::set_terminate([]() { - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - std::abort(); - }); -} - -} // namespace score::mw::com diff --git a/src/assert_handler.h b/src/assert_handler.h deleted file mode 100644 index 086fc25..0000000 --- a/src/assert_handler.h +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 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 - ********************************************************************************/ - -#ifndef SCORE_MW_IPC_BRIDGE_ASSERTHANDLER_H -#define SCORE_MW_IPC_BRIDGE_ASSERTHANDLER_H - -namespace score::mw::com -{ - -void SetupAssertHandler(); - -} // namespace score::mw::com - -#endif // SCORE_MW_IPC_BRIDGE_ASSERTHANDLER_H diff --git a/src/datatype.cpp b/src/datatype.cpp deleted file mode 100644 index fa1cad3..0000000 --- a/src/datatype.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 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 - ********************************************************************************/ - -#include "datatype.h" diff --git a/src/datatype.h b/src/datatype.h deleted file mode 100644 index c1ad05c..0000000 --- a/src/datatype.h +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 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 - ********************************************************************************/ - -#ifndef SCORE_IPC_BRIDGE_DATATYPE_H -#define SCORE_IPC_BRIDGE_DATATYPE_H - -#include "score/mw/com/types.h" - -namespace score::mw::com -{ - -constexpr std::size_t MAX_SUCCESSORS = 16U; -constexpr std::size_t MAX_LANES = 16U; - -enum class StdTimestampSyncState : std::uint32_t -{ - /// @brief Timestamp is in sync with the global master, MAX_DIFF property is guaranteed. - kStdTimestampSyncState_InSync = 0U, - /// @brief Timestamp is not in sync with the global master, no property guarantees can be given, use at your own - /// risk. - kStdTimestampSyncState_NotInSync = 1U, - /// @brief No timestamp is available due to infrastructure reasons (e.g. initial value, or no StbM integrated, or - /// prediction target timestamp cannot be calculated, ...). - kStdTimestampSyncState_Invalid = 255U -}; - -struct StdTimestamp -{ - /// @brief The sub-seconds part of the timestamp - /// - //// unit: [ns] - std::uint32_t fractional_seconds; - /// @brief The seconds part of the timestamp. - /// - /// unit: [s] - std::uint32_t seconds; - /// @brief Status whether the timestamp is in sync with the global master or not. - StdTimestampSyncState sync_status; -}; - -enum class EventDataQualifier : std::uint32_t -{ - /// @brief Event data available, normal operation. - /// - /// The event is valid and all data elements in the scope of the qualifier should be evaluated. Parts of the service - /// may still be in degradation (i.e.contained qualifiers or quality of service attributes (e.g. standard deviation) - /// must be evaluated). - kEventDataQualifier_EventDataAvailable = 0U, - /// @brief Event data available, but a degradation condition applies (e.g. calibration). The reason of the - /// degradation is stored in the parameter extendedQualifier. - /// - /// Parts of the data may still be in degradation. Therefore, the receiver must decide (based on contained - /// qualifiers or quality of service attributes) whether the data can be still used. - kEventDataQualifier_EventDataAvailableReduced = 1U, - /// @brief Data for this event is currently not available. The extendedQualifier (if present) contains information - /// on the reason for non-availability. - /// - /// The remaining information in the scope of the event (except extendedQualifier) must not be evaluated. - kEventDataQualifier_EventDataNotAvailable = 2U, - /// @brief Data for this event is currently unknown. - /// - /// The remaining information in the scope of the event (except extendedQualifier) must not be evaluated. - // kEventDataQualifier_EventDataUnknown = 14U, - /// @brief There is no event data available, due to the event data being invalid (e.g. CRC error) or due to a - /// timeout. - /// - /// The remaining information in the scope of the event (except extendedQualifier) must not be evaluated. - kEventDataQualifier_EventDataInvalid = 255U -}; - -struct MapApiLaneBoundaryData -{ -}; - -using LaneIdType = std::size_t; -using LaneWidth = std::size_t; -using LaneBoundaryId = std::size_t; - -namespace map_api -{ - -using LinkId = std::size_t; -using LengthM = std::double_t; - -struct LaneConnectionInfo -{ -}; - -using LaneConnectionInfoList = std::array; - -struct LaneRestrictionInfo -{ -}; - -using LaneRestrictionInfoList = std::array; - -struct ShoulderLaneInfo -{ -}; - -using ShoulderLaneInfoList = std::array; - -struct LaneToLinkAssociation -{ -}; - -using LaneUsedInBothDirections = bool; - -} // namespace map_api - -namespace adp -{ - -struct MapApiPointData -{ -}; - -enum class LaneType : std::size_t -{ - UNKNOWN, -}; - -enum class LaneTypeNew : std::size_t -{ - Unknown, -}; - -struct TurnDirection -{ -}; - -namespace map_api -{ - -using SpeedLimit = std::size_t; -using LaneFollowsMpp = bool; - -} // namespace map_api - -} // namespace adp - -struct MapApiLaneData -{ - MapApiLaneData() = default; - - MapApiLaneData(MapApiLaneData&&) = default; - - MapApiLaneData(const MapApiLaneData&) = default; - - MapApiLaneData& operator=(MapApiLaneData&&) = default; - - MapApiLaneData& operator=(const MapApiLaneData&) = default; - - /// @brief range: [1, n]. Unique ID of the lane - LaneIdType lane_id{0U}; - - /// @brief range: [1, n]. The IDs of all links that this lane belongs to - std::array link_ids; - - /// @brief The IDs of all lane from which this lane can be reached in longitudinal direction - std::array predecessor_lanes; - - /// @brief The IDs of all lane that can be reached from this lane in longitudinal direction - std::array successor_lanes; - - /// @brief The center line of this lane - std::array center_line; - - /// @brief The innermost left boundary at the beginning of this lane - LaneBoundaryId left_boundary_id{0U}; - - /// @brief The innermost right boundary at the beginning of this lane - LaneBoundaryId right_boundary_id{0U}; - - /// @brief The ID of the lane to the left - /// @note 0 indicates that there is no lane to the left - LaneIdType left_lane_id{0U}; - - /// @brief The id of the lane ro the right - /// @note 0 indicates that there is no lane to the right - LaneIdType right_lane_id{0U}; - - /// @brief The type of the lane - adp::LaneType lane_type{adp::LaneType::UNKNOWN}; - - /// @brief The type of the lane - adp::LaneTypeNew lane_type_new{adp::LaneTypeNew::Unknown}; - - /// @brief Describes Lane Connection Type and the range on the lane for which it applies - map_api::LaneConnectionInfoList lane_connection_info; - - /// @brief Describes Lane Restriction Type and the range on the lane for which it applies - map_api::LaneRestrictionInfoList lane_restriction_info; - - /// @brief Describes Shoulder Lane Type and the range on the lane for which it applies - /// @note not provided by MapDAL as of 6.08.2021r - map_api::ShoulderLaneInfoList shoulder_lane_info; - - /// @brief The turn direction associated with the lane - adp::TurnDirection turn_direction; - /// @brief unit: [cm]. The width of the current lane - /// @details This is the smallest width over the whole lane. When the lane is splitting or - /// merging, the width can be 0. - /// The width is also set to 0 when no width is available. - LaneWidth width_in_cm{0U}; - - /// @brief unit: [m]. The length of the current lane - map_api::LengthM length_in_m{0.0}; - - /// @brief The speed limits on the current lane - std::array speed_limits; - - /// @brief struct describing whether the lane is part of calculated Most Probable Path, or if yes within a range - adp::map_api::LaneFollowsMpp lane_follows_mpp; - - /// @brief Boolean flag describing whether lane is fully attributed - bool is_fully_attributed{false}; - - /// @brief array containing the IDs of all left lane boundaries ordered from curb to middle - std::array left_lane_boundaries_ids; - - /// @brief array containing the IDs of all right lane boundaries ordered from curb to middle - std::array right_lane_boundaries_ids; - - /// @brief links associated with current lane - std::array link_associations; - - /// @brief array of lane ranges where lane can be used in both directions. - std::array used_in_both_directions; -}; - -struct LaneGroupData -{ -}; - -struct MapApiLanesStamped -{ - MapApiLanesStamped() = default; - - MapApiLanesStamped(MapApiLanesStamped&&) = default; - - MapApiLanesStamped(const MapApiLanesStamped&) = default; - - MapApiLanesStamped& operator=(MapApiLanesStamped&&) = default; - - MapApiLanesStamped& operator=(const MapApiLanesStamped&) = default; - - StdTimestamp time_stamp{0, 0, StdTimestampSyncState::kStdTimestampSyncState_Invalid}; - - /// @brief A name of the coordinate frame, used while fetching data. - /// - /// Depending on the driving scenario, different coordinate frames can be used. - /// Case "map_debug" : for Highway scenario it is an NTM planar coordinate system. - /// Case: "local_map_frame": for Urban scenario it is a vehicle's local coordinate system. - std::array frame_id; - - /// @brief Current projection id. - /// - /// In case of NTM geodetic reference system, a zone can be of an arbitrary size, thus doesn't have a fixed - /// descriptor. This variable provides an index of the zone, in which the vehicle is currently located. - /// - /// range: [0, n] - std::uint32_t projection_id{}; - - /// @brief Describes the different kinds of quality levels of interface data. (placeholder for future concrete - /// implementation, for now we just initialize by not available) - EventDataQualifier event_data_qualifier{EventDataQualifier::kEventDataQualifier_EventDataNotAvailable}; - - /// @brief An array, containing lane boundaries, which refer to lanes from the given parent data structure. Lane - /// boundary indicates edge of the lane. - std::array lane_boundaries; - - /// @brief All lanes from HD map for a relevant piece of road. - std::array lanes; - - std::array lane_groups; - - std::uint32_t x; - std::size_t hash_value; -}; - -template -class IpcBridgeInterface : public Trait::Base -{ - public: - using Trait::Base::Base; - - typename Trait::template Event map_api_lanes_stamped_{*this, "map_api_lanes_stamped"}; -}; - -using IpcBridgeProxy = AsProxy; -using IpcBridgeSkeleton = AsSkeleton; - -} // namespace score::mw::com - -#endif // SCORE_IPC_BRIDGE_DATATYPE_H diff --git a/src/etc/logging.json b/src/etc/logging.json deleted file mode 100644 index ac6589c..0000000 --- a/src/etc/logging.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "appId": "IPBR", - "appDesc": "ipc_bridge", - "logLevel": "kDebug", - "logLevelThresholdConsole": "kDebug", - "logMode": "kRemote|kConsole", - "dynamicDatarouterIdentifiers" : true -} diff --git a/src/etc/mw_com_config.json b/src/etc/mw_com_config.json deleted file mode 100644 index 1e104bd..0000000 --- a/src/etc/mw_com_config.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "serviceTypes": [ - { - "serviceTypeName": "/score/MapApiLanesStamped", - "version": { - "major": 1, - "minor": 0 - }, - "bindings": [ - { - "binding": "SHM", - "serviceId": 6432, - "events": [ - { - "eventName": "map_api_lanes_stamped", - "eventId": 1 - }, - { - "eventName": "dummy_data_stamped", - "eventId": 2 - } - ] - } - ] - } - ], - "serviceInstances": [ - { - "instanceSpecifier": "score/MapApiLanesStamped", - "serviceTypeName": "/score/MapApiLanesStamped", - "version": { - "major": 1, - "minor": 0 - }, - "instances": [ - { - "instanceId": 1, - "allowedConsumer": { - "QM": [ - 4002, - 0 - ] - }, - "allowedProvider": { - "QM": [ - 4001, - 0 - ] - }, - "asil-level": "QM", - "binding": "SHM", - "events": [ - { - "eventName": "map_api_lanes_stamped", - "numberOfSampleSlots": 10, - "maxSubscribers": 3 - } - ] - } - ] - } - ] -} diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 4876ca9..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 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 - ********************************************************************************/ - -#include "assert_handler.h" -#include "sample_sender_receiver.h" - -#include - -#include -#include - -#include "score/mw/com/runtime.h" - -using namespace std::chrono_literals; - -struct Params -{ - score::cpp::optional mode; - score::cpp::optional instance_manifest; - score::cpp::optional cycle_time; - score::cpp::optional cycle_num; - bool check_sample_hash; -}; - -template -score::cpp::optional GetValueIfProvided(const boost::program_options::variables_map& args, std::string arg_string) -{ - return (args.count(arg_string) > 0U) ? static_cast(args[arg_string].as()) - : score::cpp::optional(); -} - -Params ParseCommandLineArguments(const int argc, const char** argv) -{ - namespace po = boost::program_options; - - po::options_description options; - - options.add_options()("help,h", "Display the help message"); - options.add_options()( - "num-cycles,n", - po::value()->default_value(0U), - "Number of cycles that are executed before determining success or failure. 0 indicates no limit."); - options.add_options()("mode,m", - po::value(), - "Set to either send/skeleton or recv/proxy to determine the role of the process"); - options.add_options()("cycle-time,t", po::value(), "Cycle time in milliseconds for sending/polling"); - options.add_options()( - "service_instance_manifest,s", po::value(), "Path to the com configuration file"); - options.add_options()( - "disable-hash-check,d", - po::bool_switch(), - "Do not check the sample hash value in the receiver. If true, the sample hash is not checked."); - - po::variables_map args; - const auto parsed_args = - po::command_line_parser{argc, argv} - .options(options) - .style(po::command_line_style::unix_style | po::command_line_style::allow_long_disguise) - .run(); - po::store(parsed_args, args); - - if (args.count("help") > 0U) - { - std::cerr << options << std::endl; - std::exit(EXIT_SUCCESS); - } - - return {GetValueIfProvided(args, "mode"), - GetValueIfProvided(args, "service_instance_manifest"), - GetValueIfProvided(args, "cycle-time"), - GetValueIfProvided(args, "num-cycles"), - args.count("disable-hash-check") == 0U}; -} - -int main(const int argc, const char** argv) -{ - score::mw::com::SetupAssertHandler(); - Params params = ParseCommandLineArguments(argc, argv); - - if (!params.mode.has_value() || !params.cycle_num.has_value() || !params.cycle_time.has_value()) - { - std::cerr << "Mode, number of cycles and cycle time should be specified" << std::endl; - return EXIT_FAILURE; - } - - if (params.instance_manifest.has_value()) - { - const std::string& manifest_path = params.instance_manifest.value(); - score::StringLiteral runtime_args[2u] = {"-service_instance_manifest", manifest_path.c_str()}; - score::mw::com::runtime::InitializeRuntime(2, runtime_args); - } - - const auto mode = params.mode.value(); - const auto cycles = params.cycle_num.value(); - const auto cycle_time = params.cycle_time.value(); - const auto check_sample_hash = params.check_sample_hash; - - score::mw::com::EventSenderReceiver event_sender_receiver{}; - - const auto instance_specifier_result = score::mw::com::InstanceSpecifier::Create("score/MapApiLanesStamped"); - if (!instance_specifier_result.has_value()) - { - std::cerr << "Invalid instance specifier, terminating." << std::endl; - return EXIT_FAILURE; - } - const auto& instance_specifier = instance_specifier_result.value(); - - if (mode == "send" || mode == "skeleton") - { - return event_sender_receiver.RunAsSkeleton(instance_specifier, cycle_time, cycles); - } - else if (mode == "recv" || mode == "proxy") - { - return event_sender_receiver.RunAsProxy(instance_specifier, cycle_time, cycles, false, check_sample_hash); - } - else - { - std::cerr << "Unknown mode " << mode << ", terminating." << std::endl; - return EXIT_FAILURE; - } -} diff --git a/src/sample_sender_receiver.cpp b/src/sample_sender_receiver.cpp deleted file mode 100644 index 5bc1384..0000000 --- a/src/sample_sender_receiver.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 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 - ********************************************************************************/ - -#include "sample_sender_receiver.h" -#include "score/mw/com/impl/generic_proxy.h" -#include "score/mw/com/impl/generic_proxy_event.h" -#include "score/mw/com/impl/handle_type.h" - -#include "score/concurrency/notification.h" - -#include "score/mw/com/impl/proxy_event.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::chrono_literals; - -namespace score::mw::com -{ - -namespace -{ - -constexpr std::size_t START_HASH = 64738U; - -std::ostream& operator<<(std::ostream& stream, const InstanceSpecifier& instance_specifier) -{ - stream << instance_specifier.ToString(); - return stream; -} - -template -void ToStringImpl(std::ostream& o, T t) -{ - o << t; -} - -template -void ToStringImpl(std::ostream& o, T t, Args... args) -{ - ToStringImpl(o, t); - ToStringImpl(o, args...); -} - -template -std::string ToString(Args... args) -{ - std::ostringstream oss; - ToStringImpl(oss, args...); - return oss.str(); -} - -void HashArray(const std::array& array, std::size_t& seed) -{ - const std::ptrdiff_t buffer_size = - reinterpret_cast(&*array.cend()) - reinterpret_cast(&*array.cbegin()); - SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(buffer_size > 0); - seed = score::cpp::hash_bytes_fnv1a(static_cast(array.data()), static_cast(buffer_size), seed); -} - -class SampleReceiver -{ - public: - explicit SampleReceiver(const InstanceSpecifier& instance_specifier, bool check_sample_hash = true) - : instance_specifier_{instance_specifier}, - last_received_{}, - received_{0U}, - check_sample_hash_{check_sample_hash} - { - } - - void ReceiveSample(const MapApiLanesStamped& map) noexcept - { - std::cout << ToString(instance_specifier_, ": Received sample: ", map.x, "\n"); - - if (CheckReceivedSample(map)) - { - received_ += 1U; - } - last_received_ = map.x; - } - - std::size_t GetReceivedSampleCount() const noexcept - { - return received_; - } - - private: - bool CheckReceivedSample(const MapApiLanesStamped& map) const noexcept - { - if (last_received_.has_value()) - { - if (map.x <= last_received_.value()) - { - std::cerr << ToString(instance_specifier_, - ": The received sample is out of order. Expected that ", - map.x, - " > ", - last_received_.value(), - "\n"); - return false; - } - } - - if (check_sample_hash_) - { - std::size_t hash_value = START_HASH; - for (const MapApiLaneData& lane : map.lanes) - { - HashArray(lane.successor_lanes, hash_value); - } - - if (hash_value != map.hash_value) - { - std::cerr << ToString(instance_specifier_, - ": Unexpected data received, hash comparison failed: ", - hash_value, - ", expected ", - map.hash_value, - "\n"); - return false; - } - } - - return true; - } - - const score::mw::com::InstanceSpecifier& instance_specifier_; - score::cpp::optional last_received_; - std::size_t received_; - bool check_sample_hash_; -}; - -score::cpp::optional>> GetMapApiLanesStampedProxyEvent( - IpcBridgeProxy& proxy) -{ - return proxy.map_api_lanes_stamped_; -} - -score::cpp::optional> GetMapApiLanesStampedProxyEvent( - GenericProxy& generic_proxy) -{ - const std::string event_name{"map_api_lanes_stamped"}; - auto event_it = generic_proxy.GetEvents().find(event_name); - if (event_it == generic_proxy.GetEvents().cend()) - { - std::cerr << "Could not find event " << event_name << " in generic proxy event map\n"; - return {}; - } - return event_it->second; -} - -/// \brief Function that returns the value pointed to by a pointer -const MapApiLanesStamped& GetSamplePtrValue(const MapApiLanesStamped* const sample_ptr) -{ - return *sample_ptr; -} - -/// \brief Function that casts and returns the value pointed to by a void pointer -/// -/// Assumes that the object in memory being pointed to is of type MapApiLanesStamped. -const MapApiLanesStamped& GetSamplePtrValue(const void* const void_ptr) -{ - auto* const typed_ptr = static_cast(void_ptr); - return *typed_ptr; -} - -/// \brief Function that extracts the underlying pointer to const from a SamplePtr and casts away the const. Only used -/// in death test to check that we can't modify the SamplePtr! -template -SampleType* ExtractNonConstPointer(const SamplePtr& sample) noexcept -{ - const SampleType* sample_const_ptr = sample.get(); - - // The underlying shared memory in which the SamplePtr is stored (i.e. the data section) is opened read-only by the - // operating system when we open and mmap the memory into our consumer process. However, the SampleType itself is - // not a const object (although the SamplePtr holds a pointer to const). The standard states that "Modifying a const - // object through a non-const access path and referring to a volatile object through a non-volatile glvalue results - // in undefined behavior." (https://en.cppreference.com/w/cpp/language/const_cast). We are _not_ modifying a const - // object. We are modifying a non-const object that is pointer to by a pointer to const. Therefore, modifying the - // underlying object after using const cast is not undefined behaviour. We expect that the failure should occur - // since the memory in which the object is allocated is in read-only memory. - auto* sample_non_const_ptr = const_cast(sample_const_ptr); - return sample_non_const_ptr; -} - -void ModifySampleValue(const SamplePtr& sample) -{ - auto* const sample_non_const_ptr = ExtractNonConstPointer(sample); - sample_non_const_ptr->x += 1; -} - -void ModifySampleValue(const SamplePtr& sample) -{ - auto* const sample_non_const_ptr = ExtractNonConstPointer(sample); - - auto* const typed_ptr = static_cast(sample_non_const_ptr); - typed_ptr->x += 1; -} - -template -score::Result GetHandleFromSpecifier(const InstanceSpecifier& instance_specifier) -{ - std::cout << ToString(instance_specifier, ": Running as proxy, looking for services\n"); - ServiceHandleContainer handles{}; - do - { - auto handles_result = ProxyType::FindService(instance_specifier); - if (!handles_result.has_value()) - { - return MakeUnexpected(std::move(handles_result.error())); - } - handles = std::move(handles_result).value(); - if (handles.size() == 0) - { - std::this_thread::sleep_for(500ms); - } - } while (handles.size() == 0); - - std::cout << ToString(instance_specifier, ": Found service, instantiating proxy\n"); - return handles.front(); -} - -Result> PrepareMapLaneSample(IpcBridgeSkeleton& skeleton, - const std::size_t cycle) -{ - const std::default_random_engine::result_type seed{static_cast( - std::chrono::steady_clock::now().time_since_epoch().count())}; - std::default_random_engine rng{seed}; - - auto sample_result = skeleton.map_api_lanes_stamped_.Allocate(); - if (!sample_result.has_value()) - { - return sample_result; - } - auto sample = std::move(sample_result).value(); - sample->hash_value = START_HASH; - sample->x = static_cast(cycle); - - std::cout << ToString("Sending sample: ", sample->x, "\n"); - for (MapApiLaneData& lane : sample->lanes) - { - for (LaneIdType& successor : lane.successor_lanes) - { - successor = std::uniform_int_distribution()(rng); - } - - HashArray(lane.successor_lanes, sample->hash_value); - } - return sample; -} - -} // namespace - -template -int EventSenderReceiver::RunAsProxy(const score::mw::com::InstanceSpecifier& instance_specifier, - const score::cpp::optional cycle_time, - const std::size_t num_cycles, - bool try_writing_to_data_segment, - bool check_sample_hash) -{ - // For a GenericProxy, the SampleType will be void. For a regular proxy, it will by MapApiLanesStamped. - using SampleType = - typename std::conditional::value, void, MapApiLanesStamped>::type; - constexpr std::size_t SAMPLES_PER_CYCLE = 2U; - - auto handle_result = GetHandleFromSpecifier(instance_specifier); - if (!handle_result.has_value()) - { - std::cerr << "Unable to find service: " << instance_specifier - << ". Failed with error: " << handle_result.error() << ", bailing!\n"; - return EXIT_FAILURE; - } - auto handle = handle_result.value(); - - auto proxy_result = ProxyType::Create(std::move(handle)); - if (!proxy_result.has_value()) - { - std::cerr << "Unable to construct proxy: " << proxy_result.error() << ", bailing!\n"; - return EXIT_FAILURE; - } - auto& proxy = proxy_result.value(); - - auto map_api_lanes_stamped_event_optional = GetMapApiLanesStampedProxyEvent(proxy); - if (!map_api_lanes_stamped_event_optional.has_value()) - { - std::cerr << "Could not get MapApiLanesStamped proxy event\n"; - return EXIT_FAILURE; - } - auto& map_api_lanes_stamped_event = map_api_lanes_stamped_event_optional.value().get(); - - concurrency::Notification event_received; - if (!cycle_time.has_value()) - { - map_api_lanes_stamped_event.SetReceiveHandler([&event_received, &instance_specifier]() { - std::cout << ToString(instance_specifier, ": Callback called\n"); - event_received.notify(); - }); - } - - std::cout << ToString(instance_specifier, ": Subscribing to service\n"); - map_api_lanes_stamped_event.Subscribe(SAMPLES_PER_CYCLE); - - score::cpp::optional last_received{}; - SampleReceiver receiver{instance_specifier, check_sample_hash}; - for (std::size_t cycle = 0U; cycle < num_cycles;) - { - const auto cycle_start_time = std::chrono::steady_clock::now(); - if (cycle_time.has_value()) - { - std::this_thread::sleep_for(*cycle_time); - } - - const auto received_before = receiver.GetReceivedSampleCount(); - Result num_samples_received = map_api_lanes_stamped_event.GetNewSamples( - [&receiver, try_writing_to_data_segment](SamplePtr sample) noexcept { - if (try_writing_to_data_segment) - { - // Try writing to the data segment (in which the sample data is stored). Used in a death test to - // ensure that this is not possible. - ModifySampleValue(sample); - } - - // For the GenericProxy case, the void pointer managed by the SamplePtr will be cast to - // MapApiLanesStamped. - const MapApiLanesStamped& sample_value = GetSamplePtrValue(sample.get()); - receiver.ReceiveSample(sample_value); - }, - SAMPLES_PER_CYCLE); - const auto received = receiver.GetReceivedSampleCount() - received_before; - - const bool get_new_samples_api_error = !num_samples_received.has_value(); - const bool mismatch_api_returned_receive_count_vs_sample_callbacks = *num_samples_received != received; - const bool receive_handler_called_without_new_samples = *num_samples_received == 0 && !cycle_time.has_value(); - - if (get_new_samples_api_error || mismatch_api_returned_receive_count_vs_sample_callbacks || - receive_handler_called_without_new_samples) - { - std::stringstream ss; - ss << instance_specifier << ": Error in cycle " << cycle << " during sample reception: "; - if (!get_new_samples_api_error) - { - if (mismatch_api_returned_receive_count_vs_sample_callbacks) - { - ss << "number of received samples doesn't match to what IPC claims: " << *num_samples_received - << " vs " << received; - } - else - { - ss << "expected at least one new sample, since event-notifier has been called, but " - "GetNewSamples() didn't provide one! "; - } - } - else - { - ss << std::move(num_samples_received).error(); - } - ss << ", terminating.\n"; - std::cerr << ss.str(); - - map_api_lanes_stamped_event.Unsubscribe(); - return EXIT_FAILURE; - } - - if (*num_samples_received >= 1U) - { - std::cout << ToString(instance_specifier, ": Proxy received valid data\n"); - cycle += *num_samples_received; - } - - const auto cycle_duration = std::chrono::steady_clock::now() - cycle_start_time; - - std::cout << ToString(instance_specifier, - ": Cycle duration ", - std::chrono::duration_cast(cycle_duration).count(), - "ms\n"); - - event_received.reset(); - } - - std::cout << ToString(instance_specifier, ": Unsubscribing...\n"); - map_api_lanes_stamped_event.Unsubscribe(); - std::cout << ToString(instance_specifier, ": and terminating, bye bye\n"); - return EXIT_SUCCESS; -} - -int EventSenderReceiver::RunAsSkeleton(const score::mw::com::InstanceSpecifier& instance_specifier, - const std::chrono::milliseconds cycle_time, - const std::size_t num_cycles) -{ - auto create_result = IpcBridgeSkeleton::Create(instance_specifier); - if (!create_result.has_value()) - { - std::cerr << "Unable to construct skeleton: " << create_result.error() << ", bailing!\n"; - return EXIT_FAILURE; - } - auto& skeleton = create_result.value(); - - const auto offer_result = skeleton.OfferService(); - if (!offer_result.has_value()) - { - std::cerr << "Unable to offer service for skeleton: " << offer_result.error() << ", bailing!\n"; - return EXIT_FAILURE; - } - std::cout << "Starting to send data\n"; - - for (std::size_t cycle = 0U; cycle < num_cycles || num_cycles == 0U; ++cycle) - { - auto sample_result = PrepareMapLaneSample(skeleton, cycle); - if (!sample_result.has_value()) - { - std::cerr << "No sample received. Exiting.\n"; - return EXIT_FAILURE; - } - auto sample = std::move(sample_result).value(); - - { - std::lock_guard lock{event_sending_mutex_}; - skeleton.map_api_lanes_stamped_.Send(std::move(sample)); - event_published_ = true; - } - std::this_thread::sleep_for(cycle_time); - } - - std::cout << "Stop offering service..."; - skeleton.StopOfferService(); - std::cout << "and terminating, bye bye\n"; - - return EXIT_SUCCESS; -} - -template int EventSenderReceiver::RunAsProxy>( - const score::mw::com::InstanceSpecifier&, - const score::cpp::optional, - const std::size_t, - bool, - bool); -template int EventSenderReceiver::RunAsProxy( - const score::mw::com::InstanceSpecifier&, - const score::cpp::optional, - const std::size_t, - bool, - bool); - -} // namespace score::mw::com diff --git a/src/sample_sender_receiver.h b/src/sample_sender_receiver.h deleted file mode 100644 index b5e77b4..0000000 --- a/src/sample_sender_receiver.h +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 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 - ********************************************************************************/ - -#ifndef SCORE_MW_COM_IPC_BRIDGE_SAMPLE_SENDER_RECEIVER_H -#define SCORE_MW_COM_IPC_BRIDGE_SAMPLE_SENDER_RECEIVER_H - -#include "datatype.h" - -#include - -#include -#include -#include -#include -#include - -namespace score::mw::com -{ - -class EventSenderReceiver -{ - public: - int RunAsSkeleton(const score::mw::com::InstanceSpecifier& instance_specifier, - const std::chrono::milliseconds cycle_time, - const std::size_t num_cycles); - - template > - int RunAsProxy(const score::mw::com::InstanceSpecifier& instance_specifier, - const score::cpp::optional cycle_time, - const std::size_t num_cycles, - bool try_writing_to_data_segment = false, - bool check_sample_hash = true); - - private: - std::mutex event_sending_mutex_{}; - std::atomic event_published_{false}; - - std::mutex map_lanes_mutex_{}; - std::vector> map_lanes_list_{}; -}; - -} // namespace score::mw::com - -#endif // SCORE_MW_COM_IPC_BRIDGE_SAMPLE_SENDER_RECEIVER_H diff --git a/scorex/internal/templates/module/src/BUILD.tmpl b/src_cpp/BUILD similarity index 81% rename from scorex/internal/templates/module/src/BUILD.tmpl rename to src_cpp/BUILD index d63c345..5035e61 100644 --- a/scorex/internal/templates/module/src/BUILD.tmpl +++ b/src_cpp/BUILD @@ -1,19 +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 -# ******************************************************************************* -cc_binary( - name = "main", - srcs = [ - "main.cpp", - ], - visibility = ["//visibility:public"], -) +# ******************************************************************************* +# 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 +# ******************************************************************************* +cc_binary( + name = "scrample_cpp", + srcs = ["main.cpp"], + data = ["//config:logging.json"], + visibility = ["//visibility:public"], + deps = [ + "@score_logging//score/mw/log", + ], +) diff --git a/src_cpp/main.cpp b/src_cpp/main.cpp new file mode 100644 index 0000000..e63e2ec --- /dev/null +++ b/src_cpp/main.cpp @@ -0,0 +1,43 @@ +/******************************************************************************** + * Copyright (c) 2026 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 + ********************************************************************************/ + +#include "score/mw/log/logging.h" + +#include +#include +#include +#include + +int main() +{ + const char* runfiles_dir = std::getenv("RUNFILES_DIR"); + if (runfiles_dir != nullptr) + { + std::string config_path = std::string(runfiles_dir) + "/_main/config/logging.json"; + setenv("MW_LOG_CONFIG_FILE", config_path.c_str(), 1); + } + else + { + char exe_path[PATH_MAX]; + ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1); + if (len != -1) + { + exe_path[len] = '\0'; + std::string config_path = std::string(exe_path) + ".runfiles/_main/config/logging.json"; + setenv("MW_LOG_CONFIG_FILE", config_path.c_str(), 1); + } + } + + score::mw::log::LogInfo("scrample") << "Hello from SCRAMPLE!"; + return 0; +} diff --git a/scorex/internal/templates/application/feo_app/src/BUILD.tmpl b/src_rust/BUILD similarity index 55% rename from scorex/internal/templates/application/feo_app/src/BUILD.tmpl rename to src_rust/BUILD index 24fa5b4..055a473 100644 --- a/scorex/internal/templates/application/feo_app/src/BUILD.tmpl +++ b/src_rust/BUILD @@ -1,36 +1,38 @@ -# ******************************************************************************* -# 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_binary", "rust_library") - -rust_binary( - name = "hello_world_app", - srcs = [ - "hello_world.rs", - ], - crate_features = ["signalling_relayed_tcp"], - rustc_flags = [ - "-Clink-arg=-lstdc++", - "-Clink-arg=-lm", - "-Clink-arg=-lc", - ], - visibility = ["//visibility:public"], - deps = [ - "@score_feo//feo:libfeo_rust", - "@score_feo//feo-log:libfeo_log_rust", - "@score_feo//feo-time:libfeo_time_rust", - "@score_feo//feo-logger:libfeo_logger_rust", - "@score_feo//feo-tracing:libfeo_tracing_rust", - ], -) - +# ******************************************************************************* +# Copyright (c) 2026 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_binary") + +RUSTC_FLAGS = select({ + "@platforms//os:qnx": [ + "-Clink-arg=-lc++", + "-Clink-arg=-lm", + ], + "//conditions:default": [ + "-Clink-arg=-lstdc++", + "-Clink-arg=-lm", + "-Clink-arg=-lc", + ], +}) + +rust_binary( + name = "scrample_rust", + srcs = ["main.rs"], + data = ["//config:logging.json"], + edition = "2021", + rustc_flags = RUSTC_FLAGS, + visibility = ["//visibility:public"], + deps = [ + "@score_baselibs_rust//src/log/score_log", + "@score_logging//score/mw/log/rust/score_log_bridge", + ], +) diff --git a/src_rust/main.rs b/src_rust/main.rs new file mode 100644 index 0000000..49f7623 --- /dev/null +++ b/src_rust/main.rs @@ -0,0 +1,31 @@ +// ******************************************************************************* +// Copyright (c) 2026 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 +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* +use score_log::info; +use score_log_bridge::ScoreLogBridgeBuilder; +use std::path::PathBuf; + +fn main() { + let config_path = std::env::var("RUNFILES_DIR") + .map(|d| PathBuf::from(d).join("_main/config/logging.json")) + .unwrap_or_else(|_| { + let exe = std::env::current_exe().unwrap(); + PathBuf::from(format!("{}.runfiles", exe.display())).join("_main/config/logging.json") + }); + + ScoreLogBridgeBuilder::new() + .context("scrample") + .config(config_path) + .set_as_default_logger(); + + info!("Hello from SCRAMPLE!"); +}