|
24 | 24 | DEBUG_VARIABLES = "variables"
|
25 | 25 | DEBUG_INCLUDES = "includes"
|
26 | 26 |
|
| 27 | +def EscapeForCString(string): |
| 28 | + if isinstance(string, str): |
| 29 | + string = string.encode(encoding='utf8') |
| 30 | + |
| 31 | + result = '' |
| 32 | + for char in string: |
| 33 | + if not (32 <= char < 127) or char in (ord('\\'), ord('"')): |
| 34 | + result += '\\%03o' % char |
| 35 | + else: |
| 36 | + result += chr(char) |
| 37 | + return result |
27 | 38 |
|
28 | 39 | def DebugOutput(mode, message, *args):
|
29 | 40 | if "all" in gyp.debug or mode in gyp.debug:
|
@@ -106,18 +117,19 @@ def Load(
|
106 | 117 |
|
107 | 118 | output_dir = params["options"].generator_output or params["options"].toplevel_dir
|
108 | 119 | if default_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 |
| - ), |
| 120 | + product_dir_abs = os.path.join( |
| 121 | + output_dir, "out", default_variables.get("build_type", "default") |
114 | 122 | )
|
115 | 123 | else:
|
116 |
| - default_variables.setdefault( |
117 |
| - "PRODUCT_DIR_ABS", |
118 |
| - os.path.join(output_dir, default_variables["CONFIGURATION_NAME"]), |
| 124 | + product_dir_abs = os.path.join( |
| 125 | + output_dir, default_variables["CONFIGURATION_NAME"] |
119 | 126 | )
|
120 | 127 |
|
| 128 | + default_variables.setdefault("PRODUCT_DIR_ABS", product_dir_abs) |
| 129 | + default_variables.setdefault( |
| 130 | + "PRODUCT_DIR_ABS_CSTR", EscapeForCString(product_dir_abs) |
| 131 | + ) |
| 132 | + |
121 | 133 | # Give the generator the opportunity to set additional variables based on
|
122 | 134 | # the params it will receive in the output phase.
|
123 | 135 | if getattr(generator, "CalculateVariables", None):
|
|
0 commit comments