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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 # Define the args we pass to the pkg-config script for other build files that | 49 # Define the args we pass to the pkg-config script for other build files that |
50 # need to invoke it manually. | 50 # need to invoke it manually. |
51 if (sysroot != "") { | 51 if (sysroot != "") { |
52 # Pass the sysroot if we're using one (it requires the CPU arch also). | 52 # Pass the sysroot if we're using one (it requires the CPU arch also). |
53 pkg_config_args = [ | 53 pkg_config_args = [ |
54 "-s", | 54 "-s", |
55 sysroot, | 55 sysroot, |
56 "-a", | 56 "-a", |
57 current_cpu, | 57 current_cpu, |
58 "--system_libdir", | |
59 system_libdir, | |
60 ] | 58 ] |
61 } else if (pkg_config != "") { | 59 } else if (pkg_config != "") { |
62 pkg_config_args = [ | 60 pkg_config_args = [ |
63 "-p", | 61 "-p", |
64 pkg_config, | 62 pkg_config, |
65 "--system_libdir", | |
66 system_libdir, | |
67 ] | 63 ] |
68 } else { | 64 } else { |
69 pkg_config_args = [] | 65 pkg_config_args = [] |
70 } | 66 } |
71 | 67 |
| 68 # Only use the custom libdir when building with the default toolchain. |
| 69 if (current_toolchain == default_toolchain) { |
| 70 pkg_config_args += [ |
| 71 "--system_libdir", |
| 72 system_libdir, |
| 73 ] |
| 74 } |
| 75 |
72 template("pkg_config") { | 76 template("pkg_config") { |
73 assert(defined(invoker.packages), | 77 assert(defined(invoker.packages), |
74 "Variable |packages| must be defined to be a list in pkg_config.") | 78 "Variable |packages| must be defined to be a list in pkg_config.") |
75 config(target_name) { | 79 config(target_name) { |
76 args = pkg_config_args + invoker.packages | 80 args = pkg_config_args + invoker.packages |
77 if (defined(invoker.extra_args)) { | 81 if (defined(invoker.extra_args)) { |
78 args += invoker.extra_args | 82 args += invoker.extra_args |
79 } | 83 } |
80 | 84 |
81 pkgresult = exec_script(pkg_config_script, args, "value") | 85 pkgresult = exec_script(pkg_config_script, args, "value") |
82 include_dirs = pkgresult[0] | 86 include_dirs = pkgresult[0] |
83 cflags = pkgresult[1] | 87 cflags = pkgresult[1] |
84 | 88 |
85 if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { | 89 if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { |
86 libs = pkgresult[2] | 90 libs = pkgresult[2] |
87 lib_dirs = pkgresult[3] | 91 lib_dirs = pkgresult[3] |
88 ldflags = pkgresult[4] | 92 ldflags = pkgresult[4] |
89 } | 93 } |
90 | 94 |
91 forward_variables_from(invoker, | 95 forward_variables_from(invoker, |
92 [ | 96 [ |
93 "defines", | 97 "defines", |
94 "visibility", | 98 "visibility", |
95 ]) | 99 ]) |
96 } | 100 } |
97 } | 101 } |
OLD | NEW |