Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: build/linux/pkg-config-wrapper

Issue 5105005: Improve pkg-config-wrapper to support ChromiumOS sysroots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add copyright+license notice, add some description Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/linux/rewrite_dirs.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/linux/pkg-config-wrapper
diff --git a/build/linux/pkg-config-wrapper b/build/linux/pkg-config-wrapper
index d94b99747d58f4f0e96cc5e47156ec74611e705a..4b5455b8e9a0522822b6151268d06735c9dbe448 100755
--- a/build/linux/pkg-config-wrapper
+++ b/build/linux/pkg-config-wrapper
@@ -1,16 +1,37 @@
-#!/bin/sh
+#!/bin/bash
+# Copyright (c) 2010 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.
+
+# This program wraps around pkg-config to generate the correct include and
+# library paths when cross-compiling using a sysroot.
+# The assumption is that the sysroot contains the .pc files in usr/lib/pkgconfig
+# and usr/share/pkgconfig (relative to the sysroot) and that they output paths
+# relative to some parent path of the sysroot.
+# This assumption is valid for a range of sysroots, in particular: a
+# LSB-compliant root filesystem mounted at the sysroot, and a board build
+# directory of a Chromium OS chroot.
root="$1"
if [ -z "$root" ]
then
- echo "usage: $0 /path/to/sysroot [pkg-config-arguments]" >&2
+ echo "usage: $0 /path/to/sysroot [pkg-config-arguments] package" >&2
exit 1
fi
rewrite=`dirname $0`/rewrite_dirs.py
+package=${!#}
shift
config_path=$root/usr/lib/pkgconfig:$root/usr/share/pkgconfig
set -e
-result=`PKG_CONFIG_PATH=$config_path pkg-config --define-variable=prefix=/usr "$@"`
-echo "$result"| $rewrite $root
+# Some sysroots, like the Chromium OS ones, may generate paths that are not
+# relative to the sysroot. For example,
+# /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths
+# relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of
+# relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr).
+# To support this correctly, it's necessary to extract the prefix to strip from
+# pkg-config's |prefix| variable.
+prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'`
+result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"`
+echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix"
« no previous file with comments | « no previous file | build/linux/rewrite_dirs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698