mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
improve cmake_build.py
This commit is contained in:
parent
2c7f0cdd07
commit
e61b5cdc44
@ -61,6 +61,8 @@ else()
|
|||||||
option(PK_BUILD_STATIC_LIB "Build static library" ON)
|
option(PK_BUILD_STATIC_LIB "Build static library" ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(PK_BUILD_STATIC_MAIN "Build static main" OFF)
|
||||||
|
|
||||||
if(PK_BUILD_SHARED_LIB)
|
if(PK_BUILD_SHARED_LIB)
|
||||||
message(">> Building shared library")
|
message(">> Building shared library")
|
||||||
add_library(${PROJECT_NAME} SHARED ${POCKETPY_SRC})
|
add_library(${PROJECT_NAME} SHARED ${POCKETPY_SRC})
|
||||||
@ -68,8 +70,13 @@ elseif(PK_BUILD_STATIC_LIB)
|
|||||||
message(">> Building static library")
|
message(">> Building static library")
|
||||||
add_library(${PROJECT_NAME} STATIC ${POCKETPY_SRC})
|
add_library(${PROJECT_NAME} STATIC ${POCKETPY_SRC})
|
||||||
else()
|
else()
|
||||||
message(">> Building shared library + executable")
|
if(PK_BUILD_STATIC_MAIN)
|
||||||
add_library(${PROJECT_NAME} SHARED ${POCKETPY_SRC})
|
message(">> Building static library + executable")
|
||||||
|
add_library(${PROJECT_NAME} STATIC ${POCKETPY_SRC})
|
||||||
|
else()
|
||||||
|
message(">> Building shared library + executable")
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${POCKETPY_SRC})
|
||||||
|
endif()
|
||||||
add_executable(main src2/main.c)
|
add_executable(main src2/main.c)
|
||||||
target_link_libraries(main ${PROJECT_NAME})
|
target_link_libraries(main ${PROJECT_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
@ -7,28 +7,36 @@ assert os.system("python prebuild.py") == 0
|
|||||||
if not os.path.exists("build"):
|
if not os.path.exists("build"):
|
||||||
os.mkdir("build")
|
os.mkdir("build")
|
||||||
|
|
||||||
assert len(sys.argv) <= 2
|
# python cmake_build.py [Debug|Release|RelWithDebInfo] ...
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) > 1:
|
||||||
config = sys.argv[1]
|
config = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
config = 'Release'
|
config = 'Release'
|
||||||
|
|
||||||
|
extra_flags = " ".join(sys.argv[2:])
|
||||||
|
|
||||||
assert config in ['Debug', 'Release', 'RelWithDebInfo']
|
assert config in ['Debug', 'Release', 'RelWithDebInfo']
|
||||||
|
|
||||||
os.chdir("build")
|
os.chdir("build")
|
||||||
|
|
||||||
code = os.system(f"cmake .. -DPK_ENABLE_OS=ON -DCMAKE_BUILD_TYPE={config}")
|
code = os.system(f"cmake .. -DPK_ENABLE_OS=ON -DCMAKE_BUILD_TYPE={config} {extra_flags}")
|
||||||
assert code == 0
|
assert code == 0
|
||||||
code = os.system(f"cmake --build . --config {config}")
|
code = os.system(f"cmake --build . --config {config}")
|
||||||
assert code == 0
|
assert code == 0
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
shutil.copy(f"{config}/main.exe", "../main.exe")
|
shutil.copy(f"{config}/main.exe", "../main.exe")
|
||||||
shutil.copy(f"{config}/pocketpy.dll", "../pocketpy.dll")
|
dll_path = f"{config}/pocketpy.dll"
|
||||||
|
if os.path.exists(dll_path):
|
||||||
|
shutil.copy(dll_path, "../pocketpy.dll")
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
shutil.copy("main", "../main")
|
shutil.copy("main", "../main")
|
||||||
shutil.copy("libpocketpy.dylib", "../libpocketpy.dylib")
|
dll_path = "libpocketpy.dylib"
|
||||||
|
if os.path.exists(dll_path):
|
||||||
|
shutil.copy(dll_path, "../libpocketpy.dylib")
|
||||||
else:
|
else:
|
||||||
shutil.copy("main", "../main")
|
shutil.copy("main", "../main")
|
||||||
shutil.copy("libpocketpy.so", "../libpocketpy.so")
|
dll_path = "libpocketpy.so"
|
||||||
|
if os.path.exists(dll_path):
|
||||||
|
shutil.copy(dll_path, "../libpocketpy.so")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user