From d3ae14ad9167e4d5128df280d803edb69767caba Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 8 Apr 2021 17:22:46 +0300 Subject: [PATCH 06/44] Meson: Add gitrev option See osdn #41881 Signed-off-by: Marko Lindqvist --- bootstrap/generate_gitrev.sh | 14 +++++++------- common/Makefile.am | 2 +- doc/INSTALL.meson | 3 +++ gen_headers/meson_fc_config.h.in | 3 +++ meson.build | 8 ++++++++ meson_options.txt | 5 +++++ 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/bootstrap/generate_gitrev.sh b/bootstrap/generate_gitrev.sh index c5bbdce6de..132c9d3e3d 100755 --- a/bootstrap/generate_gitrev.sh +++ b/bootstrap/generate_gitrev.sh @@ -6,13 +6,13 @@ # See fc_gitrev_gen.h.tmpl for details. # Parameters - $1 - top srcdir -# $2 - top builddir +# $2 - output file # # Absolete paths SRCROOT="$(cd "$1" ; pwd)" INPUTDIR="$(cd "$1/bootstrap" ; pwd)" -OUTPUTDIR="$(cd "$2/common" ; pwd)" +OUTPUTFILE="$2" REVSTATE="OFF" REV1="" @@ -37,11 +37,11 @@ REV2="dist" fi fi - sed -e "s,,$REV1," -e "s,,$REV2," -e "s,,$REVSTATE," fc_gitrev_gen.h.tmpl > "$OUTPUTDIR/fc_gitrev_gen.h.tmp" - if ! test -f "$OUTPUTDIR/fc_gitrev_gen.h" || - ! cmp "$OUTPUTDIR/fc_gitrev_gen.h" "$OUTPUTDIR/fc_gitrev_gen.h.tmp" + sed -e "s,,$REV1," -e "s,,$REV2," -e "s,,$REVSTATE," fc_gitrev_gen.h.tmpl > "${OUTPUTFILE}.tmp" + if ! test -f "${OUTPUTFILE}" || + ! cmp "${OUTPUTFILE}" "${OUTPUTFILE}.tmp" then - mv "$OUTPUTDIR/fc_gitrev_gen.h.tmp" "$OUTPUTDIR/fc_gitrev_gen.h" + mv "${OUTPUTFILE}.tmp" "${OUTPUTFILE}" fi - rm -f "$OUTPUTDIR/fc_gitrev_gen.h.tmp" + rm -f "${OUTPUTFILE}.tmp" ) > /dev/null diff --git a/common/Makefile.am b/common/Makefile.am index 4a6539d960..e346323237 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -176,4 +176,4 @@ endif .PHONY : fc_gitrev_gen.h fc_gitrev_gen.h : - "$(top_srcdir)/bootstrap/generate_gitrev.sh" "$(top_srcdir)" "$(top_builddir)" + "$(top_srcdir)/bootstrap/generate_gitrev.sh" "$(top_srcdir)" "$(top_builddir)/common/fc_gitrev_gen.h" diff --git a/doc/INSTALL.meson b/doc/INSTALL.meson index 04b54a3366..0a0c80206d 100644 --- a/doc/INSTALL.meson +++ b/doc/INSTALL.meson @@ -129,6 +129,9 @@ ruledit (boolean): nls (boolean): Build in Native Language Support. Defaults to true. +gitrev (boolean): + Include git commit id to the version string. + run.sh ------ diff --git a/gen_headers/meson_fc_config.h.in b/gen_headers/meson_fc_config.h.in index 00d42a36ba..c634218f50 100644 --- a/gen_headers/meson_fc_config.h.in +++ b/gen_headers/meson_fc_config.h.in @@ -49,6 +49,9 @@ /* Native language support enabled */ #mesondefine ENABLE_NLS +/* Include git commit id to version string */ +#mesondefine GITREV + /* Can run programs as root */ #mesondefine ALWAYS_ROOT diff --git a/meson.build b/meson.build index 2b78dd4485..a5d31c2ffa 100644 --- a/meson.build +++ b/meson.build @@ -275,6 +275,10 @@ if get_option('nls') priv_conf_data.set('ENABLE_NLS', 1) endif +if get_option('gitrev') + priv_conf_data.set('GITREV', 1) +endif + configure_file(input : 'gen_headers/meson_fc_config.h.in', output : 'fc_config.h', configuration: priv_conf_data) @@ -338,6 +342,10 @@ pack_client = custom_target('packets_client', output: ['packhand_gen.h', '', '', '@OUTPUT0@', '@OUTPUT1@', '', ''], depend_files: files('common/networking/packets.def')) +gitrev = custom_target('gitrev', output: 'fc_gitrev_gen.h', + command: ['sh', files('bootstrap/generate_gitrev.sh'), meson.source_root(), '@OUTPUT@'], + build_by_default: get_option('gitrev')) + tolua_cmd = find_program('tolua') tolua = generator(tolua_cmd, diff --git a/meson_options.txt b/meson_options.txt index d6be6714cf..a8119393a8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -44,3 +44,8 @@ option('nls', type: 'boolean', value: true, description: 'Native Language Support') + +option('gitrev', + type: 'boolean', + value: false, + description: 'Include git commit id to the version string') -- 2.30.2