pocketpy/build.py
BLUELOVETH d4696d6931 bug workaround on MacOS
Number::stoi may raise std::out_of_range but it cannot be caught via catch(std::exception&). We use catch(...) for now. Note that catch(...) may catch pkpy::Exception or any others.
2023-07-03 15:02:58 +08:00

28 lines
766 B
Python

import os
import sys
import shutil
assert __name__ == "__main__"
os.system("python3 prebuild.py")
src_file_list = []
for file in os.listdir("src"):
if file.endswith(".cpp"):
src_file_list.append("src/" + file)
main_src_arg = " ".join(src_file_list+["src2/main.cpp"])
print(main_src_arg)
linux_common = " -Wfatal-errors --std=c++17 -O1 -Wall -fno-rtti -stdlib=libc++ -Iinclude/ "
linux_cmd = "clang++ -o pocketpy " + main_src_arg + linux_common
if "web" in sys.argv:
os.system(r'''
rm -rf web/lib/
mkdir -p web/lib/
em++ ''' + main_src_arg + '''-Iinclude/ -fno-rtti -fexceptions -O3 -sEXPORTED_FUNCTIONS=_pkpy_new_repl,_pkpy_repl_input,_pkpy_new_vm -sEXPORTED_RUNTIME_METHODS=ccall -o web/lib/pocketpy.js
''')
else:
os.system(linux_cmd)