From 6dcf3bd819c75e29c25411f090582da3efeb45b0 Mon Sep 17 00:00:00 2001 From: floppyhammer Date: Wed, 3 Sep 2025 10:03:06 +0800 Subject: [PATCH 1/2] Fix macOS build --- src/RtlUsbAdapter.cpp | 2 +- txdemo/main.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/RtlUsbAdapter.cpp b/src/RtlUsbAdapter.cpp index 0eb5bb3..dce8a66 100644 --- a/src/RtlUsbAdapter.cpp +++ b/src/RtlUsbAdapter.cpp @@ -1,7 +1,7 @@ #include "RtlUsbAdapter.h" #include -#if defined(__ANDROID__) || defined(_MSC_VER) +#if defined(__ANDROID__) || defined(_MSC_VER) || defined(__APPLE__) #include #else #include diff --git a/txdemo/main.cpp b/txdemo/main.cpp index 8333e13..1460fd0 100644 --- a/txdemo/main.cpp +++ b/txdemo/main.cpp @@ -10,7 +10,9 @@ #define fork() (0) #define sleep(seconds) Sleep((seconds)*1000) #elif defined(__ANDROID__) - // On Android, include the libusb header as required. + #include +#elif defined(__APPLE__) + #include #include #else #include From 05ec39b4291d01166b9ee37050e58a3783433f6d Mon Sep 17 00:00:00 2001 From: floppyhammer Date: Wed, 3 Sep 2025 19:56:43 +0800 Subject: [PATCH 2/2] Add macOS to CI --- .github/workflows/cmake-multi-platform.yml | 99 +++++++++++----------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index a220013..e2fe95d 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -24,7 +24,7 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-latest] build_type: [Release] c_compiler: [gcc, clang, cl] include: @@ -37,6 +37,12 @@ jobs: - os: ubuntu-latest c_compiler: clang cpp_compiler: clang++ + - os: macos-latest + c_compiler: clang + cpp_compiler: clang++ + - os: macos-latest + c_compiler: gcc + cpp_compiler: g++ exclude: - os: windows-latest c_compiler: gcc @@ -44,61 +50,54 @@ jobs: c_compiler: clang - os: ubuntu-latest c_compiler: cl + - os: macos-latest + c_compiler: cl steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set reusable strings - # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. - id: strings - shell: bash - run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - name: Install dependency libraries (Windows) - id: vars - if: runner.os == 'Windows' - run: | - git clone https://github.com/Microsoft/vcpkg.git - cd vcpkg - .\bootstrap-vcpkg.bat - .\vcpkg integrate install - .\vcpkg install libusb - echo ("VCPKG_ROOT=" + "$PWD") >> $env:GITHUB_ENV + - name: Install dependency libraries (Windows) + id: vars + if: runner.os == 'Windows' + run: | + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + .\bootstrap-vcpkg.bat + .\vcpkg integrate install + .\vcpkg install libusb + echo ("VCPKG_ROOT=" + "$PWD") >> $env:GITHUB_ENV - - name: Install dependency libraries (Linux) - if: runner.os == 'Linux' - run: - sudo apt-get install libusb-1.0-0-dev + - name: Install dependency libraries (Linux) + if: runner.os == 'Linux' + run: + sudo apt install libusb-1.0-0-dev - - name: Configure CMake (Windows) - if: runner.os == 'Windows' - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }} + - name: Install dependency libraries (macOS) + if: runner.os == 'macOS' + run: + brew install libusb - - name: Configure CMake (Linux) - if: runner.os == 'Linux' - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }} + - name: Configure CMake + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} - - name: Build - # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest --build-config ${{ matrix.build_type }} + - name: Test + working-directory: ${{ steps.strings.outputs.build-output-dir }} + # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest --build-config ${{ matrix.build_type }}