This repository has been archived by the owner on Dec 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathSCsub
92 lines (72 loc) · 2.87 KB
/
SCsub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Import('env')
Import('env_lua')
import sys
import os
import platform
def run(cmd):
print("Running: %s" % cmd)
res = os.system(cmd)
code = 0
if (os.name == 'nt'):
code = res
else:
code = os.WEXITSTATUS(res)
if code != 0:
print("Error: return code: " + str(code))
sys.exit(code)
def build_luajit():
if not env_lua.msvc:
os.chdir("luaJIT")
# cross compile linux->windows
if env['PLATFORM'] == 'posix' and env['platform'] == 'windows':
run("make clean")
run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static" TARGET_SYS=Windows' % (env['luaapi_host_cc'], env['CC'].replace("-gcc", "-").replace("-clang", "-")))
elif env['platform']=='macos':
run("make clean MACOSX_DEPLOYMENT_TARGET=10.12")
run('make CC="%s" TARGET_FLAGS="-arch %s" MACOSX_DEPLOYMENT_TARGET=10.12' % (env['CC'], env['arch']))
elif env['platform']=='linuxbsd':
host_arch = platform.machine()
run("make clean")
if (host_arch != env['arch']):
if (host_arch == 'x86_64' and env['arch'] == 'x86_32'):
host_cc = env['luaapi_host_cc'] + ' -m32'
run('make HOST_CC="%s" CROSS="%s" BUILDMODE="static"' % (host_cc, env['CC'].replace("-gcc", "-").replace("-clang", "-")))
else:
print("ERROR: Unsupported cross compile!")
sys.exit(-1)
else:
run('make CC="%s" BUILDMODE="static"' % env['CC'])
else:
print("ERROR: Unsupported platform '%s'." % env['platform'])
sys.exit(-1)
else:
os.chdir("luaJIT/src")
run("msvcbuild static")
env_lua = env_lua.Clone()
luaver = env["luaapi_luaver"]
if luaver == "jit":
if env["luaapi_luajit_build"]:
build_luajit()
if env_lua.msvc:
# hack for msvc builds. See https://github.com/godotengine/godot/issues/23687
env.Append(LIBS=[File('luaJIT/src/luajit.lib')])
env.Append(LIBS=[File('luaJIT/src/lua51.lib')])
else:
env.Append(LIBPATH=[Dir("luaJIT/src").abspath])
env.Append(LIBS=['libluajit'])
elif luaver == "5.1":
env_lua.Append(CPPDEFINES='MAKE_LIB')
if env['PLATFORM'] == 'posix' and env['platform'] == 'linuxbsd':
env_lua.Append(CPPDEFINES='LUA_USE_POSIX')
if not env_lua.msvc:
env_lua['CFLAGS'].remove('-std=gnu11')
env_lua.Append(CFLAGS=['-std=c99'])
env_lua.add_source_files(env.modules_sources,'lua/*.c')
else:
env_lua.Append(CPPDEFINES='MAKE_LIB')
if env['PLATFORM'] == 'posix' and env['platform'] == 'linuxbsd':
env_lua.Append(CPPDEFINES='LUA_USE_POSIX')
if not env_lua.msvc:
env_lua['CFLAGS'].remove('-std=gnu11')
env_lua.Append(CFLAGS=['-std=c99'])
env_lua.add_source_files(env.modules_sources,'lua/onelua.c')