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

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

Issue 1348493002: Add fnl build target (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
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
11 import ast 11 import ast
12 import os.path 12 import os.path
13 import re 13 import re
14 14
15 from .config import Config 15 from .config import Config
16 16
17 17
18 def BuildDirectoryForConfig(config, src_root): 18 def BuildDirectoryForConfig(config, src_root):
19 """ 19 """
20 Returns the build directory for the given configuration. 20 Returns the build directory for the given configuration.
21 """ 21 """
22 subdir = "" 22 subdir = ""
23 if config.target_os == Config.OS_ANDROID: 23 if config.target_os == Config.OS_ANDROID:
24 subdir += "android_" 24 subdir += "android_"
25 if config.target_cpu != Config.ARCH_ARM: 25 if config.target_cpu != Config.ARCH_ARM:
26 subdir += config.target_cpu + "_" 26 subdir += config.target_cpu + "_"
27 elif config.target_os == Config.OS_IOS: 27 elif config.target_os == Config.OS_IOS:
28 subdir += "ios_" 28 subdir += "ios_"
29 elif config.target_os == Config.OS_FNL:
viettrungluu 2015/09/15 23:48:23 Do these checks in alphabetical order.
cdotstout 2015/09/16 22:01:00 Done.
30 subdir += "fnl_"
29 if config.is_simulator: 31 if config.is_simulator:
30 subdir += "sim_" 32 subdir += "sim_"
31 if config.is_official_build: 33 if config.is_official_build:
32 subdir += "Official" 34 subdir += "Official"
33 elif config.is_debug: 35 elif config.is_debug:
34 subdir += "Debug" 36 subdir += "Debug"
35 else: 37 else:
36 subdir += "Release" 38 subdir += "Release"
37 if config.sanitizer == Config.SANITIZER_ASAN: 39 if config.sanitizer == Config.SANITIZER_ASAN:
38 subdir += "_asan" 40 subdir += "_asan"
39 if not(config.is_debug) and config.dcheck_always_on: 41 if not(config.is_debug) and config.dcheck_always_on:
40 subdir += "_dcheck" 42 subdir += "_dcheck"
41 return os.path.join(src_root, "out", subdir) 43 return os.path.join(src_root, "out", subdir)
42 44
45 def TargetSysrootForConfig(config, src_root):
viettrungluu 2015/09/15 23:48:23 Needs a docstring.
cdotstout 2015/09/16 22:01:00 Unused, removed.
46 sysroot = ""
47 if config.target_os == Config.OS_FNL:
48 sysroot = os.path.join(src_root, "fnl_buildroot")
49 return sysroot
43 50
44 def GNArgsForConfig(config): 51 def GNArgsForConfig(config):
45 """ 52 """
46 Return the arguments for gn for the given configuration. This function returns 53 Return the arguments for gn for the given configuration. This function returns
47 a dictionary with boolean values as boolean. 54 a dictionary with boolean values as boolean.
48 """ 55 """
49 gn_args = {} 56 gn_args = {}
50 57
51 gn_args["is_debug"] = bool(config.is_debug) 58 gn_args["is_debug"] = bool(config.is_debug)
52 gn_args["is_official_build"] = bool(config.is_official_build) 59 gn_args["is_official_build"] = bool(config.is_official_build)
53 gn_args["is_asan"] = config.sanitizer == Config.SANITIZER_ASAN 60 gn_args["is_asan"] = config.sanitizer == Config.SANITIZER_ASAN
54 61
55 if config.is_clang is not None: 62 if config.is_clang is not None:
56 gn_args["is_clang"] = bool(config.is_clang) 63 gn_args["is_clang"] = bool(config.is_clang)
57 else: 64 else:
58 gn_args["is_clang"] = config.target_os not in (Config.OS_ANDROID, 65 gn_args["is_clang"] = config.target_os not in (Config.OS_ANDROID,
59 Config.OS_WINDOWS) 66 Config.OS_WINDOWS,
67 Config.OS_FNL)
viettrungluu 2015/09/15 23:48:23 Alphabetical order.
cdotstout 2015/09/16 22:01:00 Done.
60 68
61 if config.values.get("use_goma"): 69 if config.values.get("use_goma"):
62 gn_args["use_goma"] = True 70 gn_args["use_goma"] = True
63 gn_args["goma_dir"] = config.values["goma_dir"] 71 gn_args["goma_dir"] = config.values["goma_dir"]
64 else: 72 else:
65 gn_args["use_goma"] = False 73 gn_args["use_goma"] = False
66 74
67 gn_args["dcheck_always_on"] = config.dcheck_always_on 75 gn_args["dcheck_always_on"] = config.dcheck_always_on
68 76
69 if config.target_os == Config.OS_ANDROID: 77 if config.target_os == Config.OS_ANDROID:
70 gn_args["target_os"] = "android" 78 gn_args["target_os"] = "android"
71 elif config.target_os == Config.OS_IOS: 79 elif config.target_os == Config.OS_IOS:
72 gn_args["target_os"] = "ios" 80 gn_args["target_os"] = "ios"
73 gn_args["ios_deployment_target"] = "7.0" 81 gn_args["ios_deployment_target"] = "7.0"
74 gn_args["clang_use_chrome_plugins"] = False 82 gn_args["clang_use_chrome_plugins"] = False
75 if config.is_simulator: 83 if config.is_simulator:
76 gn_args["use_libjpeg_turbo"] = False 84 gn_args["use_libjpeg_turbo"] = False
77 gn_args["use_ios_simulator"] = config.is_simulator 85 gn_args["use_ios_simulator"] = config.is_simulator
78 elif config.target_os == Config.OS_LINUX: 86 elif config.target_os == Config.OS_LINUX:
79 gn_args["use_aura"] = False 87 gn_args["use_aura"] = False
80 gn_args["use_glib"] = False 88 gn_args["use_glib"] = False
81 gn_args["use_system_harfbuzz"] = False 89 gn_args["use_system_harfbuzz"] = False
90 elif config.target_os == Config.OS_FNL:
viettrungluu 2015/09/15 23:48:23 "
cdotstout 2015/09/16 22:01:00 Done.
91 gn_args["target_os"] = "fnl"
92 gn_args["use_aura"] = False
93 gn_args["use_glib"] = False
94 gn_args["use_ozone"] = True
95 gn_args["use_system_harfbuzz"] = False
82 96
83 gn_args["target_cpu"] = config.target_cpu 97 gn_args["target_cpu"] = config.target_cpu
98 gn_args["target_sysroot"] = config.values.get("target_sysroot", "")
84 99
85 if "use_nacl" in config.values: 100 if "use_nacl" in config.values:
86 gn_args["mojo_use_nacl"] = config.values.get("use_nacl", False) 101 gn_args["mojo_use_nacl"] = config.values.get("use_nacl", False)
87 102
88 if "mojo_use_go" in config.values: 103 if "mojo_use_go" in config.values:
89 gn_args["mojo_use_go"] = config.values.get("mojo_use_go", False) 104 gn_args["mojo_use_go"] = config.values.get("mojo_use_go", False)
90 if gn_args["mojo_use_go"]: 105 if gn_args["mojo_use_go"]:
91 gn_args["go_build_tool"] = config.values.get("go_build_tool") 106 gn_args["go_build_tool"] = config.values.get("go_build_tool")
92 107
93 extra_args = config.values.get("gn_args") 108 extra_args = config.values.get("gn_args")
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 if config_args["use_goma"]: 140 if config_args["use_goma"]:
126 config_args["goma_dir"] = args.get("goma_dir") 141 config_args["goma_dir"] = args.get("goma_dir")
127 config_args["use_nacl"] = args.get("mojo_use_nacl", False) 142 config_args["use_nacl"] = args.get("mojo_use_nacl", False)
128 config_args["mojo_use_go"] = args.get("mojo_use_go", False) 143 config_args["mojo_use_go"] = args.get("mojo_use_go", False)
129 if config_args["mojo_use_go"]: 144 if config_args["mojo_use_go"]:
130 config_args["go_build_tool"] = args.get("go_build_tool") 145 config_args["go_build_tool"] = args.get("go_build_tool")
131 config_args["target_os"] = args.get("target_os") 146 config_args["target_os"] = args.get("target_os")
132 config_args["target_cpu"] = args.get("target_cpu") 147 config_args["target_cpu"] = args.get("target_cpu")
133 config_args["dcheck_always_on"] = args.get("dcheck_always_on") 148 config_args["dcheck_always_on"] = args.get("dcheck_always_on")
134 config_args["is_simulator"] = args.get("use_ios_simulator", False) 149 config_args["is_simulator"] = args.get("use_ios_simulator", False)
150 config_args["target_sysroot"] = args.get("target_sysroot")
135 return Config(**config_args) 151 return Config(**config_args)
136 152
137 153
138 def ParseGNConfig(build_dir): 154 def ParseGNConfig(build_dir):
139 """ 155 """
140 Parse the gn config file present in |build_dir|. This function returns a 156 Parse the gn config file present in |build_dir|. This function returns a
141 dictionary with boolean values as boolean. 157 dictionary with boolean values as boolean.
142 """ 158 """
143 TRANSLATIONS = { 159 TRANSLATIONS = {
144 "true": "True", 160 "true": "True",
145 "false": "False", 161 "false": "False",
146 } 162 }
147 gn_file = os.path.join(build_dir, "args.gn") 163 gn_file = os.path.join(build_dir, "args.gn")
148 values = {} 164 values = {}
149 with open(gn_file, "r") as f: 165 with open(gn_file, "r") as f:
150 for line in f.readlines(): 166 for line in f.readlines():
151 line = re.sub("\s*#.*", "", line) 167 line = re.sub("\s*#.*", "", line)
152 result = re.match("^\s*(\w+)\s*=\s*(.*)\s*$", line) 168 result = re.match("^\s*(\w+)\s*=\s*(.*)\s*$", line)
153 if result: 169 if result:
154 key = result.group(1) 170 key = result.group(1)
155 value = result.group(2) 171 value = result.group(2)
156 values[key] = ast.literal_eval(TRANSLATIONS.get(value, value)) 172 values[key] = ast.literal_eval(TRANSLATIONS.get(value, value))
157 return values 173 return values
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698