mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Build FISH-BUILD-VERSION-FILE in CMake build
This adds support for creating the FISH-BUILD-VERSION-FILE in the CMake build. A FISH-BUILD-VERSION-FILE is created in the CMake directory and only updated when necessary.
This commit is contained in:
parent
d7baabab8d
commit
861b55d7d8
2 changed files with 15 additions and 10 deletions
|
@ -30,11 +30,13 @@ SET(FISH_SRCS
|
||||||
src/wgetopt.cpp src/wildcard.cpp src/wutil.cpp
|
src/wgetopt.cpp src/wildcard.cpp src/wutil.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set up FISH-BUILD-VERSION-FILE
|
# Set up the version target.
|
||||||
# Note this happens when CMake runs, not when the generated build system runs
|
# This creates the file FISH-BUILD-VERSION-FILE which is only modified if necessary.
|
||||||
EXECUTE_PROCESS(COMMAND build_tools/git_version_gen.sh
|
ADD_CUSTOM_COMMAND(OUTPUT "FISH-BUILD-VERSION-FILE"
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
DEPENDS CHECK-FISH-BUILD-VERSION-FILE)
|
||||||
OUTPUT_QUIET)
|
|
||||||
|
ADD_CUSTOM_TARGET("CHECK-FISH-BUILD-VERSION-FILE"
|
||||||
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh)
|
||||||
|
|
||||||
# Set up config.h
|
# Set up config.h
|
||||||
INCLUDE(CMakeFiles/ConfigureChecks.cmake)
|
INCLUDE(CMakeFiles/ConfigureChecks.cmake)
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# Originally from the git sources (GIT-VERSION-GEN)
|
# Originally from the git sources (GIT-VERSION-GEN)
|
||||||
# Presumably (C) Junio C Hamano <junkio@cox.net>
|
# Presumably (C) Junio C Hamano <junkio@cox.net>
|
||||||
# Reused under GPL v2.0
|
# Reused under GPL v2.0
|
||||||
# Modified for fish by David Adam <zanchey@ucc.gu.uwa.edu.au>
|
# Modified for fish by David Adam <zanchey@ucc.gu.uwa.edu.au>
|
||||||
|
|
||||||
|
# Find the fish git directory as two levels up from this directory.
|
||||||
|
GIT_DIR=$(dirname $(dirname "${BASH_SOURCE[0]}"))
|
||||||
|
|
||||||
FBVF=FISH-BUILD-VERSION-FILE
|
FBVF=FISH-BUILD-VERSION-FILE
|
||||||
DEF_VER=unknown
|
DEF_VER=unknown
|
||||||
|
|
||||||
|
@ -12,17 +15,17 @@ DEF_VER=unknown
|
||||||
if test -f version
|
if test -f version
|
||||||
then
|
then
|
||||||
VN=$(cat version) || VN="$DEF_VER"
|
VN=$(cat version) || VN="$DEF_VER"
|
||||||
elif ! VN=$(git describe --always --dirty 2>/dev/null); then
|
elif ! VN=$(git -C "$GIT_DIR" describe --always --dirty 2>/dev/null); then
|
||||||
VN="$DEF_VER"
|
VN="$DEF_VER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -r $FBVF
|
if test -r $FBVF
|
||||||
then
|
then
|
||||||
VC=$(sed -e 's/^FISH_BUILD_VERSION = //' <$FBVF)
|
VC=$(sed -e 's/^FISH_BUILD_VERSION=//' <$FBVF)
|
||||||
else
|
else
|
||||||
VC=unset
|
VC=unset
|
||||||
fi
|
fi
|
||||||
test "$VN" = "$VC" || {
|
test "$VN" = "$VC" || {
|
||||||
echo >&2 "FISH_BUILD_VERSION = $VN"
|
echo >&2 "FISH_BUILD_VERSION=$VN"
|
||||||
echo "FISH_BUILD_VERSION = $VN" >$FBVF
|
echo "FISH_BUILD_VERSION=$VN" >$FBVF
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue