Simplify build

R=aerotwist@chromium.org

Change-Id: I9588e519fd491cf116517f6d4971d44ee64c2dfc
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1905826
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
diff --git a/.gn b/.gn
index 5db68ae..246faa5 100644
--- a/.gn
+++ b/.gn
@@ -6,10 +6,8 @@
 # tree and to set startup options. For documentation on the values set in this
 # file, run "gn help dotfile" at the command line.
 
-import("//build/dotfile_settings.gni")
-
 # The location of the build configuration file.
-buildconfig = "//build/config/BUILDCONFIG.gn"
+buildconfig = "//build_overrides/BUILDCONFIG.gn"
 
 # These are the targets to check headers for by default. The files in targets
 # matching these patterns (see "gn help label_pattern" for format) will have
@@ -17,11 +15,6 @@
 # "gn check" or "gn gen --check".
 check_targets = [ "*" ]
 
-# These are the list of GN files that run exec_script. This whitelist exists
-# to force additional review for new uses of exec_script, which is strongly
-# discouraged except for gypi_to_gn calls.
-exec_script_whitelist = build_dotfile_settings.exec_script_whitelist
-
 default_args = {
   # Enable by default to provide unbundled resource files.
   debug_devtools = true
diff --git a/BUILD.gn b/BUILD.gn
index bda00a5..a455a83 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2,7 +2,6 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//build/config/features.gni")
 import("//third_party/blink/public/public_features.gni")
 import("//third_party/blink/renderer/core/core.gni")
 
diff --git a/DEPS b/DEPS
index 8eb146d..4075a97 100644
--- a/DEPS
+++ b/DEPS
@@ -6,18 +6,12 @@
   'build_url': 'https://chromium.googlesource.com/chromium/src/build.git',
   'build_revision': '61ec5dc258b9fbc17504d1276e0c3eaf4656e372',
 
-  'buildtools_url': 'https://chromium.googlesource.com/chromium/src/buildtools.git',
-  'buildtools_revision': '140e4d7c45ffb55ce5dc4d11a0c3938363cd8257',
-
   'depot_tools_url': 'https://chromium.googlesource.com/chromium/tools/depot_tools',
   'depot_tools_revision': '512f92b73181c8e1d99d38cd9b73fbf41151636a',
 
   'inspector_protocol_url': 'https://chromium.googlesource.com/deps/inspector_protocol',
   'inspector_protocol_revision': 'd2fc9b958e1eeb1e956f3e2208afa9923bdc9b67',
 
-  'clang_format_url': 'https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format.git',
-  'clang_format_revision': 'bb994c6f067340c1135eb43eed84f4b33cfa7397',
-
   # GN CIPD package version.
   'gn_version': 'git_revision:ad9e442d92dcd9ee73a557428cfc336b55cbd533',
 
@@ -31,12 +25,6 @@
 allowed_hosts = [ 'chromium.googlesource.com' ]
 
 deps = {
-  'devtools-frontend/buildtools/clang_format/script':
-    Var('clang_format_url') + '@' + Var('clang_format_revision'),
-
-  'devtools-frontend/buildtools':
-    Var('buildtools_url') + '@' + Var('buildtools_revision'),
-
   'devtools-frontend/buildtools/linux64': {
     'packages': [
       {
@@ -128,53 +116,6 @@
     ],
   },
 
-  {
-    'name': 'sysroot_x64',
-    'pattern': '.',
-    'condition': 'checkout_linux and checkout_x64',
-    'action': ['python',
-               'devtools-frontend/build/linux/sysroot_scripts/install-sysroot.py',
-               '--arch=x64'],
-  },
-
-  # Pull clang-format binaries using checked-in hashes.
-  {
-    'name': 'clang_format_win',
-    'pattern': '.',
-    'condition': 'host_os == "win"',
-    'action': [ 'python',
-                'devtools-frontend/third_party/depot_tools/download_from_google_storage.py',
-                '--no_resume',
-                '--no_auth',
-                '--bucket', 'chromium-clang-format',
-                '-s', 'devtools-frontend/buildtools/win/clang-format.exe.sha1',
-    ],
-  },
-  {
-    'name': 'clang_format_mac',
-    'pattern': '.',
-    'condition': 'host_os == "mac"',
-    'action': [ 'python',
-                'devtools-frontend/third_party/depot_tools/download_from_google_storage.py',
-                '--no_resume',
-                '--no_auth',
-                '--bucket', 'chromium-clang-format',
-                '-s', 'devtools-frontend/buildtools/mac/clang-format.sha1',
-    ],
-  },
-  {
-    'name': 'clang_format_linux',
-    'pattern': '.',
-    'condition': 'host_os == "linux"',
-    'action': [ 'python',
-                'devtools-frontend/third_party/depot_tools/download_from_google_storage.py',
-                '--no_resume',
-                '--no_auth',
-                '--bucket', 'chromium-clang-format',
-                '-s', 'devtools-frontend/buildtools/linux64/clang-format.sha1',
-    ],
-  },
-
   # Pull chromium from common storage
   {
     'name': 'chromium_linux',
diff --git a/build_overrides/BUILDCONFIG.gn b/build_overrides/BUILDCONFIG.gn
new file mode 100644
index 0000000..cee7a95
--- /dev/null
+++ b/build_overrides/BUILDCONFIG.gn
@@ -0,0 +1,85 @@
+# Copyright (c) 2019 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# =============================================================================
+# WHAT IS THIS FILE?
+# =============================================================================
+#
+# This is the master GN build configuration. This file is loaded after the
+# build args (args.gn) for the build directory and after the toplevel ".gn"
+# file (which points to this file as the build configuration).
+#
+# This particular version of BUILDCONFIG.gn is derived from the original
+# at //build/config/BUILDCONFIG.gn, but does not include many of the toolchain
+# settings that are relevant for compiling C++.
+
+# =============================================================================
+# BUILD FLAGS
+# =============================================================================
+
+declare_args() {
+  # Set to enable the official build level of optimization. This has nothing
+  # to do with branding, but enables an additional level of optimization above
+  # release (!is_debug). This might be better expressed as a tri-state
+  # (debug, release, official) but for historical reasons there are two
+  # separate flags.
+  is_official_build = false
+
+  # Whether we're a traditional desktop unix.
+  is_desktop_linux = current_os == "linux"
+
+  # Set to true when compiling with the Clang compiler.
+  is_clang = true
+
+  # Allows the path to a custom target toolchain to be injected as a single
+  # argument, and set as the default toolchain.
+  custom_toolchain = ""
+
+  # This should not normally be set as a build argument.  It's here so that
+  # every toolchain can pass through the "global" value via toolchain_args().
+  host_toolchain = ""
+
+  # DON'T ADD MORE FLAGS HERE. Read the comment above.
+}
+
+declare_args() {
+  # Debug build. Enabling official builds automatically sets is_debug to false.
+  is_debug = !is_official_build
+}
+
+# ==============================================================================
+# TOOLCHAIN SETUP
+# ==============================================================================
+#
+# We don't actually compile anything, so taking the Linux X64 toolchain suffices.
+set_default_toolchain("//build/toolchain/linux:x64")
+
+# =============================================================================
+# OS DEFINITIONS
+# =============================================================================
+#
+# We set these various is_FOO booleans for convenience in writing OS-based
+# conditions.
+#
+# - is_android, is_chromeos, is_ios, and is_win should be obvious.
+# - is_mac is set only for desktop Mac. It is not set on iOS.
+# - is_posix is true for mac and any Unix-like system (basically everything
+#   except Windows).
+# - is_linux is true for desktop Linux and ChromeOS, but not Android (which is
+#   generally too different despite being based on the Linux kernel).
+#
+# Do not add more is_* variants here for random lesser-used Unix systems like
+# aix or one of the BSDs. If you need to check these, just check the
+# current_os value directly.
+
+is_android = current_os == "android"
+is_chromeos = current_os == "chromeos"
+is_fuchsia = current_os == "fuchsia"
+is_ios = current_os == "ios"
+is_linux = current_os == "chromeos" || current_os == "linux"
+is_mac = current_os == "mac"
+is_nacl = current_os == "nacl"
+is_win = current_os == "win" || current_os == "winuwp"
+
+is_posix = !is_win && !is_fuchsia