Skip to content

Commit fc44f31

Browse files
authored
Merge pull request #214 from shiguredo/feature/include-cleaner
clang-include-cleaner と clang-format を適用する
2 parents a55ebf5 + 90b6b17 commit fc44f31

136 files changed

Lines changed: 1657 additions & 392 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
key: windows-cuda-${{ steps.versions.outputs.cuda_version }}.v1
5555
- run: echo "${CUDA_VERSION}" > _install\windows_x86_64\release\cuda.version
5656
if: steps.cache-cuda.outputs.cache-hit == 'true'
57-
- run: python3 run.py --test --run-e2e-test --package ${{ matrix.name }}
57+
- run: python3 run.py build --test --run-e2e-test --package ${{ matrix.name }}
5858
env:
5959
SORA_CPP_SDK_TEMP_DIR: C:\
6060
- name: Get package name
@@ -116,7 +116,7 @@ jobs:
116116
run: |
117117
echo "user=`users`" >> $GITHUB_OUTPUT
118118
id: env
119-
- run: python3 run.py --test --run-e2e-test --package ${{ matrix.name }}
119+
- run: python3 run.py build --test --run-e2e-test --package ${{ matrix.name }}
120120
- name: Get package name
121121
run: |
122122
source _package/${{ matrix.name }}/release/sora.env
@@ -271,7 +271,7 @@ jobs:
271271
- name: Setup Android SDK
272272
uses: android-actions/setup-android@v3
273273
if: matrix.platform.os == 'android'
274-
- run: python3 run.py --test --run-e2e-test --package ${{ matrix.platform.name }}
274+
- run: python3 run.py build --test --run-e2e-test --package ${{ matrix.platform.name }}
275275
- name: Get package name
276276
run: |
277277
source _package/${{ matrix.platform.name }}/release/sora.env

.github/workflows/formatter.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: formatter
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "doc/**"
7+
- "**.md"
8+
- "LICENSE"
9+
- "NOTICE"
10+
11+
jobs:
12+
run-ubuntu:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
platform:
17+
- name: ubuntu-24.04_x86_64
18+
runs-on: ubuntu-24.04
19+
os: ubuntu
20+
arch: x86_64
21+
name: Build sora-cpp-sdk for ${{ matrix.platform.name }}
22+
runs-on: ${{ matrix.platform.runs-on }}
23+
env:
24+
TEST_SIGNALING_URL: ${{ secrets.TEST_SIGNALING_URL }}
25+
TEST_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }}
26+
TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }}
27+
TEST_MATRIX_NAME: ${{ matrix.platform.name }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
# IWYU を適用するにはまずビルドする必要がある
31+
# Ubuntu 24.04 だと libtinfo5 が見つからない問題があるので、その修正
32+
# ref: https://qiita.com/gengen16k/items/88cf3c18a40a94205fab
33+
- name: Fix CUDA issues for Ubuntu 24.04
34+
if: matrix.platform.name == 'ubuntu-24.04_x86_64'
35+
run: |
36+
sudo tee /etc/apt/sources.list.d/jammy.list << EOF
37+
deb http://archive.ubuntu.com/ubuntu/ jammy universe
38+
EOF
39+
40+
sudo tee /etc/apt/preferences.d/pin-jammy <<EOF
41+
Package: *
42+
Pin: release n=jammy
43+
Pin-Priority: -10
44+
45+
Package: libtinfo5
46+
Pin: release n=jammy
47+
Pin-Priority: 990
48+
EOF
49+
- name: Install deps for ${{ matrix.platform.name }}
50+
if: matrix.platform.os == 'ubuntu' && matrix.platform.arch == 'x86_64'
51+
run: |
52+
source VERSION
53+
sudo apt-get update
54+
sudo apt-get install -y software-properties-common
55+
56+
# X11
57+
sudo apt-get install libx11-dev libxext-dev
58+
59+
# OpenGL
60+
sudo apt-get install -y libgl-dev
61+
62+
# CUDA
63+
# libssl1.1 が必要
64+
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
65+
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
66+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
67+
sudo dpkg -i cuda-keyring_*all.deb
68+
sudo apt-get update
69+
DEBIAN_FRONTEND=noninteractive sudo apt-get -y install cuda=$CUDA_VERSION
70+
71+
# clang-20
72+
wget https://apt.llvm.org/llvm.sh
73+
chmod a+x llvm.sh
74+
sudo ./llvm.sh 20
75+
- run: python3 run.py build --test ${{ matrix.platform.name }}
76+
- name: Build Examples
77+
run: |
78+
cd examples
79+
mkdir examples_${{ matrix.platform.name }}
80+
for app in sdl_sample sumomo messaging_recvonly_sample; do
81+
python3 $app/${{ matrix.platform.name }}/run.py --local-sora-cpp-sdk-dir ..
82+
done
83+
if: matrix.platform.os == 'ubuntu' && matrix.platform.name != 'ubuntu-22.04_armv8'
84+
- name: Run IWYU
85+
run: python3 run.py iwyu ubuntu-24.04_x86_64 || git diff --exit-code
86+
- name: Run clang format
87+
run: python3 run.py format || git diff --exit-code
88+
- name: Check diff
89+
run: git diff --exit-code
90+
91+
notification:
92+
name: Slack Notification
93+
runs-on: ubuntu-24.04
94+
needs:
95+
- run-ubuntu
96+
if: always()
97+
steps:
98+
- uses: rtCamp/action-slack-notify@v2
99+
if: |
100+
needs.run-ubuntu.result == 'failure'
101+
env:
102+
SLACK_CHANNEL: sora-cpp-sdk
103+
SLACK_COLOR: danger
104+
SLACK_TITLE: Build failed
105+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

CHANGES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111

1212
## develop
1313

14+
- [CHANGE] ライブラリのヘッダーファイルとソースファイルで使用されている include を整理する
15+
- 今まで間接的にインクルードされていたファイルが含まれなくなっている可能性があるので、破壊的変更になる
16+
- @melpon
17+
- [CHANGE] run.py のビルドをサブコマンド化する
18+
- 今まで `python3 run.py ubuntu-24.04_x86_64` でビルドしていたコマンドが`python3 run.py build ubuntu-24.04_x86_64` となる
19+
- @melpon
20+
- [ADD] clang-include-cleaner や clang-format を実行するサブコマンドを追加する
21+
- `python3 run.py iwyu ubuntu-24.04_x86_64`
22+
- `python3 run.py format`
23+
- なお iwyu を実行するには事前にビルドしておく必要がある
24+
- @melpon
25+
- [ADD] clang-include-cleaner や clang-format を GitHub Actions で実行し、差分があったらエラーにするワークフローを追加
26+
- @melpon
27+
1428
### misc
1529

1630
- [CHANGE] SDL サンプルと Sumomo から `--multistream` オプションを削除する

buildbase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def build_sora(
934934
]
935935

936936
with cd(local_sora_cpp_sdk_dir):
937-
cmd(["python3", "run.py", platform, *local_sora_cpp_sdk_args])
937+
cmd(["python3", "run.py", "build", platform, *local_sora_cpp_sdk_args])
938938

939939

940940
class SoraInfo(NamedTuple):

doc/development.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
```bash
1717
# ../webrtc-build に shiguredo-webrtc-build/webrtc-build がある場合
18-
python3 run.py ubuntu-24.04_x86_64 --local-webrtc-build-dir ../webrtc-build
18+
python3 run.py build ubuntu-24.04_x86_64 --local-webrtc-build-dir ../webrtc-build
1919
```
2020

2121
この時、VERSION に指定している WEBRTC_BUILD_VERSION に関係なく、現在 webrtc-build リポジトリでチェックアウトされている内容でビルドするため、バージョンの不整合に注意すること。
@@ -26,7 +26,7 @@ C++ SDK をデバッグビルドするには、libwebrtc も含めて、依存
2626
しかし libwebrtc のバイナリはリリースビルドであるため、libwebrtc のデバッグバイナリを作るにはローカルの webrtc-build を利用する必要がある。
2727

2828
```bash
29-
python3 run.py ubuntu-24.04_x86_64 --debug --local-webrtc-build-dir ../webrtc-build
29+
python3 run.py build ubuntu-24.04_x86_64 --debug --local-webrtc-build-dir ../webrtc-build
3030
```
3131

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

examples/messaging_recvonly_sample/macos_arm64/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def main():
142142

143143
cmake_args = []
144144
cmake_args.append(f"-DCMAKE_BUILD_TYPE={configuration}")
145+
cmake_args.append("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
145146
cmake_args.append(f"-DBOOST_ROOT={cmake_path(sora_info.boost_install_dir)}")
146147
cmake_args.append(f"-DWEBRTC_INCLUDE_DIR={cmake_path(webrtc_info.webrtc_include_dir)}")
147148
cmake_args.append(f"-DWEBRTC_LIBRARY_DIR={cmake_path(webrtc_info.webrtc_library_dir)}")

examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
1+
#include <csignal>
2+
#include <cstdint>
3+
#include <cstdlib>
4+
#include <iostream>
5+
#include <memory>
16
#include <optional>
7+
#include <ostream>
8+
#include <string>
9+
#include <utility>
10+
#include <vector>
11+
12+
// Boost
13+
#include <boost/asio/executor_work_guard.hpp>
14+
#include <boost/asio/io_context.hpp>
15+
#include <boost/asio/signal_set.hpp>
16+
#include <boost/json/parse.hpp>
17+
#include <boost/json/value.hpp>
18+
#include <boost/json/value_to.hpp>
19+
#include <boost/system/detail/error_code.hpp>
20+
21+
// WebRTC
22+
#include <api/rtp_receiver_interface.h>
23+
#include <api/rtp_transceiver_interface.h>
24+
#include <api/scoped_refptr.h>
25+
#include <rtc_base/logging.h>
226

3-
// Sora
4-
#include <sora/sora_client_context.h>
27+
#ifdef _WIN32
28+
#include <rtc_base/win/scoped_com_initializer.h>
29+
#endif
530

631
// CLI11
732
#include <CLI/CLI.hpp>
833

9-
#ifdef _WIN32
10-
#include <rtc_base/win/scoped_com_initializer.h>
11-
#endif
34+
// Sora C++ SDK
35+
#include <sora/sora_client_context.h>
36+
#include <sora/sora_signaling.h>
1237

1338
struct MessagingRecvOnlySampleConfig {
1439
std::string signaling_url;
@@ -92,8 +117,8 @@ class MessagingRecvOnlySample
92117
<< " bytes" << std::endl;
93118
}
94119

95-
void OnTrack(webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver)
96-
override {}
120+
void OnTrack(webrtc::scoped_refptr<webrtc::RtpTransceiverInterface>
121+
transceiver) override {}
97122
void OnRemoveTrack(
98123
webrtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) override {}
99124

examples/messaging_recvonly_sample/ubuntu-22.04_x86_64/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def main():
171171

172172
cmake_args = []
173173
cmake_args.append(f"-DCMAKE_BUILD_TYPE={configuration}")
174+
cmake_args.append("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
174175
cmake_args.append(f"-DBOOST_ROOT={cmake_path(sora_info.boost_install_dir)}")
175176
cmake_args.append(f"-DWEBRTC_INCLUDE_DIR={cmake_path(webrtc_info.webrtc_include_dir)}")
176177
cmake_args.append(f"-DWEBRTC_LIBRARY_DIR={cmake_path(webrtc_info.webrtc_library_dir)}")

examples/messaging_recvonly_sample/ubuntu-24.04_armv8/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def main():
185185

186186
cmake_args = []
187187
cmake_args.append(f"-DCMAKE_BUILD_TYPE={configuration}")
188+
cmake_args.append("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
188189
cmake_args.append(f"-DBOOST_ROOT={cmake_path(sora_info.boost_install_dir)}")
189190
cmake_args.append(f"-DWEBRTC_INCLUDE_DIR={cmake_path(webrtc_info.webrtc_include_dir)}")
190191
cmake_args.append(f"-DWEBRTC_LIBRARY_DIR={cmake_path(webrtc_info.webrtc_library_dir)}")

examples/messaging_recvonly_sample/ubuntu-24.04_x86_64/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def main():
171171

172172
cmake_args = []
173173
cmake_args.append(f"-DCMAKE_BUILD_TYPE={configuration}")
174+
cmake_args.append("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
174175
cmake_args.append(f"-DBOOST_ROOT={cmake_path(sora_info.boost_install_dir)}")
175176
cmake_args.append(f"-DWEBRTC_INCLUDE_DIR={cmake_path(webrtc_info.webrtc_include_dir)}")
176177
cmake_args.append(f"-DWEBRTC_LIBRARY_DIR={cmake_path(webrtc_info.webrtc_library_dir)}")

0 commit comments

Comments
 (0)