First attempt of establishing an installation process

It installs the Python and .ui files under datadir/avrdude/
(e.g. /usr/bin/share/avrdude/), and a batch or shell script
to call it as avrdude-gui into the normal bin directory.
This commit is contained in:
Joerg Wunsch
2024-04-07 13:52:55 +02:00
parent 01ed0174d5
commit aab76b9f29
4 changed files with 44 additions and 1 deletions

View File

@@ -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()

1
src/python/adgui.bat.in Normal file
View File

@@ -0,0 +1 @@
"@Python3_EXECUTABLE@" "@CMAKE_INSTALL_PREFIX@\@CMAKE_INSTALL_DATADIR@\avrdude\adgui.py"

View File

@@ -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')

18
src/python/adgui.sh.in Normal file
View File

@@ -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"