Make Build/BuildVersion update embedded version number
This way, autobuilders can run it before building, in a tree where git-annex was already built, and get the current git rev embedded in the build. Before, the version number only updated when the setup program was run, which was up to cabal and not on every build.
This commit is contained in:
parent
7ecbb6bc20
commit
a1b55056fc
7 changed files with 37 additions and 15 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,6 +5,7 @@ Setup
|
||||||
tmp
|
tmp
|
||||||
test
|
test
|
||||||
Build/SysConfig
|
Build/SysConfig
|
||||||
|
Build/Version
|
||||||
Build/InstallDesktopFile
|
Build/InstallDesktopFile
|
||||||
Build/EvilSplicer
|
Build/EvilSplicer
|
||||||
Build/Standalone
|
Build/Standalone
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
{- Outputs the version of git-annex that was built, for use by
|
{- For use by autobuilders, this outputs the version of git-annex that
|
||||||
- autobuilders. Note that this includes the git rev. -}
|
- is being built, and also updates the Build/Version file so the build
|
||||||
|
- will report the right version, including the current git rev. -}
|
||||||
|
|
||||||
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
||||||
|
|
||||||
import Build.Version
|
import Build.Version
|
||||||
|
|
||||||
main = putStr =<< getVersion
|
main = do
|
||||||
|
ver <- getVersion
|
||||||
|
writeVersion ver
|
||||||
|
putStr ver
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{- Checks system configuration and generates SysConfig. -}
|
{- Checks system configuration and generates Build/SysConfig and Build/Version. -}
|
||||||
|
|
||||||
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
||||||
|
|
||||||
|
@ -12,15 +12,13 @@ import Utility.Env.Basic
|
||||||
import qualified Git.Version
|
import qualified Git.Version
|
||||||
import Utility.Directory
|
import Utility.Directory
|
||||||
|
|
||||||
import Control.Monad.IfElse
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
tests :: [TestCase]
|
tests :: [TestCase]
|
||||||
tests =
|
tests =
|
||||||
[ TestCase "version" (Config "packageversion" . StringConfig <$> getVersion)
|
[ TestCase "UPGRADE_LOCATION" getUpgradeLocation
|
||||||
, TestCase "UPGRADE_LOCATION" getUpgradeLocation
|
|
||||||
, TestCase "git" $ testCmd "git" "git --version >/dev/null"
|
, TestCase "git" $ testCmd "git" "git --version >/dev/null"
|
||||||
, TestCase "git version" getGitVersion
|
, TestCase "git version" getGitVersion
|
||||||
, testCp "cp_a" "-a"
|
, testCp "cp_a" "-a"
|
||||||
|
@ -120,6 +118,7 @@ run ts = do
|
||||||
case v of
|
case v of
|
||||||
Just "Android" -> writeSysConfig $ androidConfig config
|
Just "Android" -> writeSysConfig $ androidConfig config
|
||||||
_ -> writeSysConfig config
|
_ -> writeSysConfig config
|
||||||
|
writeVersion =<< getVersion
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
{- Hard codes some settings to cross-compile for Android. -}
|
{- Hard codes some settings to cross-compile for Android. -}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{- Package version determination, for configure script. -}
|
{- Package version determination. -}
|
||||||
|
|
||||||
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import Prelude
|
||||||
|
|
||||||
import Utility.Monad
|
import Utility.Monad
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
import Utility.Directory
|
|
||||||
|
|
||||||
type Version = String
|
type Version = String
|
||||||
|
|
||||||
|
@ -33,7 +32,6 @@ getVersion = do
|
||||||
ifM (isReleaseBuild)
|
ifM (isReleaseBuild)
|
||||||
( return changelogversion
|
( return changelogversion
|
||||||
, catchDefaultIO changelogversion $ do
|
, catchDefaultIO changelogversion $ do
|
||||||
let major = takeWhile (/= '.') changelogversion
|
|
||||||
gitversion <- takeWhile (\c -> isAlphaNum c) <$> readProcess "sh"
|
gitversion <- takeWhile (\c -> isAlphaNum c) <$> readProcess "sh"
|
||||||
[ "-c"
|
[ "-c"
|
||||||
, "git log -n 1 --format=format:'%h'"
|
, "git log -n 1 --format=format:'%h'"
|
||||||
|
@ -54,3 +52,18 @@ getChangelogVersion = do
|
||||||
return $ middle (words verline !! 1)
|
return $ middle (words verline !! 1)
|
||||||
where
|
where
|
||||||
middle = drop 1 . init
|
middle = drop 1 . init
|
||||||
|
|
||||||
|
writeVersion :: Version -> IO ()
|
||||||
|
writeVersion = writeFile "Build/Version" . body
|
||||||
|
where
|
||||||
|
body ver = unlines $ concat
|
||||||
|
[ header
|
||||||
|
, ["packageversion :: String"]
|
||||||
|
, ["packageversion = \"" ++ ver ++ "\""]
|
||||||
|
, footer
|
||||||
|
]
|
||||||
|
header = [
|
||||||
|
"{- Automatically generated. -}"
|
||||||
|
, ""
|
||||||
|
]
|
||||||
|
footer = []
|
||||||
|
|
|
@ -12,3 +12,5 @@ module BuildInfo where
|
||||||
-- This file is generated by the configure program with the results of its
|
-- This file is generated by the configure program with the results of its
|
||||||
-- probing.
|
-- probing.
|
||||||
#include "Build/SysConfig"
|
#include "Build/SysConfig"
|
||||||
|
-- This file is automatically generated from the CHANGELOG version
|
||||||
|
#include "Build/Version"
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -108,7 +108,7 @@ docs: mans
|
||||||
clean:
|
clean:
|
||||||
if [ "$(BUILDER)" != ./Setup ] && [ "$(BUILDER)" != cabal ]; then $(BUILDER) clean; fi
|
if [ "$(BUILDER)" != ./Setup ] && [ "$(BUILDER)" != cabal ]; then $(BUILDER) clean; fi
|
||||||
rm -rf tmp dist git-annex $(mans) configure *.tix .hpc \
|
rm -rf tmp dist git-annex $(mans) configure *.tix .hpc \
|
||||||
doc/.ikiwiki html dist tags Build/SysConfig \
|
doc/.ikiwiki html dist tags Build/SysConfig Build/Version \
|
||||||
Setup Build/InstallDesktopFile Build/EvilSplicer \
|
Setup Build/InstallDesktopFile Build/EvilSplicer \
|
||||||
Build/Standalone Build/OSXMkLibs Build/LinuxMkLibs \
|
Build/Standalone Build/OSXMkLibs Build/LinuxMkLibs \
|
||||||
Build/DistributionUpdate Build/BuildVersion Build/MakeMans \
|
Build/DistributionUpdate Build/BuildVersion Build/MakeMans \
|
||||||
|
|
|
@ -63,6 +63,11 @@ getextra rsync.exe 85cb7a4d16d274fcf8069b39042965ad26abd6aa
|
||||||
#stack upgrade --git
|
#stack upgrade --git
|
||||||
stack --version
|
stack --version
|
||||||
|
|
||||||
|
# Update version info for git rev being built.
|
||||||
|
mkdir -p dist
|
||||||
|
stack ghc --stack-yaml stack-windows.yaml --no-haddock Build/BuildVersion.hs
|
||||||
|
./Build/BuildVersion > dist/build-version
|
||||||
|
|
||||||
# Build git-annex
|
# Build git-annex
|
||||||
stack setup --stack-yaml stack-windows.yaml
|
stack setup --stack-yaml stack-windows.yaml
|
||||||
stack install -j 1 --stack-yaml stack-windows.yaml --no-haddock \
|
stack install -j 1 --stack-yaml stack-windows.yaml --no-haddock \
|
||||||
|
@ -73,10 +78,6 @@ withcygpreferred stack ghc --stack-yaml stack-windows.yaml --no-haddock \
|
||||||
--package nsis Build/NullSoftInstaller.hs
|
--package nsis Build/NullSoftInstaller.hs
|
||||||
./Build/NullSoftInstaller
|
./Build/NullSoftInstaller
|
||||||
|
|
||||||
mkdir -p dist
|
|
||||||
stack ghc --stack-yaml stack-windows.yaml --no-haddock Build/BuildVersion.hs
|
|
||||||
./Build/BuildVersion > dist/build-version
|
|
||||||
|
|
||||||
# Test git-annex
|
# Test git-annex
|
||||||
# The test is run in c:/WINDOWS/Temp, because running it in the autobuilder
|
# The test is run in c:/WINDOWS/Temp, because running it in the autobuilder
|
||||||
# directory runs afoul of Windows's short PATH_MAX.
|
# directory runs afoul of Windows's short PATH_MAX.
|
||||||
|
|
Loading…
Reference in a new issue