Skip to content

Commit

Permalink
Merge pull request #64 from shiguredo/feature/local-webrtc-build
Browse files Browse the repository at this point in the history
--webrtcbuild をやめて、ローカルの webrtc-build を使ってビルドする仕組みに変える
  • Loading branch information
melpon authored Feb 20, 2024
2 parents 2f7ba24 + 673ca38 commit bbb48fa
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 139 deletions.
9 changes: 7 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

## develop

- [CHANGE] WebRTC を `m121.6167.3.0` にあげる
- libwebrtc から cricket::MediaEngineDependencies が削除されたため、 SoraClientContextConfig から configure_media_dependencies を削除した
- [CHANGE] `--webrtcbuild`, `--webrtc-fetch` などの webrtc ローカルビルドに関するフラグを削除し、代わりに `--webrtc-build-dir``--webrtc-build-args` を追加する
- これにより、既存の webrtc-build ディレクトリを使ってローカルビルドを行うことができるようになる
- @melpon
- [CHANGE] SoraClientContextConfig から configure_media_dependencies を削除した
- libwebrtc から cricket::MediaEngineDependencies が削除されたため
- @enm10k
- [UPDATE] WebRTC を `m121.6167.3.0` にあげる
- @torikizi @enm10k
- [UPDATE] Boost を1.84.0 にあげる
- @enm10k
Expand Down
28 changes: 28 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@
- ビルドフラグによらず常にビルドされるファイルは、サブディレクトリを作らず `include/sora/``src/` に保存する
- ビルドフラグによってビルドされたりされなかったりするファイルは、サブディレクトリを作ってそこに保存する

## ローカルの webrtc-build を利用する

ローカルの webrtc-build を使ってビルドするには、以下のようにする。

```bash
# ../webrtc-build に shiguredo-webrtc-build/webrtc-build がある場合
python3 run.py ubuntu-20.04_x86_64 --webrtc-build-dir ../webrtc-build
```

webrtc-build に引数を渡してビルドする場合、以下のようにする。

```bash
python3 run.py ubuntu-20.04_x86_64 --webrtc-build-dir ../webrtc-build --webrtc-build-args='--webrtc-fetch'
```

この時、VERSION に指定している WEBRTC_BUILD_VERSION に関係なく、現在 webrtc-build リポジトリでチェックアウトされている内容でビルドするため、バージョンの不整合に注意すること。

## デバッグビルド

C++ SDK をデバッグビルドするには、libwebrtc も含めて、依存ライブラリすべてをデバッグビルドする必要がある。
しかし libwebrtc のバイナリはリリースビルドであるため、libwebrtc のデバッグバイナリを作るにはローカルの webrtc-build を利用する必要がある。

```bash
python3 run.py ubuntu-20.04_x86_64 --debug --webrtc-build-dir ../webrtc-build
```

このように `--debug` を付けると、C++ SDK だけでなく、ローカルの webrtc-build を含む全ての依存ライブラリもデバッグビルドを行う。

## メモ

- ubuntu-20.04_x86_64, ubuntu-22.04_x86_64 のビルドに必要な依存
Expand Down
212 changes: 104 additions & 108 deletions run.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions third_party/lyra/toolchain/android/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cc_toolchain_config(
'%sysroot%/usr/include',
'%sysroot%/usr/local/include',
"%{webrtc_include_dir}/third_party/libc++abi/src/include",
"%{llvm_dir}/libcxx/include",
"%{libcxx_dir}/include",
],
tool_paths = {
"ar": '%{android_ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar',
Expand Down Expand Up @@ -86,7 +86,7 @@ cc_toolchain_config(
],
# conly_flags = [],
cxx_flags = [
"-isystem%{llvm_dir}/libcxx/include",
"-isystem%{libcxx_dir}/include",
"-isystem%{webrtc_include_dir}/third_party/libc++abi/src/include",
"-std=c++17",
"-nostdinc++",
Expand All @@ -100,7 +100,7 @@ cc_toolchain_config(
link_flags = [
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-B", "%{llvm_dir}/clang/bin/",
"-B", "%{clang_dir}/bin/",
"-L", "%{webrtc_library_dir}",
"--target=aarch64-none-linux-android%{android_api}",
],
Expand Down
9 changes: 6 additions & 3 deletions third_party/lyra/toolchain/android/toolchain_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ def _impl(repository_ctx):
return

if not ('CLANG_VERSION' in repository_ctx.os.environ and
'BAZEL_LLVM_DIR' in repository_ctx.os.environ and
'BAZEL_CLANG_DIR' in repository_ctx.os.environ and
'BAZEL_LIBCXX_DIR' in repository_ctx.os.environ and
'BAZEL_WEBRTC_INCLUDE_DIR' in repository_ctx.os.environ and
'BAZEL_WEBRTC_LIBRARY_DIR' in repository_ctx.os.environ):
return

android_ndk = repository_ctx.os.environ['ANDROID_NDK_HOME']
android_api = repository_ctx.os.environ['ANDROID_API']
clang_version = repository_ctx.os.environ['CLANG_VERSION']
llvm_dir = repository_ctx.os.environ['BAZEL_LLVM_DIR']
clang_dir = repository_ctx.os.environ['BAZEL_CLANG_DIR']
libcxx_dir = repository_ctx.os.environ['BAZEL_LIBCXX_DIR']
webrtc_include_dir = repository_ctx.os.environ['BAZEL_WEBRTC_INCLUDE_DIR']
webrtc_library_dir = repository_ctx.os.environ['BAZEL_WEBRTC_LIBRARY_DIR']
repository_ctx.template(
Expand All @@ -22,7 +24,8 @@ def _impl(repository_ctx):
"%{android_ndk}": android_ndk,
"%{android_api}": android_api,
"%{clang_version}": clang_version,
"%{llvm_dir}": llvm_dir,
"%{clang_dir}": clang_dir,
"%{libcxx_dir}": libcxx_dir,
"%{webrtc_include_dir}": webrtc_include_dir,
"%{webrtc_library_dir}": webrtc_library_dir,
},
Expand Down
40 changes: 20 additions & 20 deletions third_party/lyra/toolchain/linux_x86_64/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ cc_toolchain_config(
abi_version = "local",
abi_libc_version = "local",
cxx_builtin_include_directories = [
"%{llvm_dir}/clang/lib/clang/%{clang_version}/include",
"%{clang_dir}/lib/clang/%{clang_version}/include",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"%{llvm_dir}/libcxx/include",
"%{libcxx_dir}/include",
"%{webrtc_include_dir}/third_party/libc++abi/src/include",
],
tool_paths = {
"ar": "%{llvm_dir}/clang/bin/llvm-ar",
"cpp": "%{llvm_dir}/clang/bin/clang++",
"gcc": "%{llvm_dir}/clang/bin/clang",
"ld": "%{llvm_dir}/clang/bin/lld",
"nm": "%{llvm_dir}/clang/bin/llvm-nm",
"strip": "%{llvm_dir}/clang/bin/llvm-strip",
"ar": "%{clang_dir}/bin/llvm-ar%{llvm_postfix}",
"cpp": "%{clang_dir}/bin/clang%{llvm_postfix}++",
"gcc": "%{clang_dir}/bin/clang%{llvm_postfix}",
"ld": "%{clang_dir}/bin/lld%{llvm_postfix}",
"nm": "%{clang_dir}/bin/llvm-nm%{llvm_postfix}",
"strip": "%{clang_dir}/bin/llvm-strip%{llvm_postfix}",
"llvm-cov": "llvm-cov",
"objdump": "objdump",
},
Expand Down Expand Up @@ -83,7 +83,7 @@ cc_toolchain_config(
],
# conly_flags = [],
cxx_flags = [
"-isystem%{llvm_dir}/libcxx/include",
"-isystem%{libcxx_dir}/include",
"-isystem%{webrtc_include_dir}/third_party/libc++abi/src/include",
"-std=c++17",
"-nostdinc++",
Expand All @@ -95,7 +95,7 @@ cc_toolchain_config(
link_flags = [
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-B", "%{llvm_dir}/clang/bin/",
"-B", "%{clang_dir}/bin/",
"-L", "%{webrtc_library_dir}",
],
# archive_flags = [],
Expand Down Expand Up @@ -140,21 +140,21 @@ cc_toolchain_config(
abi_version = "local",
abi_libc_version = "local",
cxx_builtin_include_directories = [
"%{llvm_dir}/clang/lib/clang/%{clang_version}/include",
"%{clang_dir}/lib/clang/%{clang_version}/include",
"%{sysroot}/usr/include/aarch64-linux-gnu",
"%{sysroot}/usr/include",
"/usr/include/aarch64-linux-gnu",
"/usr/include",
"%{llvm_dir}/libcxx/include",
"%{libcxx_dir}/include",
"%{webrtc_include_dir}/third_party/libc++abi/src/include",
],
tool_paths = {
"ar": "%{llvm_dir}/clang/bin/llvm-ar",
"cpp": "%{llvm_dir}/clang/bin/clang++",
"gcc": "%{llvm_dir}/clang/bin/clang",
"ld": "%{llvm_dir}/clang/bin/lld",
"nm": "%{llvm_dir}/clang/bin/llvm-nm",
"strip": "%{llvm_dir}/clang/bin/llvm-strip",
"ar": "%{clang_dir}/bin/llvm-ar%{llvm_postfix}",
"cpp": "%{clang_dir}/bin/clang%{llvm_postfix}++",
"gcc": "%{clang_dir}/bin/clang%{llvm_postfix}",
"ld": "%{clang_dir}/bin/lld%{llvm_postfix}",
"nm": "%{clang_dir}/bin/llvm-nm%{llvm_postfix}",
"strip": "%{clang_dir}/bin/llvm-strip%{llvm_postfix}",
"llvm-cov": "llvm-cov",
"objdump": "objdump",
},
Expand Down Expand Up @@ -207,7 +207,7 @@ cc_toolchain_config(
],
# conly_flags = [],
cxx_flags = [
"-isystem%{llvm_dir}/libcxx/include",
"-isystem%{libcxx_dir}/include",
"-isystem%{webrtc_include_dir}/third_party/libc++abi/src/include",
"-std=c++17",
"-nostdinc++",
Expand All @@ -219,7 +219,7 @@ cc_toolchain_config(
link_flags = [
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-B", "%{llvm_dir}/clang/bin/",
"-B", "%{clang_dir}/bin/",
"-L", "%{webrtc_library_dir}",
"--target=aarch64-linux-gnu",
],
Expand Down
11 changes: 8 additions & 3 deletions third_party/lyra/toolchain/linux_x86_64/toolchain_configure.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
def _impl(repository_ctx):
if not ('CLANG_VERSION' in repository_ctx.os.environ and
'BAZEL_LLVM_DIR' in repository_ctx.os.environ and
'BAZEL_CLANG_DIR' in repository_ctx.os.environ and
'BAZEL_LIBCXX_DIR' in repository_ctx.os.environ and
'BAZEL_WEBRTC_INCLUDE_DIR' in repository_ctx.os.environ and
'BAZEL_WEBRTC_LIBRARY_DIR' in repository_ctx.os.environ):
return

clang_version = repository_ctx.os.environ['CLANG_VERSION']
llvm_dir = repository_ctx.os.environ['BAZEL_LLVM_DIR']
clang_dir = repository_ctx.os.environ['BAZEL_CLANG_DIR']
llvm_postfix = repository_ctx.os.environ['BAZEL_LLVM_POSTFIX'] if 'BAZEL_LLVM_POSTFIX' in repository_ctx.os.environ else ''
libcxx_dir = repository_ctx.os.environ['BAZEL_LIBCXX_DIR']
webrtc_include_dir = repository_ctx.os.environ['BAZEL_WEBRTC_INCLUDE_DIR']
webrtc_library_dir = repository_ctx.os.environ['BAZEL_WEBRTC_LIBRARY_DIR']
sysroot = repository_ctx.os.environ['BAZEL_SYSROOT'] if 'BAZEL_SYSROOT' in repository_ctx.os.environ else ''
Expand All @@ -15,7 +18,9 @@ def _impl(repository_ctx):
repository_ctx.attr.src,
{
"%{clang_version}": clang_version,
"%{llvm_dir}": llvm_dir,
"%{clang_dir}": clang_dir,
"%{llvm_postfix}": llvm_postfix,
"%{libcxx_dir}": libcxx_dir,
"%{webrtc_include_dir}": webrtc_include_dir,
"%{webrtc_library_dir}": webrtc_library_dir,
"%{sysroot}": sysroot,
Expand Down

0 comments on commit bbb48fa

Please sign in to comment.