Skip to content

Commit 454554e

Browse files
authored
Add SunOS support (#40)
- add CI for NetBSD, OmniOS (SunOS-like system) and OpenBSD
1 parent 0c424f7 commit 454554e

3 files changed

Lines changed: 113 additions & 17 deletions

File tree

.github/workflows/builds.yml

Lines changed: 101 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
COMMON_CTEST_ARGS: --no-compress-output --output-on-failure -E "^set_option$"
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v6
1818
with:
1919
path: src
2020
- name: Install dependencies
@@ -33,7 +33,7 @@ jobs:
3333
working-directory: build/static
3434
run: ninja install
3535
- name: Check artifacts
36-
uses: andstor/file-existence-action@v2
36+
uses: andstor/file-existence-action@v3
3737
with:
3838
files: "install/shared/lib/libusb-1.0.so, \
3939
install/shared/include/libusb-1.0/libusb.h, \
@@ -50,21 +50,21 @@ jobs:
5050
run: ctest --output-junit test_static.xml ${{ env.COMMON_CTEST_ARGS }}
5151
- name: Upload Test Results
5252
if: always()
53-
uses: actions/upload-artifact@v4
53+
uses: actions/upload-artifact@v6
5454
with:
5555
name: Test Results Ubuntu
5656
path: |
5757
build/shared/test_shared.xml
5858
build/static/test_static.xml
5959
6060
61-
macos-buid:
61+
macos-build:
6262
runs-on: macos-latest
6363
env:
6464
COMMON_CTEST_ARGS: --no-compress-output --output-on-failure
6565

6666
steps:
67-
- uses: actions/checkout@v3
67+
- uses: actions/checkout@v6
6868
with:
6969
path: src
7070
- name: Install dependencies
@@ -81,7 +81,7 @@ jobs:
8181
working-directory: build/static
8282
run: ninja install
8383
- name: Check artifacts
84-
uses: andstor/file-existence-action@v2
84+
uses: andstor/file-existence-action@v3
8585
with:
8686
files: "install/shared/lib/libusb-1.0.dylib, \
8787
install/shared/include/libusb-1.0/libusb.h, \
@@ -98,22 +98,22 @@ jobs:
9898
run: ctest --output-junit test_static.xml ${{ env.COMMON_CTEST_ARGS }}
9999
- name: Upload Test Results
100100
if: always()
101-
uses: actions/upload-artifact@v4
101+
uses: actions/upload-artifact@v6
102102
with:
103103
name: Test Results macOS
104104
path: |
105105
build/shared/test_shared.xml
106106
build/static/test_static.xml
107107
108108
109-
windows-msvc-buid:
109+
windows-msvc-build:
110110
runs-on: windows-latest
111111
env:
112112
COMMON_CTEST_ARGS: --no-compress-output --output-on-failure
113113
VCVARS64_PATH: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat'
114114

115115
steps:
116-
- uses: actions/checkout@v3
116+
- uses: actions/checkout@v6
117117
with:
118118
path: src
119119
- name: Install dependencies
@@ -157,7 +157,7 @@ jobs:
157157
call "${{ env.VCVARS64_PATH }}"
158158
ninja install
159159
- name: Check artifacts
160-
uses: andstor/file-existence-action@v2
160+
uses: andstor/file-existence-action@v3
161161
with:
162162
files: "install/msvc/lib/usb-1.0.lib, \
163163
install/msvc/bin/libusb-1.0.dll, \
@@ -204,7 +204,7 @@ jobs:
204204
run: ctest --output-junit test_ninja_static.xml ${{ env.COMMON_CTEST_ARGS }}
205205
- name: Upload Test Results
206206
if: always()
207-
uses: actions/upload-artifact@v4
207+
uses: actions/upload-artifact@v6
208208
with:
209209
name: Test Results MSVC
210210
path: |
@@ -224,7 +224,7 @@ jobs:
224224
ANDROID_ARM64_CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a
225225

226226
steps:
227-
- uses: actions/checkout@v3
227+
- uses: actions/checkout@v6
228228
with:
229229
path: src
230230
- name: Install dependencies
@@ -251,7 +251,7 @@ jobs:
251251
working-directory: build/static_64
252252
run: ninja install
253253
- name: Check artifacts
254-
uses: andstor/file-existence-action@v2
254+
uses: andstor/file-existence-action@v3
255255
with:
256256
files: "install/shared_32/lib/libusb-1.0.so, \
257257
install/shared_32/include/libusb-1.0/libusb.h, \
@@ -267,7 +267,7 @@ jobs:
267267
emscripten-build:
268268
runs-on: ubuntu-latest
269269
steps:
270-
- uses: actions/checkout@v3
270+
- uses: actions/checkout@v6
271271
with:
272272
path: src
273273
- name: Setup emsdk
@@ -287,15 +287,99 @@ jobs:
287287
working-directory: build/static
288288
run: ninja install
289289
- name: Check artifacts
290-
uses: andstor/file-existence-action@v2
290+
uses: andstor/file-existence-action@v3
291291
with:
292292
files: "install/static/lib/libusb-1.0.a, \
293293
install/static/include/libusb-1.0/libusb.h"
294294
fail: true
295295

296+
netbsd-build:
297+
runs-on: ubuntu-latest
298+
steps:
299+
- uses: actions/checkout@v6
300+
with:
301+
path: src
302+
- uses: cross-platform-actions/action@v0.32.0
303+
with:
304+
operating_system: netbsd
305+
architecture: x86-64
306+
version: '10.1'
307+
run: |
308+
sudo pkgin update
309+
sudo pkgin -y install cmake ninja-build
310+
rm -rf build install
311+
cmake -B build/shared -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=ON
312+
cmake -B build/static -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=OFF
313+
ninja -C build/shared install
314+
ninja -C build/static install
315+
- name: Check artifacts
316+
uses: andstor/file-existence-action@v3
317+
with:
318+
files: "install/shared/lib/libusb-1.0.so, \
319+
install/shared/include/libusb-1.0/libusb.h, \
320+
install/static/lib/libusb-1.0.a, \
321+
install/static/include/libusb-1.0/libusb.h"
322+
fail: true
323+
324+
omnios-build:
325+
runs-on: ubuntu-latest
326+
steps:
327+
- uses: actions/checkout@v6
328+
with:
329+
path: src
330+
- uses: cross-platform-actions/action@v0.32.0
331+
with:
332+
operating_system: omnios
333+
architecture: x86-64
334+
version: 'r151056'
335+
run: |
336+
sudo pkg refresh
337+
sudo pkg install build-essential cmake header-ugen header-usb ninja
338+
rm -rf build install
339+
cmake -B build/shared -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=ON
340+
cmake -B build/static -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=OFF
341+
ninja -C build/shared install
342+
ninja -C build/static install
343+
- name: Check artifacts
344+
uses: andstor/file-existence-action@v3
345+
with:
346+
files: "install/shared/lib/libusb-1.0.so, \
347+
install/shared/include/libusb-1.0/libusb.h, \
348+
install/static/lib/libusb-1.0.a, \
349+
install/static/include/libusb-1.0/libusb.h"
350+
fail: true
351+
352+
openbsd-build:
353+
runs-on: ubuntu-latest
354+
steps:
355+
- uses: actions/checkout@v6
356+
with:
357+
path: src
358+
- uses: cross-platform-actions/action@v0.32.0
359+
with:
360+
operating_system: openbsd
361+
architecture: x86-64
362+
version: '7.8'
363+
run: |
364+
sudo pkg_add -u
365+
sudo pkg_add cmake ninja
366+
rm -rf build install
367+
cmake -B build/shared -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=ON
368+
cmake -B build/static -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static -DLIBUSB_BUILD_EXAMPLES=ON -DLIBUSB_BUILD_TESTING=ON -DLIBUSB_BUILD_SHARED_LIBS=OFF
369+
ninja -C build/shared install
370+
ninja -C build/static install
371+
- name: Check artifacts
372+
uses: andstor/file-existence-action@v3
373+
with:
374+
files: "install/shared/lib/libusb-1.0.so, \
375+
install/shared/include/libusb-1.0/libusb.h, \
376+
install/static/lib/libusb-1.0.a, \
377+
install/static/include/libusb-1.0/libusb.h"
378+
fail: true
379+
296380
publish-test-results:
297381
name: "Publish Tests Results"
298-
needs: [ubuntu-build, macos-buid, windows-msvc-buid, android-build]
382+
needs: [ubuntu-build, macos-build, windows-msvc-build, android-build]
299383
runs-on: ubuntu-latest
300384
permissions:
301385
checks: write
@@ -304,7 +388,7 @@ jobs:
304388

305389
steps:
306390
- name: Download Artifacts
307-
uses: actions/download-artifact@v4
391+
uses: actions/download-artifact@v7
308392
with:
309393
path: artifacts
310394
- name: Publish Test Results

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if(EMSCRIPTEN)
2222
enable_language(CXX)
2323
endif()
2424

25+
message("Building usb-1.0 for: ${CMAKE_SYSTEM_NAME}")
26+
2527
# This function generates all the local variables what end up getting written to config.
2628
# We use a function as any vars set in this context don't mess with the rest of the file.
2729
# e.g. Logging LIBUSB_ENABLE_LOGGING mapps to ENABLE_LOGGING in the config, keeps it clean
@@ -250,6 +252,11 @@ else()
250252
target_sources(usb-1.0 PRIVATE
251253
"${LIBUSB_ROOT}/os/openbsd_usb.c"
252254
)
255+
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
256+
target_sources(usb-1.0 PRIVATE
257+
"${LIBUSB_ROOT}/os/sunos_usb.c"
258+
)
259+
target_link_libraries(usb-1.0 PRIVATE -ldevinfo -lnvpair)
253260
elseif(EMSCRIPTEN)
254261
target_sources(usb-1.0 PRIVATE
255262
"${LIBUSB_ROOT}/os/emscripten_webusb.cpp"

tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ target_link_libraries(libusb_tests_build_interface INTERFACE usb-1.0)
1010
target_include_directories(libusb_tests_build_interface INTERFACE "${LIBUSB_GEN_INCLUDES}")
1111
target_compile_definitions(libusb_tests_build_interface INTERFACE $<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS=1>)
1212

13+
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD|OpenBSD")
14+
find_package(Threads REQUIRED)
15+
target_link_libraries(libusb_tests_build_interface INTERFACE Threads::Threads)
16+
endif()
17+
1318
function(add_libusb_test TEST_NAME)
1419
set(SOURCES "${TESTS_ROOT}/testlib.c")
1520
foreach(SOURCE_NAME ${ARGN})

0 commit comments

Comments
 (0)