1
0

cmake_build.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import os
  2. import sys
  3. import shutil
  4. assert os.system("python prebuild.py") == 0
  5. if not os.path.exists("build"):
  6. os.mkdir("build")
  7. # python cmake_build.py [Debug|Release|RelWithDebInfo] ...
  8. if len(sys.argv) > 1:
  9. config = sys.argv[1]
  10. else:
  11. config = 'Release'
  12. extra_flags = " ".join(sys.argv[2:])
  13. assert config in ['Debug', 'Release', 'RelWithDebInfo']
  14. os.chdir("build")
  15. code = os.system(f"cmake .. -DPK_ENABLE_MIMALLOC=ON -DCMAKE_BUILD_TYPE={config} {extra_flags}")
  16. assert code == 0
  17. code = os.system(f"cmake --build . --config {config} -j 4")
  18. assert code == 0
  19. if sys.platform == "win32":
  20. shutil.copy(f"{config}/main.exe", "../main.exe")
  21. dll_path = f"{config}/pocketpy.dll"
  22. if os.path.exists(dll_path):
  23. shutil.copy(dll_path, "../pocketpy.dll")
  24. elif sys.platform == "darwin":
  25. shutil.copy("main", "../main")
  26. dll_path = "libpocketpy.dylib"
  27. if os.path.exists(dll_path):
  28. shutil.copy(dll_path, "../libpocketpy.dylib")
  29. else:
  30. shutil.copy("main", "../main")
  31. dll_path = "libpocketpy.so"
  32. if os.path.exists(dll_path):
  33. shutil.copy(dll_path, "../libpocketpy.so")