diff --git a/.github/workflows/build_native.yml b/.github/workflows/build_native.yml index 6e7e119e1..18a5e5cdb 100644 --- a/.github/workflows/build_native.yml +++ b/.github/workflows/build_native.yml @@ -156,25 +156,23 @@ jobs: - name: Generate build info id: build_info + env: + VERSION_INPUT: ${{ github.event.inputs.version }} + CREATE_RELEASE_INPUT: ${{ github.event.inputs.create_release }} + EVENT_NAME: ${{ github.event_name }} + MATRIX_ARCH: ${{ matrix.arch }} run: | - # Use manual version if provided, otherwise generate using same scheme as CMake - if [ -n "${{ github.event.inputs.version }}" ]; then - VERSION="${{ github.event.inputs.version }}" + if [ -n "$VERSION_INPUT" ]; then + VERSION="$VERSION_INPUT" else - # Match CMakeLists.txt date-based versioning: YYYY.MM.DD BUILD_YEAR=$(date -u +"%Y") BUILD_MONTH=$(date -u +"%m") BUILD_DAY=$(date -u +"%d") VERSION="${BUILD_YEAR}.${BUILD_MONTH}.${BUILD_DAY}" - - # Add git commit info if available (match CMake logic) COMMIT_SHA=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") if [ "$COMMIT_SHA" != "unknown" ]; then VERSION="${VERSION}+git.${COMMIT_SHA}" - - # Check if repository is dirty (has uncommitted changes) - # In CI, we'll skip dirty check as the workspace should be clean - if [ "${{ github.event_name }}" = "workflow_dispatch" ] && ! git diff --quiet 2>/dev/null; then + if [ "$EVENT_NAME" = "workflow_dispatch" ] && ! git diff --quiet 2>/dev/null; then VERSION="${VERSION}.dirty" fi fi @@ -183,11 +181,9 @@ jobs: COMMIT_SHA=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") BUILD_DATE=$(date -u +"%Y%m%d_%H%M%S") - # For releases, ensure we have a clean version without build date suffix - RELEASE_VERSION="${VERSION}" - if [ "${{ github.event.inputs.create_release }}" = "true" ] || [[ "${GITHUB_REF}" == refs/tags/* ]]; then - # For releases, use a cleaner version format - if [ -z "${{ github.event.inputs.version }}" ]; then + RELEASE_VERSION="$VERSION" + if [ "$CREATE_RELEASE_INPUT" = "true" ] || [[ "${GITHUB_REF}" == refs/tags/* ]]; then + if [ -z "$VERSION_INPUT" ]; then RELEASE_VERSION="${BUILD_YEAR}.${BUILD_MONTH}.${BUILD_DAY}" if [ "$COMMIT_SHA" != "unknown" ]; then RELEASE_VERSION="${RELEASE_VERSION}+git.${COMMIT_SHA}" @@ -195,15 +191,14 @@ jobs: fi fi - echo "version=${VERSION}" >> $GITHUB_OUTPUT - echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT - echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT - echo "build_date=${BUILD_DATE}" >> $GITHUB_OUTPUT - echo "package_name=openauto-${{ matrix.arch }}-${VERSION}" >> $GITHUB_OUTPUT - - echo "Generated version: ${VERSION}" - echo "Release version: ${RELEASE_VERSION}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT + echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT + echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT + echo "package_name=openauto-$MATRIX_ARCH-$VERSION" >> $GITHUB_OUTPUT + echo "Generated version: $VERSION" + echo "Release version: $RELEASE_VERSION" - name: Build for ${{ matrix.arch }} on ${{ matrix.distro }} run: | echo "Building OpenAuto for ${{ matrix.arch }} architecture" diff --git a/.github/workflows/build_with_apt_aasdk.yml.disabled b/.github/workflows/build_with_apt_aasdk.yml.disabled deleted file mode 100644 index d8a1704b8..000000000 --- a/.github/workflows/build_with_apt_aasdk.yml.disabled +++ /dev/null @@ -1,340 +0,0 @@ -name: Build OpenAuto using APT-provided libaasdk - -on: - push: - branches: - - main - - develop - - 'feature/**' - - 'bugfix/**' - paths-ignore: - - '**.md' - - 'docs/**' - - '.gitignore' - pull_request: - branches: - - main - - develop - paths-ignore: - - '**.md' - - 'docs/**' - - '.gitignore' - workflow_dispatch: - inputs: - distro: - description: 'Debian distribution to build' - required: false - default: 'all' - type: choice - options: - - all - - bookworm - - trixie - version: - description: 'Build version (optional)' - required: false - default: '' - type: string - trigger_release: - description: 'Trigger release workflow after build' - required: false - default: false - type: boolean - trigger_apt_publish: - description: 'Trigger APT publish workflow after build' - required: false - default: false - type: boolean - -jobs: - prepare: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - distro: ${{ steps.set-matrix.outputs.distro }} - steps: - - name: Set build matrix - id: set-matrix - run: | - # Determine which distro(s) to build - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - DISTRO="${{ inputs.distro }}" - else - # For push/PR, build all distros - DISTRO="all" - fi - - echo "distro=${DISTRO}" >> $GITHUB_OUTPUT - - # Generate matrix based on selected distro(s) - if [ "$DISTRO" = "all" ]; then - # Build all distros: all architectures for all - echo 'matrix={"include":[ - {"arch":"amd64","platform":"linux/amd64","distro":"bookworm"}, - {"arch":"amd64","platform":"linux/amd64","distro":"trixie"}, - {"arch":"arm64","platform":"linux/arm64","distro":"bookworm"}, - {"arch":"arm64","platform":"linux/arm64","distro":"trixie"}, - {"arch":"armhf","platform":"linux/arm/v7","distro":"bookworm"}, - {"arch":"armhf","platform":"linux/arm/v7","distro":"trixie"} - ]}' >> $GITHUB_OUTPUT - elif [ "$DISTRO" = "trixie" ]; then - # Trixie only: all architectures - echo 'matrix={"include":[ - {"arch":"amd64","platform":"linux/amd64","distro":"trixie"}, - {"arch":"arm64","platform":"linux/arm64","distro":"trixie"}, - {"arch":"armhf","platform":"linux/arm/v7","distro":"trixie"} - ]}' >> $GITHUB_OUTPUT - elif [ "$DISTRO" = "bookworm" ]; then - # Bookworm only: all architectures - echo 'matrix={"include":[ - {"arch":"amd64","platform":"linux/amd64","distro":"bookworm"}, - {"arch":"arm64","platform":"linux/arm64","distro":"bookworm"}, - {"arch":"armhf","platform":"linux/arm/v7","distro":"bookworm"} - ]}' >> $GITHUB_OUTPUT - else - echo "ERROR: Unknown distro: $DISTRO" - exit 1 - fi - - - name: Build Plan Summary - run: | - echo "## 🏗️ OpenAuto Build Plan" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Distribution:** ${{ steps.set-matrix.outputs.distro }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Build Matrix" >> $GITHUB_STEP_SUMMARY - echo '```json' >> $GITHUB_STEP_SUMMARY - echo '${{ steps.set-matrix.outputs.matrix }}' | jq '.' >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - if [ "${{ steps.set-matrix.outputs.distro }}" = "all" ]; then - echo "📦 Building for **All distributions** (Bookworm and Trixie - amd64, arm64, armhf each)" >> $GITHUB_STEP_SUMMARY - elif [ "${{ steps.set-matrix.outputs.distro }}" = "trixie" ]; then - echo "📦 Building for **Trixie** only (amd64, arm64, armhf)" >> $GITHUB_STEP_SUMMARY - elif [ "${{ steps.set-matrix.outputs.distro }}" = "bookworm" ]; then - echo "📦 Building for **Bookworm** only (amd64, arm64, armhf)" >> $GITHUB_STEP_SUMMARY - fi - - build: - needs: prepare - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} - max-parallel: 6 - - name: Build OpenAuto for ${{ matrix.arch }} on ${{ matrix.distro }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up QEMU for cross-platform builds - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build in Debian ${{ matrix.distro }} container for ${{ matrix.arch }} - uses: addnab/docker-run-action@v3 - with: - image: debian:${{ matrix.distro }} - options: --platform ${{ matrix.platform }} -v ${{ github.workspace }}:/workspace -w /workspace - shell: bash - run: | - set -euxo pipefail - export DEBIAN_FRONTEND=noninteractive - - # Base tooling - apt-get update - apt-get install -y --no-install-recommends \ - ca-certificates curl gnupg build-essential cmake pkg-config git \ - dpkg-dev fakeroot file \ - libusb-1.0-0-dev libtag1-dev librtaudio-dev libgps-dev \ - libprotobuf-dev protobuf-compiler \ - libssl-dev libblkid-dev \ - libboost-system-dev libboost-log-dev \ - qtbase5-dev qtmultimedia5-dev qttools5-dev qttools5-dev-tools qtconnectivity5-dev - - # Add OpenCarDev APT repository (signed-by best practice) - install -d -m 0755 /etc/apt/keyrings - curl -fsSL https://opencardev.github.io/packages/opencardev.gpg.key -o /etc/apt/keyrings/opencardev.gpg - chmod 0644 /etc/apt/keyrings/opencardev.gpg - echo "deb [signed-by=/etc/apt/keyrings/opencardev.gpg] https://opencardev.github.io/packages ${{ matrix.distro }} main" > /etc/apt/sources.list.d/opencardev.list - apt-get update - - # Install libaasdk-dev (try architecture-specific name first, then generic) - # Current APT repo uses arch-specific naming: libaasdk--dev - ARCH="${{ matrix.arch }}" - if apt-cache show libaasdk-${ARCH}-dev >/dev/null 2>&1; then - echo "Installing architecture-specific package: libaasdk-${ARCH}-dev" - apt-get install -y --no-install-recommends libaasdk-${ARCH}-dev - elif apt-cache show libaasdk-dev >/dev/null 2>&1; then - echo "Installing generic multiarch package: libaasdk-dev" - apt-get install -y --no-install-recommends libaasdk-dev - else - echo "ERROR: libaasdk-dev package not found in APT repository" - echo "Available libaasdk packages:" - apt-cache search libaasdk || true - exit 1 - fi - - # Install aap_protobuf development package if available (name may vary) - if apt-cache show aap-protobuf-dev >/dev/null 2>&1; then - apt-get install -y --no-install-recommends aap-protobuf-dev - elif apt-cache show aap_protobuf-dev >/dev/null 2>&1; then - apt-get install -y --no-install-recommends aap_protobuf-dev - else - echo "aap_protobuf dev package not found in APT; relying on Findaap_protobuf.cmake" - fi - - # Prove installation - dpkg -l | grep libaasdk || true - - # Configure and build - # Use -DNOPI=ON for non-Raspberry Pi targets (amd64, arm64) - CMAKE_NOPI_FLAG="" - case "${{ matrix.arch }}" in - amd64|arm64) - CMAKE_NOPI_FLAG="-DNOPI=ON" - ;; - *) - CMAKE_NOPI_FLAG="-DNOPI=OFF" - ;; - esac - - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release ${CMAKE_NOPI_FLAG} - cmake --build build -j"$(nproc)" - cmake --build build --target package || true - - # List outputs - echo "=== Build outputs ===" - find build -name "*.deb" -o -name "autoapp" -o -name "btservice" | head -20 - - - name: Generate build info (version) - id: build_info - shell: bash - run: | - # Generate version matching CMake logic: YYYY.MM.DD +git. [.dirty] - BUILD_YEAR=$(date -u +"%Y") - BUILD_MONTH=$(date -u +"%m") - BUILD_DAY=$(date -u +"%d") - VERSION="${BUILD_YEAR}.${BUILD_MONTH}.${BUILD_DAY}" - - if git rev-parse --short HEAD >/dev/null 2>&1; then - COMMIT_SHA=$(git rev-parse --short HEAD) - VERSION="${VERSION}+git.${COMMIT_SHA}" - if ! git diff --quiet 2>/dev/null; then - VERSION="${VERSION}.dirty" - fi - fi - - echo "version=${VERSION}" >> $GITHUB_OUTPUT - echo "commit_sha=${COMMIT_SHA:-unknown}" >> $GITHUB_OUTPUT - echo "build_date=${BUILD_YEAR}${BUILD_MONTH}${BUILD_DAY}" >> $GITHUB_OUTPUT - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: openauto-${{ matrix.arch }}-${{ matrix.distro }} - path: | - build/*.deb - build/bin/autoapp - build/bin/btservice - retention-days: 14 - - - name: Summary - shell: bash - run: | - set -e - echo "## OpenAuto build using APT-provided libaasdk" >> $GITHUB_STEP_SUMMARY - echo "- Architecture: ${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY - echo "- Distribution: ${{ matrix.distro }}" >> $GITHUB_STEP_SUMMARY - echo "- Platform: ${{ matrix.platform }}" >> $GITHUB_STEP_SUMMARY - echo "- Using APT repo: https://opencardev.github.io/packages" >> $GITHUB_STEP_SUMMARY - echo "- Version: ${{ steps.build_info.outputs.version }}" >> $GITHUB_STEP_SUMMARY - echo "- Artifacts: openauto-${{ matrix.arch }}-${{ matrix.distro }}" >> $GITHUB_STEP_SUMMARY - - release_triggers: - needs: [build, test] - runs-on: ubuntu-latest - if: github.event.inputs.trigger_release == 'true' || github.event.inputs.trigger_apt_publish == 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main') - steps: - - name: Trigger Release Workflow - if: github.event.inputs.trigger_release == 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main') - run: | - echo "Triggering release workflow with build run ID: ${{ github.run_id }}" - gh workflow run release.yml --repo ${{ github.repository }} \ - -f build_run_id="${{ github.run_id }}" \ - -f version="${{ github.event.inputs.version }}" \ - -f create_draft="false" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - - - name: Trigger APT Publish Workflow - if: github.event.inputs.trigger_apt_publish == 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main') - run: | - # Determine distribution for APT publish - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - DIST="${{ inputs.distro }}" - else - DIST="both" - fi - - echo "Triggering APT repository update via repository_dispatch for build run ${{ github.run_id }}" - curl -X POST \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${{ secrets.PACKAGES_REPO_TOKEN }}" \ - https://api.github.com/repos/opencardev/packages/dispatches \ - -d "{ - \"event_type\": \"publish-apt-packages\", - \"client_payload\": { - \"source_repo\": \"${{ github.repository }}\", - \"build_run_id\": \"${{ github.run_id }}\", - \"distribution\": \"${DIST}\" - } - }" - echo "✅ Dispatched to opencardev/packages with distribution: ${DIST}. Check workflow runs there." - env: - PACKAGES_REPO_TOKEN: ${{ secrets.PACKAGES_REPO_TOKEN }} - - test: - needs: build - runs-on: ubuntu-latest - if: success() - steps: - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - pattern: openauto-* - merge-multiple: true - path: ./test-artifacts - - - name: Generate test report - shell: bash - run: | - echo "# OpenAuto Build Test Report" > test-report.md - echo "" >> test-report.md - echo "## Build Summary" >> test-report.md - echo "- Build Date: $(date -u)" >> test-report.md - echo "- Commit: ${{ github.sha }}" >> test-report.md - echo "- Branch: ${{ github.ref_name }}" >> test-report.md - echo "" >> test-report.md - echo "## Package Information" >> test-report.md - find ./test-artifacts -name "*.deb" -type f | while read -r pkg; do - echo "### $(basename "$pkg")" >> test-report.md - echo '```' >> test-report.md - dpkg-deb --field "$pkg" Package Architecture Version Depends 2>/dev/null >> test-report.md || true - echo '```' >> test-report.md - echo "" >> test-report.md - done - - - name: Upload test report - uses: actions/upload-artifact@v4 - with: - name: openauto-test-report-${{ github.run_number }} - path: test-report.md - retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc5833aff..a15e44c3a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,32 +4,32 @@ on: workflow_dispatch: inputs: build_run_id: - description: 'Build run ID to create release from' + description: "Build run ID to create release from" required: true type: string version: - description: 'Release version (leave empty for auto-generated)' + description: "Release version (leave empty for auto-generated)" required: false - default: '' + default: "" type: string create_draft: - description: 'Create as draft release' + description: "Create as draft release" required: false default: false type: boolean workflow_call: inputs: build_run_id: - description: 'Build run ID to create release from' + description: "Build run ID to create release from" required: true type: string version: - description: 'Release version (leave empty for auto-generated)' + description: "Release version (leave empty for auto-generated)" required: false - default: '' + default: "" type: string create_draft: - description: 'Create as draft release' + description: "Create as draft release" required: false default: false type: boolean @@ -78,11 +78,14 @@ jobs: echo "build_date=${BUILD_DATE}" >> $GITHUB_OUTPUT - name: Download artifacts from build run + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_RUN_ID: ${{ inputs.build_run_id }} run: | - echo "Downloading artifacts from run ID: ${{ inputs.build_run_id }}" + echo "Downloading artifacts from run ID: $BUILD_RUN_ID" mkdir -p ./release-artifacts - gh run download ${{ inputs.build_run_id }} --dir ./downloaded-artifacts + gh run download "$BUILD_RUN_ID" --dir ./downloaded-artifacts # Collect common build outputs if [ -d "./downloaded-artifacts" ]; then @@ -94,8 +97,6 @@ jobs: echo "Downloaded artifacts:" ls -la ./release-artifacts/ || true - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create GitHub Release uses: softprops/action-gh-release@v1 @@ -113,4 +114,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: - version: ${{ steps.release_info.outputs.version }} \ No newline at end of file + version: ${{ steps.release_info.outputs.version }} diff --git a/.github/workflows/trigger-apt-publish.yml b/.github/workflows/trigger-apt-publish.yml index 3498b791f..06d6f1046 100644 --- a/.github/workflows/trigger-apt-publish.yml +++ b/.github/workflows/trigger-apt-publish.yml @@ -4,13 +4,13 @@ on: workflow_dispatch: inputs: build_run_id: - description: 'Build run ID to publish to APT repo' + description: "Build run ID to publish to APT repo" required: true type: string distribution: - description: 'Distribution to publish to' + description: "Distribution to publish to" required: false - default: 'trixie' + default: "trixie" type: choice options: - trixie @@ -22,21 +22,25 @@ jobs: runs-on: ubuntu-latest steps: - name: Dispatch to packages repo + env: + BUILD_RUN_ID: ${{ inputs.build_run_id }} + REPOSITORY: ${{ github.repository }} + DISTRIBUTION: ${{ inputs.distribution }} + PACKAGES_REPO_TOKEN: ${{ secrets.PACKAGES_REPO_TOKEN }} run: | - echo "Triggering APT repository update for build run ${{ inputs.build_run_id }}" + echo "Triggering APT repository update for build run \"$BUILD_RUN_ID\"" curl -X POST \ -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token ${{ secrets.PACKAGES_REPO_TOKEN }}" \ + -H "Authorization: token $PACKAGES_REPO_TOKEN" \ https://api.github.com/repos/opencardev/packages/dispatches \ -d '{ "event_type": "publish-apt-packages", "client_payload": { - "source_repo": "${{ github.repository }}", - "build_run_id": "${{ inputs.build_run_id }}", + "source_repo": "'$REPOSITORY'", + "build_run_id": "'$BUILD_RUN_ID'", "apt_import": true, - "distribution": "${{ inputs.distribution }}" + "distribution": "'$DISTRIBUTION'" } }' - echo "✅ APT repository update triggered successfully!" - echo "Check: https://github.com/opencardev/packages/actions" \ No newline at end of file + echo "Check: https://github.com/opencardev/packages/actions" diff --git a/CMakeLists.txt b/CMakeLists.txt index c99a97028..2b7b0c325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,11 +93,28 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # macOS list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/taglib) include(FindProtobuf) else () - find_package(Protobuf REQUIRED) + # Linux specific command + find_path(Protobuf_INCLUDE_DIR google/protobuf/message.h PATHS /usr/include /usr/local/include) + find_library(Protobuf_LIBRARY protobuf PATHS /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/aarch64-linux-gnu /usr/lib/arm-linux-gnueabihf /usr/local/lib) + find_program(PROTOBUF_PROTOC_EXECUTABLE protoc) + message(STATUS "Found Protobuf include: ${Protobuf_INCLUDE_DIR}") + message(STATUS "Found Protobuf library: ${Protobuf_LIBRARY}") + message(STATUS "Found protoc: ${PROTOBUF_PROTOC_EXECUTABLE}") + if(NOT Protobuf_INCLUDE_DIR OR NOT Protobuf_LIBRARY OR NOT PROTOBUF_PROTOC_EXECUTABLE) + message(FATAL_ERROR "Protobuf not found. Please install libprotobuf-dev and protobuf-compiler") + endif() + set(Protobuf_FOUND TRUE) + set(PROTOBUF_LIBRARIES ${Protobuf_LIBRARY}) + set(PROTOBUF_INCLUDE_DIR ${Protobuf_INCLUDE_DIR}) endif () -find_package(aap_protobuf REQUIRED) -find_package(aasdk REQUIRED) +find_package(aap_protobuf) +find_package(aasdk) + +if(NOT AAP_PROTOBUF_FOUND OR NOT AASDK_FOUND) +message(FATAL_ERROR "aap_protobuf or aasdk not found. Please build and install AASDK first.") +endif() + find_package(Boost REQUIRED COMPONENTS system log_setup log OPTIONAL_COMPONENTS unit_test_framework) find_package(libusb-1.0 REQUIRED) find_package(Qt5 COMPONENTS DBus Multimedia MultimediaWidgets Bluetooth Network) diff --git a/Dockerfile b/Dockerfile index 8e36b1e6b..d1be3c1c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ ARG DEBIAN_VERSION=trixie FROM debian:${DEBIAN_VERSION}-slim # Build arguments -ARG TARGET_ARCH=amd64 +ARG TARGET_ARCH=$(dpkg --print-architecture) ARG BUILD_TYPE=release ARG DEBIAN_FRONTEND=noninteractive @@ -67,32 +67,6 @@ RUN apt-get update && apt-get install -y \ # Add OpenCarDev APT repository for libaasdk ARG DEBIAN_VERSION -RUN install -d -m 0755 /etc/apt/keyrings && \ - curl -fsSL https://opencardev.github.io/packages/opencardev.gpg.key -o /etc/apt/keyrings/opencardev.gpg && \ - chmod 0644 /etc/apt/keyrings/opencardev.gpg && \ - echo "deb [signed-by=/etc/apt/keyrings/opencardev.gpg] https://opencardev.github.io/packages ${DEBIAN_VERSION} main" > /etc/apt/sources.list.d/opencardev.list && \ - # Temporary safety: if requested distro is not yet published in APT repo, fall back to trixie - if ! curl -fsSL "https://opencardev.github.io/packages/dists/${DEBIAN_VERSION}/Release" >/dev/null; then \ - echo "WARNING: OpenCarDev APT repo does not have '${DEBIAN_VERSION}'. Falling back to 'trixie' for libaasdk."; \ - echo "deb [signed-by=/etc/apt/keyrings/opencardev.gpg] https://opencardev.github.io/packages trixie main" > /etc/apt/sources.list.d/opencardev.list; \ - fi - -# Install libaasdk from APT repository (attempt selected distro, fall back to trixie if not yet published) -RUN set -eux; \ - if ! apt-get update; then \ - echo "WARNING: APT update failed for ${DEBIAN_VERSION}. Falling back to 'trixie' for libaasdk source."; \ - echo "deb [signed-by=/etc/apt/keyrings/opencardev.gpg] https://opencardev.github.io/packages trixie main" > /etc/apt/sources.list.d/opencardev.list; \ - apt-get update; \ - fi; \ - if apt-cache show libaasdk >/dev/null 2>&1 && apt-cache show libaasdk-dev >/dev/null 2>&1; then \ - echo "Installing libaasdk and libaasdk-dev together"; \ - apt-get install -y --no-install-recommends libaasdk libaasdk-dev; \ - else \ - echo "ERROR: No libaasdk or libaasdk-dev package found"; \ - apt-cache search libaasdk || true; \ - exit 1; \ - fi && \ - apt-get clean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /src @@ -110,7 +84,7 @@ RUN mkdir -p /output RUN chmod +x /src/build.sh # Build OpenAuto using unified build script -RUN /src/build.sh ${BUILD_TYPE} --package --output-dir /output +RUN /src/build.sh ${BUILD_TYPE} --with-aasdk --package --output-dir /output # Default command CMD ["bash", "-c", "echo 'OpenAuto build container ready. Packages are in /output/'"] diff --git a/README.md b/README.md index 95f83c0d6..144f9202e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md) ### Support project -[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R4HXE5ESDR4U4) +[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=YAA3LW393L46S) For support of other platforms please contact me at f1xstudiopl@gmail.com @@ -58,7 +58,7 @@ OpenAuto provides a unified build script (`build.sh`) that works consistently ac ```bash # Build release version (recommended for production) # Note: main/master branches default to release, other branches default to debug -./build.sh release --package +./build.sh release --package --with-aasdk # Build debug version with symbols (for development/debugging) # Debug builds create packages with -dbg suffix (openauto-dbg) diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index 784b9e993..fc75e34fb --- a/build.sh +++ b/build.sh @@ -26,6 +26,7 @@ NOPI_FLAG="-DNOPI=ON" CLEAN_BUILD=false PACKAGE=false OUTPUT_DIR="/output" +WITH_AASDK=false SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SOURCE_DIR="${SCRIPT_DIR}" @@ -60,6 +61,10 @@ while [[ $# -gt 0 ]]; do OUTPUT_DIR="$2" shift 2 ;; + --with-aasdk) + WITH_AASDK=true + shift + ;; --help|-h) echo "Usage: $0 [release|debug] [OPTIONS]" echo "" @@ -71,6 +76,7 @@ while [[ $# -gt 0 ]]; do echo " --clean Clean build directory before building" echo " --package Create DEB packages after building" echo " --output-dir Directory to copy packages (default: /output)" + echo " --with-aasdk Clone AASDK newdev branch and build/install it" echo " --help Show this help message" echo "" echo "Examples:" @@ -87,6 +93,23 @@ while [[ $# -gt 0 ]]; do esac done +# Handle AASDK cloning and building if requested +if [ "$WITH_AASDK" = true ]; then + echo "" + echo "Cloning AASDK newdev branch..." + if [ -d "aasdk-build" ]; then + rm -rf "aasdk-build" + fi + git clone --branch newdev https://github.com/opencardev/aasdk.git aasdk-build + cd aasdk-build + echo "Building and installing AASDK..." + chmod +x build.sh + export TARGET_ARCH="$TARGET_ARCH" + ./build.sh $BUILD_TYPE install + cd "${SOURCE_DIR}" + echo "AASDK build and install completed." +fi + # Determine build directory and CMake build type if [ "$BUILD_TYPE" = "debug" ]; then BUILD_DIR="${SOURCE_DIR}/build-debug" @@ -120,6 +143,59 @@ mkdir -p "${BUILD_DIR}" TARGET_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null || echo "amd64") echo "Target architecture: ${TARGET_ARCH}" +find_cross_compiler() { + local prefix="$1" + local compiler="" + + # First try the base name (might be a symlink to latest) + if command -v "${prefix}gcc" &> /dev/null && [ -x "$(command -v "${prefix}gcc")" ]; then + compiler="$(command -v "${prefix}gcc")" + else + # Find all versioned compilers and pick the latest that actually exists and is executable + local candidates=() + for candidate in $(ls /usr/bin/${prefix}gcc-* 2>/dev/null | sort -V); do + if [ -x "$candidate" ]; then + candidates+=("$candidate") + fi + done + if [ ${#candidates[@]} -gt 0 ]; then + compiler="${candidates[-1]}" + fi + fi + + if [ -n "$compiler" ] && [ -x "$compiler" ]; then + echo "$compiler" + return 0 + else + return 1 + fi +} + +setup_cross_compilation() { + if [ "$TARGET_ARCH" != "amd64" ]; then + echo "Setting up cross-compilation for ${TARGET_ARCH}..." + + case $TARGET_ARCH in + arm64) + local c_compiler=$(find_cross_compiler "aarch64-linux-gnu-") + if [ $? -eq 0 ]; then + CMAKE_ARGS+=(-DCMAKE_C_COMPILER="$c_compiler") + CMAKE_ARGS+=(-DCMAKE_CXX_COMPILER="${c_compiler/gcc/g++}") + fi + ;; + armhf) + local c_compiler=$(find_cross_compiler "arm-linux-gnueabihf-") + if [ $? -eq 0 ]; then + CMAKE_ARGS+=(-DCMAKE_C_COMPILER="$c_compiler") + CMAKE_ARGS+=(-DCMAKE_CXX_COMPILER="${c_compiler/gcc/g++}") + fi + ;; + esac + fi +} + +setup_cross_compilation + # Compute distro-specific release suffix if [ -f "${SOURCE_DIR}/scripts/distro_release.sh" ]; then DISTRO_DEB_RELEASE=$(bash "${SOURCE_DIR}/scripts/distro_release.sh")