From c633255c011afcadeccc58e53daa696e9509da4e Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Wed, 11 May 2022 23:27:55 +0200 Subject: [PATCH 1/2] CMake: Add initial support for texinfo docs --- .github/workflows/build.yml | 4 + CMakeLists.txt | 4 + src/doc/CMakeLists.txt | 169 +++++++++++++++++++++++++++++++++ src/doc/parts.cmake | 37 ++++++++ src/doc/programmer_types.cmake | 28 ++++++ src/doc/programmers.cmake | 28 ++++++ 6 files changed, 270 insertions(+) create mode 100644 src/doc/CMakeLists.txt create mode 100644 src/doc/parts.cmake create mode 100644 src/doc/programmer_types.cmake create mode 100644 src/doc/programmers.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01a23f7e..dbb7a0cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,9 +47,13 @@ jobs: libusb-1.0-0-dev libhidapi-dev libftdi1-dev + texinfo + texlive + texi2html - name: Configure run: >- cmake + -D BUILD_DOC=1 -D DEBUG_CMAKE=1 -D HAVE_LINUXGPIO=1 -D HAVE_LINUXSPI=1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2840ff78..400da29f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,6 +281,10 @@ endif() add_subdirectory(src) +if(BUILD_DOC) + add_subdirectory(src/doc) +endif() + # ===================================== # Configuration # ===================================== diff --git a/src/doc/CMakeLists.txt b/src/doc/CMakeLists.txt new file mode 100644 index 00000000..e845503c --- /dev/null +++ b/src/doc/CMakeLists.txt @@ -0,0 +1,169 @@ +# +# CMakeLists.txt - CMake project for AVRDUDE documentation +# Copyright (C) 2022 Marius Greuel +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +set(AVRDUDE_CONF "${PROJECT_BINARY_DIR}/src/avrdude.conf") + +set(TEXINFOS "${CMAKE_CURRENT_SOURCE_DIR}/avrdude.texi") +set(GENERATED_TEXINFOS + programmers.texi + programmer_types.texi + parts.texi + version.texi + ) + +string(TIMESTAMP TODAY "%d %B %Y") +set(DOCS_VERSION ${PROJECT_VERSION}) +set(DOCS_UPDATED ${TODAY}) + +find_program(MAKEINFO_EXECUTABLE NAMES makeinfo) +find_program(TEXI2HTML_EXECUTABLE NAMES texi2html) + +# ===================================== +# Custom rules for auto-generated texi +# ===================================== + +add_custom_target(avrdude_binaries DEPENDS avrdude conf) + +add_custom_command( + OUTPUT programmers.txt + DEPENDS avrdude_binaries + COMMAND $ -C ${AVRDUDE_CONF} -c ? 2>&1 | more > programmers.txt + VERBATIM + ) + +add_custom_command( + OUTPUT programmer_types.txt + DEPENDS avrdude_binaries + COMMAND $ -C ${AVRDUDE_CONF} -c ?type 2>&1 | more > programmer_types.txt + VERBATIM + ) + +add_custom_command( + OUTPUT parts.txt + DEPENDS avrdude_binaries + COMMAND $ -C ${AVRDUDE_CONF} -p ? 2>&1 | more > parts.txt + VERBATIM + ) + +add_custom_command( + OUTPUT programmers.texi + DEPENDS programmers.txt + COMMAND ${CMAKE_COMMAND} + -D TXT_FILE=programmers.txt + -D TEXI_FILE=programmers.texi + -P "${CMAKE_CURRENT_SOURCE_DIR}/programmers.cmake" + VERBATIM + ) + +add_custom_command( + OUTPUT programmer_types.texi + DEPENDS programmer_types.txt + COMMAND ${CMAKE_COMMAND} + -D TXT_FILE=programmer_types.txt + -D TEXI_FILE=programmer_types.texi + -P "${CMAKE_CURRENT_SOURCE_DIR}/programmer_types.cmake" + VERBATIM + ) + +add_custom_command( + OUTPUT parts.texi + DEPENDS parts.txt + COMMAND ${CMAKE_COMMAND} + -D TXT_FILE=parts.txt + -D TEXI_FILE=parts.texi + -D COMMENTS_FILE=${CMAKE_CURRENT_SOURCE_DIR}/parts_comments.txt + -P "${CMAKE_CURRENT_SOURCE_DIR}/parts.cmake" + VERBATIM + ) + +add_custom_command( + OUTPUT version.texi + COMMAND ${CMAKE_COMMAND} -E echo "@set EDITION ${DOCS_VERSION}" > version.texi + COMMAND ${CMAKE_COMMAND} -E echo "@set VERSION ${DOCS_VERSION}" >> version.texi + COMMAND ${CMAKE_COMMAND} -E echo "@set UPDATED ${DOCS_UPDATED}" >> version.texi + VERBATIM + ) + +# ===================================== +# Custom rules for output files +# ===================================== + +add_custom_command( + OUTPUT avrdude.info + COMMAND ${MAKEINFO_EXECUTABLE} -o avrdude.info ${TEXINFOS} + DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS} + VERBATIM + ) + +add_custom_command( + OUTPUT avrdude.dvi + COMMAND ${MAKEINFO_EXECUTABLE} + --dvi + --Xopt=--quiet + --Xopt=--build-dir=dvi + -o avrdude.dvi + ${TEXINFOS} + DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS} + VERBATIM + ) + +add_custom_command( + OUTPUT avrdude.pdf + COMMAND ${MAKEINFO_EXECUTABLE} + --pdf + --Xopt=--quiet + --Xopt=--build-dir=pdf + -o avrdude.pdf + ${TEXINFOS} + DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS} + VERBATIM + ) + +add_custom_command( + OUTPUT avrdude.ps + COMMAND ${MAKEINFO_EXECUTABLE} + --ps + --Xopt=--quiet + --Xopt=--build-dir=ps + -o avrdude.ps + ${TEXINFOS} + DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS} + VERBATIM + ) + +add_custom_command( + OUTPUT avrdude-html/avrdude.html + COMMAND ${TEXI2HTML_EXECUTABLE} + --split=node + --css-include=avrdude.css + --output=avrdude-html + -I ${CMAKE_CURRENT_BINARY_DIR} + ${TEXINFOS} + DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS} avrdude.css + VERBATIM + ) + +# ===================================== +# Custom targets for output files +# ===================================== + +add_custom_target(info ALL DEPENDS avrdude.info) +add_custom_target(dvi ALL DEPENDS avrdude.dvi) +add_custom_target(pdf ALL DEPENDS avrdude.pdf) +add_custom_target(ps ALL DEPENDS avrdude.ps) +add_custom_target(html ALL DEPENDS avrdude-html/avrdude.html) diff --git a/src/doc/parts.cmake b/src/doc/parts.cmake new file mode 100644 index 00000000..c305743d --- /dev/null +++ b/src/doc/parts.cmake @@ -0,0 +1,37 @@ +# +# programmers.cmake - create parts.texi from parts.txt +# Copyright (C) 2022 Marius Greuel +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +file(STRINGS ${COMMENTS_FILE} COMMENTS_CONTENTS) + +file(STRINGS ${TXT_FILE} TXT_CONTENTS REGEX "=") + +set(TEXI_CONTENTS "") +foreach(TXT_LINE IN LISTS TXT_CONTENTS) + string(REGEX REPLACE "^[ \t]*([^ \t]+)[ \t]*=[ \t]*(.*)$" "@item @code{\\1} @tab \\2" TEXI_LINE "${TXT_LINE}") + + foreach(COMMENTS_LINE IN LISTS COMMENTS_CONTENTS) + string(REGEX MATCH "^([^ \t]*)(.*)$" DUMMY "${COMMENTS_LINE}") + set(PART_REGEX "${CMAKE_MATCH_1}") + set(COMMENT "${CMAKE_MATCH_2}") + string(REGEX REPLACE "(${PART_REGEX})" "\\1${COMMENT}" TEXI_LINE "${TEXI_LINE}") + endforeach() + + set(TEXI_CONTENTS "${TEXI_CONTENTS}${TEXI_LINE}\n") +endforeach() + +file(WRITE ${TEXI_FILE} "${TEXI_CONTENTS}") diff --git a/src/doc/programmer_types.cmake b/src/doc/programmer_types.cmake new file mode 100644 index 00000000..7e62f611 --- /dev/null +++ b/src/doc/programmer_types.cmake @@ -0,0 +1,28 @@ +# +# programmer_types.cmake - create programmer_types.texi from programmer_types.txt +# Copyright (C) 2022 Marius Greuel +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +file(STRINGS ${TXT_FILE} TXT_CONTENTS REGEX "=") + +SET(TEXI_CONTENTS "") +foreach(TXT_LINE IN LISTS TXT_CONTENTS) + string(REGEX REPLACE "^[ \t]*([^ \t]+)[ \t]*=[ \t]*(.*)$" "@item @code{\\1} @tab \\2" TEXI_LINE "${TXT_LINE}") + string(REGEX REPLACE "]+)>?" "@url{\\1}" TEXI_LINE "${TEXI_LINE}") + set(TEXI_CONTENTS "${TEXI_CONTENTS}${TEXI_LINE}\n") +endforeach() + +file(WRITE ${TEXI_FILE} "${TEXI_CONTENTS}") diff --git a/src/doc/programmers.cmake b/src/doc/programmers.cmake new file mode 100644 index 00000000..b8611c0f --- /dev/null +++ b/src/doc/programmers.cmake @@ -0,0 +1,28 @@ +# +# programmers.cmake - create programmers.texi from programmers.txt +# Copyright (C) 2022 Marius Greuel +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +file(STRINGS ${TXT_FILE} TXT_CONTENTS REGEX "=") + +SET(TEXI_CONTENTS "") +foreach(TXT_LINE IN LISTS TXT_CONTENTS) + string(REGEX REPLACE "^[ \t]*([^ \t]+)[ \t]*=[ \t]*(.*)$" "@item @code{\\1} @tab \\2" TEXI_LINE "${TXT_LINE}") + string(REGEX REPLACE "[ \t>]*,?[ \t>]*]+)>?" ",@*\n@url{\\1}" TEXI_LINE "${TEXI_LINE}") + set(TEXI_CONTENTS "${TEXI_CONTENTS}${TEXI_LINE}\n") +endforeach() + +file(WRITE ${TEXI_FILE} "${TEXI_CONTENTS}") From 8ecae62f4a060e3e7df3f28f8268d7ff871e6400 Mon Sep 17 00:00:00 2001 From: Marius Greuel Date: Sun, 4 Sep 2022 17:48:12 +0200 Subject: [PATCH 2/2] CMake: Add install commands for docs --- src/doc/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/doc/CMakeLists.txt b/src/doc/CMakeLists.txt index e845503c..9c8030c3 100644 --- a/src/doc/CMakeLists.txt +++ b/src/doc/CMakeLists.txt @@ -167,3 +167,13 @@ add_custom_target(dvi ALL DEPENDS avrdude.dvi) add_custom_target(pdf ALL DEPENDS avrdude.pdf) add_custom_target(ps ALL DEPENDS avrdude.ps) add_custom_target(html ALL DEPENDS avrdude-html/avrdude.html) + +# ===================================== +# Install +# ===================================== + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.info" DESTINATION ${CMAKE_INSTALL_INFODIR}) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.dvi" DESTINATION ${CMAKE_INSTALL_DOCDIR}) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.pdf" DESTINATION ${CMAKE_INSTALL_DOCDIR}) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.ps" DESTINATION ${CMAKE_INSTALL_DOCDIR}) +install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/avrdude-html" DESTINATION ${CMAKE_INSTALL_DOCDIR})