format GN files, and invert if->config to config->if

Both if (...) { config ... } else { config ... } and config { if (...) { ...}
else { ... } } work.  We just happen to do the if inside the config more often
than the other way around.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2347953002

Review-Url: https://codereview.chromium.org/2347953002
This commit is contained in:
mtklein 2016-09-16 14:44:18 -07:00 committed by Commit bot
parent 54d9b6688d
commit b9be979eae
2 changed files with 133 additions and 129 deletions

View File

@ -481,7 +481,8 @@ component("skia") {
"src/ports/SkTypeface_win_dw.cpp", "src/ports/SkTypeface_win_dw.cpp",
"src/xps/SkDocument_XPS.cpp", "src/xps/SkDocument_XPS.cpp",
] ]
sources -= [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ] sources -=
[ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
} else { } else {
sources += [ sources += [
"src/ports/SkOSFile_posix.cpp", "src/ports/SkOSFile_posix.cpp",

View File

@ -24,44 +24,28 @@ declare_args() {
compiler_prefix = "" compiler_prefix = ""
} }
if (is_win) { config("default") {
config("default") { asmflags = []
cflags = [ cflags = []
"/FS", # Preserve previous PDB behavior. cflags_c = []
cflags_cc = []
defines = []
ldflags = []
if (is_win) {
cflags += [
"/FS", # Preserve previous PDB behavior.
"/bigobj", # Some of our files are bigger than the regular limits. "/bigobj", # Some of our files are bigger than the regular limits.
] ]
cflags_c = ["/TC"] cflags_c += [ "/TC" ]
cflags_cc = ["/TP"] cflags_cc += [ "/TP" ]
defines = [ defines += [
"_HAS_EXCEPTIONS=0", "_HAS_EXCEPTIONS=0",
"WIN32_LEAN_AND_MEAN", "WIN32_LEAN_AND_MEAN",
"NOMINMAX", "NOMINMAX",
] ]
} } else {
config("no_rtti") { } cflags += [
config("debug_symbols") { }
} else {
config("debug_symbols") {
# It's annoying to wait for full debug symbols to push over
# to Android devices. -gline-tables-only is a lot slimmer.
if (is_android) {
cflags = [ "-gline-tables-only" ]
} else {
cflags = [ "-g" ]
}
}
config("no_rtti") {
if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
cflags_cc = [ "-fno-rtti" ]
}
}
config("default") {
asmflags = []
cflags = [
"-O1", "-O1",
"-fstrict-aliasing", "-fstrict-aliasing",
"-fPIC", "-fPIC",
@ -78,7 +62,7 @@ if (is_win) {
"-Wno-deprecated-declarations", "-Wno-deprecated-declarations",
"-Wno-unused-parameter", "-Wno-unused-parameter",
] ]
cflags_cc = [ cflags_cc += [
"-std=c++11", "-std=c++11",
"-fno-exceptions", "-fno-exceptions",
"-fno-threadsafe-statics", "-fno-threadsafe-statics",
@ -86,100 +70,118 @@ if (is_win) {
"-Wnon-virtual-dtor", "-Wnon-virtual-dtor",
] ]
ldflags = [] }
if (current_cpu == "arm") { if (current_cpu == "arm") {
cflags += [ cflags += [
"-march=armv7-a", "-march=armv7-a",
"-mfpu=neon", "-mfpu=neon",
"-mthumb", "-mthumb",
] ]
} else if (current_cpu == "mipsel") { } else if (current_cpu == "mipsel") {
cflags += [ cflags += [
"-march=mips32r2", "-march=mips32r2",
"-mdspr2", "-mdspr2",
] ]
} else if (current_cpu == "x86") { } else if (current_cpu == "x86") {
asmflags += [ "-m32" ] asmflags += [ "-m32" ]
cflags += [ cflags += [
"-m32", "-m32",
"-msse2", "-msse2",
"-mfpmath=sse", "-mfpmath=sse",
] ]
ldflags += [ "-m32" ] ldflags += [ "-m32" ]
} }
if (is_android) { if (is_android) {
asmflags += [ asmflags += [
"--target=$ndk_target", "--target=$ndk_target",
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
] ]
cflags += [ cflags += [
"--sysroot=$ndk/platforms/$ndk_platform", "--sysroot=$ndk/platforms/$ndk_platform",
"--target=$ndk_target", "--target=$ndk_target",
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
] ]
cflags_cc += [ cflags_cc += [
"-isystem$ndk/sources/android/support/include", "-isystem$ndk/sources/android/support/include",
"-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include", "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include",
] ]
ldflags += [ ldflags += [
"--sysroot=$ndk/platforms/$ndk_platform", "--sysroot=$ndk/platforms/$ndk_platform",
"--target=$ndk_target", "--target=$ndk_target",
"-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
"-pie", "-pie",
] ]
lib_dirs = [ lib_dirs = [
"$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib", "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
"$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x", "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
] ]
libs = [ libs = [
# Order matters here! Keep these three in exactly this order. # Order matters here! Keep these three in exactly this order.
"c++_static", "c++_static",
"c++abi", "c++abi",
"android_support", "android_support",
] ]
if (target_cpu == "arm") { if (target_cpu == "arm") {
libs += [ "unwind" ] libs += [ "unwind" ]
}
}
if (is_linux) {
libs = [ "pthread" ]
}
if (sanitize != "") {
# You can either pass the sanitizers directly, e.g. "address,undefined",
# or pass one of the couple common aliases used by the bots.
sanitizers = sanitize
if (sanitize == "ASAN") {
sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
} else if (sanitize == "TSAN") {
sanitizers = "thread"
} else if (sanitize == "MSAN") {
sanitizers = "memory"
}
cflags += [
"-fsanitize=$sanitizers",
"-fno-sanitize-recover=$sanitizers",
"-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
]
ldflags += [ "-fsanitize=$sanitizers" ]
if (sanitizers == "memory") {
cflags += [ "-fsanitize-memory-track-origins" ]
cflags_cc += [ "-stdlib=libc++" ]
ldflags += [ "-stdlib=libc++" ]
}
} }
} }
config("release") { if (is_linux) {
libs = [ "pthread" ]
}
if (sanitize != "") {
# You can either pass the sanitizers directly, e.g. "address,undefined",
# or pass one of the couple common aliases used by the bots.
sanitizers = sanitize
if (sanitize == "ASAN") {
sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
} else if (sanitize == "TSAN") {
sanitizers = "thread"
} else if (sanitize == "MSAN") {
sanitizers = "memory"
}
cflags += [
"-fsanitize=$sanitizers",
"-fno-sanitize-recover=$sanitizers",
"-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
]
ldflags += [ "-fsanitize=$sanitizers" ]
if (sanitizers == "memory") {
cflags += [ "-fsanitize-memory-track-origins" ]
cflags_cc += [ "-stdlib=libc++" ]
ldflags += [ "-stdlib=libc++" ]
}
}
}
config("debug_symbols") {
# It's annoying to wait for full debug symbols to push over
# to Android devices. -gline-tables-only is a lot slimmer.
if (is_android) {
cflags = [ "-gline-tables-only" ]
} else if (!is_win) {
cflags = [ "-g" ]
}
}
config("no_rtti") {
if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
if (!is_win) {
cflags_cc = [ "-fno-rtti" ]
}
}
}
config("release") {
if (!is_win) {
cflags = [ "-O3" ] cflags = [ "-O3" ]
defines = [ "NDEBUG" ]
} }
defines = [ "NDEBUG" ]
} }
config("executable") { config("executable") {
@ -194,9 +196,10 @@ config("executable") {
} }
toolchain("msvc") { toolchain("msvc") {
vc = "$windk\VC\bin\amd64\cl.exe" vc = "$windk\VC\bin\amd64\cl.exe"
vlink = "$windk\VC\bin\amd64\link.exe" vlink = "$windk\VC\bin\amd64\link.exe"
vlib = "$windk\VC\bin\amd64\lib.exe" vlib = "$windk\VC\bin\amd64\lib.exe"
# TODO: add a python function that generates the includes using <VSPATH>/win_sdk/bin/SetEnv.<cpu>.json # TODO: add a python function that generates the includes using <VSPATH>/win_sdk/bin/SetEnv.<cpu>.json
windk_include_dirs = "/I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\winrt /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\ucrt /I$windk\win_sdk\bin\..\..\VC\include /I$windk\win_sdk\bin\..\..\VC\atlmfc\include " windk_include_dirs = "/I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\winrt /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\ucrt /I$windk\win_sdk\bin\..\..\VC\include /I$windk\win_sdk\bin\..\..\VC\atlmfc\include "
@ -208,7 +211,7 @@ toolchain("msvc") {
# Label names may have spaces in them so the pdbname must be quoted. The # Label names may have spaces in them so the pdbname must be quoted. The
# source and output don't need to be quoted because GN knows they're a # source and output don't need to be quoted because GN knows they're a
# full file name and will quote automatically when necessary. # full file name and will quote automatically when necessary.
command = "$vc /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" command = "$vc /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
depsformat = "msvc" depsformat = "msvc"
description = "CC {{output}}" description = "CC {{output}}"
@ -234,10 +237,11 @@ toolchain("msvc") {
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
] ]
rspfile_content = "$windk_include_dirs {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" rspfile_content = "$windk_include_dirs {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}"
} }
tool("alink") { tool("alink") {
rspfile = "{{output}}.rsp" rspfile = "{{output}}.rsp"
# gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/win_tool.py") # gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/win_tool.py")
command = "$vlib /nologo {{arflags}} /OUT:{{output}} @$rspfile" command = "$vlib /nologo {{arflags}} /OUT:{{output}} @$rspfile"
description = "LIB {{output}}" description = "LIB {{output}}"
@ -269,6 +273,7 @@ toolchain("msvc") {
#"{{root_out_dir}}/{{target_output_name}}{{output_extension}}", #"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
exename, exename,
] ]
#if (symbol_level != 0) { #if (symbol_level != 0) {
# outputs += [ pdbname ] # outputs += [ pdbname ]
#} #}
@ -279,14 +284,12 @@ toolchain("msvc") {
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
} }
tool("stamp") { tool("stamp") {
win_stamp_path = rebase_path("win_stamp.py") win_stamp_path = rebase_path("win_stamp.py")
command = "python $win_stamp_path {{output}}" command = "python $win_stamp_path {{output}}"
} }
} }
toolchain("gcc_like") { toolchain("gcc_like") {
lib_switch = "-l" lib_switch = "-l"
lib_dir_switch = "-L" lib_dir_switch = "-L"