diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5d268eb..0205e6ad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -126,6 +126,15 @@ if(WIN32 OR MINGW) "${CMAKE_CURRENT_SOURCE_DIR}/windows.rc.in" "${CMAKE_CURRENT_BINARY_DIR}/windows.rc" ) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/python/adgui.bat.in" + "${CMAKE_CURRENT_BINARY_DIR}/avrdude-gui.bat" + ) +else() + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/python/adgui.sh.in" + "${CMAKE_CURRENT_BINARY_DIR}/avrdude-gui" + ) endif() add_custom_command( @@ -384,3 +393,17 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.conf" TYPE SYSCONF) install(FILES "avrdude.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" ) + +if(HAVE_SWIG) + execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" + OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) + install(TARGETS swig_avrdude DESTINATION ${PYTHON_SITE_PACKAGES}) + install(FILES ${CMAKE_BINARY_DIR}/src/swig_avrdude.py DESTINATION ${PYTHON_SITE_PACKAGES}) + install(DIRECTORY python/ DESTINATION ${CMAKE_INSTALL_DATADIR}/avrdude FILES_MATCHING PATTERN "*.ui") + install(DIRECTORY python/ DESTINATION ${CMAKE_INSTALL_DATADIR}/avrdude FILES_MATCHING PATTERN "*.py") + if(WIN32 OR MINGW) + install(PROGRAMS ${CMAKE_BINARY_DIR}/src/avrdude-gui.bat TYPE BIN) + else() + install(PROGRAMS ${CMAKE_BINARY_DIR}/src/avrdude-gui TYPE BIN) + endif() +endif() diff --git a/src/python/adgui.bat.in b/src/python/adgui.bat.in new file mode 100644 index 00000000..f7f44dbe --- /dev/null +++ b/src/python/adgui.bat.in @@ -0,0 +1 @@ +"@Python3_EXECUTABLE@" "@CMAKE_INSTALL_PREFIX@\@CMAKE_INSTALL_DATADIR@\avrdude\adgui.py" diff --git a/src/python/adgui.py b/src/python/adgui.py index 251cf2b8..50384895 100755 --- a/src/python/adgui.py +++ b/src/python/adgui.py @@ -42,7 +42,8 @@ elif os.name == 'nt': break if builddir == None: - print("Cannot determine build directory, module loading might fail.", file=sys.stderr) + #print("Cannot determine build directory, module loading might fail.", file=sys.stderr) + pass else: sys.path.append(builddir) sys.path.append(builddir + '/python') diff --git a/src/python/adgui.sh.in b/src/python/adgui.sh.in new file mode 100644 index 00000000..4a56dfc9 --- /dev/null +++ b/src/python/adgui.sh.in @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ ! -d "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/avrdude" ] ; then + echo "Installation directory @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/avrdude missing" >&2 + exit 1 +fi + +if [ ! -f "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/avrdude/adgui.py" ] ; then + echo "Program file @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/avrdude/adgui.py missing" >&2 + exit 1 +fi + +if [ ! -x "@Python3_EXECUTABLE@" ] ; then + echo "Python interpreter @Python3_EXECUTABLE@ missing" >&2 + exit 1 +fi + +exec "@Python3_EXECUTABLE@" "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/avrdude/adgui.py"