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

Side by Side Diff: printing/cups_config_helper.py

Issue 311603003: Add src/printing to the GN build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« build/config/linux/BUILD.gn ('K') | « build/config/linux/BUILD.gn ('k') | 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 TODO(evan): remove me once 14 TODO(evan): remove me once
15 https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/163704 15 https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/163704
Lei Zhang 2014/06/02 22:37:02 I just noticed this too. On my Linux machine, cups
brettw 2014/06/02 22:53:26 I actually need this for GN to get the libs the wa
Lei Zhang 2014/06/02 23:33:27 Ok, I'll make a pass through this file later and c
16 is fixed. 16 is fixed.
17 """ 17 """
18 18
19 import subprocess 19 import subprocess
20 import sys 20 import sys
21 21
22 def usage(): 22 def usage():
23 print 'usage: %s {--cflags|--ldflags|--libs}' % sys.argv[0] 23 print 'usage: %s {--api-version|--cflags|--ldflags|--libs|--libs-for-gn}' % \
24 sys.argv[0]
24 25
25 26
26 def run_cups_config(mode): 27 def run_cups_config(mode):
27 """Run cups-config with all --cflags etc modes, parse out the mode we want, 28 """Run cups-config with all --cflags etc modes, parse out the mode we want,
28 and return those flags as a list.""" 29 and return those flags as a list."""
29 30
30 cups = subprocess.Popen(['cups-config', '--cflags', '--ldflags', '--libs'], 31 cups = subprocess.Popen(['cups-config', '--cflags', '--ldflags', '--libs'],
31 stdout=subprocess.PIPE) 32 stdout=subprocess.PIPE)
32 flags = cups.communicate()[0].strip() 33 flags = cups.communicate()[0].strip()
33 34
(...skipping 19 matching lines...) Expand all
53 54
54 return flags_subset 55 return flags_subset
55 56
56 57
57 def main(): 58 def main():
58 if len(sys.argv) != 2: 59 if len(sys.argv) != 2:
59 usage() 60 usage()
60 return 1 61 return 1
61 62
62 mode = sys.argv[1] 63 mode = sys.argv[1]
63 if mode not in ('--cflags', '--libs', '--ldflags'): 64 if mode == '--api-version':
65 subprocess.call(['cups-config', '--api-version'])
66 return 0
67
68 # All other modes get the flags.
69 if mode not in ('--cflags', '--libs', '--libs-for-gn', '--ldflags'):
64 usage() 70 usage()
65 return 1 71 return 1
72
73 if mode == '--libs-for-gn':
74 gn_libs_output = True
75 mode = '--libs'
76 else:
77 gn_libs_output = False
78
66 flags = run_cups_config(mode) 79 flags = run_cups_config(mode)
67 print ' '.join(flags) 80
81 if gn_libs_output:
82 # Strip "-l" from beginning of libs, quote, and surround in [ ].
83 print '['
Lei Zhang 2014/06/02 23:33:27 We should sanity check and make sure |lib| starts
84 for lib in flags:
85 print '"%s", ' % lib[2:]
86 print ']'
87 else:
88 print ' '.join(flags)
89
68 return 0 90 return 0
69 91
70 92
71 if __name__ == '__main__': 93 if __name__ == '__main__':
72 sys.exit(main()) 94 sys.exit(main())
OLDNEW
« build/config/linux/BUILD.gn ('K') | « build/config/linux/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698