Add JavaScript platform support (emcc, wasm).
Includes update to `README.md` with instructions on how to build a GDNative library for webassembly.
This commit is contained in:
32
SConstruct
32
SConstruct
@@ -86,7 +86,7 @@ opts.Add(EnumVariable(
|
||||
'platform',
|
||||
'Target platform',
|
||||
host_platform,
|
||||
allowed_values=('linux', 'freebsd', 'osx', 'windows', 'android', 'ios'),
|
||||
allowed_values=('linux', 'freebsd', 'osx', 'windows', 'android', 'ios', 'javascript'),
|
||||
ignorecase=2
|
||||
))
|
||||
opts.Add(EnumVariable(
|
||||
@@ -375,6 +375,34 @@ elif env['platform'] == 'android':
|
||||
env.Append(CCFLAGS=['--target=' + arch_info['target'] + env['android_api_level'], '-march=' + arch_info['march'], '-fPIC'])#, '-fPIE', '-fno-addrsig', '-Oz'])
|
||||
env.Append(CCFLAGS=arch_info['ccflags'])
|
||||
|
||||
elif env["platform"] == "javascript":
|
||||
env["ENV"] = os.environ
|
||||
env["CC"] = "emcc"
|
||||
env["CXX"] = "em++"
|
||||
env["AR"] = "emar"
|
||||
env["RANLIB"] = "emranlib"
|
||||
env.Append(CPPFLAGS=["-s", "SIDE_MODULE=1"])
|
||||
env.Append(LINKFLAGS=["-s", "SIDE_MODULE=1"])
|
||||
env["SHOBJSUFFIX"] = ".bc"
|
||||
env["SHLIBSUFFIX"] = ".wasm"
|
||||
# Use TempFileMunge since some AR invocations are too long for cmd.exe.
|
||||
# Use POSIX-style paths, required with TempFileMunge.
|
||||
env["ARCOM_POSIX"] = env["ARCOM"].replace("$TARGET", "$TARGET.posix").replace("$SOURCES", "$SOURCES.posix")
|
||||
env["ARCOM"] = "${TEMPFILE(ARCOM_POSIX)}"
|
||||
|
||||
# All intermediate files are just LLVM bitcode.
|
||||
env["OBJPREFIX"] = ""
|
||||
env["OBJSUFFIX"] = ".bc"
|
||||
env["PROGPREFIX"] = ""
|
||||
# Program() output consists of multiple files, so specify suffixes manually at builder.
|
||||
env["PROGSUFFIX"] = ""
|
||||
env["LIBPREFIX"] = "lib"
|
||||
env["LIBSUFFIX"] = ".bc"
|
||||
env["LIBPREFIXES"] = ["$LIBPREFIX"]
|
||||
env["LIBSUFFIXES"] = ["$LIBSUFFIX"]
|
||||
env.Replace(SHLINKFLAGS='$LINKFLAGS')
|
||||
env.Replace(SHLINKFLAGS='$LINKFLAGS')
|
||||
|
||||
env.Append(CPPPATH=[
|
||||
'.',
|
||||
env['headers_dir'],
|
||||
@@ -413,6 +441,8 @@ if env['platform'] == 'android':
|
||||
arch_suffix = env['android_arch']
|
||||
if env['platform'] == 'ios':
|
||||
arch_suffix = env['ios_arch']
|
||||
if env['platform'] == 'javascript':
|
||||
arch_suffix = 'wasm'
|
||||
|
||||
library = env.StaticLibrary(
|
||||
target='bin/' + 'libgodot-cpp.{}.{}.{}{}'.format(
|
||||
|
||||
Reference in New Issue
Block a user