Creating an empty Python module

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-06-01 13:57:06 +02:00
parent ee0a5374d8
commit d62f7abd95
2 changed files with 18 additions and 3 deletions

View File

@ -48,12 +48,12 @@ foreach (family ${FAMILIES})
aux_source_directory(${family}/ ${ufamily}_FILES)
add_executable(nextpnr-${family} ${COMMON_FILES} ${${ufamily}_FILES})
# TODO: also build an importable Python module
# PYTHON_ADD_MODULE(pynextpnr_${family} ${COMMON_FILES} ${${ufamily}_FILES})
set(family_targets nextpnr-${family})
PYTHON_ADD_MODULE(nextpnrpy_${family} ${COMMON_FILES} ${${ufamily}_FILES})
set(family_targets nextpnr-${family} nextpnrpy_${family})
include(${family}/family.cmake)
foreach (target ${family_targets})
target_include_directories(${target} PRIVATE ${family}/)
target_compile_definitions(${target} PRIVATE ARCH_${ufamily} ARCHNAME="${family}")
target_compile_definitions(${target} PRIVATE ARCH_${ufamily} ARCHNAME=${family})
target_link_libraries(${target} LINK_PUBLIC ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
endforeach (target)
endforeach (family)

15
common/pybindings.cc Normal file
View File

@ -0,0 +1,15 @@
#include "design.h"
#include "chip.h"
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
using namespace boost::python;
#define PASTER(x,y) x ## _ ## y
#define EVALUATOR(x,y) PASTER(x,y)
#define MODULE_NAME EVALUATOR(nextpnrpy, ARCHNAME)
BOOST_PYTHON_MODULE (MODULE_NAME) {
}