Merge branch 'ps/build-hotfix'
A topic to optionally build with meson, which has graduated to 'master' recently, has regressed the normal Makefile build, which is being corrected. * ps/build-hotfix: meson: add options to override build information GIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE GIT-VERSION-GEN: fix overriding GIT_VERSION Makefile: introduce template for GIT-VERSION-GEN Makefile: drop unneeded indirection for GIT-VERSION-GEN outputs Makefile: stop including "GIT-VERSION-FILE" in docsmaint
commit
f074cdea46
|
@ -181,6 +181,10 @@ endif
|
|||
-include ../config.mak.autogen
|
||||
-include ../config.mak
|
||||
|
||||
# Set GIT_VERSION_OVERRIDE such that version_gen knows to substitute
|
||||
# GIT_VERSION in case it was set by the user.
|
||||
GIT_VERSION_OVERRIDE := $(GIT_VERSION)
|
||||
|
||||
ifndef NO_MAN_BOLD_LITERAL
|
||||
XMLTO_EXTRA += -m manpage-bold-literal.xsl
|
||||
endif
|
||||
|
@ -211,12 +215,10 @@ XMLTO_EXTRA += --skip-validation
|
|||
XMLTO_EXTRA += -x manpage.xsl
|
||||
|
||||
asciidoctor-extensions.rb: asciidoctor-extensions.rb.in FORCE
|
||||
$(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@+
|
||||
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
|
||||
$(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@)
|
||||
else
|
||||
asciidoc.conf: asciidoc.conf.in FORCE
|
||||
$(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@+
|
||||
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
|
||||
$(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@)
|
||||
endif
|
||||
|
||||
ASCIIDOC_DEPS += docinfo.html
|
||||
|
@ -276,13 +278,6 @@ install-pdf: pdf
|
|||
install-html: html
|
||||
'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
|
||||
|
||||
../GIT-VERSION-FILE: FORCE
|
||||
$(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
|
||||
|
||||
ifneq ($(filter-out lint-docs clean,$(MAKECMDGOALS)),)
|
||||
-include ../GIT-VERSION-FILE
|
||||
endif
|
||||
|
||||
mergetools_txt = mergetools-diff.txt mergetools-merge.txt
|
||||
|
||||
#
|
||||
|
|
|
@ -219,6 +219,7 @@ asciidoc_conf = custom_target(
|
|||
input: meson.current_source_dir() / 'asciidoc.conf.in',
|
||||
output: 'asciidoc.conf',
|
||||
depends: [git_version_file],
|
||||
env: version_gen_environment,
|
||||
)
|
||||
|
||||
asciidoc_common_options = [
|
||||
|
|
|
@ -27,33 +27,45 @@ fi
|
|||
GIT_CEILING_DIRECTORIES="$SOURCE_DIR/.."
|
||||
export GIT_CEILING_DIRECTORIES
|
||||
|
||||
# First see if there is a version file (included in release tarballs),
|
||||
# then try git-describe, then default.
|
||||
if test -f "$SOURCE_DIR"/version
|
||||
if test -z "$GIT_VERSION"
|
||||
then
|
||||
VN=$(cat "$SOURCE_DIR"/version) || VN="$DEF_VER"
|
||||
elif {
|
||||
test -d "$SOURCE_DIR/.git" ||
|
||||
test -d "${GIT_DIR:-.git}" ||
|
||||
test -f "$SOURCE_DIR"/.git;
|
||||
} &&
|
||||
VN=$(git -C "$SOURCE_DIR" describe --match "v[0-9]*" HEAD 2>/dev/null) &&
|
||||
case "$VN" in
|
||||
*$LF*) (exit 1) ;;
|
||||
v[0-9]*)
|
||||
git -C "$SOURCE_DIR" update-index -q --refresh
|
||||
test -z "$(git -C "$SOURCE_DIR" diff-index --name-only HEAD --)" ||
|
||||
VN="$VN-dirty" ;;
|
||||
esac
|
||||
then
|
||||
VN=$(echo "$VN" | sed -e 's/-/./g');
|
||||
else
|
||||
VN="$DEF_VER"
|
||||
# First see if there is a version file (included in release tarballs),
|
||||
# then try git-describe, then default.
|
||||
if test -f "$SOURCE_DIR"/version
|
||||
then
|
||||
VN=$(cat "$SOURCE_DIR"/version) || VN="$DEF_VER"
|
||||
elif {
|
||||
test -d "$SOURCE_DIR/.git" ||
|
||||
test -d "${GIT_DIR:-.git}" ||
|
||||
test -f "$SOURCE_DIR"/.git;
|
||||
} &&
|
||||
VN=$(git -C "$SOURCE_DIR" describe --match "v[0-9]*" HEAD 2>/dev/null) &&
|
||||
case "$VN" in
|
||||
*$LF*) (exit 1) ;;
|
||||
v[0-9]*)
|
||||
git -C "$SOURCE_DIR" update-index -q --refresh
|
||||
test -z "$(git -C "$SOURCE_DIR" diff-index --name-only HEAD --)" ||
|
||||
VN="$VN-dirty" ;;
|
||||
esac
|
||||
then
|
||||
VN=$(echo "$VN" | sed -e 's/-/./g');
|
||||
else
|
||||
VN="$DEF_VER"
|
||||
fi
|
||||
|
||||
GIT_VERSION=$(expr "$VN" : v*'\(.*\)')
|
||||
fi
|
||||
|
||||
if test -z "$GIT_BUILT_FROM_COMMIT"
|
||||
then
|
||||
GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null)
|
||||
fi
|
||||
|
||||
if test -z "$GIT_DATE"
|
||||
then
|
||||
GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null)
|
||||
fi
|
||||
|
||||
GIT_VERSION=$(expr "$VN" : v*'\(.*\)')
|
||||
GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null)
|
||||
GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null)
|
||||
if test -z "$GIT_USER_AGENT"
|
||||
then
|
||||
GIT_USER_AGENT="git/$GIT_VERSION"
|
||||
|
|
25
Makefile
25
Makefile
|
@ -591,13 +591,6 @@ include shared.mak
|
|||
#
|
||||
# Disable -pedantic compilation.
|
||||
|
||||
GIT-VERSION-FILE: FORCE
|
||||
@OLD=$$(cat $@ 2>/dev/null || :) && \
|
||||
$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" GIT-VERSION-FILE.in $@ && \
|
||||
NEW=$$(cat $@ 2>/dev/null || :) && \
|
||||
if test "$$OLD" != "$$NEW"; then echo "$$NEW" >&2; fi
|
||||
-include GIT-VERSION-FILE
|
||||
|
||||
# Set our default configuration.
|
||||
#
|
||||
# Among the variables below, these:
|
||||
|
@ -1465,6 +1458,18 @@ ifdef DEVELOPER
|
|||
include config.mak.dev
|
||||
endif
|
||||
|
||||
GIT-VERSION-FILE: FORCE
|
||||
@OLD=$$(cat $@ 2>/dev/null || :) && \
|
||||
$(call version_gen,"$(shell pwd)",GIT-VERSION-FILE.in,$@) && \
|
||||
NEW=$$(cat $@ 2>/dev/null || :) && \
|
||||
if test "$$OLD" != "$$NEW"; then echo "$$NEW" >&2; fi
|
||||
|
||||
# We need to set GIT_VERSION_OVERRIDE before including the version file as
|
||||
# otherwise any user-provided value for GIT_VERSION would have been overridden
|
||||
# already.
|
||||
GIT_VERSION_OVERRIDE := $(GIT_VERSION)
|
||||
-include GIT-VERSION-FILE
|
||||
|
||||
# what 'all' will build and 'install' will install in gitexecdir,
|
||||
# excluding programs for built-in commands
|
||||
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
|
||||
|
@ -2511,8 +2516,7 @@ pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \
|
|||
-DPAGER_ENV='$(PAGER_ENV_CQ_SQ)'
|
||||
|
||||
version-def.h: version-def.h.in GIT-VERSION-GEN GIT-VERSION-FILE GIT-USER-AGENT
|
||||
$(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@+
|
||||
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
|
||||
$(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
|
||||
|
||||
version.sp version.s version.o: version-def.h
|
||||
|
||||
|
@ -2553,8 +2557,7 @@ $(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh generate-script.sh GIT-BUILD-OPTIONS G
|
|||
mv $@+ $@
|
||||
|
||||
git.rc: git.rc.in GIT-VERSION-GEN GIT-VERSION-FILE
|
||||
$(QUIET_GEN)$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@+
|
||||
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
|
||||
$(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
|
||||
|
||||
git.res: git.rc GIT-PREFIX
|
||||
$(QUIET_RC)$(RC) -i $< -o $@
|
||||
|
|
13
meson.build
13
meson.build
|
@ -201,6 +201,16 @@ if get_option('sane_tool_path') != ''
|
|||
script_environment.prepend('PATH', get_option('sane_tool_path'))
|
||||
endif
|
||||
|
||||
# The environment used by GIT-VERSION-GEN. Note that we explicitly override
|
||||
# environment variables that might be set by the user. This is by design so
|
||||
# that we always use whatever Meson has configured instead of what is present
|
||||
# in the environment.
|
||||
version_gen_environment = script_environment
|
||||
version_gen_environment.set('GIT_BUILT_FROM_COMMIT', get_option('built_from_commit'))
|
||||
version_gen_environment.set('GIT_DATE', get_option('build_date'))
|
||||
version_gen_environment.set('GIT_USER_AGENT', get_option('user_agent'))
|
||||
version_gen_environment.set('GIT_VERSION', get_option('version'))
|
||||
|
||||
compiler = meson.get_compiler('c')
|
||||
|
||||
libgit_sources = [
|
||||
|
@ -1484,6 +1494,7 @@ git_version_file = custom_target(
|
|||
],
|
||||
input: meson.current_source_dir() / 'GIT-VERSION-FILE.in',
|
||||
output: 'GIT-VERSION-FILE',
|
||||
env: version_gen_environment,
|
||||
build_always_stale: true,
|
||||
)
|
||||
|
||||
|
@ -1500,6 +1511,7 @@ version_def_h = custom_target(
|
|||
# Depend on GIT-VERSION-FILE so that we don't always try to rebuild this
|
||||
# target for the same commit.
|
||||
depends: [git_version_file],
|
||||
env: version_gen_environment,
|
||||
)
|
||||
|
||||
# Build a separate library for "version.c" so that we do not have to rebuild
|
||||
|
@ -1543,6 +1555,7 @@ if host_machine.system() == 'windows'
|
|||
input: meson.current_source_dir() / 'git.rc.in',
|
||||
output: 'git.rc',
|
||||
depends: [git_version_file],
|
||||
env: version_gen_environment,
|
||||
)
|
||||
|
||||
common_main_sources += import('windows').compile_resources(git_rc,
|
||||
|
|
|
@ -16,6 +16,16 @@ option('runtime_prefix', type: 'boolean', value: false,
|
|||
option('sane_tool_path', type: 'string', value: '',
|
||||
description: 'A colon-separated list of paths to prepend to PATH if your tools in /usr/bin are broken.')
|
||||
|
||||
# Build information compiled into Git and other parts like documentation.
|
||||
option('build_date', type: 'string', value: '',
|
||||
description: 'Build date reported by our documentation.')
|
||||
option('built_from_commit', type: 'string', value: '',
|
||||
description: 'Commit that Git was built from reported by git-version(1).')
|
||||
option('user_agent', type: 'string', value: '',
|
||||
description: 'User agent reported to remote servers.')
|
||||
option('version', type: 'string', value: '',
|
||||
description: 'Version string reported by git-version(1) and other tools.')
|
||||
|
||||
# Features supported by Git.
|
||||
option('curl', type: 'feature', value: 'enabled',
|
||||
description: 'Build helpers used to access remotes with the HTTP transport.')
|
||||
|
|
11
shared.mak
11
shared.mak
|
@ -116,3 +116,14 @@ endef
|
|||
define libpath_template
|
||||
-L$(1) $(if $(filter-out -L,$(CC_LD_DYNPATH)),$(CC_LD_DYNPATH)$(1))
|
||||
endef
|
||||
|
||||
# Populate build information into a file via GIT-VERSION-GEN. Requires the
|
||||
# absolute path to the root source directory as well as input and output files
|
||||
# as arguments, in that order.
|
||||
define version_gen
|
||||
GIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)" \
|
||||
GIT_DATE="$(GIT_DATE)" \
|
||||
GIT_USER_AGENT="$(GIT_USER_AGENT)" \
|
||||
GIT_VERSION="$(GIT_VERSION_OVERRIDE)" \
|
||||
$(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)"
|
||||
endef
|
||||
|
|
Loading…
Reference in New Issue