Skip to content

Commit e611509

Browse files
committed
Use cmake to build
1 parent 936ef5d commit e611509

File tree

3 files changed

+69
-133
lines changed

3 files changed

+69
-133
lines changed

examples/camera-controller/BUILD.gn

+10-3
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,26 @@ config("config") {
3131
"${chip_root}/src/lib",
3232
]
3333

34-
defines = [ "CONFIG_USE_SEPARATE_EVENTLOOP=${config_use_separate_eventloop}" ]
34+
defines = [
35+
"CONFIG_USE_SEPARATE_EVENTLOOP=${config_use_separate_eventloop}",
36+
# Force new C++ ABI for standard library (post-GCC 5)
37+
"_GLIBCXX_USE_CXX11_ABI=1",
38+
]
3539

3640
# Note: CONFIG_USE_LOCAL_STORAGE is tested for via #ifdef, not #if.
3741
if (config_use_local_storage) {
3842
defines += [ "CONFIG_USE_LOCAL_STORAGE" ]
3943
}
4044

4145
cflags_cc = [
46+
"-std=c++17",
47+
"-fexceptions",
48+
"-frtti",
4249
"-Wno-shadow",
4350
"-Wno-unreachable-code",
4451
"-Wno-non-virtual-dtor",
4552
"-Wno-implicit-fallthrough",
46-
]
53+
]
4754
}
4855

4956
static_library("camera-controller-utils") {
@@ -100,7 +107,6 @@ static_library("camera-controller-utils") {
100107
"${chip_root}/src/platform",
101108
"${chip_root}/third_party/inipp",
102109
"${chip_root}/third_party/jsoncpp",
103-
"${chip_root}/third_party/libdatachannel",
104110
]
105111

106112
public_configs = [ ":config" ]
@@ -119,6 +125,7 @@ executable("camera-controller") {
119125
deps = [
120126
":camera-controller-utils",
121127
"${chip_root}/src/platform/logging:stdio",
128+
"${chip_root}/third_party/libdatachannel:libdatachannel",
122129
]
123130

124131
output_dir = root_out_dir

third_party/libdatachannel/BUILD.gn

+12-130
Original file line numberDiff line numberDiff line change
@@ -12,138 +12,20 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
config("libdatachannel_config") {
16-
include_dirs = [
17-
"repo/include",
18-
"repo/include/rtc",
19-
]
20-
}
2115

22-
config("libdatachannel_config_disable_warnings") {
23-
cflags_cc = [
24-
"-Wno-shadow",
25-
"-Wno-unreachable-code",
26-
"-Wno-non-virtual-dtor",
27-
"-Wno-implicit-fallthrough",
16+
action("build_libdatachannel") {
17+
script = "scripts/build_libdatachannel.py"
18+
outputs = [
19+
"$target_gen_dir/repo/build/libdatachannel.so",
2820
]
21+
args = []
2922
}
3023

31-
config("libdatachannel_config_enable_features") {
32-
cflags_cc = [
33-
"-fexceptions",
34-
"-frtti",
35-
]
36-
}
37-
38-
source_set("libdatachannel") {
39-
include_dirs = [
40-
"repo/src",
41-
"repo/include/rtc",
42-
"repo/deps/plog/include",
43-
"repo/deps/usrsctp/usrsctplib",
44-
"repo/deps/libjuice/include",
45-
"repo/deps/libsrtp/include",
46-
]
47-
48-
# ---------------------------------------------------------------------------
49-
# Source files from repo/src/*.cpp
50-
# ---------------------------------------------------------------------------
51-
sources = [
52-
"repo/src/av1rtppacketizer.cpp",
53-
"repo/src/candidate.cpp",
54-
"repo/src/capi.cpp",
55-
"repo/src/channel.cpp",
56-
"repo/src/configuration.cpp",
57-
"repo/src/datachannel.cpp",
58-
"repo/src/description.cpp",
59-
"repo/src/global.cpp",
60-
"repo/src/h264rtpdepacketizer.cpp",
61-
"repo/src/h264rtppacketizer.cpp",
62-
"repo/src/h265nalunit.cpp",
63-
"repo/src/h265rtpdepacketizer.cpp",
64-
"repo/src/h265rtppacketizer.cpp",
65-
"repo/src/mediahandler.cpp",
66-
"repo/src/message.cpp",
67-
"repo/src/nalunit.cpp",
68-
"repo/src/pacinghandler.cpp",
69-
"repo/src/peerconnection.cpp",
70-
"repo/src/plihandler.cpp",
71-
"repo/src/rembhandler.cpp",
72-
"repo/src/rtcpnackresponder.cpp",
73-
"repo/src/rtcpreceivingsession.cpp",
74-
"repo/src/rtcpsrreporter.cpp",
75-
"repo/src/rtp.cpp",
76-
"repo/src/rtpdepacketizer.cpp",
77-
"repo/src/rtppacketizationconfig.cpp",
78-
"repo/src/rtppacketizer.cpp",
79-
"repo/src/track.cpp",
80-
"repo/src/websocket.cpp",
81-
"repo/src/websocketserver.cpp",
82-
]
83-
84-
# ---------------------------------------------------------------------------
85-
# Source files from repo/src/impl/*.cpp
86-
# ---------------------------------------------------------------------------
87-
sources += [
88-
"repo/src/impl/certificate.cpp",
89-
"repo/src/impl/channel.cpp",
90-
"repo/src/impl/datachannel.cpp",
91-
"repo/src/impl/dtlssrtptransport.cpp",
92-
"repo/src/impl/dtlstransport.cpp",
93-
"repo/src/impl/http.cpp",
94-
"repo/src/impl/httpproxytransport.cpp",
95-
"repo/src/impl/icetransport.cpp",
96-
"repo/src/impl/init.cpp",
97-
"repo/src/impl/logcounter.cpp",
98-
"repo/src/impl/peerconnection.cpp",
99-
"repo/src/impl/pollinterrupter.cpp",
100-
"repo/src/impl/pollservice.cpp",
101-
"repo/src/impl/processor.cpp",
102-
"repo/src/impl/sctptransport.cpp",
103-
"repo/src/impl/sha.cpp",
104-
"repo/src/impl/tcpserver.cpp",
105-
"repo/src/impl/tcptransport.cpp",
106-
"repo/src/impl/threadpool.cpp",
107-
"repo/src/impl/tls.cpp",
108-
"repo/src/impl/tlstransport.cpp",
109-
"repo/src/impl/track.cpp",
110-
"repo/src/impl/transport.cpp",
111-
"repo/src/impl/utils.cpp",
112-
"repo/src/impl/verifiedtlstransport.cpp",
113-
"repo/src/impl/websocket.cpp",
114-
"repo/src/impl/websocketserver.cpp",
115-
"repo/src/impl/wshandshake.cpp",
116-
"repo/src/impl/wstransport.cpp",
117-
]
24+
shared_library("libdatachannel") {
25+
# Ensure the script runs first
26+
deps = [ ":build_libdatachannel" ]
11827

119-
public_configs = [ ":libdatachannel_config" ]
120-
configs += [
121-
":libdatachannel_config_disable_warnings",
122-
":libdatachannel_config_enable_features",
123-
]
124-
125-
defines = [
126-
"BUILD_SHARED_LIBS=1", # default ON in the CMake
127-
"BUILD_SHARED_DEPS_LIBS=0", # default OFF
128-
"USE_GNUTLS=0", # default OFF => no GnuTLS
129-
"USE_MBEDTLS=0", # default OFF => no MbedTLS
130-
"USE_NICE=0", # default OFF => no libnice
131-
"PREFER_SYSTEM_LIB=0", # default OFF
132-
"USE_SYSTEM_SRTP=0", # default from PREFER_SYSTEM_LIB
133-
"USE_SYSTEM_JUICE=0",
134-
"USE_SYSTEM_USRSCTP=0",
135-
"USE_SYSTEM_PLOG=0",
136-
"USE_SYSTEM_JSON=0",
137-
"NO_WEBSOCKET=0", # default OFF
138-
"NO_MEDIA=0", # default OFF
139-
"NO_EXAMPLES=0", # default OFF
140-
"NO_TESTS=0", # default OFF
141-
"WARNINGS_AS_ERRORS=0", # default OFF
142-
"CAPI_STDCALL=0", # default OFF
143-
"SCTP_DEBUG=0", # default OFF
144-
"RTC_UPDATE_VERSION_HEADER=0", # default OFF
145-
"RTC_ENABLE_WEBSOCKET=0",
146-
"RTC_ENABLE_MEDIA=0",
147-
"RTC_SYSTEM_SRTP=0",
148-
]
149-
}
28+
# GN will link this .so into dependent targets
29+
lib_dirs = [ rebase_path("$target_gen_dir/repo/build", root_build_dir) ]
30+
libs = [ "datachannel" ]
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import subprocess
4+
import sys
5+
6+
def main():
7+
# Get the script directory
8+
script_dir = os.path.dirname(os.path.abspath(__file__))
9+
10+
# Set the repo directory
11+
repo_dir = os.path.join(script_dir, "..", "repo")
12+
13+
# Change to the repo directory
14+
os.chdir(repo_dir)
15+
print(f"Changed directory to: {repo_dir}")
16+
17+
# Generate build files in ./build
18+
cmake_cmd = [
19+
"cmake",
20+
"-B", "build",
21+
"-DUSE_GNUTLS=0",
22+
"-DUSE_NICE=0",
23+
"-DCMAKE_BUILD_TYPE=Release",
24+
"-DNO_MEDIA=ON",
25+
"-DNO_WEBSOCKET=ON"
26+
]
27+
28+
print(f"Running: {' '.join(cmake_cmd)}")
29+
result = subprocess.run(cmake_cmd, check=True)
30+
31+
# Change to build directory
32+
build_dir = os.path.join(repo_dir, "build")
33+
os.chdir(build_dir)
34+
print(f"Changed directory to: {build_dir}")
35+
36+
# Build with Make
37+
make_cmd = ["make", "-j2"]
38+
print(f"Running: {' '.join(make_cmd)}")
39+
result = subprocess.run(make_cmd, check=True)
40+
41+
print("libdatachannel build complete.")
42+
print(f"Artifacts are located in: {build_dir}")
43+
44+
return 0
45+
46+
if __name__ == "__main__":
47+
sys.exit(main())

0 commit comments

Comments
 (0)