Skip to content

Commit

Permalink
ci: Docker build for Fedora/Mingw (libusb#535)
Browse files Browse the repository at this point in the history
Use GithubActions Docker build for Fedora/Mingw builds.
To avoid using `builds.sr.ht`.
Related: libusb#476
  • Loading branch information
Youw committed May 1, 2023
1 parent 8588168 commit df12234
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 33 deletions.
33 changes: 0 additions & 33 deletions .builds/fedora-mingw.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,73 @@ jobs:
name: hidapi-win
path: artifacts/
retention-days: ${{ (github.event_name == 'pull_request' || github.ref_name != 'master') && 7 || 90 }}


fedora-mingw:

runs-on: ubuntu-latest
container: fedora:latest
steps:
- uses: actions/checkout@v3
with:
path: hidapisrc
- name: Install dependencies
run: sudo dnf install -y autoconf automake libtool mingw64-gcc cmake ninja-build make
- name: Configure CMake
run: |
rm -rf build install
mingw64-cmake -B build/shared-cmake -S hidapisrc -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared-cmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
mingw64-cmake -B build/static-cmake -S hidapisrc -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static-cmake -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
- name: Configure Automake
working-directory: hidapisrc
run: |
./bootstrap
mingw64-configure
- name: Build CMake Shared
working-directory: build/shared-cmake
run: ninja install
- name: Build CMake Static
working-directory: build/static-cmake
run: ninja install
- name: Build Automake
working-directory: hidapisrc
run: |
make
make DESTDIR=$PWD/../install/automake install
make clean
- name: Build manual Makefile
working-directory: hidapisrc/windows
run: make -f Makefile-manual OS=MINGW CC=x86_64-w64-mingw32-gcc
- name: Check artifacts
uses: andstor/file-existence-action@v2
with:
files: "install/shared-cmake/bin/libhidapi.dll, \
install/shared-cmake/lib/libhidapi.dll.a, \
install/shared-cmake/include/hidapi/hidapi.h, \
install/shared-cmake/include/hidapi/hidapi_winapi.h, \
install/static-cmake/lib/libhidapi.a, \
install/static-cmake/include/hidapi/hidapi.h, \
install/static-cmake/include/hidapi/hidapi_winapi.h"
fail: true
- name: Check CMake Export Package Shared
run: |
mingw64-cmake \
-GNinja \
-B build/shared_test \
-S hidapisrc/hidtest \
-Dhidapi_DIR=$PWD/install/shared-cmake/lib/cmake/hidapi \
-DCMAKE_INSTALL_PREFIX=install/shared_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
cd build/shared_test
ninja install
- name: Check CMake Export Package Static
run: |
mingw64-cmake \
-GNinja \
-B build/static_test \
-S hidapisrc/hidtest \
-Dhidapi_DIR=$PWD/install/static-cmake/lib/cmake/hidapi \
-DCMAKE_INSTALL_PREFIX=install/static_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
cd build/static_test
ninja install
13 changes: 13 additions & 0 deletions windows/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ static void register_winapi_error_to_buffer(wchar_t **error_buffer, const WCHAR
}
}

#if defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Warray-bounds"
#endif
/* A bug in GCC/mingw gives:
* error: array subscript 0 is outside array bounds of 'wchar_t *[0]' {aka 'short unsigned int *[]'} [-Werror=array-bounds]
* | free(*error_buffer);
* Which doesn't make sense in this context. */

static void register_string_error_to_buffer(wchar_t **error_buffer, const WCHAR *string_error)
{
free(*error_buffer);
Expand All @@ -292,6 +301,10 @@ static void register_string_error_to_buffer(wchar_t **error_buffer, const WCHAR
}
}

#if defined(__GNUC__)
# pragma GCC diagnostic pop
#endif

static void register_winapi_error(hid_device *dev, const WCHAR *op)
{
register_winapi_error_to_buffer(&dev->last_error_str, op);
Expand Down

0 comments on commit df12234

Please sign in to comment.