Skip to content

Commit 8fcc7d7

Browse files
authored
build: link with libc++ and libc++abi on Linux and Windows (#175)
* build: integrate libc++ and libc++abi for cross-platform support * fix: GitHub actions * build: update clang compiler paths in x86_64-linux-clang.cmake * build: add libc++ as the standard library for linking * fix: linux build by adding libc++-dev and libc++abi-dev * Revert "fix: linux build by adding libc++-dev and libc++abi-dev" This reverts commit f0461e1. * build: inherit libc++ include paths and set as standard library for Linux * refactor: update DesktopCapturer to use unique_ptr and improve method signatures * build: update CMakeLists.txt to inherit libc++ include paths for both Linux and Windows * build: update CMake and action files for aarch32 and aarch64 support
1 parent c442cb6 commit 8fcc7d7

File tree

23 files changed

+347
-116
lines changed

23 files changed

+347
-116
lines changed

.github/actions/build/action.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,31 @@ runs:
4747
server-password: MAVEN_TOKEN
4848

4949
- name: Build
50-
run: mvn package -DskipTests
50+
run: |
51+
if [ "${{ inputs.platform-name }}" == "linux_arm" ]; then
52+
mvn package -DskipTests -Plinux-aarch32
53+
elif [ "${{ inputs.platform-name }}" == "linux_arm64" ]; then
54+
mvn package -DskipTests -Plinux-aarch64
55+
else
56+
mvn package -DskipTests
57+
fi
5158
shell: bash
5259

5360
- name: Test
61+
if: ${{ inputs.platform-name != 'linux_arm' && inputs.platform-name != 'linux_arm64' }}
5462
run: mvn -B jar:jar surefire:test
5563
shell: bash
5664

5765
- name: Deploy
5866
env:
5967
MAVEN_USERNAME: ${{ inputs.maven-username }}
6068
MAVEN_TOKEN: ${{ inputs.maven-password }}
61-
run: mvn deploy -DskipTests
69+
run: |
70+
if [ "${{ inputs.platform-name }}" == "linux_arm" ]; then
71+
mvn deploy -DskipTests -Plinux-aarch32
72+
elif [ "${{ inputs.platform-name }}" == "linux_arm64" ]; then
73+
mvn deploy -DskipTests -Plinux-aarch64
74+
else
75+
mvn deploy -DskipTests
76+
fi
6277
shell: bash

.github/actions/prepare-linux/action.yml

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,74 @@ runs:
3333
sudo apt-get update
3434
sudo apt-get install -y pulseaudio libpulse-dev libasound2-dev libdbus-1-dev libudev-dev libv4l-dev libx11-dev libxcomposite-dev libxrandr-dev libxfixes-dev binutils cmake git locales lsb-release ninja-build pkg-config python3 python3-setuptools rsync unzip wget xz-utils
3535
36-
# More recent LLVM and Clang.
37-
wget https://apt.llvm.org/llvm.sh
38-
chmod +x llvm.sh
39-
sudo ./llvm.sh ${{ matrix.llvm }} all
36+
# Chromium Clang to be used with the clang toolchain file
37+
#curl -s https://raw.githubusercontent.com/chromium/chromium/main/tools/clang/scripts/update.py | python3 - --output-dir=/opt/clang
38+
# Use a more stable version of Clang
39+
sudo mkdir -p /opt/clang
40+
wget https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-llvmorg-20-init-9764-gb81d8e90-72.tar.xz
41+
sudo tar -xvf clang-llvmorg-20-init-9764-gb81d8e90-72.tar.xz -C /opt/clang
4042
4143
# Required for testing
4244
#pulseaudio --start
4345
sudo apt-get install -y pipewire pipewire-pulse gstreamer1.0-pipewire libspa-0.2-bluetooth libspa-0.2-jack pipewire-audio-client-libraries
4446
systemctl --user daemon-reload
4547
systemctl --user --now enable pipewire{,-pulse}.{socket,service}
4648
shell: bash
49+
50+
- name: Install required packages for arm
51+
if: matrix.platform.name == 'linux_arm'
52+
run: |
53+
sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
54+
55+
sudo dpkg --add-architecture armhf
56+
57+
sudo rm /etc/apt/sources.list
58+
59+
sudo tee -a /etc/apt/sources.list > /dev/null <<EOT
60+
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse
61+
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse
62+
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted universe multiverse
63+
EOT
64+
65+
sudo apt-get update
66+
67+
sudo apt install -y \
68+
libpulse-dev:armhf \
69+
libx11-dev:armhf \
70+
libxfixes-dev:armhf \
71+
libxrandr-dev:armhf \
72+
libxcomposite-dev:armhf \
73+
libdbus-1-dev:armhf
74+
75+
# Avoid python3 conflict errors.
76+
sudo apt install -y --no-install-recommends libudev-dev:armhf
77+
shell: bash
78+
79+
- name: Install required packages for arm64
80+
if: matrix.platform.name == 'linux_arm64'
81+
run: |
82+
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
83+
84+
sudo dpkg --add-architecture arm64
85+
86+
sudo rm /etc/apt/sources.list
87+
88+
sudo tee -a /etc/apt/sources.list > /dev/null <<EOT
89+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse
90+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse
91+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted universe multiverse
92+
EOT
93+
94+
sudo apt-get update
95+
96+
sudo apt install -y \
97+
libpulse-dev:arm64 \
98+
libx11-dev:arm64 \
99+
libxfixes-dev:arm64 \
100+
libxrandr-dev:arm64 \
101+
libxcomposite-dev:arm64 \
102+
libdbus-1-dev:arm64
103+
104+
# Avoid python3 conflict errors.
105+
sudo apt install -y --no-install-recommends libudev-dev:arm64
106+
shell: bash

.github/actions/prepare-macos/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ runs:
77
steps:
88
- name: Install required packages
99
run: |
10-
brew install ninja
1110
# Required for macos-13
1211
pip install setuptools
1312
# Required for macos-14

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ jobs:
5252
fail-fast: false
5353
matrix:
5454
platform:
55+
- name: linux_arm
56+
runs-on: ubuntu-22.04
57+
- name: linux_arm64
58+
runs-on: ubuntu-22.04
5559
- name: linux_x86-64
5660
runs-on: ubuntu-22.04
5761
java: [17]
58-
llvm: [21]
5962
runs-on: ${{ matrix.platform.runs-on }}
6063
steps:
6164
- name: Checkout code

.github/workflows/release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ env:
1818

1919
jobs:
2020
prepare-release:
21-
strategy:
22-
matrix:
23-
llvm: [ 21 ]
2421
runs-on: ubuntu-22.04
2522
steps:
2623
- id: prepare
@@ -100,7 +97,6 @@ jobs:
10097
- name: linux_x86-64
10198
runs-on: ubuntu-22.04
10299
java: [17]
103-
llvm: [21]
104100
runs-on: ${{ matrix.platform.runs-on }}
105101
steps:
106102
- name: Checkout code

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Maven Central artifacts contain native libraries that can be loaded on the follo
4040
<tr align="center">
4141
<th>Linux</th>
4242
<td>✔</td>
43-
<td>-</td>
44-
<td>-</td>
43+
<td>✔ armeabi-v7a</td>
44+
<td>✔ arm64-v8a</td>
4545
</tr>
4646
<tr align="center">
4747
<th>macOS</th>

webrtc-jni/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
<id>windows-clang</id>
149149
<properties>
150150
<cmake.clang>-T ClangCL</cmake.clang>
151+
<cmake.toolchain.file>toolchain/x86_64-windows-clang.cmake</cmake.toolchain.file>
151152
</properties>
152153
</profile>
153154
<profile>
@@ -159,7 +160,7 @@
159160
</os>
160161
</activation>
161162
<properties>
162-
<cmake.toolchain.file>toolchain/x86_64-linux-gnu.cmake</cmake.toolchain.file>
163+
<cmake.toolchain.file>toolchain/x86_64-linux-clang.cmake</cmake.toolchain.file>
163164
</properties>
164165
</profile>
165166
<profile>
@@ -171,7 +172,7 @@
171172
</os>
172173
</activation>
173174
<properties>
174-
<cmake.toolchain.file>toolchain/aarch32-linux-gnu.cmake</cmake.toolchain.file>
175+
<cmake.toolchain.file>toolchain/aarch32-linux-clang.cmake</cmake.toolchain.file>
175176
</properties>
176177
</profile>
177178
<profile>
@@ -183,7 +184,7 @@
183184
</os>
184185
</activation>
185186
<properties>
186-
<cmake.toolchain.file>toolchain/aarch64-linux-gnu.cmake</cmake.toolchain.file>
187+
<cmake.toolchain.file>toolchain/aarch64-linux-clang.cmake</cmake.toolchain.file>
187188
</properties>
188189
</profile>
189190
</profiles>

webrtc-jni/src/main/cpp/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,18 @@ if(APPLE)
8181
set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c++")
8282
target_link_libraries(${PROJECT_NAME} "-framework Foundation" "-framework AVFoundation" "-framework CoreMedia" "-framework CoreAudio" "-framework IOKit")
8383
elseif(LINUX)
84-
target_link_libraries(${PROJECT_NAME} -static-libgcc -static-libstdc++ pulse udev)
84+
if(NOT TARGET_CPU MATCHES "^arm")
85+
set(CXX_LIBS "-static-libgcc -stdlib=libc++ -lc++ -lc++abi")
86+
else()
87+
set(CXX_LIBS "-static-libgcc")
88+
endif()
89+
90+
target_link_libraries(${PROJECT_NAME} ${CXX_LIBS} pulse udev)
8591
elseif(WIN32)
86-
target_link_libraries(${PROJECT_NAME} dwmapi.lib mf.lib mfreadwrite.lib mfplat.lib mfuuid.lib shcore.lib)
92+
target_link_libraries(${PROJECT_NAME} c++.lib msvcprt.lib dwmapi.lib mf.lib mfreadwrite.lib mfplat.lib mfuuid.lib shcore.lib)
8793
endif()
8894

8995
install(TARGETS ${PROJECT_NAME}
9096
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime
9197
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime
92-
)
98+
)

webrtc-jni/src/main/cpp/dependencies/jni-voithos/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ target_include_directories(${PROJECT_NAME}
7979
include/jni
8080
include/jni/${JNI_PLATFORM}
8181
)
82+
83+
if(LINUX OR WIN32)
84+
target_link_libraries(${PROJECT_NAME} PRIVATE webrtc)
85+
endif()

webrtc-jni/src/main/cpp/dependencies/jni-voithos/src/JavaUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "JavaThreadEnv.h"
1717
#include "JavaWrappedException.h"
1818

19+
#include <exception>
1920
#include <ios>
2021

2122
bool ExceptionCheck(JNIEnv * env)

0 commit comments

Comments
 (0)