Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/em-config.py
6173 views
1
#!/usr/bin/env python3
2
# Copyright 2012 The Emscripten Authors. All rights reserved.
3
# Emscripten is available under two separate licenses, the MIT license and the
4
# University of Illinois/NCSA Open Source License. Both these licenses can be
5
# found in the LICENSE file.
6
7
"""This is a helper tool which is designed to make it possible
8
for other apps to read emscripten's configuration variables
9
in a unified way. Usage:
10
11
em-config VAR_NAME
12
13
This tool prints the value of the variable to stdout if one
14
is found, or exits with 1 if the variable does not exist.
15
"""
16
17
import re
18
import sys
19
20
from tools import config
21
22
23
def main():
24
if len(sys.argv) != 2 or \
25
not re.match(r"^[\w\W_][\w\W_\d]*$", sys.argv[1]) or \
26
not hasattr(config, sys.argv[1]):
27
print('Usage: em-config VAR_NAME', file=sys.stderr)
28
sys.exit(1)
29
30
print(getattr(config, sys.argv[1]))
31
return 0
32
33
34
if __name__ == '__main__':
35
sys.exit(main())
36
37