OLD | NEW |
---|---|
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/sysroot.gni") | 5 import("//build/config/sysroot.gni") |
6 | 6 |
7 # Defines a config specifying the result of running pkg-config for the given | 7 # Defines a config specifying the result of running pkg-config for the given |
8 # packages. Put the package names you want to query in the "packages" variable | 8 # packages. Put the package names you want to query in the "packages" variable |
9 # inside the template invocation. | 9 # inside the template invocation. |
10 # | 10 # |
(...skipping 14 matching lines...) Expand all Loading... | |
25 # ignore_libs = true | 25 # ignore_libs = true |
26 | 26 |
27 declare_args() { | 27 declare_args() { |
28 # A pkg-config wrapper to call instead of trying to find and call the right | 28 # A pkg-config wrapper to call instead of trying to find and call the right |
29 # pkg-config directly. Wrappers like this are common in cross-compilation | 29 # pkg-config directly. Wrappers like this are common in cross-compilation |
30 # environments. | 30 # environments. |
31 # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on | 31 # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on |
32 # the sysroot mechanism to find the right .pc files. | 32 # the sysroot mechanism to find the right .pc files. |
33 pkg_config = "" | 33 pkg_config = "" |
34 | 34 |
35 # A optional pkg-config wrapper to use for tools built on the host. | |
36 host_pkg_config = "" | |
37 | |
35 # CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfig | 38 # CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfig |
36 # and one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfi g | 39 # and one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfi g |
37 # depending on whether the systemroot is for a 32 or 64 bit architecture. | 40 # depending on whether the systemroot is for a 32 or 64 bit architecture. |
38 # | 41 # |
39 # When build under GYP, CrOS board builds specify the 'system_libdir' variable | 42 # When build under GYP, CrOS board builds specify the 'system_libdir' variable |
40 # as part of the GYP_DEFINES provided by the CrOS emerge build or simple | 43 # as part of the GYP_DEFINES provided by the CrOS emerge build or simple |
41 # chrome build scheme. This variable permits controlling this for GN builds | 44 # chrome build scheme. This variable permits controlling this for GN builds |
42 # in similar fashion by setting the `system_libdir` variable in the build's | 45 # in similar fashion by setting the `system_libdir` variable in the build's |
43 # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture. | 46 # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture. |
44 system_libdir = "lib" | 47 system_libdir = "lib" |
(...skipping 13 matching lines...) Expand all Loading... | |
58 ] | 61 ] |
59 } else if (pkg_config != "") { | 62 } else if (pkg_config != "") { |
60 pkg_config_args = [ | 63 pkg_config_args = [ |
61 "-p", | 64 "-p", |
62 pkg_config, | 65 pkg_config, |
63 ] | 66 ] |
64 } else { | 67 } else { |
65 pkg_config_args = [] | 68 pkg_config_args = [] |
66 } | 69 } |
67 | 70 |
68 # Only use the custom libdir when building with the target sysroot. | |
69 if (target_sysroot != "" && sysroot == target_sysroot) { | 71 if (target_sysroot != "" && sysroot == target_sysroot) { |
70 pkg_config_args += [ | 72 pkg_config_args += [ |
71 "--system_libdir", | 73 "--system_libdir", |
72 system_libdir, | 74 system_libdir, |
73 ] | 75 ] |
74 } | 76 } |
75 | 77 |
78 if (host_pkg_config != "") { | |
79 host_pkg_config_args = [ | |
80 "-p", | |
81 host_pkg_config, | |
82 ] | |
83 } else { | |
84 host_pkg_config_args = pkg_config_args | |
85 } | |
86 | |
76 template("pkg_config") { | 87 template("pkg_config") { |
88 # Only use the custom libdir when building with the target sysroot. | |
Dirk Pranke
2017/04/21 00:25:25
Why did this comment move?
richard.townsend
2017/04/21 17:08:03
Done.
| |
89 if (host_toolchain == current_toolchain) { | |
90 active_pkg_config_args = host_pkg_config_args | |
91 } else { | |
92 active_pkg_config_args = pkg_config_args | |
93 } | |
Dirk Pranke
2017/04/21 00:25:25
I'd probably move this if down to line 97 and just
richard.townsend
2017/04/21 17:08:03
Done.
| |
77 assert(defined(invoker.packages), | 94 assert(defined(invoker.packages), |
78 "Variable |packages| must be defined to be a list in pkg_config.") | 95 "Variable |packages| must be defined to be a list in pkg_config.") |
79 config(target_name) { | 96 config(target_name) { |
80 args = pkg_config_args + invoker.packages | 97 args = active_pkg_config_args + invoker.packages |
81 if (defined(invoker.extra_args)) { | 98 if (defined(invoker.extra_args)) { |
82 args += invoker.extra_args | 99 args += invoker.extra_args |
83 } | 100 } |
84 | 101 |
85 pkgresult = exec_script(pkg_config_script, args, "value") | 102 pkgresult = exec_script(pkg_config_script, args, "value") |
86 include_dirs = pkgresult[0] | 103 include_dirs = pkgresult[0] |
87 cflags = pkgresult[1] | 104 cflags = pkgresult[1] |
88 | 105 |
89 if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { | 106 if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { |
90 libs = pkgresult[2] | 107 libs = pkgresult[2] |
91 lib_dirs = pkgresult[3] | 108 lib_dirs = pkgresult[3] |
92 ldflags = pkgresult[4] | 109 ldflags = pkgresult[4] |
93 } | 110 } |
94 | 111 |
95 forward_variables_from(invoker, | 112 forward_variables_from(invoker, |
96 [ | 113 [ |
97 "defines", | 114 "defines", |
98 "visibility", | 115 "visibility", |
99 ]) | 116 ]) |
100 } | 117 } |
101 } | 118 } |
OLD | NEW |