From 95ba4446355ffd95eca68d3c3ba7fc3c2e364b6d Mon Sep 17 00:00:00 2001 From: agrieve Date: Mon, 25 Apr 2016 08:47:13 -0700 Subject: [PATCH] Move linux pkg_config() calls into separate BUILD.gn files This showed up as a bottleneck for gn gen on Android. Refactoring these out improves gn gen time (avg of 3 trails on my machine) from 2151->1984 BUG=none Review URL: https://codereview.chromium.org/1909273002 Cr-Commit-Position: refs/heads/master@{#389484} --- .gn | 1 + BUILD.gn | 18 ++++++ build/config/linux/BUILD.gn | 89 ++++---------------------- build/config/linux/atk/BUILD.gn | 40 ++++++++++++ build/config/linux/dbus/BUILD.gn | 11 ++++ build/config/linux/gconf/BUILD.gn | 19 ++++++ build/config/linux/libffi/BUILD.gn | 9 +++ build/config/linux/pangocairo/BUILD.gn | 9 +++ build/config/posix/BUILD.gn | 4 ++ build/linux/BUILD.gn | 9 ++- chrome/BUILD.gn | 2 +- chrome/browser/BUILD.gn | 4 +- chrome/browser/extensions/BUILD.gn | 2 +- chrome/browser/ui/libgtk2ui/BUILD.gn | 2 +- chromeos/BUILD.gn | 6 +- content/browser/BUILD.gn | 8 +-- content/common/BUILD.gn | 2 +- dbus/BUILD.gn | 8 +-- device/BUILD.gn | 2 +- device/battery/BUILD.gn | 4 +- extensions/browser/BUILD.gn | 2 +- net/BUILD.gn | 4 +- skia/BUILD.gn | 5 +- third_party/wayland/BUILD.gn | 6 +- ui/accessibility/BUILD.gn | 2 +- ui/base/BUILD.gn | 2 +- ui/base/ime/BUILD.gn | 2 +- ui/gfx/BUILD.gn | 2 +- 28 files changed, 162 insertions(+), 112 deletions(-) create mode 100644 build/config/linux/atk/BUILD.gn create mode 100644 build/config/linux/dbus/BUILD.gn create mode 100644 build/config/linux/gconf/BUILD.gn create mode 100644 build/config/linux/libffi/BUILD.gn create mode 100644 build/config/linux/pangocairo/BUILD.gn diff --git a/.gn b/.gn index a33683477a8da..b6a59c3e52c0e 100644 --- a/.gn +++ b/.gn @@ -209,6 +209,7 @@ exec_script_whitelist = [ "//build/config/ios/ios_sdk.gni", "//build/config/linux/BUILD.gn", "//build/config/linux/pkg_config.gni", + "//build/config/linux/atk/BUILD.gn", "//build/config/mac/mac_sdk.gni", "//build/config/posix/BUILD.gn", "//build/config/sysroot.gni", diff --git a/BUILD.gn b/BUILD.gn index d89ba2cf03c39..284d1006aa6a8 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -892,6 +892,24 @@ group("chromium_builder_perf") { group("aura_builder") { } +if (is_android) { + group("optimize_gn_gen") { + deps = [ + # These run expensive scripts in non-default toolchains. Generally, host + # toolchain targets are loaded in the later part of the run, and the + # result is they push out the end of generation. By preloading these, the + # scripts can be parallelized with the rest of the load. + "//build/config/linux(//build/toolchain/linux:clang_x64)", + "//build/config/posix(//build/toolchain/linux:clang_x64)", + + # Include x86 toolchains as well since V8 uses them for 32-bit snapshot + # generation. + "//build/config/linux(//build/toolchain/linux:clang_x86)", + "//build/config/posix(//build/toolchain/linux:clang_x86)", + ] + } +} + # Because of the source assignment filter, many targets end up over-filtering # their sources if the output directory contains a platform name. Assert that # this doesn't happen. http://crbug.com/548283 diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn index c0871f881e765..9e56b770fd979 100644 --- a/build/config/linux/BUILD.gn +++ b/build/config/linux/BUILD.gn @@ -3,9 +3,10 @@ # found in the LICENSE file. import("//build/config/linux/pkg_config.gni") -import("//build/config/features.gni") -import("//build/config/sysroot.gni") -import("//build/config/ui.gni") + +group("linux") { + visibility = [ "//:optimize_gn_gen" ] +} # This is included by reference in the //build/config/compiler config that # is applied to all targets. It is here to separate out the logic that is @@ -29,47 +30,9 @@ config("runtime_library") { config("fontconfig") { visibility = [ "//build/linux:fontconfig" ] - libs = [ "fontconfig" ] } -pkg_config("freetype2") { - visibility = [ "//build/linux:freetype2" ] - - packages = [ "freetype2" ] -} - -pkg_config("glib") { - packages = [ - "glib-2.0", - "gmodule-2.0", - "gobject-2.0", - "gthread-2.0", - ] -} - -if (use_pango || use_cairo) { - pkg_config("pangocairo") { - packages = [ "pangocairo" ] - } -} - -if (use_pango) { - pkg_config("pangoft2") { - packages = [ "pangoft2" ] - } -} - -# Note: if your target also depends on //dbus, you don't need to add this -# config (it will get added automatically if you depend on //dbus). -pkg_config("dbus") { - packages = [ "dbus-1" ] -} - -pkg_config("libffi") { - packages = [ "libffi" ] -} - config("x11") { libs = [ "X11", @@ -120,41 +83,11 @@ config("libresolv") { libs = [ "resolv" ] } -# CrOS doesn't install GTK, gconf or any gnome packages. -if (!is_chromeos && use_gconf) { - # These packages should _only_ be expected when building for a target. - # If these extra checks are not run, gconf is required when building host - # tools for a CrOS build. - if (current_toolchain == default_toolchain) { - pkg_config("atk") { - packages = [ "atk" ] - atk_lib_dir = exec_script(pkg_config_script, - pkg_config_args + [ - "--libdir", - "atk", - ], - "string") - defines = [ "ATK_LIB_DIR=\"$atk_lib_dir\"" ] - } - - # gn orders flags on a target before flags from configs. The default config - # adds -Wall, and these flags have to be after -Wall -- so they need to - # come from a config and can't be on the target directly. - config("atk_warnings") { - cflags = [ - # glib uses the pre-c++11 typedef-as-static_assert hack. - "-Wno-unused-local-typedef", - - # G_DEFINE_TYPE automatically generates a *get_instance_private - # inline function after glib 2.37. That's unused. Prevent to - # complain about it. - "-Wno-unused-function", - ] - } - - pkg_config("gconf") { - packages = [ "gconf-2.0" ] - defines = [ "USE_GCONF" ] - } - } +pkg_config("glib") { + packages = [ + "glib-2.0", + "gmodule-2.0", + "gobject-2.0", + "gthread-2.0", + ] } diff --git a/build/config/linux/atk/BUILD.gn b/build/config/linux/atk/BUILD.gn new file mode 100644 index 0000000000000..96bf8c0a5f88c --- /dev/null +++ b/build/config/linux/atk/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright 2016 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. + +import("//build/config/features.gni") +import("//build/config/linux/pkg_config.gni") + +# CrOS doesn't install GTK, gconf or any gnome packages. +assert(!is_chromeos && use_gconf) + +# These packages should _only_ be expected when building for a target. +# If these extra checks are not run, gconf is required when building host +# tools for a CrOS build. +assert(current_toolchain == default_toolchain) + +pkg_config("atk") { + packages = [ "atk" ] + atk_lib_dir = exec_script(pkg_config_script, + pkg_config_args + [ + "--libdir", + "atk", + ], + "string") + defines = [ "ATK_LIB_DIR=\"$atk_lib_dir\"" ] +} + +# gn orders flags on a target before flags from configs. The default config +# adds -Wall, and these flags have to be after -Wall -- so they need to +# come from a config and can't be on the target directly. +config("warnings") { + cflags = [ + # glib uses the pre-c++11 typedef-as-static_assert hack. + "-Wno-unused-local-typedef", + + # G_DEFINE_TYPE automatically generates a *get_instance_private + # inline function after glib 2.37. That's unused. Prevent to + # complain about it. + "-Wno-unused-function", + ] +} diff --git a/build/config/linux/dbus/BUILD.gn b/build/config/linux/dbus/BUILD.gn new file mode 100644 index 0000000000000..a26ca92b5fcfd --- /dev/null +++ b/build/config/linux/dbus/BUILD.gn @@ -0,0 +1,11 @@ +# Copyright 2016 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. + +import("//build/config/linux/pkg_config.gni") + +# Note: if your target also depends on //dbus, you don't need to add this +# config (it will get added automatically if you depend on //dbus). +pkg_config("dbus") { + packages = [ "dbus-1" ] +} diff --git a/build/config/linux/gconf/BUILD.gn b/build/config/linux/gconf/BUILD.gn new file mode 100644 index 0000000000000..262e96aa8e400 --- /dev/null +++ b/build/config/linux/gconf/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright 2016 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. + +import("//build/config/features.gni") +import("//build/config/linux/pkg_config.gni") + +# CrOS doesn't install GTK, gconf or any gnome packages. +assert(!is_chromeos && use_gconf) + +# These packages should _only_ be expected when building for a target. +# If these extra checks are not run, gconf is required when building host +# tools for a CrOS build. +assert(current_toolchain == default_toolchain) + +pkg_config("gconf") { + packages = [ "gconf-2.0" ] + defines = [ "USE_GCONF" ] +} diff --git a/build/config/linux/libffi/BUILD.gn b/build/config/linux/libffi/BUILD.gn new file mode 100644 index 0000000000000..a4041727b1c09 --- /dev/null +++ b/build/config/linux/libffi/BUILD.gn @@ -0,0 +1,9 @@ +# Copyright 2016 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. + +import("//build/config/linux/pkg_config.gni") + +pkg_config("libffi") { + packages = [ "libffi" ] +} diff --git a/build/config/linux/pangocairo/BUILD.gn b/build/config/linux/pangocairo/BUILD.gn new file mode 100644 index 0000000000000..727b52d533359 --- /dev/null +++ b/build/config/linux/pangocairo/BUILD.gn @@ -0,0 +1,9 @@ +# Copyright 2016 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. + +import("//build/config/linux/pkg_config.gni") + +pkg_config("pangocairo") { + packages = [ "pangocairo" ] +} diff --git a/build/config/posix/BUILD.gn b/build/config/posix/BUILD.gn index e862c50e703a7..fc5dd43210336 100644 --- a/build/config/posix/BUILD.gn +++ b/build/config/posix/BUILD.gn @@ -6,6 +6,10 @@ import("//build/config/sysroot.gni") assert(is_posix) +group("posix") { + visibility = [ "//:optimize_gn_gen" ] +} + # This is included by reference in the //build/config/compiler:runtime_library # config that is applied to all targets. It is here to separate out the logic # that is Posix-only. Please see that target for advice on what should go in diff --git a/build/linux/BUILD.gn b/build/linux/BUILD.gn index 97428b4eda155..a44c117e85f37 100644 --- a/build/linux/BUILD.gn +++ b/build/linux/BUILD.gn @@ -115,6 +115,13 @@ group("fontconfig") { } } +if (!is_chromecast) { + pkg_config("freetype2_config") { + visibility = [ ":freetype2" ] + packages = [ "freetype2" ] + } +} + group("freetype2") { if (is_chromecast) { # Chromecast platform doesn't provide freetype, so use Chromium's. @@ -123,6 +130,6 @@ group("freetype2") { "//third_party/freetype-android:freetype", ] } else { - public_configs = [ "//build/config/linux:freetype2" ] + public_configs = [ ":freetype2_config" ] } } diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index 7828eb1492df3..290cc149b5ff5 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -201,7 +201,7 @@ if (!is_android) { if (use_pango || use_cairo) { # Needed for chrome_main.cc initialization of libraries. - configs += [ "//build/config/linux:pangocairo" ] + configs += [ "//build/config/linux/pangocairo" ] } if (use_x11) { diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index d1822163215df..d153f91ee7c5e 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -876,7 +876,7 @@ source_set("browser") { if (is_linux) { if (use_aura) { - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] deps += [ "//build/linux:fontconfig", "//dbus", @@ -1233,7 +1233,7 @@ source_set("test_support") { "chromeos/system/fake_input_device_settings.cc", "chromeos/system/fake_input_device_settings.h", ] - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] deps += [ "//chromeos:test_support" ] } diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn index 35aeeaa9639f7..e2d50dc31b3af 100644 --- a/chrome/browser/extensions/BUILD.gn +++ b/chrome/browser/extensions/BUILD.gn @@ -99,7 +99,7 @@ source_set("extensions") { ".", "//chrome") sources -= [ "api/music_manager_private/device_id_linux.cc" ] - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] deps += [ "//components/chrome_apps", "//remoting/host/it2me:common", diff --git a/chrome/browser/ui/libgtk2ui/BUILD.gn b/chrome/browser/ui/libgtk2ui/BUILD.gn index 318f30755d3ec..6ce809763f318 100644 --- a/chrome/browser/ui/libgtk2ui/BUILD.gn +++ b/chrome/browser/ui/libgtk2ui/BUILD.gn @@ -70,7 +70,7 @@ component("libgtk2ui") { "gconf_listener.cc", "gconf_listener.h", ] - configs += [ "//build/config/linux:gconf" ] + configs += [ "//build/config/linux/gconf" ] } defines = [ "LIBGTK2UI_IMPLEMENTATION" ] diff --git a/chromeos/BUILD.gn b/chromeos/BUILD.gn index cd5a37e46f187..276a657669e73 100644 --- a/chromeos/BUILD.gn +++ b/chromeos/BUILD.gn @@ -58,7 +58,7 @@ component("chromeos") { # can be converted to a source set. static_library("test_support") { testonly = true - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] public_deps = [ ":chromeos", ":cryptohome_proto", @@ -118,7 +118,7 @@ static_library("test_support") { static_library("test_support_without_gmock") { testonly = true - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] deps = [ ":chromeos", ":cryptohome_proto", @@ -139,7 +139,7 @@ static_library("test_support_without_gmock") { test("chromeos_unittests") { configs += [ - "//build/config/linux:dbus", + "//build/config/linux/dbus", "//third_party/nss:system_nss_no_ssl_config", ] deps = [ diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index 9b9b44fb0dd31..b98c5f9e592e9 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn @@ -281,9 +281,9 @@ source_set("browser") { "//content") configs += [ - "//build/config/linux:atk", - "//build/config/linux:atk_warnings", - "//build/config/linux:gconf", + "//build/config/linux/atk", + "//build/config/linux/atk:warnings", + "//build/config/linux/gconf", "//build/config/linux:glib", ] } @@ -323,7 +323,7 @@ source_set("browser") { } if (use_pango) { - configs += [ "//build/config/linux:pangocairo" ] + configs += [ "//build/config/linux/pangocairo" ] } if (is_android) { diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index 30101b4a6a7eb..2019609503625 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn @@ -287,7 +287,7 @@ source_set("common") { } if (use_pango) { - configs += [ "//build/config/linux:pangocairo" ] + configs += [ "//build/config/linux/pangocairo" ] if (use_ozone) { # If we're using pango, never use this ozone file (it was removed in all # non-ozone cases above). diff --git a/dbus/BUILD.gn b/dbus/BUILD.gn index dbeee0c1dda46..1502ca753614c 100644 --- a/dbus/BUILD.gn +++ b/dbus/BUILD.gn @@ -45,7 +45,7 @@ component("dbus") { "//base", ] - public_configs = [ "//build/config/linux:dbus" ] + public_configs = [ "//build/config/linux/dbus" ] } proto_library("test_proto") { @@ -76,7 +76,7 @@ source_set("test_support") { "//testing/gmock", ] - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] } test("dbus_unittests") { @@ -109,7 +109,7 @@ test("dbus_unittests") { "//third_party/protobuf:protobuf_lite", ] - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] } executable("dbus_test_server") { @@ -127,5 +127,5 @@ executable("dbus_test_server") { "//build/config/sanitizers:deps", ] - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] } diff --git a/device/BUILD.gn b/device/BUILD.gn index 7dbd214ea6c41..acfb715892b45 100644 --- a/device/BUILD.gn +++ b/device/BUILD.gn @@ -154,7 +154,7 @@ test("device_unittests") { } if ((is_chromeos || is_linux) && use_dbus) { - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] sources += [ "bluetooth/bluez/bluetooth_adapter_profile_bluez_unittest.cc", diff --git a/device/battery/BUILD.gn b/device/battery/BUILD.gn index 9876bc6cc7e7c..70c1d268c4d09 100644 --- a/device/battery/BUILD.gn +++ b/device/battery/BUILD.gn @@ -36,7 +36,7 @@ if (!is_android) { ] if (is_chromeos) { - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] deps += [ "//chromeos:chromeos", "//chromeos:power_manager_proto", @@ -49,7 +49,7 @@ if (!is_android) { if (is_linux && !is_chromeos) { if (use_dbus) { - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] deps += [ "//dbus" ] sources -= [ "battery_status_manager_default.cc" ] } else { diff --git a/extensions/browser/BUILD.gn b/extensions/browser/BUILD.gn index e044a7a89128d..419afc89e997a 100644 --- a/extensions/browser/BUILD.gn +++ b/extensions/browser/BUILD.gn @@ -83,7 +83,7 @@ source_set("browser") { sources += nonchromeos_sources if (is_linux) { - configs += [ "//build/config/linux:dbus" ] + configs += [ "//build/config/linux/dbus" ] deps += [ "//dbus" ] linux_sources = rebase_path( extensions_gypi_values.extensions_browser_sources_linux_nonchromeos, diff --git a/net/BUILD.gn b/net/BUILD.gn index b9f77f83ae2cb..daa320dc1b38e 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn @@ -102,7 +102,7 @@ net_configs = [ ] if (use_glib && use_gconf && !is_chromeos) { - net_configs += [ "//build/config/linux:gconf" ] + net_configs += [ "//build/config/linux/gconf" ] } if (is_linux) { @@ -937,7 +937,7 @@ if (!is_ios && !is_android) { if (is_desktop_linux && use_gconf && use_glib) { configs += [ - "//build/config/linux:gconf", + "//build/config/linux/gconf", "//build/config/linux:glib", ] deps += [ "//build/linux:gio" ] diff --git a/skia/BUILD.gn b/skia/BUILD.gn index 3565eab317001..a5872a7563503 100644 --- a/skia/BUILD.gn +++ b/skia/BUILD.gn @@ -19,8 +19,7 @@ skia_support_pdf = !is_ios && (enable_basic_printing || enable_print_preview) gypi_chromium_skia_defines = exec_script("//build/gypi_to_gn.py", [ - rebase_path( - "//skia/chromium_skia_defines.gypi"), + rebase_path("//skia/chromium_skia_defines.gypi"), "--replace=<(skia_include_path)=//third_party/skia/include", "--replace=<(skia_src_path)=//third_party/skia/src", ], @@ -466,7 +465,7 @@ component("skia") { if (is_linux) { if (use_pango) { - configs += [ "//build/config/linux:pangocairo" ] + configs += [ "//build/config/linux/pangocairo" ] } deps += [ "//build/linux:fontconfig", diff --git a/third_party/wayland/BUILD.gn b/third_party/wayland/BUILD.gn index e9652b3859ab2..ecb81e04a85ce 100644 --- a/third_party/wayland/BUILD.gn +++ b/third_party/wayland/BUILD.gn @@ -33,7 +33,7 @@ source_set("wayland_private") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code", - "//build/config/linux:libffi", + "//build/config/linux/libffi", ":wayland_config", ] } @@ -70,7 +70,7 @@ source_set("wayland_server") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code", - "//build/config/linux:libffi", + "//build/config/linux/libffi", ] public_configs = [ ":wayland_config" ] @@ -91,7 +91,7 @@ source_set("wayland_client") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code", - "//build/config/linux:libffi", + "//build/config/linux/libffi", ] public_configs = [ ":wayland_config" ] diff --git a/ui/accessibility/BUILD.gn b/ui/accessibility/BUILD.gn index 53d0801513cc9..dcd546bc6874e 100644 --- a/ui/accessibility/BUILD.gn +++ b/ui/accessibility/BUILD.gn @@ -97,7 +97,7 @@ component("accessibility") { configs += [ ":atk", ":atk_warnings", - "//build/config/linux:gconf", + "//build/config/linux/gconf", "//build/config/linux:glib", ] } diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn index 87a6a70fc9826..f057dfa24bff8 100644 --- a/ui/base/BUILD.gn +++ b/ui/base/BUILD.gn @@ -884,7 +884,7 @@ test("ui_base_unittests") { } if (use_pango) { - configs += [ "//build/config/linux:pangocairo" ] + configs += [ "//build/config/linux/pangocairo" ] } if (use_x11) { diff --git a/ui/base/ime/BUILD.gn b/ui/base/ime/BUILD.gn index e60caafc0b7f5..b6da63771f545 100644 --- a/ui/base/ime/BUILD.gn +++ b/ui/base/ime/BUILD.gn @@ -164,7 +164,7 @@ component("ime") { } if (use_pango) { - configs += [ "//build/config/linux:pangocairo" ] + configs += [ "//build/config/linux/pangocairo" ] } else { sources -= [ "composition_text_util_pango.cc", diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn index ffabe80ad05b7..026ed2a8c361a 100644 --- a/ui/gfx/BUILD.gn +++ b/ui/gfx/BUILD.gn @@ -417,7 +417,7 @@ component("gfx") { } if (use_cairo) { - configs += [ "//build/config/linux:pangocairo" ] + configs += [ "//build/config/linux/pangocairo" ] } }