Skip to content

Commit

Permalink
gn format //build
Browse files Browse the repository at this point in the history
A starting point for doing all of src, and adding a PRESUBMIT.

Includes https://codereview.chromium.org/772663002/ and https://codereview.chromium.org/770053002/.
I haven't pushed new binaries yet.

Generated via:
> cd build
> git ls-files *.gn *.gni | sed -e "s/^/@..\\\\out\\\\Debug\\\\gn format --in-place /" >x.bat && x.bat

The only things that I don't love in the current output are:

1. Turning

    args = [
      "--depfile", rebase_path(depfile, root_build_dir),
      "--android-sdk-tools", rebased_android_sdk_build_tools,
      "--dex-path", rebased_output,
    ]

into:

    args = [
      "--depfile",
      rebase_path(depfile, root_build_dir),
      "--android-sdk-tools",
      rebased_android_sdk_build_tools,
      "--dex-path",
      rebased_output,
    ]

The heuristic for this isn't trivial though, and it also affects e.g. '-Xclang' in cflags, as well
as assignments to temporaries that are later assigned to args.

2. Turning single line

    if (defined(invoker.inputs)) { inputs = invoker.inputs }

into

    if (defined(invoker.inputs)) {
      inputs = invoker.inputs
    }

This could be argued to be an improvement, but as it's very boilerplate-y perhaps an exception to
allow single line in this case is worthwhile. I think there was discussion of new syntax for this
case too, something like "inputs ?= invoker.inputs" maybe.

In both cases, I think it's worthwhile to get formatting turned on, and then go back and special
case these if we decide it's worthwhile.

R=brettw@chromium.org
BUG=348474

Review URL: https://codereview.chromium.org/766573003

Cr-Commit-Position: refs/heads/master@{#306305}
  • Loading branch information
sgraham authored and Commit bot committed Dec 2, 2014
1 parent fb49bff commit b199254
Show file tree
Hide file tree
Showing 47 changed files with 1,749 additions and 1,072 deletions.
4 changes: 3 additions & 1 deletion build/android/gyp/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ java_library("hello_world_java") {
}

java_binary("hello_world") {
deps = [ ":hello_world_java" ]
deps = [
":hello_world_java",
]
java_files = [ "java/org/chromium/helloworld/HelloWorldMain.java" ]
main_class = "org.chromium.helloworld.HelloWorldMain"
}
26 changes: 14 additions & 12 deletions build/compiled_action.gni
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,23 @@ template("compiled_action") {
# If that's not the case, we'll need another argument to the script to
# specify this, since we can't know what the output name is (it might be in
# another file not processed yet).
host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
get_label_info(host_tool, "name") + _host_executable_suffix
host_executable =
get_label_info(host_tool, "root_out_dir") + "/" +
get_label_info(host_tool, "name") + _host_executable_suffix

# Add the executable itself as an input.
inputs += [ host_executable ]

deps = [ host_tool ]
deps = [
host_tool,
]
if (defined(invoker.deps)) {
deps += invoker.deps
}

# The script takes as arguments the binary to run, and then the arguments
# to pass it.
args = [
rebase_path(host_executable, root_build_dir)
] + invoker.args
args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args
}
}

Expand Down Expand Up @@ -151,21 +152,22 @@ template("compiled_action_foreach") {
# If that's not the case, we'll need another argument to the script to
# specify this, since we can't know what the output name is (it might be in
# another file not processed yet).
host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
get_label_info(host_tool, "name") + _host_executable_suffix
host_executable =
get_label_info(host_tool, "root_out_dir") + "/" +
get_label_info(host_tool, "name") + _host_executable_suffix

# Add the executable itself as an input.
inputs += [ host_executable ]

deps = [ host_tool ]
deps = [
host_tool,
]
if (defined(invoker.deps)) {
deps += invoker.deps
}

# The script takes as arguments the binary to run, and then the arguments
# to pass it.
args = [
rebase_path(host_executable, root_build_dir)
] + invoker.args
args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args
}
}
15 changes: 6 additions & 9 deletions build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ declare_args() {
config("feature_flags") {
# TODO(brettw) most of these need to be parameterized.
defines = [
"CHROMIUM_BUILD",
"V8_DEPRECATION_WARNINGS", # Don't use deprecated V8 APIs anywhere.
"CHROMIUM_BUILD",
"V8_DEPRECATION_WARNINGS", # Don't use deprecated V8 APIs anywhere.
]

if (cld_version > 0) {
Expand Down Expand Up @@ -234,9 +234,7 @@ config("debug") {
}

config("release") {
defines = [
"NDEBUG",
]
defines = [ "NDEBUG" ]
}

# Default libraries ------------------------------------------------------------
Expand Down Expand Up @@ -271,6 +269,7 @@ config("default_libs") {
"winmm.lib",
"winspool.lib",
"ws2_32.lib",

# Please don't add more stuff here. We should actually be making this
# list smaller, since all common things should be covered. If you need
# some extra libraries, please just add a libs = [ "foo.lib" ] to your
Expand All @@ -287,7 +286,7 @@ config("default_libs") {
# '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
"c",
"dl",
"m"
"m",
]
} else if (is_mac) {
libs = [
Expand All @@ -308,8 +307,6 @@ config("default_libs") {
"UIKit.framework",
]
} else if (is_linux) {
libs = [
"dl",
]
libs = [ "dl" ]
}
}
Loading

0 comments on commit b199254

Please sign in to comment.