meso-web

Sources of the |Méso|Star> website
git clone git://git.meso-star.fr/meso-web.git
Log | Files | Refs | README | LICENSE

commit cd44bb1804693b1e9f7e1253f75e68bd781d743d
parent 9341b3f1f4fd7c3ceef1fa0e11854fc2d76e4c17
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 25 Aug 2025 11:55:41 +0200

Make hook execution a prerequisite for HTML content

Force the generation of HTML content for sections when executing one of
its hooks, as dynamically generated HTML content can then be updated.

Note that this new prerequisite applies to all HTML, whereas it could be
limited to dynamically generated HTML only. Modify this rule as soon as
it becomes a performance issue.

Diffstat:
Mhooks.sh | 28++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/hooks.sh b/hooks.sh @@ -15,12 +15,36 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +. "./meso-web.sh" + set -e + # Print on standard output the Makefile targets used to automate hook # management -sh ./list.sh hook | while read -r i; do +html="$(sh ./list.sh html)" +hook="$(sh ./list.sh hook)" + +sections | while read -r i; do + html_section="$(printf '%s\n' "${html}" \ + | sed -n "/^${i}\//p" | tr '\n' ' ')" + hook_section="$(printf '%s\n' "${hook}" \ + | sed -n "/^${i}\//p" | tr '\n' ' ' \ + | sed -e 's/\.sh[[:space:]]/.hook /g')" + + # Define Makefile target that makes section hooks prerequisites for + # the HTML content of the section. + # + # It is the files generated by each of the hooks that are + # prerequisites for the HTML files, not the scripts of the hooks + # themselves, because even if the scripts have not changed, their + # output may have been updated, which can impact the HTML content + # generated at build time. + printf '%s: %s\n' "${html_section}" "${hook_section}" +done + +printf '%s\n' "${hook}" | while read -r i; do # Divide the path into two parts: # - the top-level directory, i.e. the section # - the shell script to be executed from the section directory @@ -56,7 +80,7 @@ sh ./list.sh hook | while read -r i; do printf '%s: %s %s\n' "${tgt}" "${i}" "${dep}" printf " @( cd -- %s && \$(SHELL) %s ) > \$@\n" \ "${section}" "${hook}" - printf 'build__: %s\n' "${tgt}" # + printf 'build__: %s\n' "${tgt}" # Set the target for cleaning files generated by executing the hook. # Run it on "distclean" and not on "clean", as their generation can be