Skip to content

Commit

Permalink
Always regenerate libsass/VERSION if we are able to or it does not …
Browse files Browse the repository at this point in the history
…exist
  • Loading branch information
jakubfijalkowski committed Jun 15, 2020
1 parent d3ffecb commit 81a9f2f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import Distribution.Simple.Utils (cabalVersion,
rawSystemStdout)
import Distribution.System
import qualified Distribution.Verbosity as Verbosity
import System.Directory (doesFileExist,
import System.Directory (doesDirectoryExist,
doesFileExist,
getCurrentDirectory)

#if MIN_VERSION_Cabal(2, 0, 0)
Expand Down Expand Up @@ -68,13 +69,16 @@ execMake verbosity build_target target = do
updateLibsassVersion :: ConfigFlags -> IO ()
updateLibsassVersion flags = do
let verbosity = fromFlag $ configVerbosity flags
exists <- doesFileExist "libsass/VERSION"
unless exists $ do
gitDirExists <- doesDirectoryExist "libsass/.git"
gitFileExists <- doesFileExist "libsass/.git"
verExists <- doesFileExist "libsass/VERSION"
-- Force-update VERSION so that we always use valid one as `stack clean` does not run cabal
-- clean and we sometimes pack the wrong `VERSION` file
when (gitDirExists || gitFileExists || not verExists) $ do
ver <- rawSystemStdout verbosity "git" ["-C", "libsass", "describe",
"--abbrev=4", "--dirty", "--always", "--tags"]
writeFile "libsass/VERSION" ver


makeLibsass :: Args -> ConfigFlags -> IO HookedBuildInfo
makeLibsass _ f = do
let verbosity = fromFlag $ configVerbosity f
Expand Down

0 comments on commit 81a9f2f

Please sign in to comment.