Skip to content

Commit

Permalink
Merge pull request #84 from onthegrid007/master
Browse files Browse the repository at this point in the history
Clang Support
  • Loading branch information
moratom committed Jul 31, 2024
2 parents 85c306c + 068144a commit 2b517e1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
43 changes: 38 additions & 5 deletions .github/workflows/.dev.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<LINK_ONLY:/DELAYLOAD:libusb-1.0$<$<CONFIG:Debug>:d>.dll>")
target_link_options(${TARGET_NAME} PUBLIC "$<LINK_ONLY:/DELAYLOAD:libusb-1.0$<$<CONFIG:Debug>:d>.dll>")
endif()
endif()

Expand Down
18 changes: 9 additions & 9 deletions src/pc/protocols/usb_host.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
// project
#define MVLOG_UNIT_NAME xLinkUsb

// std
#include <mutex>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <thread>
#include <chrono>
#include <cstring>

// libraries
#ifdef XLINK_LIBUSB_LOCAL
#include <libusb.h>
Expand All @@ -15,15 +24,6 @@
#include "usb_host.h"
#include "../PlatformDeviceFd.h"

// std
#include <mutex>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <thread>
#include <chrono>
#include <cstring>

constexpr static int MAXIMUM_PORT_NUMBERS = 7;
using VidPid = std::pair<uint16_t, uint16_t>;
static const int MX_ID_TIMEOUT_MS = 100;
Expand Down

0 comments on commit 2b517e1

Please sign in to comment.