Makefile: consistently use @PLACEHOLDER@ to substitute

We have a bunch of placeholders in our scripts that we replace at build
time, for example by using sed(1). These placeholders come in three
different formats: @PLACEHOLDER@, @@PLACEHOLDER@@ and ++PLACEHOLDER++.

Next to being inconsistent it also creates a bit of a problem with
CMake, which only supports the first syntax in its `configure_file()`
function. To work around that we instead manually replace placeholders
via string operations, which is a hassle and removes safeguards that
CMake has to verify that we didn't forget to replace any placeholders.
Besides that, other build systems like Meson also support the CMake
syntax.

Unify our codebase to consistently use the syntax supported by such
build systems.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-12-06 14:24:37 +01:00
committed by Junio C Hamano
parent 4638e8806e
commit dbe46c0feb
18 changed files with 119 additions and 119 deletions

View File

@@ -79,28 +79,28 @@ 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'
-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

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