|
4 | 4 | # Use of this source code is governed by a BSD-style license that can be |
5 | 5 | # found in the LICENSE file. |
6 | 6 |
|
7 | | - |
| 7 | +from __future__ importannotations |
8 | 8 | importcopy |
9 | 9 | importgyp.input |
10 | 10 | importargparse |
|
24 | 24 | DEBUG_VARIABLES="variables" |
25 | 25 | DEBUG_INCLUDES="includes" |
26 | 26 |
|
| 27 | +defEscapeForCString(string: bytes|str) ->str: |
| 28 | +ifisinstance(string, str): |
| 29 | +string=string.encode(encoding='utf8') |
| 30 | + |
| 31 | +backslash_or_double_quote= {ord('\\'), ord('"')} |
| 32 | +result= [] |
| 33 | +forcharinstring: |
| 34 | +ifcharinbackslash_or_double_quoteornot32<=char<127: |
| 35 | +result+='\\%03o'%char |
| 36 | +else: |
| 37 | +result+=chr(char) |
| 38 | +returnresult |
27 | 39 |
|
28 | 40 | defDebugOutput(mode, message, *args): |
29 | 41 | if"all"ingyp.debugormodeingyp.debug: |
@@ -106,18 +118,19 @@ def Load( |
106 | 118 |
|
107 | 119 | output_dir=params["options"].generator_outputorparams["options"].toplevel_dir |
108 | 120 | ifdefault_variables["GENERATOR"] =="ninja": |
109 | | -default_variables.setdefault( |
110 | | -"PRODUCT_DIR_ABS", |
111 | | -os.path.join( |
112 | | -output_dir, "out", default_variables.get("build_type", "default") |
113 | | - ), |
| 121 | +product_dir_abs=os.path.join( |
| 122 | +output_dir, "out", default_variables.get("build_type", "default") |
114 | 123 | ) |
115 | 124 | else: |
116 | | -default_variables.setdefault( |
117 | | -"PRODUCT_DIR_ABS", |
118 | | -os.path.join(output_dir, default_variables["CONFIGURATION_NAME"]), |
| 125 | +product_dir_abs=os.path.join( |
| 126 | +output_dir, default_variables["CONFIGURATION_NAME"] |
119 | 127 | ) |
120 | 128 |
|
| 129 | +default_variables.setdefault("PRODUCT_DIR_ABS", product_dir_abs) |
| 130 | +default_variables.setdefault( |
| 131 | +"PRODUCT_DIR_ABS_CSTR", EscapeForCString(product_dir_abs) |
| 132 | + ) |
| 133 | + |
121 | 134 | # Give the generator the opportunity to set additional variables based on |
122 | 135 | # the params it will receive in the output phase. |
123 | 136 | ifgetattr(generator, "CalculateVariables", None): |
@@ -253,7 +266,7 @@ def Noop(value): |
253 | 266 | forname, metadatainoptions._regeneration_metadata.items(): |
254 | 267 | opt=metadata["opt"] |
255 | 268 | value=getattr(options, name) |
256 | | -value_predicate=metadata["type"] =="path"andFixPathorNoop |
| 269 | +value_predicate=(metadata["type"] =="path"andFixPath)orNoop |
257 | 270 | action=metadata["action"] |
258 | 271 | env_name=metadata["env_name"] |
259 | 272 | ifaction=="append": |
|
0 commit comments