Makefile: extract script to generate gitweb.js

Similar to the preceding commit, also extract the script to generate the "gitweb.js" file. While the logic itself is trivial, it helps us avoid duplication of logic across build systems and ensures that the build systems will remain in sync with each other in case the logic ever needs to change. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Dec 6, 2024 at 14:24 UTC 19d8fe7da650970e5c18681f98d258fd924ecf9b
2 files changed +14 -1
gitweb/Makefile
+2 -1
@@ -115,9 +115,10 @@ $(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl
115 $(MAK_DIR_GITWEB)generate-gitweb-cgi.sh $(MAK_DIR_GITWEB)/GITWEB-BUILD-OPTIONS ./GIT-VERSION-FILE $< $@+ && \
116 mv $@+ $@
117
118 +$(MAK_DIR_GITWEB)static/gitweb.js: $(MAK_DIR_GITWEB)generate-gitweb-js.sh
119 $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))
120 $(QUIET_GEN)$(RM) $@ $@+ && \
120 - cat $^ >$@+ && \
121 + $(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $^ && \
122 mv $@+ $@
123
124 ### Installation rules
gitweb/generate-gitweb-js.sh new
+12
@@ -0,0 +1,12 @@
1 +#!/bin/sh
2 +
3 +if test "$#" -lt 2
4 +then
5 + echo >&2 "USAGE: $0 <OUTPUT> <INPUT>..."
6 + exit 1
7 +fi
8 +
9 +OUTPUT="$1"
10 +shift
11 +
12 +cat "$@" >"$OUTPUT"