diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f727ed2..ec5d3c90 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,7 @@ env: jobs: linux-x86_64: + if: ${{ false }} runs-on: ubuntu-latest defaults: run: @@ -185,6 +186,7 @@ jobs: !**/*.o msvc: + if: ${{ false }} runs-on: windows-latest defaults: run: @@ -274,19 +276,33 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./src/doc + working-directory: ./src steps: - uses: actions/checkout@v2 - name: Install prerequisites - run: sudo apt-get install -y texlive texi2html + run: >- + sudo apt-get install -y + build-essential + cmake + flex + bison + libelf-dev + libusb-dev + libusb-1.0-0-dev + libhidapi-dev + libftdi1-dev + libreadline-dev + texlive + texi2html - name: Configure run: >- cmake + -D BUILD_DOC=1 -D DEBUG_CMAKE=1 -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -B ../../cmake_build + -B ../cmake_build - name: Build - run: cmake --build ../../cmake_build + run: cmake --build ../cmake_build - name: Archive build artifacts if: always() uses: actions/upload-artifact@v2 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e9bd6c14..7110fc9e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -639,6 +639,14 @@ add_executable(avrdude target_link_libraries(avrdude PUBLIC libavrdude) +# ===================================== +# Documentation +# ===================================== + +if(BUILD_DOC) + add_subdirectory(doc) +endif() + # ===================================== # Install # ===================================== diff --git a/src/doc/CMakeLists.txt b/src/doc/CMakeLists.txt new file mode 100644 index 00000000..1291fa4c --- /dev/null +++ b/src/doc/CMakeLists.txt @@ -0,0 +1,140 @@ +# +# 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 . +# + +cmake_minimum_required(VERSION 3.12) + +# TODO: Fix path to binaries +set(AVRDUDE_EXE "${PROJECT_BINARY_DIR}/avrdude") +set(AVRDUDE_CONF "${PROJECT_BINARY_DIR}/avrdude.conf") + +set(TEXINFOS "${CMAKE_CURRENT_SOURCE_DIR}/avrdude.texi") +set(GENERATED_TEXINFOS + version.texi + programmers.texi + programmer_types.texi + parts.texi) + +string(TIMESTAMP TODAY "%d %B %Y") + +set(DOCS_VERSION "${PROJECT_VERSION}") +set(DOCS_UPDATED ${TODAY}) + +# ===================================== +# Find executables +# ===================================== + +find_program(AWK_EXECUTABLE NAMES gawk awk REQUIRED) +find_program(SED_EXECUTABLE NAMES sed REQUIRED) +find_program(MAKEINFO_EXECUTABLE NAMES makeinfo REQUIRED) +find_program(TEXI2DVI_EXECUTABLE NAMES texi2dvi REQUIRED) +find_program(TEXI2HTML_EXECUTABLE NAMES texi2html REQUIRED) +find_program(DVIPS_EXECUTABLE NAMES dvips REQUIRED) + +# ===================================== +# Custom rules +# ===================================== + +# TODO: Use CMake REGEX for awk/sed magic + +add_custom_command( + OUTPUT programmers.texi + DEPENDS avrdude + COMMAND ${AVRDUDE_EXE} -C ${AVRDUDE_CONF} -c ? 2>&1 + | ${AWK_EXECUTABLE} "$2 ~ /^=$$/ {printf(\"@item @code{%s} @tab %s\\n\",$1,gensub(\"[^=]+=[ \t]*\",\"\",1))}" + | ${SED_EXECUTABLE} "s# *,\\? *<\\?\\(http[s]\\?://[^ \\t>]*\\)>\\?#,@*\\n@url{\\1}#g" + > programmers.texi + VERBATIM + ) + +add_custom_command( + OUTPUT programmer_types.texi + DEPENDS avrdude + COMMAND ${AVRDUDE_EXE} -C ${AVRDUDE_CONF} -c ?type 2>&1 + | ${AWK_EXECUTABLE} "$2 ~ /^=$$/ {printf(\"@item @code{%s} @tab %s\\n\",$1,gensub(\"[^=]+=[ \t]*\",\"\",1))}" + | ${SED_EXECUTABLE} "s#<\\?\\(http[s]\\?://[^ \\t,>]*\\)>\\?#@url{\\1}#g" + > programmer_types.texi + VERBATIM + ) + +add_custom_command( + OUTPUT parts.texi + DEPENDS avrdude + COMMAND ${AVRDUDE_EXE} -C ${AVRDUDE_CONF} -p ? 2>&1 + | ${AWK_EXECUTABLE} "$2 ~ /^=$$/ {printf(\"@item @code{%s} @tab %s\\n\",$1,gensub(\"[^=]+=[ \t]*\",\"\",1))}" + # | ${SED_EXECUTABLE} -e "\`sed \"s:\\([^ \\t]*\\)[ \\t]*\\(.*\\):s/\\1$/\\1 \\2/g:g\" parts.texi + 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 + ) + +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 ${TEXI2DVI_EXECUTABLE} --tidy -q -o avrdude.dvi ${TEXINFOS} + DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS} + VERBATIM + ) + +add_custom_command( + OUTPUT avrdude.ps + COMMAND ${DVIPS_EXECUTABLE} -q -o avrdude.ps avrdude.dvi + DEPENDS avrdude.dvi + VERBATIM + ) + +add_custom_command( + OUTPUT avrdude.pdf + COMMAND ${TEXI2DVI_EXECUTABLE} --pdf --batch --tidy -q -o avrdude.pdf ${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} + VERBATIM + ) + +# ===================================== +# Targets +# ===================================== + +add_custom_target(info ALL DEPENDS avrdude.info) +add_custom_target(dvi ALL DEPENDS avrdude.dvi) +add_custom_target(ps ALL DEPENDS avrdude.ps) +add_custom_target(pdf ALL DEPENDS avrdude.pdf) +add_custom_target(html ALL DEPENDS avrdude-html/avrdude.html)