Skip to content

Instantly share code, notes, and snippets.

@sonygod
Created December 1, 2022 00:50
Show Gist options
  • Save sonygod/2f51626a24363b23c9eaa6008d216e6f to your computer and use it in GitHub Desktop.
Save sonygod/2f51626a24363b23c9eaa6008d216e6f to your computer and use it in GitHub Desktop.
scons build wasm
'''
Author: sonygod sonygodx@gmail.com
Date: 2022-11-29 14:31:23
LastEditors: sonygod sonygodx@gmail.com
LastEditTime: 2022-11-29 15:07:59
FilePath: \haxec\SConstruct
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
print("... Hello, Scons !")
import os;
env = Environment()
env.Append(CPPPATH = ["./src"]);
env.Append(LINKFLAGS = ['-s', 'EXPORTED_FUNCTIONS=\'["_malloc","_free","_get_minicycles","_is_planar"]\'']);
# -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'
env.Append(LINKFLAGS = ['-s', 'EXPORTED_RUNTIME_METHODS=\'["ccall", "cwrap"]\'']);
#-s ENVIRONMENT=web
env.Append(LINKFLAGS = ['-s', 'ENVIRONMENT=web']);
# -s EXPORT_ES6=1
env.Append(LINKFLAGS = ['-s', 'EXPORT_ES6=1']);
# -s MODULARIZE=1
env.Append(LINKFLAGS = ['-s', 'MODULARIZE=1']);
#-s MALLOC=emmalloc
env.Append(LINKFLAGS = ['-s', 'MALLOC=emmalloc']);
#-s ALLOW_MEMORY_GROWTH
env.Append(LINKFLAGS = ['-s', 'ALLOW_MEMORY_GROWTH']);
env.Append(LINKFLAGS = ['-O3']);
os.environ["EMSCRIPTEN_ROOT"] = "/root/emsdk/upstream/emscripten"
env.Tool("emscripten", toolpath = ["/root/emsdk/upstream/emscripten/tools/scons/site_scons/site_tools/emscripten"])
env.Program(target="bin/LoadWASM", source=["src/Wasm_MiniCycles.cpp"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment