Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/emmake.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 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 shutil
25
import sys
26
from tools import building
27
from tools import shared
28
from tools import utils
29
from subprocess import CalledProcessError
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. 'sdl2-config' will match with
58
# 'sdl2-config.bat' in PATH.
59
print('make: ' + ' '.join(args), file=sys.stderr)
60
try:
61
shared.check_call(args, shell=utils.WINDOWS, env=env)
62
return 0
63
except CalledProcessError as e:
64
return e.returncode
65
66
67
if __name__ == '__main__':
68
sys.exit(run())
69
70