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

Side by Side Diff: components/policy/tools/grd_helper.py

Issue 2509243003: Split off 'Google' category into separate ADMX/ADML files (Closed)
Patch Set: Android build fix Created 4 years 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
OLDNEW
(Empty)
1 #!/usr/bin/env 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 """Helper to extract the output files from a grd file.
7 Usage: Call add_options to add the parser options (see optparser module).
8 Then call get_grd_outputs with the options obtained from parser.parse_args.
9 """
10
11 import os
12 import sys
13
14
15 def add_options(parser):
16 '''Adds options to an option parser that are required for getting grit output
17 files.
18
19 The following options are required:
20 --grit_info: Path to the grit_info.py script.
21 --grd_input: Path to the grd file.
22 --grd_strip_path_prefix: Prefix to be removed from the output paths.
23
24 The following options are optional:
25 -D <define1> ... -D <defineN>: List of grit defines.
26 -E <env1> ... -D <envN>: List of grit build environment variables.
27
28 Args:
29 parser: Option parser (from optparse.OptionParser()).
30 '''
31 parser.add_option("--grit_info", dest="grit_info")
32 parser.add_option("--grd_input", dest="grd_input")
33 parser.add_option("--grd_strip_path_prefix", dest="grd_strip_path_prefix")
34 parser.add_option("-D", action="append", dest="grit_defines", default=[])
35 parser.add_option("-E", action="append", dest="grit_build_env", default=[])
36
37
38 def get_grd_outputs(options):
39 '''Retrieves output files from a grd file. Call |add_options| before invoking
40 the option parser.
41
42 Args:
43 options: Parsed options (first return value from parser.parse_args(...)).
44 '''
45 # Build a list of defines (parsed from -D <define> args).
46 grit_defines = {}
47 for define in options.grit_defines:
48 grit_defines[define] = 1
49
50 # Get the grit outputs.
51 grit_path = os.path.join(os.getcwd(), os.path.dirname(options.grit_info))
52 sys.path.append(grit_path)
53 import grit_info
54 outputs = grit_info.Outputs(options.grd_input, grit_defines,
55 'GRIT_DIR/../gritsettings/resource_ids')
56
57 # Strip the path prefix from the filenames.
58 result = []
59 for item in outputs:
60 assert item.startswith(options.grd_strip_path_prefix)
61 result.append(item[len(options.grd_strip_path_prefix):])
62 return result
OLDNEW
« no previous file with comments | « components/policy/tools/create_google_admx.py ('k') | components/policy/tools/make_policy_zip.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698