mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[gn] no propagating diagnostic flags (#12219)
This commit moves the diagnostic flags into the toolchain itself, preventing these flags being propagated to OpenThread dependents.
This commit is contained in:
@@ -33,13 +33,6 @@ config("openthread_config") {
|
||||
defines += [ "OPENTHREAD_CONFIG_FILE=${openthread_config_file}" ]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-Werror",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wundef",
|
||||
]
|
||||
|
||||
include_dirs = openthread_project_include_dirs
|
||||
|
||||
include_dirs += [
|
||||
|
||||
@@ -38,4 +38,8 @@ if (current_os == "") {
|
||||
current_os = target_os
|
||||
}
|
||||
|
||||
set_default_toolchain("//etc/gn/toolchain:gcc")
|
||||
declare_args() {
|
||||
use_clang = false
|
||||
}
|
||||
|
||||
set_default_toolchain("//etc/gn/toolchain")
|
||||
|
||||
@@ -25,10 +25,25 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
toolchain("gcc") {
|
||||
toolchain("toolchain") {
|
||||
diagnostic_cflags = [
|
||||
"-Werror",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wundef",
|
||||
]
|
||||
if (use_clang) {
|
||||
cc = "clang"
|
||||
cxx = "clang++"
|
||||
} else {
|
||||
cc = "gcc"
|
||||
cxx = "g++"
|
||||
}
|
||||
cflags = string_join(" ", diagnostic_cflags)
|
||||
|
||||
tool("cc") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
||||
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} $cflags {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
description = "CC {{output}}"
|
||||
outputs = [
|
||||
@@ -37,7 +52,7 @@ toolchain("gcc") {
|
||||
}
|
||||
tool("cxx") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "g++ -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
|
||||
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} $cflags {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
description = "CXX {{output}}"
|
||||
outputs = [
|
||||
@@ -59,7 +74,7 @@ toolchain("gcc") {
|
||||
soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
|
||||
sofile = "{{output_dir}}/$soname"
|
||||
rspfile = soname + ".rsp"
|
||||
command = "g++ -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile"
|
||||
command = "$cxx -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile"
|
||||
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
|
||||
description = "SOLINK $soname"
|
||||
# Use this for {{output_extension}} expansions unless a target manually
|
||||
@@ -79,7 +94,7 @@ toolchain("gcc") {
|
||||
tool("link") {
|
||||
outfile = "{{target_output_name}}{{output_extension}}"
|
||||
rspfile = "$outfile.rsp"
|
||||
command = "g++ {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
|
||||
command = "$cxx {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
|
||||
description = "LINK $outfile"
|
||||
default_output_dir = "{{root_out_dir}}"
|
||||
rspfile_content = "{{inputs}}"
|
||||
|
||||
+12
-12
@@ -34,23 +34,23 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
main()
|
||||
check_build()
|
||||
{
|
||||
# Check GN build for OT1.1
|
||||
rm gn-out -r || true
|
||||
gn gen --check gn-out
|
||||
gn args gn-out --list
|
||||
ninja -C gn-out
|
||||
test -f gn-out/obj/src/core/libopenthread-ftd.a
|
||||
|
||||
# Check GN build for OT1.4
|
||||
rm gn-out -r || true
|
||||
mkdir gn-out
|
||||
echo 'openthread_config_thread_version = "1.4"' >gn-out/args.gn
|
||||
gn gen --check gn-out
|
||||
gn gen --check gn-out "$@"
|
||||
gn args gn-out --list
|
||||
ninja -C gn-out
|
||||
test -f gn-out/obj/src/core/libopenthread-ftd.a
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
for thread_version in 1.4 1.1; do
|
||||
for use_clang in true false; do
|
||||
check_build --args="use_clang=$use_clang openthread_config_thread_version=\"$thread_version\""
|
||||
done
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user