Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/em-config.py
4091 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 sys
18
import re
19
from tools import config
20
21
22
def main():
23
if len(sys.argv) != 2 or \
24
not re.match(r"^[\w\W_][\w\W_\d]*$", sys.argv[1]) or \
25
not hasattr(config, sys.argv[1]):
26
print('Usage: em-config VAR_NAME', file=sys.stderr)
27
sys.exit(1)
28
29
print(getattr(config, sys.argv[1]))
30
return 0
31
32
33
if __name__ == '__main__':
34
sys.exit(main())
35
36