(path)
| 170 | |
| 171 | |
| 172 | def generate_config(path): |
| 173 | if os.path.exists(path): |
| 174 | exit_with_error(f'config file already exists: `{path}`') |
| 175 | |
| 176 | # Note: repr is used to ensure the paths are escaped correctly on Windows. |
| 177 | # The full string is replaced so that the template stays valid Python. |
| 178 | |
| 179 | config_data = utils.read_file(path_from_root('tools/config_template.py')) |
| 180 | config_data = config_data.splitlines()[3:] # remove the initial comment |
| 181 | config_data = '\n'.join(config_data) + '\n' |
| 182 | # autodetect some default paths |
| 183 | llvm_root = os.path.dirname(shutil.which('wasm-ld') or '/usr/bin/wasm-ld') |
| 184 | config_data = config_data.replace("'{{{ LLVM_ROOT }}}'", repr(llvm_root)) |
| 185 | |
| 186 | binaryen_root = os.path.dirname(os.path.dirname(shutil.which('wasm-opt') or '/usr/local/bin/wasm-opt')) |
| 187 | config_data = config_data.replace("'{{{ BINARYEN_ROOT }}}'", repr(binaryen_root)) |
| 188 | |
| 189 | node = shutil.which('node') or shutil.which('nodejs') or 'node' |
| 190 | config_data = config_data.replace("'{{{ NODE }}}'", repr(node)) |
| 191 | |
| 192 | # write |
| 193 | utils.write_file(path, config_data) |
| 194 | |
| 195 | print('''\ |
| 196 | An Emscripten settings file has been generated at: |
| 197 | |
| 198 | %s |
| 199 | |
| 200 | It contains our best guesses for the important paths, which are: |
| 201 | |
| 202 | LLVM_ROOT = %s |
| 203 | BINARYEN_ROOT = %s |
| 204 | NODE_JS = %s |
| 205 | |
| 206 | Please edit the file if any of those are incorrect.\ |
| 207 | ''' % (path, llvm_root, binaryen_root, node), file=sys.stderr) |
| 208 | |
| 209 | |
| 210 | def find_config_file(): |
no test coverage detected