Split targets mixing .c and .cc sources.
The Bazel build format doesn't support having separate
lists of compilation flags for C and C++; it just has a single
copts list for cc_library:
https://bazel.build/versions/master/docs/be/c-cpp.html#cc_binary.copts
This makes it hard to convert our GN targets to Bazel when there are
compiler warnings that aren't supported for C (like -Woverloaded-virtual
being added in bugs.webrtc.org/6653).
The solution for this is to move all .c files to their own targets
and remove C++-only compiler flags during conversion.
New targets:
//webrtc/common_audio:common_audio_c
//webrtc/common_audio:common_audio_neon_c
//webrtc/modules/audio_coding:g711_c
//webrtc/modules/audio_coding:g722_c
//webrtc/modules/audio_coding:ilbc_c
//webrtc/modules/audio_coding:isac_c
//webrtc/modules/audio_coding:isac_fix_c
//webrtc/modules/audio_coding:isac_test_util
//webrtc/modules/audio_coding:pcm16b_c
//webrtc/modules/audio_coding:webrtc_opusj_c
//webrtc/modules/audio_device:mac_portaudio
//webrtc/modules/audio_procssing:audio_processing_c
//webrtc/modules/audio_procssing:audio_processing_neon_c
This CL also adds a PRESUBMIT.py check that will throw an error
if targets are mixing .c and .cc files, to preven this from regressing.
BUG=webrtc:6653
NOTRY=True
Review-Url: https://codereview.webrtc.org/2550563003
Cr-Commit-Position: refs/heads/master@{#15433}
diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn
index 77a9c3e..efbf7e0 100644
--- a/webrtc/modules/audio_coding/BUILD.gn
+++ b/webrtc/modules/audio_coding/BUILD.gn
@@ -225,10 +225,6 @@
"codecs/g711/audio_decoder_pcm.h",
"codecs/g711/audio_encoder_pcm.cc",
"codecs/g711/audio_encoder_pcm.h",
- "codecs/g711/g711.c",
- "codecs/g711/g711.h",
- "codecs/g711/g711_interface.c",
- "codecs/g711/g711_interface.h",
]
public_configs = [ ":g711_config" ]
@@ -237,6 +233,19 @@
":audio_decoder_interface",
":audio_encoder_interface",
]
+ public_deps = [
+ ":g711_c",
+ ]
+}
+
+rtc_source_set("g711_c") {
+ visibility = [ ":*" ] # Only targets in this file can depend on this.
+ sources = [
+ "codecs/g711/g711.c",
+ "codecs/g711/g711.h",
+ "codecs/g711/g711_interface.c",
+ "codecs/g711/g711_interface.h",
+ ]
}
config("g722_config") {
@@ -252,11 +261,6 @@
"codecs/g722/audio_decoder_g722.h",
"codecs/g722/audio_encoder_g722.cc",
"codecs/g722/audio_encoder_g722.h",
- "codecs/g722/g722_decode.c",
- "codecs/g722/g722_enc_dec.h",
- "codecs/g722/g722_encode.c",
- "codecs/g722/g722_interface.c",
- "codecs/g722/g722_interface.h",
]
public_configs = [ ":g722_config" ]
@@ -265,6 +269,20 @@
":audio_decoder_interface",
":audio_encoder_interface",
]
+ public_deps = [
+ ":g722_c",
+ ]
+}
+
+rtc_source_set("g722_c") {
+ visibility = [ ":*" ] # Only targets in this file can depend on this.
+ sources = [
+ "codecs/g722/g722_decode.c",
+ "codecs/g722/g722_enc_dec.h",
+ "codecs/g722/g722_encode.c",
+ "codecs/g722/g722_interface.c",
+ "codecs/g722/g722_interface.h",
+ ]
}
config("ilbc_config") {
@@ -276,14 +294,32 @@
rtc_static_library("ilbc") {
sources = [
- "codecs/ilbc/abs_quant.c",
- "codecs/ilbc/abs_quant.h",
- "codecs/ilbc/abs_quant_loop.c",
- "codecs/ilbc/abs_quant_loop.h",
"codecs/ilbc/audio_decoder_ilbc.cc",
"codecs/ilbc/audio_decoder_ilbc.h",
"codecs/ilbc/audio_encoder_ilbc.cc",
"codecs/ilbc/audio_encoder_ilbc.h",
+ ]
+
+ public_configs = [ ":ilbc_config" ]
+
+ deps = [
+ ":audio_decoder_interface",
+ ":audio_encoder_interface",
+ "../../base:rtc_base_approved",
+ "../../common_audio",
+ ]
+ public_deps = [
+ ":ilbc_c",
+ ]
+}
+
+rtc_source_set("ilbc_c") {
+ visibility = [ ":*" ] # Only targets in this file can depend on this.
+ sources = [
+ "codecs/ilbc/abs_quant.c",
+ "codecs/ilbc/abs_quant.h",
+ "codecs/ilbc/abs_quant_loop.c",
+ "codecs/ilbc/abs_quant_loop.h",
"codecs/ilbc/augmented_cb_corr.c",
"codecs/ilbc/augmented_cb_corr.h",
"codecs/ilbc/bw_expand.c",
@@ -424,9 +460,6 @@
public_configs = [ ":ilbc_config" ]
deps = [
- ":audio_decoder_interface",
- ":audio_encoder_interface",
- "../../base:rtc_base_approved",
"../../common_audio",
]
}
@@ -449,6 +482,23 @@
rtc_static_library("isac") {
sources = [
+ "codecs/isac/main/source/audio_decoder_isac.cc",
+ "codecs/isac/main/source/audio_encoder_isac.cc",
+ ]
+
+ deps = [
+ ":audio_decoder_interface",
+ ":audio_encoder_interface",
+ ":isac_common",
+ ]
+ public_deps = [
+ ":isac_c",
+ ]
+}
+
+rtc_static_library("isac_c") {
+ visibility = [ ":*" ] # Only targets in this file can depend on this.
+ sources = [
"codecs/isac/main/include/audio_decoder_isac.h",
"codecs/isac/main/include/audio_encoder_isac.h",
"codecs/isac/main/include/isac.h",
@@ -456,8 +506,6 @@
"codecs/isac/main/source/arith_routines.h",
"codecs/isac/main/source/arith_routines_hist.c",
"codecs/isac/main/source/arith_routines_logist.c",
- "codecs/isac/main/source/audio_decoder_isac.cc",
- "codecs/isac/main/source/audio_encoder_isac.cc",
"codecs/isac/main/source/bandwidth_estimator.c",
"codecs/isac/main/source/bandwidth_estimator.h",
"codecs/isac/main/source/codec.h",
@@ -512,9 +560,6 @@
public_configs = [ ":isac_config" ]
deps = [
- ":audio_decoder_interface",
- ":audio_encoder_interface",
- ":isac_common",
"../..:webrtc_common",
"../../base:rtc_base_approved",
"../../common_audio",
@@ -530,6 +575,31 @@
rtc_static_library("isac_fix") {
sources = [
+ "codecs/isac/fix/source/audio_decoder_isacfix.cc",
+ "codecs/isac/fix/source/audio_encoder_isacfix.cc",
+ ]
+
+ public_configs = [ ":isac_fix_config" ]
+
+ deps = [
+ ":audio_decoder_interface",
+ ":audio_encoder_interface",
+ ":isac_common",
+ "../../common_audio",
+ "../../system_wrappers",
+ ]
+ public_deps = [
+ ":isac_fix_c",
+ ]
+
+ if (rtc_build_with_neon) {
+ deps += [ ":isac_neon" ]
+ }
+}
+
+rtc_source_set("isac_fix_c") {
+ visibility = [ ":*" ] # Only targets in this file can depend on this.
+ sources = [
"codecs/isac/fix/include/audio_decoder_isacfix.h",
"codecs/isac/fix/include/audio_encoder_isacfix.h",
"codecs/isac/fix/include/isacfix.h",
@@ -537,8 +607,6 @@
"codecs/isac/fix/source/arith_routines_hist.c",
"codecs/isac/fix/source/arith_routines_logist.c",
"codecs/isac/fix/source/arith_routins.h",
- "codecs/isac/fix/source/audio_decoder_isacfix.cc",
- "codecs/isac/fix/source/audio_encoder_isacfix.cc",
"codecs/isac/fix/source/bandwidth_estimator.c",
"codecs/isac/fix/source/bandwidth_estimator.h",
"codecs/isac/fix/source/codec.h",
@@ -582,18 +650,6 @@
public_configs = [ ":isac_fix_config" ]
- deps = [
- ":audio_decoder_interface",
- ":audio_encoder_interface",
- ":isac_common",
- "../../common_audio",
- "../../system_wrappers",
- ]
-
- if (rtc_build_with_neon) {
- deps += [ ":isac_neon" ]
- }
-
if (current_cpu == "arm" && arm_version >= 7) {
sources += [
"codecs/isac/fix/source/lattice_armv7.S",
@@ -628,6 +684,10 @@
sources -= [ "codecs/isac/fix/source/pitch_filter_c.c" ]
}
}
+
+ deps = [
+ "../../common_audio",
+ ]
}
if (rtc_build_with_neon) {
@@ -676,8 +736,6 @@
"codecs/pcm16b/audio_decoder_pcm16b.h",
"codecs/pcm16b/audio_encoder_pcm16b.cc",
"codecs/pcm16b/audio_encoder_pcm16b.h",
- "codecs/pcm16b/pcm16b.c",
- "codecs/pcm16b/pcm16b.h",
]
deps = [
@@ -685,6 +743,18 @@
":audio_encoder_interface",
":g711",
]
+ public_deps = [
+ ":pcm16b_c",
+ ]
+ public_configs = [ ":pcm16b_config" ]
+}
+
+rtc_source_set("pcm16b_c") {
+ visibility = [ ":*" ] # Only targets in this file can depend on this.
+ sources = [
+ "codecs/pcm16b/pcm16b.c",
+ "codecs/pcm16b/pcm16b.h",
+ ]
public_configs = [ ":pcm16b_config" ]
}
@@ -699,9 +769,6 @@
"codecs/opus/audio_decoder_opus.h",
"codecs/opus/audio_encoder_opus.cc",
"codecs/opus/audio_encoder_opus.h",
- "codecs/opus/opus_inst.h",
- "codecs/opus/opus_interface.c",
- "codecs/opus/opus_interface.h",
]
deps = [
@@ -711,6 +778,9 @@
"../../base:rtc_analytics",
"../../base:rtc_base_approved",
]
+ public_deps = [
+ ":webrtc_opus_c",
+ ]
defines = []
if (rtc_opus_variable_complexity) {
@@ -720,12 +790,31 @@
}
if (rtc_build_opus) {
+ public_deps += [ rtc_opus_dir ]
+ } else if (build_with_mozilla) {
+ include_dirs = [ getenv("DIST") + "/include/opus" ]
+ }
+}
+
+rtc_source_set("webrtc_opus_c") {
+ visibility = [ ":*" ] # Only targets in this file can depend on this.
+ sources = [
+ "codecs/opus/opus_inst.h",
+ "codecs/opus/opus_interface.c",
+ "codecs/opus/opus_interface.h",
+ ]
+
+ if (rtc_build_opus) {
public_deps = [
rtc_opus_dir,
]
} else if (build_with_mozilla) {
include_dirs = [ getenv("DIST") + "/include/opus" ]
}
+
+ deps = [
+ "../../base:rtc_base_approved",
+ ]
}
if (rtc_enable_protobuf) {
@@ -1568,12 +1657,18 @@
}
}
+ rtc_source_set("isac_test_util") {
+ testonly = true
+ sources = [
+ "codecs/isac/main/util/utility.c",
+ ]
+ }
+
rtc_executable("isac_test") {
testonly = true
sources = [
"codecs/isac/main/test/simpleKenny.c",
- "codecs/isac/main/util/utility.c",
]
include_dirs = [
@@ -1584,6 +1679,7 @@
deps = [
":isac",
+ ":isac_test_util",
"../../base:rtc_base_approved",
]
@@ -1620,11 +1716,11 @@
sources = [
"codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc",
- "codecs/isac/main/util/utility.c",
]
deps = [
":isac",
+ ":isac_test_util",
"../../base:rtc_base_approved",
]
@@ -1640,11 +1736,11 @@
sources = [
"codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc",
- "codecs/isac/main/util/utility.c",
]
deps = [
":isac",
+ ":isac_test_util",
]
include_dirs = [