forked from pocketpy/pocketpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmake_build.py
42 lines (33 loc) · 1.09 KB
/
cmake_build.py
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
import os
import sys
import shutil
assert os.system("python prebuild.py") == 0
if not os.path.exists("build"):
os.mkdir("build")
# python cmake_build.py [Debug|Release|RelWithDebInfo] ...
if len(sys.argv) > 1:
config = sys.argv[1]
else:
config = 'Release'
extra_flags = " ".join(sys.argv[2:])
assert config in ['Debug', 'Release', 'RelWithDebInfo']
os.chdir("build")
code = os.system(f"cmake .. -DPK_ENABLE_OS=ON -DCMAKE_BUILD_TYPE={config} {extra_flags}")
assert code == 0
code = os.system(f"cmake --build . --config {config}")
assert code == 0
if sys.platform == "win32":
shutil.copy(f"{config}/main.exe", "../main.exe")
dll_path = f"{config}/pocketpy.dll"
if os.path.exists(dll_path):
shutil.copy(dll_path, "../pocketpy.dll")
elif sys.platform == "darwin":
shutil.copy("main", "../main")
dll_path = "libpocketpy.dylib"
if os.path.exists(dll_path):
shutil.copy(dll_path, "../libpocketpy.dylib")
else:
shutil.copy("main", "../main")
dll_path = "libpocketpy.so"
if os.path.exists(dll_path):
shutil.copy(dll_path, "../libpocketpy.so")