mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Prevent unnecessary recompilation of Semantic.Version in dev mode.
Right now, Semantic.Version is recompiled on every invocation of `stack build`, since we marked it as `-fforce-recomp` to ensure that all deployments are tagged appropriately for haystack. However, this entails a good deal of wasted time during development. With some liberal application of `CPP`, we can make this recompilation only happen on CI, thanks to the `release` flag and passing in a compiler flag. To test: * apply the patch * `stack build semantic`, then `stack exec semantic -- -v`. It should print `semantic version 0.4.0 (<development>)`. * `stack clean semantic && stack build --ghc-options=-DCOMPUTE_GIT_SHA`. `stack exec semantic -- -v` should then print out the correct SHA. Though it's probably not strictly necessary, I've marked the `semantic` and `semanticd` executables to compile with -DCOMPUTE_GIT_SHA, just in case.
This commit is contained in:
parent
42bb569ba9
commit
b361c9ef79
@ -287,7 +287,7 @@ library
|
||||
, StrictData
|
||||
, TypeApplications
|
||||
if flag(release)
|
||||
ghc-options: -Wall -Werror -Wmissing-export-lists -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O1 -j
|
||||
ghc-options: -Wall -Werror -Wmissing-export-lists -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O1 -j -DCOMPUTE_GIT_SHA
|
||||
else
|
||||
ghc-options: -Wall -Wmissing-export-lists -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O0 -j
|
||||
ghc-prof-options: -fprof-auto
|
||||
@ -296,7 +296,7 @@ executable semantic
|
||||
hs-source-dirs: app
|
||||
main-is: Main.hs
|
||||
if flag(release)
|
||||
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O1 -j
|
||||
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O1 -j -DCOMPUTE_GIT_SHA
|
||||
else
|
||||
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O0 -j
|
||||
cc-options: -DU_STATIC_IMPLEMENTATION=1
|
||||
|
@ -1,4 +1,7 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
#ifdef COMPUTE_GIT_SHA
|
||||
{-# OPTIONS_GHC -fforce-recomp #-} -- So that gitHash is correct.
|
||||
#endif
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Semantic.Version
|
||||
( buildSHA
|
||||
@ -6,12 +9,19 @@ module Semantic.Version
|
||||
) where
|
||||
|
||||
import Data.Version (showVersion)
|
||||
#ifdef COMPUTE_GIT_SHA
|
||||
import Development.GitRev
|
||||
#endif
|
||||
import Paths_semantic (version)
|
||||
|
||||
-- The SHA1 hash of this build of semantic.
|
||||
-- If compiled as a development build, this will be all zeroes.
|
||||
buildSHA :: String
|
||||
#ifdef COMPUTE_GIT_SHA
|
||||
buildSHA = $(gitHash)
|
||||
#else
|
||||
buildSHA = "<development>"
|
||||
#endif
|
||||
|
||||
-- The version string of this build of semantic.
|
||||
buildVersion :: String
|
||||
|
Loading…
Reference in New Issue
Block a user