Skip to content

Commit

Permalink
Add CC to the GN build, work on GPU more
Browse files Browse the repository at this point in the history
BUG=
R=jamesr@chromium.org
TBR=piman

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273588 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed May 29, 2014
1 parent 5298cc9 commit d05751a
Show file tree
Hide file tree
Showing 10 changed files with 1,176 additions and 60 deletions.
8 changes: 4 additions & 4 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ group("root") {
#"//base(//build/toolchain/nacl:x86_newlib)",

"//apps/common/api:apps_api",
"//cc",
#"//chrome",
"//components/favicon_base",
"//components/language_usage_metrics",
Expand All @@ -38,8 +39,7 @@ group("root") {
"//device/usb",
#"//extensions/common/api:extensions_api",
"//gin",
"//gpu/command_buffer/client",
"//gpu/command_buffer/service",
"//gpu",
"//google_apis",
"//ipc",
"//mojo",
Expand Down Expand Up @@ -98,6 +98,7 @@ group("root") {

if (is_android) {
deps -= [
"//cc",
"//content/public/common",
"//content/public/renderer",
"//ppapi:ppapi_c",
Expand All @@ -109,8 +110,7 @@ group("root") {
# This stuff all depends on ui/surface which requires some .class jni
# generators (ui/gl/gl.gyp:surface_jni_headers).
"//ui/gl",
"//gpu/command_buffer/client",
"//gpu/command_buffer/service",
"//gpu",
"//ui/surface",
]
}
Expand Down
99 changes: 76 additions & 23 deletions build/config/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,63 @@ pkg_config("gconf") {
defines = [ "USE_GCONF" ]
}

# name: Name to use for the value of the --name arg.
# output_h/output_cc: Names for the generated header/cc file with no dir.
# header: header file to process. Example: "<foo/bar.h>"
# functions: List of strings for functions to process.
# config: Label of the config generated by pkgconfig.
template("generate_library_loader") {
output_h = "$root_gen_dir/library_loaders/" + invoker.output_h
output_cc = "$root_gen_dir/library_loaders/" + invoker.output_cc

action_visibility = ":$target_name"
action("${target_name}_loader") {
visibility = action_visibility

script = "//tools/generate_library_loader/generate_library_loader.py"
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}

outputs = [ output_h, output_cc ]

args = [
"--name", invoker.name,
"--output-h", rebase_path(output_h),
"--output-cc", rebase_path(output_cc),
"--header", invoker.header,
# Note GYP build exposes a per-target variable to control this, which, if
# manually set to true, will disable dlopen(). Its not clear this is
# needed, so here we just leave off. If this can be done globally, we
# can expose one switch for this value, otherwise we need to add a template
# param for this.
"--link-directly=0",
] + invoker.functions
}

source_set(target_name) {
direct_dependent_configs = [ invoker.config ]
sources = [ output_h, output_cc ]
deps = [ ":${target_name}_loader" ]
}
}

pkg_config("gio_config") {
packages = [ "gio-2.0" ]
defines = [ "USE_GIO" ]
ignore_libs = true # Loader generated below.
}

gio_output_h = "$root_gen_dir/library_loaders/libgio.h"
gio_output_cc = "$root_gen_dir/library_loaders/libgio_loader.cc"
# This generates a target named "gio".
generate_library_loader("gio") {
name = "LibGioLoader"
output_h = "libgio.h"
output_cc = "libgio_loader.cc"
# TODO(brettw) convert ti "<gio/gio.h>" once GN doesn't mangle <>.
header = "\"gio/gio.h\""
config = ":gio_config"

action("make_gio_headers") {
visibility = ":gio"

script = "//tools/generate_library_loader/generate_library_loader.py"

outputs = [ gio_output_h, gio_output_cc ]

args = [
"--name", "LibGioLoader",
"--output-h", rebase_path(gio_output_h),
"--output-cc", rebase_path(gio_output_cc),
# TODO(brettw) convert ti "<gio/gio.h>" once GN doesn't mangle <>.
"--header", "\"gio/gio.h\"",
# Note GYP build exposes a variable linux_link_gsettings to control this,
# which, if manually set to true, will disable dlopen() for this. Its not
# clear this is needed, so here we just leave off.
"--link-directly=0",
functions = [
"g_settings_new",
"g_settings_get_child",
"g_settings_get_string",
Expand All @@ -117,8 +149,29 @@ action("make_gio_headers") {
]
}

source_set("gio") {
direct_dependent_configs = [ ":gio_config" ]
sources = [ gio_output_h, gio_output_cc ]
deps = [ ":make_gio_headers" ]
# pkgconfig doesn't return anything interesting for this other than -lpci
# on suppotred systems, so we hardcode.
config("libpci_config") {
# This is not needed as long as we're setting link_directly=0 for the library
# loaders.
#libs = [ "pci" ]
}

# This generates a target named "libpci".
generate_library_loader("libpci") {
name = "LibPciLoader"
output_h = "libpci.h"
output_cc = "libpci_loader.cc"
# TODO(brettw) convert to "<pci/pci.h>" once GN doesn't mangle <>.
header = "\"pci/pci.h\""
config = ":libpci_config"

functions = [
"pci_alloc",
"pci_init",
"pci_cleanup",
"pci_scan_bus",
"pci_fill_info",
"pci_lookup_name",
]
}
12 changes: 9 additions & 3 deletions build/config/linux/pkg_config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import("//build/config/sysroot.gni")
#
# You can also use "extra args" to filter out results (see pkg-config.py):
# extra_args = [ "-v, "foo" ]
# To ignore libs and ldflags (only cflags/defines will be set, which is useful
# when doing manual dynamic linking), set:
# ignore_libs = true

template("pkg_config") {
assert(defined(invoker.packages),
Expand All @@ -40,9 +43,12 @@ template("pkg_config") {
args, "value")
include_dirs = pkgresult[0]
cflags = pkgresult[1]
libs = pkgresult[2]
lib_dirs = pkgresult[3]
ldflags = pkgresult[4]

if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) {
libs = pkgresult[2]
lib_dirs = pkgresult[3]
ldflags = pkgresult[4]
}

if (defined(invoker.defines)) {
defines = invoker.defines
Expand Down
Loading

0 comments on commit d05751a

Please sign in to comment.