Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 478f01c

Browse files
authored
Allow building OWT SDK with OpenSSL on Linux. (#681)
1 parent 3c12194 commit 478f01c

File tree

8 files changed

+75
-91
lines changed

8 files changed

+75
-91
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ You need [Doxygen](http://www.doxygen.nl/) in your path.
1818

1919
### Prepare the development environment
2020
Before you start, make sure you have the following prerequisites installed/configured:
21-
2221
- [WebRTC stack build dependencies](https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/development/prerequisite-sw/index.md).
2322
- [Proxy settings](https://github.com/open-webrtc-toolkit/owt-client-native/wiki/Proxy-config-for-building-native-SDK).
2423

@@ -66,7 +65,7 @@ target_os = []
6665
Common build options shared by Windows and Linux:
6766
- By default `x86|Debug` library will be created. Specify `--arch x64` if you want to build x64 libraries; Specify `--scheme release` if release version of library is to be built.
6867
- The built binary will be under path specified by `--output_path`. If `--output_path` is not set, the built binary will be under `src/out` directory.
69-
- The optional `--ssl_root` should be set to the root directory of lastest OpenSSL 1.1.1 binary. If specified, SDK will link to external openssl library instead of boringssl.
68+
- The optional `--ssl_root` should be set to the root directory of lastest OpenSSL 3.0 series directory. If specified, build tool will search external OpenSSL headers in `ssl_root/include` and OpenSSL binaries in `ssl_root/bin`. But binaries are not included in OWT SDK, so applications still need to link libcrypto and libssl.
7069
- Use `--gn_gen` to generate args.gn during the first build or when you change either `ssl_root`/`msdk_root`/`quic_root` options.
7170
- The optional `--quic_root` should point to the directory containing WebTransport library pre-built from owt-sdk-quic repo. This will build the SDK with WebTransport enabled for
7271
conference mode. Refer to [README.webtransport](https://github.com/open-webrtc-toolkit/owt-client-native/blob/main/README.webtransport) for the version of webtransport library to be used.

scripts/build-win.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def gngen(arch, ssl_root, msdk_root, quic_root, scheme, tests, runtime):
5555
gn_args.append('is_debug=true')
5656
gn_args.append('enable_iterator_debugging=true')
5757
if ssl_root:
58-
gn_args.append('owt_use_openssl=true')
59-
gn_args.append('owt_openssl_header_root="%s"' % (ssl_root + r'\include'))
60-
gn_args.append('owt_openssl_lib_root="%s"' % (ssl_root + r'\lib'))
58+
gn_args.append('rtc_build_ssl=false')
59+
gn_args.append('rtc_ssl_root="%s/include"' % ssl_root)
60+
gn_args.append('libsrtp_ssl_root="%s/include"' % ssl_root)
6161
if msdk_root:
6262
if arch == 'x86':
6363
msdk_lib = msdk_root + r'\lib\win32'
@@ -103,32 +103,12 @@ def ninjabuild(arch, scheme):
103103
return True
104104

105105

106-
def _getlibs(arch, scheme, ssl_root):
107-
'''Returns an array contains all .lib files' path
108-
'''
109-
result = []
110-
owt_path = os.path.join(OUT_PATH, r'%s-%s\obj\talk\owt\owt.lib' % (scheme, arch))
111-
result.append(owt_path)
112-
ssl_lib_path = os.path.join(ssl_root, 'lib')
113-
for root, dirs, files in os.walk(ssl_lib_path):
114-
for file in files:
115-
name, ext = os.path.splitext(file)
116-
if ext == '.lib' and name not in LIB_BLACK_LIST and 'test' not in name:
117-
result.append(os.path.abspath(os.path.join(root, file)))
118-
print('Merged %s.lib' % name)
119-
elif ext == '.lib':
120-
print('Skip %s.lib' % name)
121-
return result
122-
123-
124-
def _mergelibs(arch, scheme, ssl_root):
106+
def _copylibs(arch, scheme):
125107
out_lib = OUT_LIB % {'scheme': scheme}
126108
if os.path.exists(os.path.join(OUT_PATH, out_lib)):
127109
os.remove(os.path.join(OUT_PATH, out_lib))
128-
libs = _getlibs(arch, scheme, ssl_root)
129-
command = ['lib.exe', '/OUT:out\%s' % out_lib]
130-
command.extend(libs)
131-
subprocess.call(command, cwd=HOME_PATH)
110+
owt_path = os.path.join(OUT_PATH, r'%s-%s\obj\talk\owt\owt.lib' % (scheme, arch))
111+
shutil.copy(owt_path, os.path.join('out',out_lib))
132112

133113

134114
# Run unit tests on simulator. Return True if all tests are passed.
@@ -202,6 +182,8 @@ def main():
202182
if opts.ssl_root and not os.path.exists(os.path.expanduser(opts.ssl_root)):
203183
print('Invalid ssl_root.')
204184
return 1
185+
if opts.ssl_root:
186+
print('As ssl_root is specified, please link OpenSSL binaries into your application.')
205187
if opts.msdk_root and not os.path.exists(os.path.expanduser(opts.msdk_root)):
206188
print('Invalid msdk_root')
207189
return 1
@@ -216,7 +198,7 @@ def main():
216198
if not ninjabuild(opts.arch, opts.scheme):
217199
return 1
218200
else:
219-
_mergelibs(opts.arch, opts.scheme, opts.ssl_root)
201+
_copylibs(opts.arch, opts.scheme)
220202
if opts.tests:
221203
if not runtest(opts.arch, opts.scheme):
222204
return 1

scripts/build.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def gngen(arch, ssl_root, scheme):
6363
else:
6464
gn_args += (' is_debug=true')
6565
if ssl_root:
66-
gn_args += (' owt_use_openssl=true owt_openssl_header_root="%s" '\
67-
'owt_openssl_lib_root="%s"'%(ssl_root+'/include',ssl_root+'/lib'))
66+
gn_args += (' rtc_build_ssl=false rtc_ssl_root="%s" '\
67+
'libsrtp_ssl_root="%s"'%(ssl_root+'/include', ssl_root+'/include'))
6868
ret = subprocess.call(['gn', 'gen', getoutputpath(arch, scheme), '--args=%s' % gn_args],
6969
cwd=HOME_PATH, shell=False)
7070
if ret == 0:
@@ -90,12 +90,6 @@ def copyheaders(headers_target_folder):
9090
copy_framework_header.Process(os.path.join(
9191
HEADER_PATH, file_name), os.path.join(headers_target_folder, file_name))
9292

93-
def getexternalliblist(ssl_root):
94-
libs = []
95-
libs.append('%s/lib/libcrypto.a'%ssl_root)
96-
libs.append('%s/lib/libssl.a'%ssl_root)
97-
return libs
98-
9993
def buildframework():
10094
'''Create OWT.framework in out/'''
10195
if os.path.exists(OUT_FRAMEWORK_ROOT):
@@ -125,7 +119,7 @@ def buildwebrtcframework(arch_list, scheme):
125119
subprocess.call(cmd, cwd=HOME_PATH)
126120
return True
127121

128-
def dist(arch_list, scheme, ssl_root):
122+
def dist(arch_list, scheme):
129123
buildwebrtcframework(arch_list, scheme)
130124
out_lib_path = os.path.join(OUT_PATH, OUT_LIB_NAME)
131125
if os.path.exists(out_lib_path):
@@ -136,9 +130,6 @@ def dist(arch_list, scheme, ssl_root):
136130
for target_arch in arch_list:
137131
for sdk_target in SDK_TARGETS:
138132
argu.append('%s/obj/talk/owt/lib%s.a'%(getoutputpath(target_arch, scheme), sdk_target))
139-
# Add external libs.
140-
if ssl_root:
141-
argu.extend(getexternalliblist(ssl_root))
142133
subprocess.call(argu, cwd=HOME_PATH)
143134
if scheme == 'release':
144135
subprocess.call(['strip', '-S', '-x', '%s/out/libowt.a'%HOME_PATH],
@@ -199,7 +190,7 @@ def main():
199190
return 1
200191
if not ninjabuild(arch_item, opts.scheme, SDK_TARGETS):
201192
return 1
202-
dist(opts.arch, opts.scheme, opts.ssl_root)
193+
dist(opts.arch, opts.scheme)
203194
if not opts.skip_tests:
204195
if not opts.skip_gn_gen:
205196
if not gngen(TEST_ARCH, opts.ssl_root, TEST_SCHEME):

scripts/build_linux.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
'enable_libaom=true',
3030
'is_component_build=false',
3131
'rtc_build_examples=false',
32-
# Disable usage of GTK.
33-
'rtc_use_gtk=false',
3432
# When is_clang is false, we're not using sysroot in tree.
3533
'use_sysroot=false',
3634
# For Linux build we expect application built with gcc/g++. Set SDK to use
@@ -55,11 +53,11 @@ def gngen(arch, ssl_root, msdk_root, quic_root, scheme, tests, use_gcc, fake_aud
5553
else:
5654
gn_args.append('is_debug=true')
5755
if ssl_root:
58-
gn_args.append('owt_use_openssl=true')
59-
gn_args.append('owt_openssl_header_root="%s"' % (ssl_root + r'/include'))
60-
gn_args.append('owt_openssl_lib_root="%s"' % (ssl_root + r'/lib'))
56+
gn_args.append('rtc_build_ssl=false')
57+
gn_args.append('rtc_ssl_root="%s/include"' % ssl_root)
58+
gn_args.append('libsrtp_ssl_root="%s/include"' % ssl_root)
6159
else:
62-
gn_args.append('owt_use_openssl=false')
60+
gn_args.append('rtc_build_ssl=true')
6361
if msdk_root:
6462
if arch == 'x86':
6563
msdk_lib = msdk_root + r'/lib32'

scripts/prepare_dev.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
patchList = [
3535
# TODO: Update these patches for the latest branch.
3636
# ('0001-Use-OpenSSL-for-usrsctp.patch', THIRD_PARTY_PATH),
37-
# ('0002-Use-OpenSSL-for-libsrtp.patch', LIBSRTP_PATH),
3837
# ('0003-Enable-Wunused-but-set-variable.patch', BUILD_PATH),
3938
# ('0004-Remove-webrtc_overrides.patch', THIRD_PARTY_PATH),
4039
# ('0005-Fixed-compile-issue-and-disable-thin-archive.patch', BUILD_PATH),
@@ -55,7 +54,8 @@
5554
('0022-Apply-Wno-shadow-for-clang-only.patch', THIRD_PARTY_PATH),
5655
('0023-Fix-FFMPEG-config-for-MSVC-build.patch', FFMPEG_PATH),
5756
('0024-Getting-install-build-deps-to-work-on-Ubuntu-22.04-L.patch', BUILD_PATH),
58-
('0025-Allow-ffmpeg_branding-OWT.patch', FFMPEG_PATH)
57+
('0025-Allow-ffmpeg_branding-OWT.patch', FFMPEG_PATH),
58+
('0026-Add-an-GN-variable-for-using-BoringSSL.patch', LIBSRTP_PATH)
5959
]
6060

6161
def _patch(ignoreFailures=False):

talk/owt/BUILD.gn

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ if (!is_ios) {
9797
if (rtc_enable_protobuf) {
9898
deps += [ "//third_party/protobuf:protobuf_lite" ]
9999
}
100+
101+
if (!rtc_build_ssl) {
102+
if (is_win) {
103+
libs = [
104+
"libcrypto.lib",
105+
"libssl.lib",
106+
]
107+
} else {
108+
libs = [
109+
"crypto",
110+
"ssl",
111+
]
112+
}
113+
}
100114
}
101115
} else {
102116
static_library("owt") {

talk/owt/patches/0002-Use-OpenSSL-for-libsrtp.patch

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From 6daad52e10d89d820648fd017f501541dd9b6a9d Mon Sep 17 00:00:00 2001
2+
From: Jianjun Zhu <[email protected]>
3+
Date: Fri, 10 Feb 2023 16:03:37 +0800
4+
Subject: [PATCH] Add an GN variable for using BoringSSL.
5+
6+
---
7+
BUILD.gn | 11 ++++++++---
8+
1 file changed, 8 insertions(+), 3 deletions(-)
9+
10+
diff --git a/BUILD.gn b/BUILD.gn
11+
index 0f0f9e5..18f517d 100644
12+
--- a/BUILD.gn
13+
+++ b/BUILD.gn
14+
@@ -8,6 +8,7 @@ declare_args() {
15+
# Tests may not be appropriate for some build environments, e.g. Windows.
16+
# Rather than enumerate valid options, we just let clients ask for them.
17+
build_libsrtp_tests = false
18+
+ libsrtp_ssl_root = ""
19+
}
20+
21+
config("libsrtp_config") {
22+
@@ -133,9 +134,13 @@ static_library("libsrtp") {
23+
# "crypto/cipher/aes_icm_nss.c",
24+
]
25+
26+
- public_deps = [
27+
- "//third_party/boringssl:boringssl",
28+
- ]
29+
+ if (libsrtp_ssl_root == "") {
30+
+ public_deps = [
31+
+ "//third_party/boringssl:boringssl",
32+
+ ]
33+
+ } else {
34+
+ include_dirs = [ libsrtp_ssl_root ]
35+
+ }
36+
}
37+
38+
if (build_libsrtp_tests) {
39+
--
40+
2.37.1.windows.1
41+

0 commit comments

Comments
 (0)