2013-12-17 03:53:47 +04:00
|
|
|
# Copyright (c) 2013 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.
|
|
|
|
|
2014-01-09 01:38:35 +04:00
|
|
|
import("//build/config/sysroot.gni")
|
2013-12-18 02:54:18 +04:00
|
|
|
|
2013-12-17 03:53:47 +04:00
|
|
|
# Defines a config specifying the result of running pkg-config for the given
|
|
|
|
# packages. Put the package names you want to query in the "packages" variable
|
|
|
|
# inside the template invocation.
|
|
|
|
#
|
|
|
|
# You can also add defines via the "defines" variable. This can be useful to
|
|
|
|
# add this to the config to pass defines that the library expects to get by
|
|
|
|
# users of its headers.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# pkg_config("mything") {
|
|
|
|
# packages = [ "mything1", "mything2" ]
|
|
|
|
# defines = [ "ENABLE_AWESOME" ]
|
|
|
|
# }
|
2014-04-15 03:25:13 +04:00
|
|
|
#
|
|
|
|
# You can also use "extra args" to filter out results (see pkg-config.py):
|
|
|
|
# extra_args = [ "-v, "foo" ]
|
2014-05-30 00:54:24 +04:00
|
|
|
# To ignore libs and ldflags (only cflags/defines will be set, which is useful
|
|
|
|
# when doing manual dynamic linking), set:
|
|
|
|
# ignore_libs = true
|
2013-12-17 03:53:47 +04:00
|
|
|
|
2014-09-26 05:28:02 +04:00
|
|
|
declare_args() {
|
|
|
|
# A pkg-config wrapper to call instead of trying to find and call the right
|
|
|
|
# pkg-config directly. Wrappers like this are common in cross-compilation
|
|
|
|
# environments.
|
|
|
|
# Leaving it blank defaults to searching PATH for 'pkg-config' and relying on
|
|
|
|
# the sysroot mechanism to find the right .pc files.
|
|
|
|
pkg_config = ""
|
2016-01-07 05:11:46 +03:00
|
|
|
|
|
|
|
# CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfig
|
|
|
|
# and one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfig
|
|
|
|
# depending on whether the systemroot is for a 32 or 64 bit architecture.
|
|
|
|
#
|
|
|
|
# When build under GYP, CrOS board builds specify the 'system_libdir' variable
|
|
|
|
# as part of the GYP_DEFINES provided by the CrOS emerge build or simple
|
|
|
|
# chrome build scheme. This variable permits controlling this for GN builds
|
|
|
|
# in similar fashion by setting the `system_libdir` variable in the build's
|
|
|
|
# args.gn file to 'lib' or 'lib64' as appropriate for the target architecture.
|
|
|
|
system_libdir = "lib"
|
2014-09-26 05:28:02 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 20:45:30 +03:00
|
|
|
pkg_config_script = "//build/config/linux/pkg-config.py"
|
|
|
|
|
|
|
|
# Define the args we pass to the pkg-config script for other build files that
|
|
|
|
# need to invoke it manually.
|
|
|
|
if (sysroot != "") {
|
|
|
|
# Pass the sysroot if we're using one (it requires the CPU arch also).
|
gn format //build
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-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
pkg_config_args = [
|
|
|
|
"-s",
|
2016-02-04 05:23:00 +03:00
|
|
|
rebase_path(sysroot),
|
gn format //build
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-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"-a",
|
2015-02-20 05:55:19 +03:00
|
|
|
current_cpu,
|
gn format //build
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-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
]
|
2014-11-10 20:45:30 +03:00
|
|
|
} else if (pkg_config != "") {
|
gn format //build
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-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
pkg_config_args = [
|
|
|
|
"-p",
|
|
|
|
pkg_config,
|
|
|
|
]
|
2014-11-10 20:45:30 +03:00
|
|
|
} else {
|
|
|
|
pkg_config_args = []
|
|
|
|
}
|
|
|
|
|
2016-04-26 21:57:36 +03:00
|
|
|
# Only use the custom libdir when building with the target sysroot.
|
|
|
|
if (target_sysroot != "" && sysroot == target_sysroot) {
|
2016-01-28 00:36:26 +03:00
|
|
|
pkg_config_args += [
|
|
|
|
"--system_libdir",
|
|
|
|
system_libdir,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2013-12-17 03:53:47 +04:00
|
|
|
template("pkg_config") {
|
2014-03-28 20:19:02 +04:00
|
|
|
assert(defined(invoker.packages),
|
gn format //build
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-Original-Commit-Position: refs/heads/master@{#306305}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b199254f481c5db36d56e83fce40594b06d2b81f
2014-12-02 03:25:20 +03:00
|
|
|
"Variable |packages| must be defined to be a list in pkg_config.")
|
2013-12-17 03:53:47 +04:00
|
|
|
config(target_name) {
|
2014-11-10 20:45:30 +03:00
|
|
|
args = pkg_config_args + invoker.packages
|
2014-04-15 03:25:13 +04:00
|
|
|
if (defined(invoker.extra_args)) {
|
|
|
|
args += invoker.extra_args
|
|
|
|
}
|
|
|
|
|
2014-11-10 20:45:30 +03:00
|
|
|
pkgresult = exec_script(pkg_config_script, args, "value")
|
2013-12-17 03:53:47 +04:00
|
|
|
include_dirs = pkgresult[0]
|
|
|
|
cflags = pkgresult[1]
|
2014-05-30 00:54:24 +04:00
|
|
|
|
|
|
|
if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) {
|
|
|
|
libs = pkgresult[2]
|
|
|
|
lib_dirs = pkgresult[3]
|
|
|
|
ldflags = pkgresult[4]
|
|
|
|
}
|
2014-03-28 20:19:02 +04:00
|
|
|
|
2015-08-04 22:50:33 +03:00
|
|
|
forward_variables_from(invoker,
|
|
|
|
[
|
|
|
|
"defines",
|
|
|
|
"visibility",
|
|
|
|
])
|
2013-12-17 03:53:47 +04:00
|
|
|
}
|
|
|
|
}
|