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

Side by Side Diff: mojo/tools/mopy/gn.py

Issue 1108173002: Roll //build, //native_client, and a few more targets of opportunity. Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Test fix Created 5 years, 7 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 | « mojo/public/tools/BUILD.gn ('k') | mojo/tools/mopy/gn_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 GN-related configuration functions, e.g., to produce a Config object from a GN 6 GN-related configuration functions, e.g., to produce a Config object from a GN
7 args.gn file). 7 args.gn file).
8 """ 8 """
9 9
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 gn_args["dcheck_always_on"] = config.dcheck_always_on 59 gn_args["dcheck_always_on"] = config.dcheck_always_on
60 60
61 gn_args["mojo_use_nacl"] = config.values.get("use_nacl", False) 61 gn_args["mojo_use_nacl"] = config.values.get("use_nacl", False)
62 62
63 gn_args["mojo_use_go"] = config.values.get("mojo_use_go", False) 63 gn_args["mojo_use_go"] = config.values.get("mojo_use_go", False)
64 if gn_args["mojo_use_go"]: 64 if gn_args["mojo_use_go"]:
65 gn_args["go_build_tool"] = config.values.get("go_build_tool") 65 gn_args["go_build_tool"] = config.values.get("go_build_tool")
66 66
67 if config.target_os == Config.OS_ANDROID: 67 if config.target_os == Config.OS_ANDROID:
68 gn_args["os"] = "android" 68 gn_args["target_os"] = "android"
69 elif config.target_os == Config.OS_CHROMEOS: 69 elif config.target_os == Config.OS_CHROMEOS:
70 gn_args["os"] = "chromeos" 70 gn_args["target_os"] = "chromeos"
71 gn_args["use_glib"] = False 71 gn_args["use_glib"] = False
72 gn_args["use_system_harfbuzz"] = False 72 gn_args["use_system_harfbuzz"] = False
73 elif config.target_os == Config.OS_LINUX: 73 elif config.target_os == Config.OS_LINUX:
74 gn_args["use_aura"] = False 74 gn_args["use_aura"] = False
75 gn_args["use_glib"] = False 75 gn_args["use_glib"] = False
76 gn_args["use_system_harfbuzz"] = False 76 gn_args["use_system_harfbuzz"] = False
77 77
78 gn_args["target_cpu"] = config.target_cpu 78 gn_args["target_cpu"] = config.target_cpu
79 79
80 extra_args = config.values.get("gn_args") 80 extra_args = config.values.get("gn_args")
(...skipping 26 matching lines...) Expand all
107 config_args["sanitizer"] = ( 107 config_args["sanitizer"] = (
108 Config.SANITIZER_ASAN if args.get("is_asan") else None) 108 Config.SANITIZER_ASAN if args.get("is_asan") else None)
109 config_args["is_clang"] = args.get("is_clang", False) 109 config_args["is_clang"] = args.get("is_clang", False)
110 config_args["use_goma"] = args.get("use_goma", False) 110 config_args["use_goma"] = args.get("use_goma", False)
111 if config_args["use_goma"]: 111 if config_args["use_goma"]:
112 config_args["goma_dir"] = args.get("goma_dir") 112 config_args["goma_dir"] = args.get("goma_dir")
113 config_args["use_nacl"] = args.get("mojo_use_nacl", False) 113 config_args["use_nacl"] = args.get("mojo_use_nacl", False)
114 config_args["mojo_use_go"] = args.get("mojo_use_go", False) 114 config_args["mojo_use_go"] = args.get("mojo_use_go", False)
115 if config_args["mojo_use_go"]: 115 if config_args["mojo_use_go"]:
116 config_args["go_build_tool"] = args.get("go_build_tool") 116 config_args["go_build_tool"] = args.get("go_build_tool")
117 config_args["target_os"] = args.get("os") 117 config_args["target_os"] = args.get("target_os")
118 config_args["target_cpu"] = args.get("target_cpu") 118 config_args["target_cpu"] = args.get("target_cpu")
119 config_args["dcheck_always_on"] = args.get("dcheck_always_on") 119 config_args["dcheck_always_on"] = args.get("dcheck_always_on")
120 return Config(**config_args) 120 return Config(**config_args)
121 121
122 122
123 def ParseGNConfig(build_dir): 123 def ParseGNConfig(build_dir):
124 """ 124 """
125 Parse the gn config file present in |build_dir|. This function returns a 125 Parse the gn config file present in |build_dir|. This function returns a
126 dictionary with boolean values as boolean. 126 dictionary with boolean values as boolean.
127 """ 127 """
128 TRANSLATIONS = { 128 TRANSLATIONS = {
129 "true": "True", 129 "true": "True",
130 "false": "False", 130 "false": "False",
131 } 131 }
132 gn_file = os.path.join(build_dir, "args.gn") 132 gn_file = os.path.join(build_dir, "args.gn")
133 values = {} 133 values = {}
134 with open(gn_file, "r") as f: 134 with open(gn_file, "r") as f:
135 for line in f.readlines(): 135 for line in f.readlines():
136 line = re.sub("\s*#.*", "", line) 136 line = re.sub("\s*#.*", "", line)
137 result = re.match("^\s*(\w+)\s*=\s*(.*)\s*$", line) 137 result = re.match("^\s*(\w+)\s*=\s*(.*)\s*$", line)
138 if result: 138 if result:
139 key = result.group(1) 139 key = result.group(1)
140 value = result.group(2) 140 value = result.group(2)
141 values[key] = ast.literal_eval(TRANSLATIONS.get(value, value)) 141 values[key] = ast.literal_eval(TRANSLATIONS.get(value, value))
142 return values 142 return values
OLDNEW
« no previous file with comments | « mojo/public/tools/BUILD.gn ('k') | mojo/tools/mopy/gn_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698