Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/emconfigure.py
6168 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 os
20
import shlex
21
import sys
22
23
from tools import building, shared
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 than `emconfigure` for cmake projects', file=sys.stderr)
44
return 1
45
46
env = building.get_building_env()
47
env['EMMAKEN_JUST_CONFIGURE'] = '1'
48
print(f'emconfigure: {shlex.join(args)} in directory {os.getcwd()}', file=sys.stderr)
49
os.environ.update(env)
50
shared.exec_process(args)
51
52
53
if __name__ == '__main__':
54
sys.exit(run())
55
56