Skip to content

Commit

Permalink
Use gmake instead of make during Setup if available
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubfijalkowski committed Jul 18, 2018
1 parent 56844a6 commit b20a035
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
25 changes: 21 additions & 4 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import Distribution.Simple.LocalBuildInfo (InstallDirs (..),
LocalBuildInfo (..),
absoluteInstallDirs,
localPkgDescr)
import Distribution.Simple.Program.Find (findProgramOnSearchPath,
defaultProgramSearchPath)
import Distribution.Simple.Setup
import Distribution.Simple.Utils (cabalVersion,
doesExecutableExist,
installExecutableFile,
rawSystemExit,
rawSystemStdout)
import Distribution.System
import qualified Distribution.Verbosity as Verbosity
import System.Directory (getCurrentDirectory)

#if MIN_VERSION_Cabal(2, 0, 0)
Expand Down Expand Up @@ -42,14 +46,28 @@ main = defaultMainWithHooks hooksFix
hooksFix = if cabalVersion < mkVersion [1, 20, 0]
then hooks { postInst = installLibsass }
else hooks
execMake :: Verbosity.Verbosity -> String -> String -> IO ()
execMake verbosity build_target target = do
gmakePath <- findProgramOnSearchPath Verbosity.silent defaultProgramSearchPath "gmake"
let makeExec = case gmakePath of
Just (p, _) -> p
Nothing -> "make"
baseArgs = if null build_target
then [makeExec, "--directory=libsass"]
else ["BUILD=" ++ build_target, makeExec, "--directory=libsass"]
makeArgs = if null target
then baseArgs
else baseArgs ++ [target]
rawSystemExit verbosity "env" makeArgs

makeLibsass :: Args -> ConfigFlags -> IO HookedBuildInfo
makeLibsass _ f = do
doesMakeExist <- doesExecutableExist "make"
let verbosity = fromFlag $ configVerbosity f
external = getCabalFlag "externalLibsass" f
target = if getCabalFlag "sharedLibsass" f then "shared" else "static"
unless external $ rawSystemExit verbosity "env"
["BUILD=" ++ target, "make", "--directory=libsass"]
makeExec = if doesMakeExist then "make" else "gmake"
unless external $ execMake verbosity target ""
return emptyHookedBuildInfo

disablePostConfHooks :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
Expand Down Expand Up @@ -119,8 +137,7 @@ installLibsass _ flags pkg_descr lbi =

cleanLibsass :: Args -> CleanFlags -> PackageDescription -> () -> IO ()
cleanLibsass _ flags _ _ =
rawSystemExit (fromFlag $ cleanVerbosity flags) "env"
["make", "--directory=libsass", "clean"]
execMake (fromFlag $ cleanVerbosity flags) "" "clean"

updateLibsassVersion :: Args -> SDistFlags -> IO HookedBuildInfo
updateLibsassVersion _ flags = do
Expand Down
9 changes: 9 additions & 0 deletions stack-lts-11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resolver: lts-11.17
packages:
- '.'
extra-deps: []
flags:
hlibsass:
sharedlibsass: false
externallibsass: false
extra-package-dbs: []
2 changes: 1 addition & 1 deletion stack-nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: nightly-2018-03-23
resolver: nightly-2018-07-18
packages:
- '.'
extra-deps: []
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-11.1
resolver: lts-12.1
packages:
- '.'
extra-deps: []
Expand Down

0 comments on commit b20a035

Please sign in to comment.