diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e120929..2f45cdf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,26 +2,86 @@ name: Qt CI on: push: - branches: [ master ] pull_request: - branches: [ master ] + workflow_dispatch: jobs: build: - - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-15] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install libusb + if: runner.os == 'Linux' run: | sudo apt update sudo apt install libusb-1.0-0-dev - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v4 + with: + modules: qtwebchannel qtpositioning qtserialport qt5compat qtwebengine + - uses: ilammy/msvc-dev-cmd@v1 + - name: Build on ${{ matrix.os }} + shell: cmd + if: runner.os == 'Windows' + run: | + vcpkg install libusb + set PKG_CONFIG_PATH=C:/vcpkg/packages/libusb_x64-windows/lib/pkgconfig;%PKG_CONFIG_PATH% + md build + cd build + qmake ../qserial.pro + nmake + dir /s + del release\*.obj release\*.cpp + - name: Build on ${{ matrix.os }} + shell: bash + if: runner.os != 'Windows' + run: | + mkdir build + cd build + qmake ../qserial.pro + make -j$(nproc) + + - name: Deploy (Windows) + if: matrix.os == 'windows-latest' + run: windeployqt build/release/QSerial.exe + + - name: Deploy (macOS) + if: matrix.os == 'macos-15' + run: macdeployqt build/QSerial.app -dmg + + - name: Deploy (Linux) + if: matrix.os == 'ubuntu-latest' + run: | + # Example using linuxdeployqt or creating a simple tarball + ldd build/QSerial + #tar -czvf QSerial-Linux.tar.gz build/QSerial + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 with: - modules: qtwebengine - - name: qmake - run: qmake qserial.pro - - name: make - run: make + name: qserial-${{ matrix.os }} + path: | + build/release + build/QSerial + build/*.dmg + if-no-files-found: error + + release: + if: startsWith(github.ref, 'refs/tags/') + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + files: artifacts/**/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 364aabd..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Create macOS release on tag push - -on: - push: - tags: - - "v*" - -jobs: - build: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - name: Install Qt - uses: jurplel/install-qt-action@v3 - with: - modules: qtwebengine - - name: qmake - run: qmake qserial.pro - - name: make - run: make - - name: Change libusb path - run: install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib QSerial.app/Contents/MacOS/QSerial - - name: Copy libusb to frameworks - run: mkdir -p QSerial.app/Contents/Frameworks && cp /usr/local/lib/libusb-1.0.0.dylib QSerial.app/Contents/Frameworks/libusb-1.0.0.dylib - - name: Qt mac deploy to .dmg - run: macdeployqt QSerial.app -verbose=1 -dmg - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: QSerial.dmg - -permissions: - contents: write diff --git a/drivers/serialportcp210x.cpp b/drivers/serialportcp210x.cpp index fe595b4..6260973 100644 --- a/drivers/serialportcp210x.cpp +++ b/drivers/serialportcp210x.cpp @@ -1,6 +1,8 @@ #include "serialportcp210x.h" #include #include +#include + #define CP210X_CTRL_IN \ (LIBUSB_RECIPIENT_INTERFACE | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN) @@ -28,14 +30,20 @@ #define TIMEOUT 300 -struct Q_PACKED SerialStatusResponse { - quint32 ulErrors; - quint32 ulHoldReasons; - quint32 ulAmountInInQueue; - quint32 ulAmountInOutQueue; - quint8 bEofReceived; - quint8 bWaitForImmediate; - quint8 bReserved; +#ifdef _MSC_VER + #define PACKED_STRUCT __declspec(align(1)) +#else + #define PACKED_STRUCT __attribute__((packed)) +#endif + +struct PACKED_STRUCT SerialStatusResponse { + uint32_t ulErrors; + uint32_t ulHoldReasons; + uint32_t ulAmountInInQueue; + uint32_t ulAmountInOutQueue; + uint8_t bEofReceived; + uint8_t bWaitForImmediate; + uint8_t bReserved; }; SerialPortCP210X::SerialPortCP210X(QObject *parent, libusb_device *device)