Merge branch 'ps/build'

Build procedure update plus introduction of Meson based builds.

* ps/build: (24 commits)
  Introduce support for the Meson build system
  Documentation: add comparison of build systems
  t: allow overriding build dir
  t: better support for out-of-tree builds
  Documentation: extract script to generate a list of mergetools
  Documentation: teach "cmd-list.perl" about out-of-tree builds
  Documentation: allow sourcing generated includes from separate dir
  Makefile: simplify building of templates
  Makefile: write absolute program path into bin-wrappers
  Makefile: allow "bin-wrappers/" directory to exist
  Makefile: refactor generators to be PWD-independent
  Makefile: extract script to generate gitweb.js
  Makefile: extract script to generate gitweb.cgi
  Makefile: extract script to massage Python scripts
  Makefile: extract script to massage Shell scripts
  Makefile: use "generate-perl.sh" to massage Perl library
  Makefile: extract script to massage Perl scripts
  Makefile: consistently use PERL_PATH
  Makefile: generate doc versions via GIT-VERSION-GEN
  Makefile: generate "git.rc" via GIT-VERSION-GEN
  ...
This commit is contained in:
Junio C Hamano
2024-12-15 17:54:32 -08:00
98 changed files with 4996 additions and 512 deletions

View File

@ -0,0 +1,24 @@
PERL_PATH=@PERL_PATH@
JSMIN=@JSMIN@
CSSMIN=@CSSMIN@
GIT_BINDIR=@GIT_BINDIR@
GITWEB_CONFIG=@GITWEB_CONFIG@
GITWEB_CONFIG_SYSTEM=@GITWEB_CONFIG_SYSTEM@
GITWEB_CONFIG_COMMON=@GITWEB_CONFIG_COMMON@
GITWEB_HOME_LINK_STR=@GITWEB_HOME_LINK_STR@
GITWEB_SITENAME=@GITWEB_SITENAME@
GITWEB_PROJECTROOT=@GITWEB_PROJECTROOT@
GITWEB_PROJECT_MAXDEPTH=@GITWEB_PROJECT_MAXDEPTH@
GITWEB_EXPORT_OK=@GITWEB_EXPORT_OK@
GITWEB_STRICT_EXPORT=@GITWEB_STRICT_EXPORT@
GITWEB_BASE_URL=@GITWEB_BASE_URL@
GITWEB_LIST=@GITWEB_LIST@
GITWEB_HOMETEXT=@GITWEB_HOMETEXT@
GITWEB_CSS=@GITWEB_CSS@
GITWEB_LOGO=@GITWEB_LOGO@
GITWEB_FAVICON=@GITWEB_FAVICON@
GITWEB_JS=@GITWEB_JS@
GITWEB_SITE_HTML_HEAD_STRING=@GITWEB_SITE_HTML_HEAD_STRING@
GITWEB_SITE_HEADER=@GITWEB_SITE_HEADER@
GITWEB_SITE_FOOTER=@GITWEB_SITE_FOOTER@
HIGHLIGHT_BIN=@HIGHLIGHT_BIN@

View File

@ -77,48 +77,48 @@ GITWEB_JSLIB_FILES += static/js/javascript-detection.js
GITWEB_JSLIB_FILES += static/js/adjust-timezone.js
GITWEB_JSLIB_FILES += static/js/blame_incremental.js
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_CONFIG_COMMON++|$(GITWEB_CONFIG_COMMON)|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_HTML_HEAD_STRING++|$(GITWEB_SITE_HTML_HEAD_STRING)|g' \
-e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
-e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
.PHONY: FORCE
$(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS: FORCE
@rm -f $@+
@echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
@sed -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|' \
-e 's|@JSMIN@|$(JSMIN)|' \
-e 's|@CSSMIN@|$(CSSMIN)|' \
-e 's|@GIT_VERSION@|$(GIT_VERSION)|' \
-e 's|@GIT_BINDIR@|$(bindir)|' \
-e 's|@GITWEB_CONFIG@|$(GITWEB_CONFIG)|' \
-e 's|@GITWEB_CONFIG_SYSTEM@|$(GITWEB_CONFIG_SYSTEM)|' \
-e 's|@GITWEB_CONFIG_COMMON@|$(GITWEB_CONFIG_COMMON)|' \
-e 's|@GITWEB_HOME_LINK_STR@|$(GITWEB_HOME_LINK_STR)|' \
-e 's|@GITWEB_SITENAME@|$(GITWEB_SITENAME)|' \
-e 's|@GITWEB_PROJECTROOT@|$(GITWEB_PROJECTROOT)|' \
-e 's|@GITWEB_PROJECT_MAXDEPTH@|$(GITWEB_PROJECT_MAXDEPTH)|' \
-e 's|@GITWEB_EXPORT_OK@|$(GITWEB_EXPORT_OK)|' \
-e 's|@GITWEB_STRICT_EXPORT@|$(GITWEB_STRICT_EXPORT)|' \
-e 's|@GITWEB_BASE_URL@|$(GITWEB_BASE_URL)|' \
-e 's|@GITWEB_LIST@|$(GITWEB_LIST)|' \
-e 's|@GITWEB_HOMETEXT@|$(GITWEB_HOMETEXT)|' \
-e 's|@GITWEB_CSS@|$(GITWEB_CSS)|' \
-e 's|@GITWEB_LOGO@|$(GITWEB_LOGO)|' \
-e 's|@GITWEB_FAVICON@|$(GITWEB_FAVICON)|' \
-e 's|@GITWEB_JS@|$(GITWEB_JS)|' \
-e 's|@GITWEB_SITE_HTML_HEAD_STRING@|$(GITWEB_SITE_HTML_HEAD_STRING)|' \
-e 's|@GITWEB_SITE_HEADER@|$(GITWEB_SITE_HEADER)|' \
-e 's|@GITWEB_SITE_FOOTER@|$(GITWEB_SITE_FOOTER)|' \
-e 's|@HIGHLIGHT_BIN@|$(HIGHLIGHT_BIN)|' \
$(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS.in >"$@+"
@cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
$(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)generate-gitweb-cgi.sh
$(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS
$(MAK_DIR_GITWEB)gitweb.cgi: GIT-VERSION-FILE
$(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl
$(QUIET_GEN)$(RM) $@ $@+ && \
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
$(GITWEB_REPLACE) $< >$@+ && \
chmod +x $@+ && \
$(MAK_DIR_GITWEB)generate-gitweb-cgi.sh $(MAK_DIR_GITWEB)/GITWEB-BUILD-OPTIONS ./GIT-VERSION-FILE $< $@+ && \
mv $@+ $@
$(MAK_DIR_GITWEB)static/gitweb.js: $(MAK_DIR_GITWEB)generate-gitweb-js.sh
$(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))
$(QUIET_GEN)$(RM) $@ $@+ && \
cat $^ >$@+ && \
$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $^ && \
mv $@+ $@
### Installation rules

47
gitweb/generate-gitweb-cgi.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
set -e
if test $# -ne 4
then
echo >&2 "USAGE: $0 <GITWEB-BUILD-OPTIONS> <GIT-VERSION-FILE> <INPUT> <OUTPUT>"
exit 1
fi
GITWEB_BUILD_OPTIONS="$1"
GIT_VERSION_FILE="$2"
INPUT="$3"
OUTPUT="$4"
. "$GITWEB_BUILD_OPTIONS"
. "$GIT_VERSION_FILE"
sed -e "1s|#!/usr/bin/perl|#!$PERL_PATH|" \
-e "s|@PERL_PATH@|$PERL_PATH|" \
-e "s|@JSMIN@|$JSMIN|" \
-e "s|@CSSMIN@|$CSSMIN|" \
-e "s|@GIT_VERSION@|$GIT_VERSION|" \
-e "s|@GIT_BINDIR@|$GIT_BINDIR|" \
-e "s|@GITWEB_CONFIG@|$GITWEB_CONFIG|" \
-e "s|@GITWEB_CONFIG_SYSTEM@|$GITWEB_CONFIG_SYSTEM|" \
-e "s|@GITWEB_CONFIG_COMMON@|$GITWEB_CONFIG_COMMON|" \
-e "s|@GITWEB_HOME_LINK_STR@|$GITWEB_HOME_LINK_STR|" \
-e "s|@GITWEB_SITENAME@|$GITWEB_SITENAME|" \
-e "s|@GITWEB_PROJECTROOT@|$GITWEB_PROJECTROOT|" \
-e "s|@GITWEB_PROJECT_MAXDEPTH@|$GITWEB_PROJECT_MAXDEPTH|" \
-e "s|@GITWEB_EXPORT_OK@|$GITWEB_EXPORT_OK|" \
-e "s|@GITWEB_STRICT_EXPORT@|$GITWEB_STRICT_EXPORT|" \
-e "s|@GITWEB_BASE_URL@|$GITWEB_BASE_URL|" \
-e "s|@GITWEB_LIST@|$GITWEB_LIST|" \
-e "s|@GITWEB_HOMETEXT@|$GITWEB_HOMETEXT|" \
-e "s|@GITWEB_CSS@|$GITWEB_CSS|" \
-e "s|@GITWEB_LOGO@|$GITWEB_LOGO|" \
-e "s|@GITWEB_FAVICON@|$GITWEB_FAVICON|" \
-e "s|@GITWEB_JS@|$GITWEB_JS|" \
-e "s|@GITWEB_SITE_HTML_HEAD_STRING@|$GITWEB_SITE_HTML_HEAD_STRING|" \
-e "s|@GITWEB_SITE_HEADER@|$GITWEB_SITE_HEADER|" \
-e "s|@GITWEB_SITE_FOOTER@|$GITWEB_SITE_FOOTER|" \
-e "s|@HIGHLIGHT_BIN@|$HIGHLIGHT_BIN|" \
"$INPUT" >"$OUTPUT"
chmod a+x "$OUTPUT"

12
gitweb/generate-gitweb-js.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
if test "$#" -lt 2
then
echo >&2 "USAGE: $0 <OUTPUT> <INPUT>..."
exit 1
fi
OUTPUT="$1"
shift
cat "$@" >"$OUTPUT"

View File

@ -35,7 +35,7 @@ BEGIN {
CGI->compile() if $ENV{'MOD_PERL'};
}
our $version = "++GIT_VERSION++";
our $version = "@GIT_VERSION@";
our ($my_url, $my_uri, $base_url, $path_info, $home_link);
sub evaluate_uri {
@ -80,46 +80,46 @@ sub evaluate_uri {
# core git executable to use
# this can just be "git" if your webserver has a sensible PATH
our $GIT = "++GIT_BINDIR++/git";
our $GIT = "@GIT_BINDIR@/git";
# absolute fs-path which will be prepended to the project path
#our $projectroot = "/pub/scm";
our $projectroot = "++GITWEB_PROJECTROOT++";
our $projectroot = "@GITWEB_PROJECTROOT@";
# fs traversing limit for getting project list
# the number is relative to the projectroot
our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
our $project_maxdepth = @GITWEB_PROJECT_MAXDEPTH@;
# string of the home link on top of all pages
our $home_link_str = "++GITWEB_HOME_LINK_STR++";
our $home_link_str = "@GITWEB_HOME_LINK_STR@";
# extra breadcrumbs preceding the home link
our @extra_breadcrumbs = ();
# name of your site or organization to appear in page titles
# replace this with something more descriptive for clearer bookmarks
our $site_name = "++GITWEB_SITENAME++"
our $site_name = "@GITWEB_SITENAME@"
|| ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
# html snippet to include in the <head> section of each page
our $site_html_head_string = "++GITWEB_SITE_HTML_HEAD_STRING++";
our $site_html_head_string = "@GITWEB_SITE_HTML_HEAD_STRING@";
# filename of html text to include at top of each page
our $site_header = "++GITWEB_SITE_HEADER++";
our $site_header = "@GITWEB_SITE_HEADER@";
# html text to include at home page
our $home_text = "++GITWEB_HOMETEXT++";
our $home_text = "@GITWEB_HOMETEXT@";
# filename of html text to include at bottom of each page
our $site_footer = "++GITWEB_SITE_FOOTER++";
our $site_footer = "@GITWEB_SITE_FOOTER@";
# URI of stylesheets
our @stylesheets = ("++GITWEB_CSS++");
our @stylesheets = ("@GITWEB_CSS@");
# URI of a single stylesheet, which can be overridden in GITWEB_CONFIG.
our $stylesheet = undef;
# URI of GIT logo (72x27 size)
our $logo = "++GITWEB_LOGO++";
our $logo = "@GITWEB_LOGO@";
# URI of GIT favicon, assumed to be image/png type
our $favicon = "++GITWEB_FAVICON++";
our $favicon = "@GITWEB_FAVICON@";
# URI of gitweb.js (JavaScript code for gitweb)
our $javascript = "++GITWEB_JS++";
our $javascript = "@GITWEB_JS@";
# URI and label (title) of GIT logo link
#our $logo_url = "https://www.kernel.org/pub/software/scm/git/docs/";
@ -128,7 +128,7 @@ our $logo_url = "https://git-scm.com/";
our $logo_label = "git homepage";
# source of projects list
our $projects_list = "++GITWEB_LIST++";
our $projects_list = "@GITWEB_LIST@";
# the width (in characters) of the projects list "Description" column
our $projects_list_description_width = 25;
@ -147,7 +147,7 @@ our $default_projects_order = "project";
# show repository only if this file exists
# (only effective if this variable evaluates to true)
our $export_ok = "++GITWEB_EXPORT_OK++";
our $export_ok = "@GITWEB_EXPORT_OK@";
# don't generate age column on the projects list page
our $omit_age_column = 0;
@ -161,11 +161,11 @@ our $omit_owner=0;
our $export_auth_hook = undef;
# only allow viewing of repositories also shown on the overview page
our $strict_export = "++GITWEB_STRICT_EXPORT++";
our $strict_export = "@GITWEB_STRICT_EXPORT@";
# list of git base URLs used for URL to where fetch project from,
# i.e. full URL is "$git_base_url/$project"
our @git_base_url_list = grep { $_ ne '' } ("++GITWEB_BASE_URL++");
our @git_base_url_list = grep { $_ ne '' } ("@GITWEB_BASE_URL@");
# default blob_plain mimetype and default charset for text/plain blob
our $default_blob_plain_mimetype = 'text/plain';
@ -200,7 +200,7 @@ our $prevent_xss = 0;
# http://andre-simon.de/zip/download.php due to assumptions about parameters and output).
# Useful if highlight is not installed on your webserver's PATH.
# [Default: highlight]
our $highlight_bin = "++HIGHLIGHT_BIN++";
our $highlight_bin = "@HIGHLIGHT_BIN@";
# information about snapshot formats that gitweb is capable of serving
our %known_snapshot_formats = (
@ -741,9 +741,9 @@ sub read_config_file {
our ($GITWEB_CONFIG, $GITWEB_CONFIG_SYSTEM, $GITWEB_CONFIG_COMMON);
sub evaluate_gitweb_config {
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
our $GITWEB_CONFIG_COMMON = $ENV{'GITWEB_CONFIG_COMMON'} || "++GITWEB_CONFIG_COMMON++";
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "@GITWEB_CONFIG@";
our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "@GITWEB_CONFIG_SYSTEM@";
our $GITWEB_CONFIG_COMMON = $ENV{'GITWEB_CONFIG_COMMON'} || "@GITWEB_CONFIG_COMMON@";
# Protect against duplications of file names, to not read config twice.
# Only one of $GITWEB_CONFIG and $GITWEB_CONFIG_SYSTEM is used, so

89
gitweb/meson.build Normal file
View File

@ -0,0 +1,89 @@
gitweb_config = configuration_data()
gitweb_config.set_quoted('PERL_PATH', perl.full_path())
gitweb_config.set_quoted('CSSMIN', '')
gitweb_config.set_quoted('JSMIN', '')
gitweb_config.set_quoted('GIT_BINDIR', get_option('prefix') / get_option('bindir'))
gitweb_config.set_quoted('GITWEB_CONFIG', get_option('gitweb_config'))
gitweb_config.set_quoted('GITWEB_CONFIG_SYSTEM', get_option('gitweb_config_system'))
gitweb_config.set_quoted('GITWEB_CONFIG_COMMON', get_option('gitweb_config_common'))
gitweb_config.set_quoted('GITWEB_HOME_LINK_STR', get_option('gitweb_home_link_str'))
gitweb_config.set_quoted('GITWEB_SITENAME', get_option('gitweb_sitename'))
gitweb_config.set_quoted('GITWEB_PROJECTROOT', get_option('gitweb_projectroot'))
gitweb_config.set_quoted('GITWEB_PROJECT_MAXDEPTH', get_option('gitweb_project_maxdepth'))
gitweb_config.set_quoted('GITWEB_EXPORT_OK', get_option('gitweb_export_ok'))
gitweb_config.set_quoted('GITWEB_STRICT_EXPORT', get_option('gitweb_strict_export'))
gitweb_config.set_quoted('GITWEB_BASE_URL', get_option('gitweb_base_url'))
gitweb_config.set_quoted('GITWEB_LIST', get_option('gitweb_list'))
gitweb_config.set_quoted('GITWEB_HOMETEXT', get_option('gitweb_hometext'))
gitweb_config.set_quoted('GITWEB_CSS', get_option('gitweb_css'))
gitweb_config.set_quoted('GITWEB_LOGO', get_option('gitweb_logo'))
gitweb_config.set_quoted('GITWEB_FAVICON', get_option('gitweb_favicon'))
gitweb_config.set_quoted('GITWEB_JS', get_option('gitweb_js'))
gitweb_config.set_quoted('GITWEB_SITE_HTML_HEAD_STRING', get_option('gitweb_site_html_head_string'))
gitweb_config.set_quoted('GITWEB_SITE_HEADER', get_option('gitweb_site_header'))
gitweb_config.set_quoted('GITWEB_SITE_FOOTER', get_option('gitweb_site_footer'))
gitweb_config.set_quoted('HIGHLIGHT_BIN', get_option('highlight_bin'))
configure_file(
input: 'GITWEB-BUILD-OPTIONS.in',
output: 'GITWEB-BUILD-OPTIONS',
configuration: gitweb_config,
)
test_dependencies += custom_target(
input: 'gitweb.perl',
output: 'gitweb.cgi',
command: [
shell,
meson.current_source_dir() / 'generate-gitweb-cgi.sh',
meson.current_build_dir() / 'GITWEB-BUILD-OPTIONS',
git_version_file.full_path(),
'@INPUT@',
'@OUTPUT@',
],
install: true,
install_dir: get_option('datadir') / 'gitweb',
depends: [git_version_file],
)
javascript_files = [
meson.current_source_dir() / 'static/js/adjust-timezone.js',
meson.current_source_dir() / 'static/js/blame_incremental.js',
meson.current_source_dir() / 'static/js/javascript-detection.js',
meson.current_source_dir() / 'static/js/lib/common-lib.js',
meson.current_source_dir() / 'static/js/lib/cookies.js',
meson.current_source_dir() / 'static/js/lib/datetime.js',
]
test_dependencies += custom_target(
input: javascript_files,
output: 'gitweb.js',
command: [
shell,
meson.current_source_dir() / 'generate-gitweb-js.sh',
'@OUTPUT@',
] + javascript_files,
install: true,
install_dir: get_option('datadir') / 'gitweb/static',
)
foreach asset : [
'static/git-favicon.png',
'static/git-logo.png',
'static/gitweb.css',
]
if meson.version().version_compare('>=1.3.0')
fs.copyfile(asset,
install: true,
install_dir: get_option('datadir') / 'gitweb' / fs.parent(asset),
)
else
configure_file(
input: asset,
output: fs.stem(asset),
copy: true,
install: true,
install_dir: get_option('datadir') / 'gitweb' / fs.parent(asset),
)
endif
endforeach