Skip to content

Commit 737e340

Browse files
committed
Merge branch 'next_release'
2 parents 9ef5278 + 483c014 commit 737e340

File tree

833 files changed

+4376
-186704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

833 files changed

+4376
-186704
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
2929
## Establish project
3030

3131
set(ANARI_SDK_VERSION_MAJOR 0)
32-
set(ANARI_SDK_VERSION_MINOR 14)
33-
set(ANARI_SDK_VERSION_PATCH 1)
32+
set(ANARI_SDK_VERSION_MINOR 15)
33+
set(ANARI_SDK_VERSION_PATCH 0)
3434
set(ANARI_SDK_VERSION
3535
${ANARI_SDK_VERSION_MAJOR}.${ANARI_SDK_VERSION_MINOR}.${ANARI_SDK_VERSION_PATCH}
3636
)

code_gen/CMakeLists.txt

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if (INSTALL_CODE_GEN_SCRIPTS)
1010
COMPONENT code_gen
1111
FILES_MATCHING
1212
PATTERN *.py
13+
PATTERN *.py.in
1314
PATTERN *.h
1415
PATTERN *.cpp
1516
PATTERN *.json
@@ -33,6 +34,10 @@ endif()
3334
option(INSTALL_PYTHON_BINDINGS "Install python bindings" OFF) # If turned on, draws in all the custom targets below (generate_all)
3435
cmake_dependent_option(LINK_BINDINGS_TO_RELEASE_PYTHON "Force the python bindings to implicitly link to a release python library on Windows, overriding possible debug python linking" OFF INSTALL_PYTHON_BINDINGS OFF)
3536

37+
option(INSTALL_LEGACY_PYTHON_BINDINGS "Install legacy python bindings" OFF) # If turned on, draws in all the custom targets below (generate_all)
38+
cmake_dependent_option(LINK_BINDINGS_TO_RELEASE_PYTHON "Force the python bindings to implicitly link to a release python library on Windows, overriding possible debug python linking" OFF INSTALL_LEGACY_PYTHON_BINDINGS OFF)
39+
40+
3641
set(API_JSON api/anari_core_1_0.json api/khr_frame_completion_callback.json)
3742

3843
add_custom_target(generate_type_utility
@@ -132,11 +137,72 @@ add_custom_target(python_bindings ${BUILD_PYTHON_BINDINGS_BY_DEFAULT}
132137
DEPENDS pyanari
133138
)
134139

135-
if (INSTALL_PYTHON_BINDINGS)
140+
if (INSTALL_LEGACY_PYTHON_BINDINGS)
136141
install(
137142
FILES ${CMAKE_CURRENT_BINARY_DIR}/anari.py
138143
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python_bindings)
139144
install(TARGETS pyanari
140145
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/python_bindings
141146
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/python_bindings)
142147
endif()
148+
149+
# New bindings
150+
151+
# Generate the C file using the Python script
152+
add_custom_command(
153+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/anari_api_bindings.c ${CMAKE_CURRENT_BINARY_DIR}/utils.py
154+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cffi_gen.py
155+
-d ${CMAKE_CURRENT_SOURCE_DIR}/devices/generic_device.json
156+
-j ${CMAKE_CURRENT_SOURCE_DIR}/api/
157+
-n anari_api
158+
-O ${CMAKE_CURRENT_BINARY_DIR}
159+
${LINK_BINDINGS_TO_RELEASE_PYTHON_FLAG}
160+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
161+
DEPENDS cffi_gen.py ${API_JSON} devices/generic_device.json
162+
COMMENT "Generating Python bindings C file"
163+
)
164+
165+
# Create the Python extension module
166+
add_library(anari_api MODULE EXCLUDE_FROM_ALL
167+
${CMAKE_CURRENT_BINARY_DIR}/anari_api_bindings.c
168+
)
169+
170+
# Set the output name to match Python's expectations
171+
if (WIN32)
172+
set(PYTHON_OBJ_EXT .pyd)
173+
else()
174+
set(PYTHON_OBJ_EXT .so)
175+
endif()
176+
set_target_properties(anari_api
177+
PROPERTIES
178+
PREFIX ""
179+
SUFFIX ${PYTHON_OBJ_EXT}
180+
)
181+
182+
# Force cffi to keep the python api as usual
183+
target_compile_definitions(anari_api PRIVATE
184+
_CFFI_NO_LIMITED_API
185+
)
186+
187+
# Link against Python libraries and anari
188+
target_link_libraries(anari_api PRIVATE Python3::Module anari_static)
189+
190+
set(ANARI_MODULE_NAME anari_api)
191+
configure_file(${ANARI_CODE_GEN_ROOT}/__init__.py.in ${CMAKE_CURRENT_BINARY_DIR}/__init__.py)
192+
193+
# Add the custom target for Python bindings
194+
add_custom_target(neo_bindings ${BUILD_PYTHON_BINDINGS_BY_DEFAULT}
195+
DEPENDS anari_api
196+
)
197+
198+
install(
199+
FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/utils.py
200+
EXCLUDE_FROM_ALL
201+
COMPONENT python_module
202+
DESTINATION anari)
203+
install(
204+
TARGETS anari_api
205+
EXCLUDE_FROM_ALL
206+
COMPONENT python_module
207+
LIBRARY DESTINATION anari
208+
RUNTIME DESTINATION anari)

0 commit comments

Comments
 (0)