Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Move linux pkg_config() calls into separate BUILD.gn files
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
agrieve authored and Commit bot committed Apr 25, 2016
1 parent 714d683 commit 95ba444
Show file tree
Hide file tree
Showing 28 changed files with 162 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
89 changes: 11 additions & 78 deletions build/config/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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",
]
}
40 changes: 40 additions & 0 deletions build/config/linux/atk/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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",
]
}
11 changes: 11 additions & 0 deletions build/config/linux/dbus/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
19 changes: 19 additions & 0 deletions build/config/linux/gconf/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
9 changes: 9 additions & 0 deletions build/config/linux/libffi/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
9 changes: 9 additions & 0 deletions build/config/linux/pangocairo/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
4 changes: 4 additions & 0 deletions build/config/posix/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion build/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -123,6 +130,6 @@ group("freetype2") {
"//third_party/freetype-android:freetype",
]
} else {
public_configs = [ "//build/config/linux:freetype2" ]
public_configs = [ ":freetype2_config" ]
}
}
2 changes: 1 addition & 1 deletion chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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" ]
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/libgtk2ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]

Expand Down
6 changes: 3 additions & 3 deletions chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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 = [
Expand Down
8 changes: 4 additions & 4 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
Expand Down Expand Up @@ -323,7 +323,7 @@ source_set("browser") {
}

if (use_pango) {
configs += [ "//build/config/linux:pangocairo" ]
configs += [ "//build/config/linux/pangocairo" ]
}

if (is_android) {
Expand Down
2 changes: 1 addition & 1 deletion content/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Loading

0 comments on commit 95ba444

Please sign in to comment.