Gitweb: add support for minifying gitweb.css
PATCH v5 2/6 Gitweb: add support for minifying gitweb.css
The build system added support minifying gitweb.js through a JavaScript minifier, but most minifiers come with support to minify CSS files as well, so we should use it if we can.
This patch will add the same facilities to gitweb.css that gitweb.js has for minification. That does not mean that they will use the same minifier though, as it is not safe to assume that all JavaScript minifiers will also minify CSS files.
Though the bandwidth savings will not be as dramatic as with the JavaScript minifier, every byte saved is important.
---
Changes since v4:
- Reworded some of the comments and documentation
Makefile | 21 +++++++++++++++------ gitweb/INSTALL | 5 +++++ gitweb/Makefile | 28 +++++++++++++++++++++------- gitweb/README | 3 ++- 4 files changed, 43 insertions(+), 14 deletions(-)
Makefile +15 -6
@@ -203,6 +203,9 @@ all:: # Define JSMIN to point to JavaScript minifier that functions as # a filter to have gitweb.js minified. # +# Define CSSMIN to point to a CSS minifier in order to generate a minified +# version of gitweb.css +# # Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if # you want to use something different. The value will be interpreted by the # shell at runtime when it is used.
@@ -279,8 +282,9 @@ lib = lib # DESTDIR= pathsep = : -# JavaScript minifier invocation that can function as filter +# JavaScript/CSS minifier invocation that can function as filter JSMIN = +CSSMIN = export prefix bindir sharedir sysconfdir
@@ -1564,18 +1568,23 @@ gitweb: $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all ifdef JSMIN -OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js -gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js -else -OTHER_PROGRAMS += gitweb/gitweb.cgi -gitweb/gitweb.cgi: gitweb/gitweb.perl +GITWEB_PROGRAMS += gitweb/gitweb.min.js endif +ifdef CSSMIN +GITWEB_PROGRAMS += gitweb/gitweb.min.css +endif +OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS) +gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS) $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) ifdef JSMIN gitweb/gitweb.min.js: gitweb/gitweb.js $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) endif # JSMIN +ifdef CSSMIN +gitweb/gitweb.min.css: gitweb/gitweb.css + $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) +endif # CSSMIN git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
gitweb/INSTALL +5 -0
@@ -66,6 +66,11 @@ file for gitweb (in gitweb/README). build configuration variables. By default gitweb tries to find them in the same directory as gitweb.cgi script. +- You can optionally generate a minified version of gitweb.css by defining + the CSSMIN build configuration variable. By default the non-minified + version of gitweb.css will be used. NOTE: if you enable this option, + substitute gitweb.min.css for all uses of gitweb.css in the help files. + Build example ~~~~~~~~~~~~~
gitweb/Makefile +21 -7
@@ -6,13 +6,17 @@ all:: # Define JSMIN to point to JavaScript minifier that functions as # a filter to have gitweb.js minified. # +# Define CSSMIN to point to a CSS minifier in order to generate a minified +# version of gitweb.css +# prefix ?= $(HOME) bindir ?= $(prefix)/bin RM ?= rm -f -# JavaScript minifier invocation that can function as filter +# JavaScript/CSS minifier invocation that can function as filter JSMIN ?= +CSSMIN ?= # default configuration for gitweb GITWEB_CONFIG = gitweb_config.perl
@@ -26,7 +30,11 @@ GITWEB_STRICT_EXPORT = GITWEB_BASE_URL = GITWEB_LIST = GITWEB_HOMETEXT = indextext.html +ifdef CSSMIN +GITWEB_CSS = gitweb.min.css +else GITWEB_CSS = gitweb.css +endif GITWEB_LOGO = git-logo.png GITWEB_FAVICON = git-favicon.png ifdef JSMIN
@@ -84,13 +92,14 @@ endif all:: gitweb.cgi +FILES = gitweb.cgi ifdef JSMIN -FILES=gitweb.cgi gitweb.min.js -gitweb.cgi: gitweb.perl gitweb.min.js -else # !JSMIN -FILES=gitweb.cgi -gitweb.cgi: gitweb.perl -endif # JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) gitweb.cgi: $(QUIET_GEN)$(RM) $@ $@+ && \
@@ -123,6 +132,11 @@ gitweb.min.js: gitweb.js $(QUIET_GEN)$(JSMIN) <$< >$@ endif # JSMIN +ifdef CSSMIN +gitweb.min.css: gitweb.css + $(QUIET_GEN)$(CSSMIN) <$ >$@ +endif + clean: $(RM) $(FILES)
gitweb/README +2 -1
@@ -80,7 +80,8 @@ You can specify the following configuration variables when building GIT: Points to the location where you put gitweb.css on your web server (or to be more generic, the URI of gitweb stylesheet). Relative to the base URI of gitweb. Note that you can setup multiple stylesheets from - the gitweb config file. [Default: gitweb.css] + the gitweb config file. [Default: gitweb.css (or gitweb.min.css if the + CSSMIN variable is defined / CSS minifier is used)] * GITWEB_LOGO Points to the location where you put git-logo.png on your web server (or to be more generic URI of logo, 72x27 size, displayed in top right
Signature · 1 line
1.7.0.3.519.g7e0613
Quoted 11 lines · Mark Rada
The build system added support minifying gitweb.js through a JavaScript minifier, but most minifiers come with support to minify CSS files as well, so we should use it if we can.
This patch will add the same facilities to gitweb.css that gitweb.js has for minification. That does not mean that they will use the same minifier though, as it is not safe to assume that all JavaScript minifiers will also minify CSS files.
Though the bandwidth savings will not be as dramatic as with the JavaScript minifier, every byte saved is important.
That's not everything this patch does, isn't it? I think you should have added to your commit message the following paragraph:
While at it, introduce GITWEB_PROGRAMS variable to Makefile and use it for gitweb instead of adding to OTHER_PROGRAMS, to keep (possible) gitweb dependencies separate.
Or something like that.
Quoted 2 lines
Signed-off-by Mark Rada <[email protected]>
I think it is good idea.
[...]
Quoted 14 lines
ifdef JSMIN
Makefile +6
-5-OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js -gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js -else -OTHER_PROGRAMS += gitweb/gitweb.cgi -gitweb/gitweb.cgi: gitweb/gitweb.perl +GITWEB_PROGRAMS += gitweb/gitweb.min.js endif +ifdef CSSMIN +GITWEB_PROGRAMS += gitweb/gitweb.min.css +endif +OTHER_PROGRAMS += gitweb/gitweb.cgi $(GITWEB_PROGRAMS) +gitweb/gitweb.cgi: gitweb/gitweb.perl $(GITWEB_PROGRAMS) $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@)
Signature · 2 lines
Jakub Narebski Poland
Quoted 9 lines · Mark Rada
gitweb/Makefile +1
-3@@ -84,13 +92,14 @@ endif all:: gitweb.cgi +FILES = gitweb.cgi ifdef JSMIN -FILES=gitweb.cgi gitweb.min.js -gitweb.cgi: gitweb.perl gitweb.min.js -else # !JSMIN
gitweb/Makefile endif · line 103
Quoted 10 lines
gitweb/Makefile +6
-3-FILES=gitweb.cgi -gitweb.cgi: gitweb.perl -endif # JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
I have a question about this last line of the patch. Are GITWEB_JS and GITWEB_CSS supposed to be a source path or a URI?
The documentation for install (and my previous assumption) was that they represented the path on the target web server. I'm used to overriding them so that gitweb.cgi can live in my /cgi-bin directory, but the static files are served from /gitweb which is readable but not executable.
After this patch I had to removed $(GITWEB_JS) and $(GITWEB_CSS) from the list of dependencies for gitweb.cgi otherwise make failed.
Have I got the wrong end of the stick?
Thanks,
Charles.
Quoted 29 lines · Charles Bailey
Quoted 9 lines · Mark Rada
gitweb/Makefile +1
-3@@ -84,13 +92,14 @@ endif all:: gitweb.cgi +FILES = gitweb.cgi ifdef JSMIN -FILES=gitweb.cgi gitweb.min.js -gitweb.cgi: gitweb.perl gitweb.min.js -else # !JSMINgitweb/Makefile endif · line 103
Quoted 10 lines
gitweb/Makefile +6
-3-FILES=gitweb.cgi -gitweb.cgi: gitweb.perl -endif # JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)I have a question about this last line of the patch. Are
GITWEB_JSandGITWEB_CSSsupposed to be a source path or a URI?The documentation for install (and my previous assumption) was that they represented the path on the target web server. I'm used to overriding them so that gitweb.cgi can live in my /cgi-bin directory, but the static files are served from /gitweb which is readable but not executable.
Quoted 4 lines
After this patch I had to removed $(GITWEB_JS) and $(GITWEB_CSS) from the list of dependencies for gitweb.cgi otherwise make failed.
Have I got the wrong end of the stick?
Thanks a lot for noticing this bug.
GITWEB_JS and GITWEB_CSS were originally meant to be URI to file with gitweb JavaScript code and default gitweb stylesheet,... but during work on minification of JavaScript code and CSS file it somehow got confused to mean source path.
If I remember correctly the original patch, before adding required support for minified gitweb.js and gitweb.css to git-instaweb script, and before support for CSS minification had
ifdef JSMIN
gitweb.cgi: gitweb.perl gitweb.min.js
else
gitweb.cgi: gitweb.perl
endif
which should probably be replaced in current situation by
ifdef JSMIN
gitweb.cgi : gitweb.min.js
endif
ifdef CSSMIN
gitweb.cgi : gitweb.min.css
endif
just adding prerequisites to gitweb.css target in gitweb/Makefile
I guess that support for adding minifiction support to git-instaweb would need to be more complicated. Perhaps
$(notdir $(GITWEB_JS)) # Makefile function
or
$(basename $GITWEB_JS) # shell command
But I guess that it wouldn't work for all cases...
Signature · 2 lines
Jakub Narebski Poland
Quoted 68 lines · Jakub Narebski
Quoted 29 lines · Charles Bailey
Quoted 9 lines · Mark Rada
gitweb/Makefile +1
-3@@ -84,13 +92,14 @@ endif all:: gitweb.cgi +FILES = gitweb.cgi ifdef JSMIN -FILES=gitweb.cgi gitweb.min.js -gitweb.cgi: gitweb.perl gitweb.min.js -else # !JSMINgitweb/Makefile endif · line 103
Quoted 10 lines
gitweb/Makefile +6
-3-FILES=gitweb.cgi -gitweb.cgi: gitweb.perl -endif # JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)I have a question about this last line of the patch. Are
GITWEB_JSandGITWEB_CSSsupposed to be a source path or a URI?The documentation for install (and my previous assumption) was that they represented the path on the target web server. I'm used to overriding them so that gitweb.cgi can live in my /cgi-bin directory, but the static files are served from /gitweb which is readable but not executable.
Quoted 4 lines
After this patch I had to removed $(GITWEB_JS) and $(GITWEB_CSS) from the list of dependencies for gitweb.cgi otherwise make failed.
Have I got the wrong end of the stick?
Thanks a lot for noticing this bug.
GITWEB_JSandGITWEB_CSSwere originally meant to be URI to file with gitweb JavaScript code and default gitweb stylesheet,... but during work on minification of JavaScript code and CSS file it somehow got confused to mean source path.If I remember correctly the original patch, before adding required support for minified gitweb.js and gitweb.css to git-instaweb script, and before support for CSS minification had
ifdef JSMIN
gitweb.cgi: gitweb.perl gitweb.min.js
else
gitweb.cgi: gitweb.perl
endifwhich should probably be replaced in current situation by
ifdef JSMIN
gitweb.cgi : gitweb.min.js
endif
ifdef CSSMIN
gitweb.cgi : gitweb.min.css
endifjust adding prerequisites to gitweb.css target in gitweb/Makefile
I guess that support for adding minifiction support to git-instaweb would need to be more complicated. Perhaps
Quoted 8 lines
$(notdir $(GITWEB_JS)) # Makefile functionor
$(basename $GITWEB_JS) # shell commandBut I guess that it wouldn't work for all cases...
Aw, frig, never thought of using gitweb like that so I made some assumptions to make things cleaner looking.
I think this can be fixed by just using different variable names? Or perhaps some nested ifdef's? I'm not sure which will be better.
I wasn't at the computer today so I'm just getting to it now, I'll try to have something when in the next day, going to bed now. Good night.
Signature · 1 line
Mark Rada
Quoted 3 lines · Mark Rada
Quoted 2 lines · Jakub Narebski
Quoted 1 line · Charles Bailey
On 01/04/2010 06:36, Mark Rada wrote:
[...]
Quoted 49 lines
Quoted 43 lines
Quoted 11 lines
Quoted 2 lines
+gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
I have a question about this last line of the patch. Are
GITWEB_JSandGITWEB_CSSsupposed to be a source path or a URI?The documentation for install (and my previous assumption) was that they represented the path on the target web server. I'm used to overriding them so that gitweb.cgi can live in my /cgi-bin directory, but the static files are served from /gitweb which is readable but not executable.
Quoted 4 lines
After this patch I had to removed $(GITWEB_JS) and $(GITWEB_CSS) from the list of dependencies for gitweb.cgi otherwise make failed.
Have I got the wrong end of the stick?
Thanks a lot for noticing this bug.
GITWEB_JSandGITWEB_CSSwere originally meant to be URI to file with gitweb JavaScript code and default gitweb stylesheet,... but during work on minification of JavaScript code and CSS file it somehow got confused to mean source path.If I remember correctly the original patch, before adding required support for minified gitweb.js and gitweb.css to git-instaweb script, and before support for CSS minification had
ifdef JSMIN
gitweb.cgi: gitweb.perl gitweb.min.js
else
gitweb.cgi: gitweb.perl
endifwhich should probably be replaced in current situation by
ifdef JSMIN
gitweb.cgi : gitweb.min.js
endif
ifdef CSSMIN
gitweb.cgi : gitweb.min.css
endifQuoted 5 lines
just adding prerequisites to gitweb.css target in gitweb/Makefile
I guess that support for adding minifiction support to git-instaweb would need to be more complicated. [...]
Quoted 8 lines
Aw, frig, never thought of using gitweb like that so I made some assumptions to make things cleaner looking.
I think this can be fixed by just using different variable names? Or perhaps some nested ifdef's? I'm not sure which will be better.
I wasn't at the computer today so I'm just getting to it now, I'll try to have something when in the next day, going to bed now. Good night.
I think the best solution for prerequisites would be to have multiple target-only (without commands) rules, which according to make documentation would get concatenated. This means the following code in gitweb/Makefile:
ifdef JSMIN
gitweb.cgi : gitweb.min.js
endif
ifdef CSSMIN
gitweb.cgi : gitweb.min.css
endif
in place of
gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
For git-instaweb I think that best solution would be to introduce new variables holding _source_ of gitweb JavaScript code and CSS, e.g.
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
in place of
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS_SOURCE)' \
...although GITWEB_CSS might mean something different for Makefile and git-instaweb than for gitweb/Makefile and gitweb itself.
Signature · 2 lines
Jakub Narebski Poland
Quoted 76 lines · Jakub Narebski
Quoted 3 lines · Mark Rada
Quoted 2 lines · Jakub Narebski
Quoted 1 line · Charles Bailey
On 01/04/2010 06:36, Mark Rada wrote:
[...]
Quoted 49 lines
Quoted 43 lines
Quoted 11 lines
Quoted 2 lines
+gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
I have a question about this last line of the patch. Are
GITWEB_JSandGITWEB_CSSsupposed to be a source path or a URI?The documentation for install (and my previous assumption) was that they represented the path on the target web server. I'm used to overriding them so that gitweb.cgi can live in my /cgi-bin directory, but the static files are served from /gitweb which is readable but not executable.
Quoted 4 lines
After this patch I had to removed $(GITWEB_JS) and $(GITWEB_CSS) from the list of dependencies for gitweb.cgi otherwise make failed.
Have I got the wrong end of the stick?
Thanks a lot for noticing this bug.
GITWEB_JSandGITWEB_CSSwere originally meant to be URI to file with gitweb JavaScript code and default gitweb stylesheet,... but during work on minification of JavaScript code and CSS file it somehow got confused to mean source path.If I remember correctly the original patch, before adding required support for minified gitweb.js and gitweb.css to git-instaweb script, and before support for CSS minification had
ifdef JSMIN
gitweb.cgi: gitweb.perl gitweb.min.js
else
gitweb.cgi: gitweb.perl
endifwhich should probably be replaced in current situation by
ifdef JSMIN
gitweb.cgi : gitweb.min.js
endif
ifdef CSSMIN
gitweb.cgi : gitweb.min.css
endifQuoted 5 lines
just adding prerequisites to gitweb.css target in gitweb/Makefile
I guess that support for adding minifiction support to git-instaweb would need to be more complicated. [...]
Quoted 8 lines
Aw, frig, never thought of using gitweb like that so I made some assumptions to make things cleaner looking.
I think this can be fixed by just using different variable names? Or perhaps some nested ifdef's? I'm not sure which will be better.
I wasn't at the computer today so I'm just getting to it now, I'll try to have something when in the next day, going to bed now. Good night.
I think the best solution for prerequisites would be to have multiple target-only (without commands) rules, which according to make documentation would get concatenated. This means the following code in gitweb/Makefile:
ifdef JSMIN
gitweb.cgi : gitweb.min.js
endif
ifdef CSSMIN
gitweb.cgi : gitweb.min.css
endif
Quoted 4 lines
in place of
gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
Hmm, I like this because it is clear (if you know that dependancies can be joined like that), I was thinking of trying to make a smaller fix using pathsubst or subst, but that seems to not be as simple as I wanted it to be.
Quoted 11 lines
For git-instaweb I think that best solution would be to introduce new variables holding _source_ of gitweb JavaScript code and CSS, e.g.
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \in place of
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS_SOURCE)' \...although
GITWEB_CSSmight mean something different forMakefileand git-instaweb than for gitweb/Makefile and gitweb itself.
Did you get those lines mixed up? I might be not understanding something here.
I was actually planning something along the lines of
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS_NAME)' \
-e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS_NAME)|' \where I introduce the GITWEB_CSS_NAME variable, to be consistent with the token in instaweb. This way we don't touch GITWEB_JS in the top level makefile.
Also, I should update dependancies for instaweb, since those were forgotten last time around. Just creating a short list of what the fix will need for when I get home tonight.
Signature · 1 line
Mark Rada
Quoted 9 lines · Mark Rada
Quoted 7 lines · Jakub Narebski
For git-instaweb I think that best solution would be to introduce new variables holding _source_ of gitweb JavaScript code and CSS, e.g.
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \in place of
Quoted 7 lines
Quoted 4 lines
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS_SOURCE)' \...although
GITWEB_CSSmight mean something different forMakefileand git-instaweb than for gitweb/Makefile and gitweb itself.Did you get those lines mixed up? I might be not understanding something here.
Ah, I'm sorry, I mixed up those two lines. They should be in reverse direction:
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS_SOURCE)' \
in place of
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
Actually I'd like to rename @@GITWEB_CSS@@ placeholder etc. in git-instaweb.sh, as @@GITWEB_CSS@@ in git-instaweb.sh means something quite different from ++GITWEB_CSS++ in gitweb/gitweb.perl...
Quoted 9 lines
I was actually planning something along the lines of
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS_NAME)' \ -e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS_NAME)|' \where I introduce the
GITWEB_CSS_NAMEvariable, to be consistent with the token in instaweb. This way we don't touchGITWEB_JSin the top level makefile.
Why not:
-e '/@@GITWEB_CSS_SOURCE@@/r $(GITWEB_CSS_SOURCE)' \
-e '/@@GITWEB_CSS_SOURCE@@/d' \
...
-e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \(assuming that $(GITWEB_CSS) does not include '|' in it, I guess... but see below).
Quoted 4 lines
Also, I should update dependancies for instaweb, since those were forgotten last time around. Just creating a short list of what the fix will need for when I get home tonight.
Something like
git-instaweb: git-instaweb.sh gitweb/gitweb.cgi $(GITWEB_CSS_SOURCE) $(GITWEB_JS_SOURCE)
P.S. I have noticed additional complication: git-instaweb really needs gitweb compiled with *specific* values of GITWEB_CSS and GITWEB_JS, so that they point to git-instaweb's installed files.
Signature · 2 lines
Jakub Narebski Poland
Quoted 6 lines · Jakub Narebski
Quoted 5 lines · Charles Bailey
Quoted 4 lines · Mark Rada
(quoted diff) +0
-0@@ -84,13 +92,14 @@ endif all:: gitweb.cgi
Quoted 13 lines
Quoted 8 lines
Review endif · line 102
Quoted 8 lines
(quoted diff) +7
-0+FILES = gitweb.cgi ifdef JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
GITWEB_JSandGITWEB_CSSwere originally meant to be URI to file with gitweb JavaScript code and default gitweb stylesheet,... but during work on minification of JavaScript code and CSS file it somehow got confused to mean source path.
I am not touching instaweb part, but this would fix the build/clean side of the things, no?
-- >8 --
gitweb: simplify gitweb.min.* generation and clean-up rules
GITWEB_CSS and GITWEB_JS are meant to be "what URI should the installed cgi script use to refer to the stylesheet and JavaScript", never "this is the name of the file we are building".
Lose incorrect assignment to them.
While we are at it, lose FILES that is used only for "clean" target in a misguided way. "make clean" should try to remove all the potential build artifacts regardless of a minor configuration change. Instead of trying to remove only the build product "make clean" would have created if it were run without "clean", explicitly list the three potential build products for removal.
--- gitweb/Makefile | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-)
gitweb/Makefile +4 -11
@@ -80,16 +80,7 @@ endif all:: gitweb.cgi -FILES = gitweb.cgi -ifdef JSMIN -FILES += gitweb.min.js -GITWEB_JS = gitweb.min.js -endif -ifdef CSSMIN -FILES += gitweb.min.css -GITWEB_CSS = gitweb.min.css -endif -gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) +gitweb.cgi: gitweb.perl gitweb.cgi: $(QUIET_GEN)$(RM) $@ $@+ && \
@@ -118,16 +109,18 @@ gitweb.cgi: mv $@+ $@ ifdef JSMIN +all:: gitweb.min.js gitweb.min.js: gitweb.js $(QUIET_GEN)$(JSMIN) <$< >$@ endif # JSMIN ifdef CSSMIN +all:: gitweb.min.css gitweb.min.css: gitweb.css $(QUIET_GEN)$(CSSMIN) <$ >$@ endif clean: - $(RM) $(FILES) + $(RM) gitweb.cgi gitweb.min.css gitweb.min.js .PHONY: all clean .FORCE-GIT-VERSION-FILE
Quoted 22 lines · Junio C Hamano
Quoted 6 lines · Jakub Narebski
Quoted 5 lines · Charles Bailey
Quoted 4 lines · Mark Rada
gitweb/Makefile +0
-0@@ -84,13 +92,14 @@ endif all:: gitweb.cgiQuoted 13 lines
Quoted 8 lines
Review endif · line 102
Quoted 8 lines
(quoted diff) +7
-0+FILES = gitweb.cgi ifdef JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
GITWEB_JSandGITWEB_CSSwere originally meant to be URI to file with gitweb JavaScript code and default gitweb stylesheet,... but during work on minification of JavaScript code and CSS file it somehow got confused to mean source path.
Quoted 3 lines
I am not touching instaweb part, but this would fix the build/clean side of the things, no?
Yes, this certainly fixes make and make clean for me with overridden GITWEB_JS and GITWEB_CSS paths.
Charles.
Quoted 21 lines · Junio C Hamano
Quoted 6 lines · Jakub Narebski
Quoted 5 lines · Charles Bailey
Quoted 4 lines · Mark Rada
gitweb/Makefile +0
-0@@ -84,13 +92,14 @@ endif all:: gitweb.cgiQuoted 13 lines
Quoted 8 lines
Review endif · line 102
Quoted 8 lines
(quoted diff) +7
-0+FILES = gitweb.cgi ifdef JSMIN +FILES += gitweb.min.js +endif +ifdef CSSMIN +FILES += gitweb.min.css +endif +gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
GITWEB_JSandGITWEB_CSSwere originally meant to be URI to file with gitweb JavaScript code and default gitweb stylesheet,... but during work on minification of JavaScript code and CSS file it somehow got confused to mean source path.
Quoted 2 lines
I am not touching instaweb part, but this would fix the build/clean side of the things, no?
Close, see below.
Quoted 9 lines
-->8 --
gitweb: simplify gitweb.min.* generation and clean-up rules
GITWEB_CSSandGITWEB_JSare meant to be "what URI should the installed cgi script use to refer to the stylesheet and JavaScript", never "this is the name of the file we are building".Lose incorrect assignment to them.
Actually the assignment was intended to provide correct *default* values for GITWEB_CSS and GITWEB_JS, so that if e.g. JSMIN is defined gitweb, in absence of build time configuration, would link gitweb.min.js instead of gitweb.js.
Quoted 7 lines
While we are at it, lose FILES that is used only for "clean" target in a misguided way. "make clean" should try to remove all the potential build artifacts regardless of a minor configuration change. Instead of trying to remove only the build product "make clean" would have created if it were run without "clean", explicitly list the three potential build products for removal.
Good.
Quoted 13 lines
Signed-off-by Junio C Hamano <[email protected]>--- gitweb/Makefile | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-)gitweb/Makefile +0
-0@@ -80,16 +80,7 @@ endif all:: gitweb.cgi
gitweb/Makefile endif · line 91
Quoted 10 lines
gitweb/Makefile +0
-9-FILES = gitweb.cgi -ifdef JSMIN -FILES += gitweb.min.js -GITWEB_JS = gitweb.min.js -endif -ifdef CSSMIN -FILES += gitweb.min.css -GITWEB_CSS = gitweb.min.css -endif
I wonder about removing assigmnet to GITWEB_JS and GITWEB_CSS. Without it "make gitweb" (in top dir) would create gitweb/gitweb.cgi and gitweb/gitweb.min.js etc.... but generated gitweb/gitweb.cgi would refer to gitweb.js, not gitweb.min.js. Unless of course one provides values for GITWEB_JS during build time.
Quoted 9 lines
gitweb/Makefile +1
-1-gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) +gitweb.cgi: gitweb.perl gitweb.cgi: $(QUIET_GEN)$(RM) $@ $@+ && \@@ -118,16 +109,18 @@ gitweb.cgi: mv $@+ $@ ifdef JSMIN
gitweb/Makefile gitweb.cgi: · line 121
Quoted 10 lines
gitweb/Makefile +2
-0+all:: gitweb.min.js gitweb.min.js: gitweb.js $(QUIET_GEN)$(JSMIN) <$<>$@ endif # JSMIN ifdef CSSMIN +all:: gitweb.min.css gitweb.min.css: gitweb.css $(QUIET_GEN)$(CSSMIN) <$>$@ endif
That makes gitweb.cgi not depend on gitweb.min.js, not gitweb.min.css. It might be right... and I think the rightness or wrongness might be tied with values of GITWEB>JS and GITWEB_CSS.
Quoted 7 lines
gitweb/Makefile +1
-1clean: - $(RM) $(FILES) + $(RM) gitweb.cgi gitweb.min.css gitweb.min.js .PHONY: all clean .FORCE-GIT-VERSION-FILE
Signature · 2 lines
Jakub Narebski Poland
Quoted 4 lines · Jakub Narebski
gitweb/Makefile endif · line 83
Quoted 2 lines
gitweb/Makefile +1
-1-gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) +gitweb.cgi: gitweb.perl...
That makes gitweb.cgi not depend on gitweb.min.js, not gitweb.min.css.
That is what I inteded to do.
Unless you are including gitweb.cgi (iow, the contents of the generated file depends on the _contents_ of gitweb.min.js (or gitweb.js), gitweb.cgi does _not_ depend on these files. Of course if you generate gitweb.cgi out of gitweb.perl with one setting of GITWEB_JS and then change your mind, then you need to regenerate it, but that is not something you can do by comparing file timestamp of gitweb.cgi and the file timestamp of $(GITWEB_JS) anyway. You would need to imitate something like how GIT-BUILD-OPTIONS is used by the primary Makefile.
Quoted 9 lines · Junio C Hamano
Quoted 4 lines · Jakub Narebski
gitweb/Makefile endif · line 83
Quoted 2 lines
gitweb/Makefile +1
-1-gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) +gitweb.cgi: gitweb.perl...
That makes gitweb.cgi not depend on gitweb.min.js, not gitweb.min.css.That is what I inteded to do.
Quoted 8 lines
Unless you are including gitweb.cgi (iow, the contents of the generated file depends on the _contents_ of gitweb.min.js (or gitweb.js), gitweb.cgi does _not_ depend on these files. Of course if you generate gitweb.cgi out of gitweb.perl with one setting of
GITWEB_JSand then change your mind, then you need to regenerate it, but that is not something you can do by comparing file timestamp of gitweb.cgi and the file timestamp of $(GITWEB_JS) anyway. You would need to imitate something like how GIT-BUILD-OPTIONS is used by the primaryMakefile.
Right. I agree.
P.S. This is nt the case with git-instaweb, which literally include gitweb.js or gitweb.min.js...
Signature · 2 lines
Jakub Narebski Poland
Quoted 19 lines · Jakub Narebski
Quoted 9 lines · Junio C Hamano
Quoted 4 lines · Jakub Narebski
gitweb/Makefile endif · line 83
Quoted 2 lines
gitweb/Makefile +1
-1-gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) +gitweb.cgi: gitweb.perl...
That makes gitweb.cgi not depend on gitweb.min.js, not gitweb.min.css.That is what I inteded to do.
Quoted 8 lines
Unless you are including gitweb.cgi (iow, the contents of the generated file depends on the _contents_ of gitweb.min.js (or gitweb.js), gitweb.cgi does _not_ depend on these files. Of course if you generate gitweb.cgi out of gitweb.perl with one setting of
GITWEB_JSand then change your mind, then you need to regenerate it, but that is not something you can do by comparing file timestamp of gitweb.cgi and the file timestamp of $(GITWEB_JS) anyway. You would need to imitate something like how GIT-BUILD-OPTIONS is used by the primaryMakefile.
Quoted 5 lines
Right. I agree.
P.S. This is nt the case with git-instaweb, which literally include gitweb.js or gitweb.min.js...
I believe we can just change the variable names as planned before as well as the dependancies, and that should fix up instaweb as far as will need to be fixed, the rest has to happen at gitweb.cgi generation time.
My understanding (please correct me if I am wrong) is that comparing the mtimes of the files is not reliable. So can't we just make gitweb.cgi depend on source .js and .css files, since any modifications there will also cause the minified versions to be regenerated? Can Junio's patch just be updated to subst the suffix of GITWEB_JS and GITWEB_CSS, which makes sure the correct version is being used?
Signature · 1 line
Mark Rada
Quoted 8 lines · Junio C Hamano
Unless you are including gitweb.cgi (iow, the contents of the generated file depends on the _contents_ of gitweb.min.js (or gitweb.js), gitweb.cgi does _not_ depend on these files. Of course if you generate gitweb.cgi out of gitweb.perl with one setting of
GITWEB_JSand then change your mind, then you need to regenerate it, but that is not something you can do by comparing file timestamp of gitweb.cgi and the file timestamp of $(GITWEB_JS) anyway. You would need to imitate something like how GIT-BUILD-OPTIONS is used by the primaryMakefile.
Here is a minimally tested patch.
In addition to the points raised by the proposed log message for the previous one, this tries to make sure that the scripts are regenerated whenever the replacement variables are modified. For a good measure, if you used different JSMIN/CSSMIN since the last time you produced minified version of these files, they are regenerated.
If this seems to work Ok, please send it back to me with a proper commit log message (concat of the above and the previous) with Tested-by: or
Acked-by: as appropriate, so that we can fix it at the tip of 'master' before we tag 1.7.1-rc2.
Thanks.
gitweb/Makefile | 75 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 38 insertions(+), 37 deletions(-)
gitweb/Makefile +38 -37
@@ -80,54 +80,55 @@ endif all:: gitweb.cgi -FILES = gitweb.cgi ifdef JSMIN -FILES += gitweb.min.js GITWEB_JS = gitweb.min.js +all:: gitweb.min.js +gitweb.min.js: gitweb.js GITWEB-BUILD-OPTIONS + $(QUIET_GEN)$(JSMIN) <$< >$@ endif + ifdef CSSMIN -FILES += gitweb.min.css GITWEB_CSS = gitweb.min.css +all:: gitweb.min.css +gitweb.min.css: gitweb.css GITWEB-BUILD-OPTIONS + $(QUIET_GEN)$(CSSMIN) <$ >$@ endif -gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS) -gitweb.cgi: +GITWEB_REPLACE = \ + -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \ + -e 's|++GIT_BINDIR++|$(bindir)|g' \ + -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \ + -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \ + -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \ + -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \ + -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \ + -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \ + -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \ + -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \ + -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \ + -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \ + -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \ + -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \ + -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \ + -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \ + -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ + -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ + -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' + +GITWEB-BUILD-OPTIONS: FORCE + @rm -f $@+ + @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+ + @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@ + +gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS $(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ - -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \ - -e 's|++GIT_BINDIR++|$(bindir)|g' \ - -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \ - -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \ - -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \ - -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \ - -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \ - -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \ - -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \ - -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \ - -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \ - -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \ - -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \ - -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \ - -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \ - -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \ - -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ - -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ - -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $< >$@+ && \ + $(GITWEB_REPLACE) $< >$@+ && \ chmod +x $@+ && \ mv $@+ $@ -ifdef JSMIN -gitweb.min.js: gitweb.js - $(QUIET_GEN)$(JSMIN) <$< >$@ -endif # JSMIN - -ifdef CSSMIN -gitweb.min.css: gitweb.css - $(QUIET_GEN)$(CSSMIN) <$ >$@ -endif - clean: - $(RM) $(FILES) + $(RM) gitweb.cgi gitweb.min.js gitweb.min.css GITWEB-BUILD-OPTIONS + +.PHONY: all clean .FORCE-GIT-VERSION-FILE FORCE -.PHONY: all clean .FORCE-GIT-VERSION-FILE