From da8db7f6f01c91866d22934cba207299acc59fde Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 7 Jan 2018 22:25:29 -0800 Subject: [PATCH] Revert "Generate FISH_BUILD_VERSION info for cmake builds" This reverts commit 25839b8c361e1dcd5f96a5e05bb48616c5531061. This was an attempt to simplify the version generation, but it computed the version at build sytem generation time rather than at build time, requiring another run of CMake to update it. --- CMakeLists.txt | 22 ++++++++++------------ build_tools/cmake_git_version_gen.sh | 24 ------------------------ cmake/Install.cmake | 11 ++++++----- src/fish_build_version.h.in | 4 ---- src/fish_version.h | 3 --- 5 files changed, 16 insertions(+), 48 deletions(-) delete mode 100755 build_tools/cmake_git_version_gen.sh delete mode 100644 src/fish_build_version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 54f3a3f9f..e31dbdd86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,18 +55,16 @@ SET(FISH_SRCS # Header files are just globbed. FILE(GLOB FISH_HEADERS src/*.h) -# git_version_gen.sh creates FISH-BUILD-VERSION-FILE if it does not exist, and updates it -# only if it is out-of-date. -execute_process( - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/build_tools/cmake_git_version_gen.sh" - OUTPUT_VARIABLE FISH_BUILD_VERSION) +# Set up the version target. +# This creates the file FISH-BUILD-VERSION-FILE which is only modified if necessary. +ADD_CUSTOM_COMMAND(OUTPUT "FISH-BUILD-VERSION-FILE" + DEPENDS CHECK-FISH-BUILD-VERSION-FILE) -message(STATUS "FISH_BUILD_VERSION: ${FISH_BUILD_VERSION}") +ADD_CUSTOM_TARGET("CHECK-FISH-BUILD-VERSION-FILE" + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh) + +SET(FBVF "FISH-BUILD-VERSION-FILE") -# Set up fish-build-version.h -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/fish_build_version.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/include/fish_build_version.h") -include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) # Set up config.h INCLUDE(cmake/ConfigureChecks.cmake) @@ -77,8 +75,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) # Set up standard directories. INCLUDE(GNUInstallDirs) -ADD_DEFINITIONS(-DCMAKE - -D_UNICODE=1 +ADD_DEFINITIONS(-D_UNICODE=1 + -DFISH_BUILD_VERSION="${FISH_BUILD_VERSION}" -DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}" -DPREFIX=L"${CMAKE_INSTALL_PREFIX}" -DDATADIR=L"${CMAKE_INSTALL_FULL_DATADIR}" diff --git a/build_tools/cmake_git_version_gen.sh b/build_tools/cmake_git_version_gen.sh deleted file mode 100755 index 0233c2513..000000000 --- a/build_tools/cmake_git_version_gen.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# Originally from the git sources (GIT-VERSION-GEN) -# Presumably (C) Junio C Hamano -# Reused under GPL v2.0 -# Modified for fish by David Adam - -# Obtain directory containing this script in POSIX-compatible manner -# See https://stackoverflow.com/a/43919044/17027 (public domain) -a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a#/}/"; BASEDIR=$(cd "$a"; pwd) -# Find the fish git directory as two levels up from this directory. -GIT_DIR=$(dirname "$a") - -DEF_VER=unknown - -# First see if there is a version file (included in release tarballs), -# then try git-describe, then default. -if test -f version -then - VN=$(cat version) || VN="$DEF_VER" -elif ! VN=$(git -C "$GIT_DIR" describe --always --dirty 2>/dev/null); then - VN="$DEF_VER" -fi - -echo -n "$VN" diff --git a/cmake/Install.cmake b/cmake/Install.cmake index c492c0fe6..6166d626d 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -109,10 +109,11 @@ FISH_CREATE_DIRS(${rel_datadir}/pkgconfig ${extra_completionsdir} # @echo "Installing pkgconfig file" # $v $(INSTALL) -m 644 fish.pc $(DESTDIR)$(datadir)/pkgconfig - -# main CMakeFiles.txt sets ${FISH_BUILD_VERSION}, not ${fish_build_version} -set(fish_build_version ${FISH_BUILD_VERSION}) -CONFIGURE_FILE(fish.pc.in fish.pc) +CONFIGURE_FILE(fish.pc.in fish.pc.noversion) +ADD_CUSTOM_COMMAND(OUTPUT fish.pc + COMMAND awk -v `cat ${FBVF}` '/^Version:/ {$$0=$$0 FISH_BUILD_VERSION} 1' fish.pc.noversion > fish.pc + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${FBVF} ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/fish.pc DESTINATION ${rel_datadir}/pkgconfig) @@ -178,7 +179,7 @@ INSTALL(FILES ${MANUALS} DESTINATION ${mandir}/man1/ OPTIONAL) INSTALL(FILES share/lynx.lss DESTINATION ${rel_datadir}/fish/) # Group install targets into a InstallTargets folder -SET_PROPERTY(TARGET +SET_PROPERTY(TARGET CHECK-FISH-BUILD-VERSION-FILE test_invocation test_fishscript test_prep tests_buildroot_target build_lexicon_filter diff --git a/src/fish_build_version.h.in b/src/fish_build_version.h.in deleted file mode 100644 index c555ff2bb..000000000 --- a/src/fish_build_version.h.in +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -//to be filled in by cmake -#define FISH_BUILD_VERSION "@FISH_BUILD_VERSION@" diff --git a/src/fish_version.h b/src/fish_version.h index a0a28207e..419c83d56 100644 --- a/src/fish_version.h +++ b/src/fish_version.h @@ -1,5 +1,2 @@ // Prototype for version receiver. -#ifdef CMAKE -#include -#endif const char *get_fish_version();