Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/emmake.py
6174 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 make for you, setting
8
the environment variables to use emcc and so forth. Usage:
9
10
emmake make [FLAGS]
11
12
Note that if you ran configure with emconfigure, then
13
the environment variables have already been detected
14
and set. This script is useful if you have no configure
15
step, and your Makefile uses the environment vars
16
directly.
17
18
The difference between this and emconfigure is that
19
emconfigure runs compilation into native code, so
20
that configure tests pass. emmake uses Emscripten to
21
generate JavaScript.
22
"""
23
24
import os
25
import shlex
26
import shutil
27
import sys
28
29
from tools import building, utils
30
31
32
#
33
# Main run() function
34
#
35
def run():
36
if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'):
37
print('''\
38
emmake is a helper for make, setting various environment
39
variables so that emcc etc. are used. Typical usage:
40
41
emmake make [FLAGS]
42
43
(but you can run any command instead of make)''', file=sys.stderr)
44
return 1
45
46
args = sys.argv[1:]
47
env = building.get_building_env()
48
49
# On Windows prefer building with mingw32-make instead of make, if it exists.
50
if utils.WINDOWS:
51
if args[0] == 'make':
52
mingw32_make = shutil.which('mingw32-make')
53
if mingw32_make:
54
args[0] = mingw32_make
55
56
# On Windows, run the execution through shell to get PATH expansion and
57
# executable extension lookup, e.g. 'make' will match with
58
# 'make.bat' in PATH.
59
print(f'emmake: "{shlex.join(args)}" in "{os.getcwd()}"', file=sys.stderr)
60
if utils.WINDOWS:
61
return utils.run_process(args, check=False, shell=True, env=env).returncode
62
else:
63
os.environ.update(env)
64
utils.exec(args)
65
66
67
if __name__ == '__main__':
68
sys.exit(run())
69
70