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

Side by Side Diff: printing/cups_config_helper.py

Issue 1554383002: Fix failure in printing/BUILD.gn when not using a sysroot. Without this change, gn gen fails with "… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update usage string Created 4 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """cups-config wrapper. 6 """cups-config wrapper.
7 7
8 cups-config, at least on Ubuntu Lucid and Natty, dumps all 8 cups-config, at least on Ubuntu Lucid and Natty, dumps all
9 cflags/ldflags/libs when passed the --libs argument. gyp would like 9 cflags/ldflags/libs when passed the --libs argument. gyp would like
10 to keep these separate: cflags are only needed when compiling files 10 to keep these separate: cflags are only needed when compiling files
11 that use cups directly, while libs are only needed on the final link 11 that use cups directly, while libs are only needed on the final link
12 line. 12 line.
13 13
14 This can be dramatically simplified or maybe removed (depending on GN 14 This can be dramatically simplified or maybe removed (depending on GN
15 requirements) when this is fixed: 15 requirements) when this is fixed:
16 https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/163704 16 https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/163704
17 is fixed. 17 is fixed.
18 """ 18 """
19 19
20 import os 20 import os
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 23
24 def usage(): 24 def usage():
25 print 'usage: %s {--api-version|--cflags|--ldflags|--libs|--libs-for-gn}' % \ 25 print ('usage: %s {--api-version|--cflags|--ldflags|--libs|--libs-for-gn} '
26 sys.argv[0] 26 '[sysroot]' % sys.argv[0])
27 27
28 28
29 def run_cups_config(cups_config, mode): 29 def run_cups_config(cups_config, mode):
30 """Run cups-config with all --cflags etc modes, parse out the mode we want, 30 """Run cups-config with all --cflags etc modes, parse out the mode we want,
31 and return those flags as a list.""" 31 and return those flags as a list."""
32 32
33 cups = subprocess.Popen([cups_config, '--cflags', '--ldflags', '--libs'], 33 cups = subprocess.Popen([cups_config, '--cflags', '--ldflags', '--libs'],
34 stdout=subprocess.PIPE) 34 stdout=subprocess.PIPE)
35 flags = cups.communicate()[0].strip() 35 flags = cups.communicate()[0].strip()
36 36
(...skipping 19 matching lines...) Expand all
56 56
57 return flags_subset 57 return flags_subset
58 58
59 59
60 def main(): 60 def main():
61 if len(sys.argv) < 2: 61 if len(sys.argv) < 2:
62 usage() 62 usage()
63 return 1 63 return 1
64 64
65 mode = sys.argv[1] 65 mode = sys.argv[1]
66 if len(sys.argv) > 2: 66 if len(sys.argv) > 2 and sys.argv[2]:
67 sysroot = sys.argv[2] 67 sysroot = sys.argv[2]
68 cups_config = os.path.join(sysroot, 'usr', 'bin', 'cups-config') 68 cups_config = os.path.join(sysroot, 'usr', 'bin', 'cups-config')
69 if not os.path.exists(cups_config): 69 if not os.path.exists(cups_config):
70 print 'cups-config not found: %s' % cups_config 70 print 'cups-config not found: %s' % cups_config
71 return 1 71 return 1
72 else: 72 else:
73 cups_config = 'cups-config' 73 cups_config = 'cups-config'
74 74
75 if mode == '--api-version': 75 if mode == '--api-version':
76 subprocess.call([cups_config, '--api-version']) 76 subprocess.call([cups_config, '--api-version'])
(...skipping 20 matching lines...) Expand all
97 print '"%s", ' % lib[2:] 97 print '"%s", ' % lib[2:]
98 print ']' 98 print ']'
99 else: 99 else:
100 print ' '.join(flags) 100 print ' '.join(flags)
101 101
102 return 0 102 return 0
103 103
104 104
105 if __name__ == '__main__': 105 if __name__ == '__main__':
106 sys.exit(main()) 106 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698