From 4964b050de4c79b4a67d776f23c64c2065ce5442 Mon Sep 17 00:00:00 2001 From: Catherine Date: Thu, 31 Aug 2023 17:52:05 +0000 Subject: [PATCH] himbaechel/gowin: recognize -DAPYCULA_INSTALL_PREFIX=.../virtualenv. This option can be empty, in which case the virtualenv is left exactly as it was in the build environment. --- himbaechel/uarch/gowin/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/himbaechel/uarch/gowin/CMakeLists.txt b/himbaechel/uarch/gowin/CMakeLists.txt index f8786626ee..dc1250ce9e 100644 --- a/himbaechel/uarch/gowin/CMakeLists.txt +++ b/himbaechel/uarch/gowin/CMakeLists.txt @@ -11,6 +11,19 @@ if(HIMBAECHEL_GOWIN_DEVICES STREQUAL "all") endif() message(STATUS "Enabled Himbaechel-Gowin devices: ${HIMBAECHEL_GOWIN_DEVICES}") +if(DEFINED ENV{APYCULA_INSTALL_PREFIX}) + set(apycula_default_install_prefix $ENV{APYCULA_INSTALL_PREFIX}) +endif() +set(APYCULA_INSTALL_PREFIX ${apycula_default_install_prefix} CACHE STRING + "Apycula install prefix (virtualenv directory)") +if(NOT APYCULA_INSTALL_PREFIX STREQUAL "") + message(STATUS "Apycula install prefix: ${APYCULA_INSTALL_PREFIX}") + set(apycula_Python3_EXECUTABLE ${APYCULA_INSTALL_PREFIX}/bin/python) +else() + message(STATUS "Apycula install prefix: (using system Python)") + set(apycula_Python3_EXECUTABLE ${Python3_EXECUTABLE}) +endif() + set(chipdb_binaries) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chipdb) foreach(device ${HIMBAECHEL_GOWIN_DEVICES}) @@ -22,7 +35,7 @@ foreach(device ${HIMBAECHEL_GOWIN_DEVICES}) set(device_bin chipdb/chipdb-${device}.bin) add_custom_command( OUTPUT ${device_bin} - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gowin_arch_gen.py -d ${device} -o ${device_bba} + COMMAND ${apycula_Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gowin_arch_gen.py -d ${device} -o ${device_bba} COMMAND bbasm ${BBASM_ENDIAN_FLAG} ${device_bba} ${device_bin}.new # atomically update COMMAND ${CMAKE_COMMAND} -E rename ${device_bin}.new ${device_bin}