Skip to content

Commit

Permalink
libusb: support building for emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
darkvision77 authored and neheb committed Feb 8, 2025
1 parent a73fce3 commit 6ff216b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,7 @@
"libusb-1.0"
],
"versions": [
"1.0.27-3",
"1.0.27-2",
"1.0.27-1",
"1.0.26-5",
Expand Down
15 changes: 13 additions & 2 deletions subprojects/packagefiles/libusb/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ project(
'c',
version: '1.0.27',
meson_version: '>=0.49.0',
default_options: [
'cpp_std=c++20',
],
)

add_project_arguments('-D_GNU_SOURCE', language: 'c')

cc = meson.get_compiler('c')
pconf = import('pkgconfig')

Expand All @@ -21,9 +22,17 @@ if host_machine.system() == 'windows'
cc.get_supported_arguments('-Wno-deprecated-declarations'),
language: 'c',
)
elif host_machine.system() == 'emscripten'
add_languages('cpp')
add_project_link_arguments(
'--bind', '-sASYNCIFY', '-sALLOW_MEMORY_GROWTH',
language: ['c', 'cpp'],
)
endif

cdata = configuration_data()
cdata.set('_GNU_SOURCE', true)

cdata.set('HAVE_SYSLOG', cc.has_function('syslog'))

if not cdata.get('HAVE_SYSLOG') and get_option('system-log')
Expand Down Expand Up @@ -102,6 +111,8 @@ elif host_machine.system() == 'windows'
sources += files('libusb/os/windows_common.c', 'libusb/os/windows_usbdk.c', 'libusb/os/windows_winusb.c')
elif host_machine.system() in ['darwin', 'netbsd', 'openbsd', 'sunos']
sources += files('libusb/os/@0@_usb.c'.format(host_machine.system()))
elif host_machine.system() == 'emscripten'
sources += files('libusb/os/emscripten_webusb.cpp')
else
sources += files('libusb/os/null_usb.c')
endif
Expand Down

0 comments on commit 6ff216b

Please sign in to comment.