2020-11-05 12:55:55 +08:00
|
|
|
include(AddMLIRPythonExtension)
|
2020-11-06 04:01:32 +08:00
|
|
|
add_custom_target(MLIRBindingsPythonExtension)
|
2020-10-10 06:50:07 +08:00
|
|
|
################################################################################
|
|
|
|
# Copy python source tree.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
set(PY_SRC_FILES
|
|
|
|
mlir/__init__.py
|
2020-10-22 14:34:01 +08:00
|
|
|
mlir/ir.py
|
|
|
|
mlir/dialects/__init__.py
|
2020-10-10 06:50:07 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(MLIRBindingsPythonSources ALL
|
|
|
|
DEPENDS ${PY_SRC_FILES}
|
|
|
|
)
|
2020-11-06 04:01:32 +08:00
|
|
|
add_dependencies(MLIRBindingsPythonExtension MLIRBindingsPythonSources)
|
2020-10-10 06:50:07 +08:00
|
|
|
|
2020-11-10 00:29:21 +08:00
|
|
|
add_dependencies(MLIRBindingsPythonExtension MLIRBindingsPythonIncGen)
|
|
|
|
|
2020-10-10 06:50:07 +08:00
|
|
|
foreach(PY_SRC_FILE ${PY_SRC_FILES})
|
|
|
|
set(PY_DEST_FILE "${PROJECT_BINARY_DIR}/python/${PY_SRC_FILE}")
|
|
|
|
add_custom_command(
|
|
|
|
TARGET MLIRBindingsPythonSources PRE_BUILD
|
|
|
|
COMMENT "Copying python source ${PY_SRC_FILE} -> ${PY_DEST_FILE}"
|
|
|
|
DEPENDS "${PY_SRC_FILE}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${PY_SRC_FILE}" "${PY_DEST_FILE}"
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
################################################################################
|
2020-11-05 12:55:55 +08:00
|
|
|
# Build core python extension
|
2020-10-10 06:50:07 +08:00
|
|
|
################################################################################
|
2020-11-06 04:01:32 +08:00
|
|
|
add_mlir_python_extension(MLIRCoreBindingsPythonExtension _mlir
|
2020-11-05 12:55:55 +08:00
|
|
|
INSTALL_DIR
|
|
|
|
python
|
|
|
|
SOURCES
|
|
|
|
MainModule.cpp
|
|
|
|
IRModules.cpp
|
|
|
|
PybindUtils.cpp
|
2020-10-10 06:50:07 +08:00
|
|
|
)
|
2020-11-06 04:01:32 +08:00
|
|
|
add_dependencies(MLIRBindingsPythonExtension MLIRCoreBindingsPythonExtension)
|
2020-10-10 06:50:07 +08:00
|
|
|
|
|
|
|
# Note that we copy from the source tree just like for headers because
|
|
|
|
# it will not be polluted with py_cache runtime artifacts (from testing and
|
|
|
|
# such).
|
|
|
|
install(
|
|
|
|
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mlir
|
|
|
|
DESTINATION python
|
|
|
|
COMPONENT MLIRBindingsPythonSources
|
|
|
|
FILES_MATCHING PATTERN "*.py"
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LLVM_ENABLE_IDE)
|
|
|
|
add_llvm_install_targets(
|
|
|
|
install-MLIRBindingsPythonSources
|
|
|
|
DEPENDS MLIRBindingsPythonSources
|
|
|
|
COMPONENT MLIRBindingsPythonSources)
|
|
|
|
endif()
|