Skip to content

Commit

Permalink
Honor 'sysroot' setting when running cups-config
Browse files Browse the repository at this point in the history
This mimic the existing behavior of build/linux/pkg-config-wrapper.

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

Cr-Commit-Position: refs/heads/master@{#331207}
  • Loading branch information
sbc100 authored and Commit bot committed May 22, 2015
1 parent 234a58c commit 05ac52d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions printing/cups_config_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
is fixed.
"""

import os
import subprocess
import sys

Expand All @@ -25,11 +26,11 @@ def usage():
sys.argv[0]


def run_cups_config(mode):
def run_cups_config(cups_config, mode):
"""Run cups-config with all --cflags etc modes, parse out the mode we want,
and return those flags as a list."""

cups = subprocess.Popen(['cups-config', '--cflags', '--ldflags', '--libs'],
cups = subprocess.Popen([cups_config, '--cflags', '--ldflags', '--libs'],
stdout=subprocess.PIPE)
flags = cups.communicate()[0].strip()

Expand Down Expand Up @@ -57,13 +58,22 @@ def run_cups_config(mode):


def main():
if len(sys.argv) != 2:
if len(sys.argv) < 2:
usage()
return 1

mode = sys.argv[1]
if len(sys.argv) > 2:
sysroot = sys.argv[2]
cups_config = os.path.join(sysroot, 'usr', 'bin', 'cups-config')
if not os.path.exists(cups_config):
print 'cups-config not found: %s' % cups_config
return 1
else:
cups_config = 'cups-config'

if mode == '--api-version':
subprocess.call(['cups-config', '--api-version'])
subprocess.call([cups_config, '--api-version'])
return 0

# All other modes get the flags.
Expand All @@ -77,7 +87,7 @@ def main():
else:
gn_libs_output = False

flags = run_cups_config(mode)
flags = run_cups_config(cups_config, mode)

if gn_libs_output:
# Strip "-l" from beginning of libs, quote, and surround in [ ].
Expand Down
4 changes: 2 additions & 2 deletions printing/printing.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@
}, {
'link_settings': {
'libraries': [
'<!@(python cups_config_helper.py --libs)',
'<!@(python cups_config_helper.py --libs <(sysroot))',
],
},
}],
['os_bsd==1', {
'cflags': [
'<!@(python cups_config_helper.py --cflags)',
'<!@(python cups_config_helper.py --cflags <(sysroot))',
],
}],
],
Expand Down

0 comments on commit 05ac52d

Please sign in to comment.