MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / parse_config_file

Function parse_config_file

tools/config.py:80–135  ·  view source on GitHub ↗

Parse the emscripten config file using python's exec. Also check EM_ environment variables to override specific config keys.

()

Source from the content-addressed store, hash-verified

78
79
80def parse_config_file():
81 """Parse the emscripten config file using python's exec.
82
83 Also check EM_<KEY> environment variables to override specific config keys.
84 """
85 config = {'__file__': EM_CONFIG}
86 config_text = utils.read_file(EM_CONFIG)
87 try:
88 exec(config_text, config)
89 except Exception as e:
90 exit_with_error('error in evaluating config file (%s): %s, text: %s', EM_CONFIG, e, config_text)
91
92 CONFIG_KEYS = (
93 'NODE_JS',
94 'BINARYEN_ROOT',
95 'LLVM_ROOT',
96 'LLVM_ADD_VERSION',
97 'CLANG_ADD_VERSION',
98 'CLOSURE_COMPILER',
99 'FROZEN_CACHE',
100 'CACHE',
101 'PORTS',
102 'COMPILER_WRAPPER',
103 )
104
105 if '_EM_TEST_RUNNER' in os.environ:
106 # TODO(sbc): Move this completely out of the core compiler and into the test framework.
107 TEST_KEYS = (
108 'NODE_JS_TEST',
109 'V8_ENGINE',
110 'SPIDERMONKEY_ENGINE',
111 'JS_ENGINES',
112 'WASMER',
113 'WASMTIME',
114 'WASM_ENGINES',
115 )
116 CONFIG_KEYS += TEST_KEYS
117 for key in TEST_KEYS:
118 globals()[key] = None
119
120 # Only propagate certain settings from the config file.
121 for key in CONFIG_KEYS:
122 env_var = 'EM_' + key
123 env_value = os.environ.get(env_var)
124 if env_value is not None:
125 if env_value in {'', '0'}:
126 env_value = None
127 # Unlike the other keys these two should always be lists.
128 if env_var in {'EM_JS_ENGINES', 'EM_WASM_ENGINES'}:
129 env_value = env_value.split(',')
130 if env_var in {'EM_CONFIG', 'EM_CACHE', 'EM_PORTS', 'EM_LLVM_ROOT', 'EM_BINARYEN_ROOT'}:
131 if not os.path.isabs(env_value):
132 exit_with_error(f'environment variable {env_var} must be an absolute path: {env_value}')
133 globals()[key] = env_value
134 elif key in config:
135 globals()[key] = config[key]
136
137

Callers 1

read_configFunction · 0.85

Calls 4

execFunction · 0.85
exit_with_errorFunction · 0.85
splitMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected