File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,34 @@ jobs:
264264 fail : true
265265 # No test runs/results: cross-compiled Android binaries are not runnable on a host machine
266266
267+ emscripten-build :
268+ runs-on : ubuntu-latest
269+ steps :
270+ - uses : actions/checkout@v3
271+ with :
272+ path : src
273+ - name : Setup emsdk
274+ uses : mymindstorm/setup-emsdk@v14
275+ - name : Verify emsdk
276+ run : emcc -v
277+ - name : Install dependencies
278+ run : |
279+ sudo apt update
280+ sudo apt install ninja-build
281+ - name : Configure
282+ run : |
283+ rm -rf build install
284+ echo "EMSDK:" $EMSDK
285+ cmake -B build/static -S src -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install/static -DLIBUSB_BUILD_EXAMPLES=OFF -DLIBUSB_BUILD_TESTING=OFF -DLIBUSB_BUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
286+ - name : Build Static
287+ working-directory : build/static
288+ run : ninja install
289+ - name : Check artifacts
290+ uses : andstor/file-existence-action@v2
291+ with :
292+ files : " install/static/lib/libusb-1.0.a, \
293+ install/static/include/libusb-1.0/libusb.h"
294+ fail : true
267295
268296 publish-test-results :
269297 name : " Publish Tests Results"
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ project(usb-1.0
1717 VERSION ${LIBUSB_VERSION}
1818 LANGUAGES C
1919)
20+ if (EMSCRIPTEN)
21+ set (CMAKE_CXX_STANDARD 20)
22+ enable_language (CXX)
23+ endif ()
2024
2125# This function generates all the local variables what end up getting written to config.
2226# We use a function as any vars set in this context don't mess with the rest of the file.
@@ -207,6 +211,11 @@ else()
207211 target_sources (usb-1.0 PRIVATE
208212 "${LIBUSB_ROOT} /os/openbsd_usb.c"
209213 )
214+ elseif (EMSCRIPTEN)
215+ target_sources (usb-1.0 PRIVATE
216+ "${LIBUSB_ROOT} /os/emscripten_webusb.cpp"
217+ )
218+ target_compile_options (usb-1.0 PRIVATE -pthread)
210219 else ()
211220 message (FATAL_ERROR "Unsupported target platform: ${CMAKE_SYSTEM_NAME} " )
212221 endif ()
You can’t perform that action at this time.
0 commit comments