Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,67 @@ on:

env:
BUILD_TYPE: Release
DEBIAN_FRONTEND: noninteractive
TZ: Asia/Shanghai

jobs:
build-and-test:
name: Build and Test - ${{ matrix.os }} (${{ matrix.arch }})
name: Build and Test - ${{ matrix.container || matrix.os }} (${{ matrix.arch }}, ${{ matrix.cmake_build_type }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 (主要测试平台)
# Linux x86_64 (主要测试平台, runner 原生环境)
- os: ubuntu-latest
container: ''
arch: x86_64
cmake_build_type: Release
use_qemu: false
# Linux x86_64 Debug 构建
- os: ubuntu-latest
container: ''
arch: x86_64
cmake_build_type: Debug
use_qemu: false
# Linux aarch64 Release 构建 (使用 QEMU 模拟)
- os: ubuntu-latest
container: ''
arch: aarch64
cmake_build_type: Release
use_qemu: true
# Ubuntu 22.04 容器 (Docker)
- os: ubuntu-latest
container: 'ubuntu:22.04'
arch: x86_64
cmake_build_type: Release
use_qemu: false
# Ubuntu 20.04 容器 (Docker)
- os: ubuntu-latest
container: 'ubuntu:20.04'
arch: x86_64
cmake_build_type: Release
use_qemu: false

steps:
- name: 准备容器环境 (Ubuntu 20.04/22.04)
if: matrix.container != ''
shell: bash
run: |
apt-get update
apt-get install -y --no-install-recommends \
sudo \
ca-certificates \
tzdata \
git \
build-essential \
cmake \
make \
libpthread-stubs0-dev \
tar \
gzip

- name: 检出代码
uses: actions/checkout@v4

Expand All @@ -50,9 +85,9 @@ jobs:
path: |
build
~/.cmake
key: ${{ runner.os }}-cmake-${{ matrix.arch }}-${{ matrix.cmake_build_type }}-${{ hashFiles('**/CMakeLists.txt') }}
key: ${{ runner.os }}-${{ matrix.container || 'native' }}-cmake-${{ matrix.arch }}-${{ matrix.cmake_build_type }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-cmake-${{ matrix.arch }}-${{ matrix.cmake_build_type }}-
${{ runner.os }}-${{ matrix.container || 'native' }}-cmake-${{ matrix.arch }}-${{ matrix.cmake_build_type }}-

- name: 安装构建依赖
run: |
Expand Down
26 changes: 19 additions & 7 deletions cmake/linkerhand-cpp-sdk-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,31 @@ if(NOT TARGET LinkerHand::linkerhand_cpp_sdk)
set_target_properties(LinkerHand::linkerhand_cpp_sdk PROPERTIES
IMPORTED_IMPLIB "${_lh_imported_implib}")
endif()
# 公共头 CanFD.h / PCANBus.h / CanFrame.h 引用了 third_party 头(Hcanbus.h /
# PCANBasic.h)。把对应 include 目录补到 imported target,下游 link 后无需手动配。
# 是否启用 CAN-FD:release-package 由 CI 在 USE_CANFD=ON 下打包,默认 ON;
# 下游可显式 -DLINKERHAND_USE_CANFD=OFF 覆盖,跳过 libcanbus 头依赖。
if(NOT DEFINED LINKERHAND_USE_CANFD)
if(EXISTS "${_lh_thirdparty_root}/libcanbus")
set(LINKERHAND_USE_CANFD ON)
else()
set(LINKERHAND_USE_CANFD OFF)
endif()
endif()
set_property(TARGET LinkerHand::linkerhand_cpp_sdk APPEND PROPERTY
INTERFACE_COMPILE_DEFINITIONS "LINKERHAND_USE_CANFD=$<IF:$<BOOL:${LINKERHAND_USE_CANFD}>,1,0>")
# 公共头 PCANBus.h / CanFrame.h(以及 CANFD 开启时的 CanFD.h)引用了 third_party
# 头(PCANBasic.h / Hcanbus.h)。把对应 include 目录补到 imported target,下游 link
# 后无需手动配。
if(_lh_thirdparty_root)
if(WIN32)
if(EXISTS "${_lh_thirdparty_root}/libcanbus/include/windows")
set_property(TARGET LinkerHand::linkerhand_cpp_sdk APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${_lh_thirdparty_root}/libcanbus/include/windows")
endif()
if(EXISTS "${_lh_thirdparty_root}/PCAN_Basic/Include")
set_property(TARGET LinkerHand::linkerhand_cpp_sdk APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${_lh_thirdparty_root}/PCAN_Basic/Include")
endif()
elseif(UNIX AND EXISTS "${_lh_thirdparty_root}/libcanbus/include/linux")
if(LINKERHAND_USE_CANFD AND EXISTS "${_lh_thirdparty_root}/libcanbus/include/windows")
set_property(TARGET LinkerHand::linkerhand_cpp_sdk APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${_lh_thirdparty_root}/libcanbus/include/windows")
endif()
elseif(UNIX AND LINKERHAND_USE_CANFD AND EXISTS "${_lh_thirdparty_root}/libcanbus/include/linux")
set_property(TARGET LinkerHand::linkerhand_cpp_sdk APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${_lh_thirdparty_root}/libcanbus/include/linux")
endif()
Expand Down
Loading
Loading