Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/emconfigure.py
4091 views
1
#!/usr/bin/env python3
2
# Copyright 2016 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 script. It runs ./configure (or cmake,
8
etc.) for you, setting the environment variables to use
9
emcc and so forth. Usage:
10
11
emconfigure ./configure [FLAGS]
12
13
You can also use this for cmake and other configure-like
14
stages. What happens is that all compilations done during
15
this command are to native code, not JS, so that configure
16
tests will work properly.
17
"""
18
19
import shlex
20
import sys
21
from tools import building
22
from tools import shared
23
from subprocess import CalledProcessError
24
25
26
#
27
# Main run() function
28
#
29
def run():
30
if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'):
31
print('''\
32
emconfigure is a helper for configure, setting various environment
33
variables so that emcc etc. are used. Typical usage:
34
35
emconfigure ./configure [FLAGS]
36
37
(but you can run any command instead of configure)''', file=sys.stderr)
38
return 1
39
40
args = sys.argv[1:]
41
42
if 'cmake' in args:
43
print('error: use `emcmake` rather then `emconfigure` for cmake projects', file=sys.stderr)
44
return 1
45
46
env = building.get_building_env()
47
# When we configure via a ./configure script, don't do config-time
48
# compilation with emcc, but instead do builds natively with Clang. This
49
# is a heuristic emulation that may or may not work.
50
env['EMMAKEN_JUST_CONFIGURE'] = '1'
51
print(f'configure: {shlex.join(args)}', file=sys.stderr)
52
try:
53
shared.check_call(args, env=env)
54
return 0
55
except CalledProcessError as e:
56
return e.returncode
57
58
59
if __name__ == '__main__':
60
sys.exit(run())
61
62