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

Side by Side Diff: printing/cups_config_helper.py

Issue 7633022: cups: parse cups-config output to reduce flags spew (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 4 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
« no previous file with comments | « no previous file | printing/printing.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5
6 """cups-config wrapper.
7
8 cups-config, at least on Ubuntu Lucid and Natty, dumps all
9 cflags/ldflags/libs when passed the --libs argument. gyp would like
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
12 line.
13 """
14
15 import subprocess
16 import sys
17
18 def usage():
19 print 'usage: %s {--cflags|--ldflags|--libs}' % sys.argv[0]
20 sys.exit(1)
21
22 def run_cups_config(mode):
23 """Run cups-config with all --cflags etc modes, parse out the mode we want,
24 and return those flags as a list."""
25
26 cups = subprocess.Popen(['cups-config', '--cflags', '--ldflags', '--libs'],
27 stdout=subprocess.PIPE)
28 flags = cups.communicate()[0].strip()
29
30 flags_subset = []
31 for flag in flags.split(' '):
32 flag_mode = None
33 if flag.startswith('-l'):
34 flag_mode = '--libs'
35 elif (flag.startswith('-L') or flag.startswith('-Wl,')):
36 flag_mode = '--ldflags'
37 elif (flag.startswith('-I') or flag.startswith('-D')):
38 flag_mode = '--cflags'
39
40 # Be conservative: for flags where we don't know which mode they
41 # belong in, always include them.
42 if flag_mode is None or flag_mode == mode:
43 flags_subset.append(flag)
44
45 return flags_subset
46
47 if len(sys.argv) != 2:
48 usage()
49
50 mode = sys.argv[1]
51 if mode not in ('--cflags', '--libs', '--ldflags'):
52 usage()
53 flags = run_cups_config(mode)
54 print ' '.join(flags)
OLDNEW
« no previous file with comments | « no previous file | printing/printing.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698