diff --git a/.github/workflows/.dev.workflow.yml b/.github/workflows/.dev.workflow.yml index 90407aa..2f09bfb 100644 --- a/.github/workflows/.dev.workflow.yml +++ b/.github/workflows/.dev.workflow.yml @@ -8,16 +8,13 @@ on: branches-ignore: - xlink_upstream - - jobs: - build: runs-on: ${{ matrix.os }} strategy: matrix: os: [macos-latest, windows-latest, ubuntu-latest] - compiler: [default] + compiler: [default, clang] libusb: [ON, OFF] include: - os: windows-latest @@ -48,6 +45,38 @@ jobs: choco install mingw choco upgrade mingw + - name: Install Clang on macOS + if: matrix.os == 'macos-latest' && matrix.compiler == 'clang' + run: | + brew install llvm + echo "/usr/local/opt/llvm/bin" >> $GITHUB_PATH + + - name: Install Clang on Ubuntu + if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang' + run: | + sudo apt-get install clang + + - name: Install Clang on Windows + if: matrix.os == 'windows-latest' && matrix.compiler == 'clang' + run: | + choco install llvm + echo "C:\Program Files\LLVM\bin" >> $env:GITHUB_PATH + + - name: Install Ninja on macOS + if: matrix.os == 'macos-latest' + run: | + brew install ninja + + - name: Install Ninja on Ubuntu + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get install ninja-build + + - name: Install Ninja on Windows + if: matrix.os == 'windows-latest' + run: | + choco install ninja + - name: configure if: matrix.compiler == 'default' run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} @@ -56,5 +85,9 @@ jobs: if: matrix.compiler == 'mingw' run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} -G"MinGW Makefiles" + - name: configure + if: matrix.compiler == 'clang' + run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} -G"Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + - name: build - run: cmake --build build --parallel + run: cmake --build build --parallel \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c768b7c..b6be6e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,10 +89,10 @@ if(XLINK_ENABLE_LIBUSB) else() # Link to CMake libusb target_link_libraries(${TARGET_NAME} PRIVATE usb-1.0) - if(WIN32 AND NOT MINGW) + if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib) # workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20022 - target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") + target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") endif() endif() diff --git a/src/pc/protocols/usb_host.cpp b/src/pc/protocols/usb_host.cpp index 65b517c..a57b749 100644 --- a/src/pc/protocols/usb_host.cpp +++ b/src/pc/protocols/usb_host.cpp @@ -1,6 +1,15 @@ // project #define MVLOG_UNIT_NAME xLinkUsb +// std +#include +#include +#include +#include +#include +#include +#include + // libraries #ifdef XLINK_LIBUSB_LOCAL #include @@ -15,15 +24,6 @@ #include "usb_host.h" #include "../PlatformDeviceFd.h" -// std -#include -#include -#include -#include -#include -#include -#include - constexpr static int MAXIMUM_PORT_NUMBERS = 7; using VidPid = std::pair; static const int MX_ID_TIMEOUT_MS = 100;