| OLD | NEW | 
|    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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   87   gn_args["target_cpu"] = config.target_cpu |   87   gn_args["target_cpu"] = config.target_cpu | 
|   88  |   88  | 
|   89   if "use_nacl" in config.values: |   89   if "use_nacl" in config.values: | 
|   90     gn_args["mojo_use_nacl"] = config.values.get("use_nacl", False) |   90     gn_args["mojo_use_nacl"] = config.values.get("use_nacl", False) | 
|   91  |   91  | 
|   92   if "mojo_use_go" in config.values: |   92   if "mojo_use_go" in config.values: | 
|   93     gn_args["mojo_use_go"] = config.values.get("mojo_use_go", False) |   93     gn_args["mojo_use_go"] = config.values.get("mojo_use_go", False) | 
|   94     if gn_args["mojo_use_go"]: |   94     if gn_args["mojo_use_go"]: | 
|   95       gn_args["go_build_tool"] = config.values.get("go_build_tool") |   95       gn_args["go_build_tool"] = config.values.get("go_build_tool") | 
|   96  |   96  | 
 |   97   gn_args["dart_boringssl_path"] = config.values.get("boringssl_path", "") | 
 |   98  | 
|   97   extra_args = config.values.get("gn_args") |   99   extra_args = config.values.get("gn_args") | 
|   98   if extra_args: |  100   if extra_args: | 
|   99     for arg in extra_args.split(): |  101     for arg in extra_args.split(): | 
|  100       (name, val) = arg.split('=') |  102       (name, val) = arg.split('=') | 
|  101       gn_args[name] = val |  103       gn_args[name] = val | 
|  102  |  104  | 
|  103   return gn_args |  105   return gn_args | 
|  104  |  106  | 
|  105  |  107  | 
|  106 def CommandLineForGNArgs(gn_args): |  108 def CommandLineForGNArgs(gn_args): | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|  133   if config_args["mojo_use_go"]: |  135   if config_args["mojo_use_go"]: | 
|  134     config_args["go_build_tool"] = args.get("go_build_tool") |  136     config_args["go_build_tool"] = args.get("go_build_tool") | 
|  135   config_args["target_os"] = args.get("target_os") |  137   config_args["target_os"] = args.get("target_os") | 
|  136   config_args["target_cpu"] = args.get("target_cpu") |  138   config_args["target_cpu"] = args.get("target_cpu") | 
|  137   config_args["dcheck_always_on"] = args.get("dcheck_always_on") |  139   config_args["dcheck_always_on"] = args.get("dcheck_always_on") | 
|  138   config_args["is_simulator"] = args.get("use_ios_simulator", False) |  140   config_args["is_simulator"] = args.get("use_ios_simulator", False) | 
|  139   if "target_sysroot" in args: |  141   if "target_sysroot" in args: | 
|  140     config_args["target_sysroot"] = args.get("target_sysroot") |  142     config_args["target_sysroot"] = args.get("target_sysroot") | 
|  141   if "toolchain_prefix" in args: |  143   if "toolchain_prefix" in args: | 
|  142     config_args["toolchain_prefix"] = args.get("toolchain_prefix") |  144     config_args["toolchain_prefix"] = args.get("toolchain_prefix") | 
 |  145   config_args["boringssl_path"] = args.get("dart_boringssl_path") | 
|  143   return Config(**config_args) |  146   return Config(**config_args) | 
|  144  |  147  | 
|  145  |  148  | 
|  146 def ParseGNConfig(build_dir): |  149 def ParseGNConfig(build_dir): | 
|  147   """ |  150   """ | 
|  148   Parse the gn config file present in |build_dir|. This function returns a |  151   Parse the gn config file present in |build_dir|. This function returns a | 
|  149   dictionary with boolean values as boolean. |  152   dictionary with boolean values as boolean. | 
|  150   """ |  153   """ | 
|  151   TRANSLATIONS = { |  154   TRANSLATIONS = { | 
|  152       "true": "True", |  155       "true": "True", | 
|  153       "false": "False", |  156       "false": "False", | 
|  154   } |  157   } | 
|  155   gn_file = os.path.join(build_dir, "args.gn") |  158   gn_file = os.path.join(build_dir, "args.gn") | 
|  156   values = {} |  159   values = {} | 
|  157   with open(gn_file, "r") as f: |  160   with open(gn_file, "r") as f: | 
|  158     for line in f.readlines(): |  161     for line in f.readlines(): | 
|  159       line = re.sub("\s*#.*", "", line) |  162       line = re.sub("\s*#.*", "", line) | 
|  160       result = re.match("^\s*(\w+)\s*=\s*(.*)\s*$", line) |  163       result = re.match("^\s*(\w+)\s*=\s*(.*)\s*$", line) | 
|  161       if result: |  164       if result: | 
|  162         key = result.group(1) |  165         key = result.group(1) | 
|  163         value = result.group(2) |  166         value = result.group(2) | 
|  164         values[key] = ast.literal_eval(TRANSLATIONS.get(value, value)) |  167         values[key] = ast.literal_eval(TRANSLATIONS.get(value, value)) | 
|  165   return values |  168   return values | 
| OLD | NEW |