Skip to content

Commit

Permalink
Merge pull request #2315 from blueloveTH/main
Browse files Browse the repository at this point in the history
Upgrade Python language bindings to `v1.2.x`
  • Loading branch information
nesbox authored Oct 8, 2023
2 parents e80febc + 60f4734 commit 6d6f8ae
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 332 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ jobs:
runs-on: windows-2019

steps:
# https://github.com/actions/runner-images/issues/2642#issuecomment-774988591
- name: configure Pagefile
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"

- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.opendb
*.suo
compile_commands.json
compile_flags.txt
sexit
.vscode/
build/install_manifest.txt
Expand Down
39 changes: 12 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,39 +397,24 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/squirrel)
target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib)

################################
# PocketPy (Python)
# pocketpy (Python)
################################

set(POCKETPY_DIR ${THIRDPARTY_DIR}/pocketpy)
add_subdirectory(${THIRDPARTY_DIR}/pocketpy)
target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0)
include_directories(${THIRDPARTY_DIR}/pocketpy/include)

if (${CMAKE_VERSION} VERSION_LESS "3.12.0")
set(Python3_EXECUTABLE "python3")
else()
find_package(Python3 COMPONENTS Interpreter)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(pocketpy PRIVATE -Wno-psabi)
endif()

add_custom_command(
OUTPUT ${POCKETPY_DIR}/src/_generated.h
COMMAND ${Python3_EXECUTABLE} preprocess.py
WORKING_DIRECTORY ${POCKETPY_DIR}
DEPENDS ${POCKETPY_DIR}/preprocess.py
)

add_library(python STATIC
${POCKETPY_DIR}/src/_generated.h
${POCKETPY_DIR}/c_bindings/pocketpy_c.cpp
)

set_target_properties(python PROPERTIES LINKER_LANGUAGE CXX)
target_compile_definitions(python PRIVATE PK_ENABLE_OS=0)
target_include_directories(python
PRIVATE ${POCKETPY_DIR}/src
PUBLIC ${POCKETPY_DIR}/c_bindings)
# alias pocketpy to python for next steps
set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python)
add_library(python ALIAS pocketpy)

if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
set_target_properties(python PROPERTIES COMPILE_FLAGS "--std=c++17")
else()
target_compile_features(python PRIVATE cxx_std_17)
if(EMSCRIPTEN)
# exceptions must be enabled for emscripten
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fexceptions")
endif()

################################
Expand Down
Loading

0 comments on commit 6d6f8ae

Please sign in to comment.