Compare commits

...

2 Commits

Author SHA1 Message Date
c0c70f5c9b Abstract over make
So on FreeBSD we get gmake.
2020-03-17 22:43:45 +01:00
fee16758de Move platform faking option into install subcommand 2020-03-17 22:43:00 +01:00
3 changed files with 33 additions and 36 deletions

View File

@ -63,7 +63,6 @@ data Options = Options
, optCache :: Bool
, optUrlSource :: Maybe URI
, optNoVerify :: Bool
, optPlatform :: Maybe PlatformRequest
-- commands
, optCommand :: Command
}
@ -86,7 +85,8 @@ data InstallCommand = InstallGHC InstallOptions
| InstallCabal InstallOptions
data InstallOptions = InstallOptions
{ instVer :: Maybe ToolVersion
{ instVer :: Maybe ToolVersion
, instPlatform :: Maybe PlatformRequest
}
data SetGHCOptions = SetGHCOptions
@ -146,18 +146,6 @@ opts =
(short 'n' <> long "no-verify" <> help
"Skip tarball checksum verification (default: False)"
)
<*> (optional
(option
(eitherReader platformParser)
( short 'p'
<> long "platform"
<> metavar "PLATFORM"
<> help
"Override for platform (triple matching ghc tarball names), e.g. x86_64-fedora27-linux"
<> internal
)
)
)
<*> com
where
parseUri s' =
@ -248,7 +236,21 @@ installP = subparser
)
installOpts :: Parser InstallOptions
installOpts = InstallOptions <$> optional toolVersionParser
installOpts =
InstallOptions
<$> optional toolVersionParser
<*> (optional
(option
(eitherReader platformParser)
( short 'p'
<> long "platform"
<> metavar "PLATFORM"
<> help
"Override for platform (triple matching ghc tarball names), e.g. x86_64-fedora27-linux"
)
)
)
setGHCOpts :: Parser SetGHCOptions
setGHCOpts = SetGHCOptions <$> optional toolVersionParser
@ -612,7 +614,7 @@ main = do
void
$ (runInstTool $ do
v <- liftE $ fromVersion dls instVer GHC
liftE $ installGHCBin dls v optPlatform
liftE $ installGHCBin dls v instPlatform
)
>>= \case
VRight _ -> runLogger
@ -635,7 +637,7 @@ Check the logs at ~/.ghcup/logs and the build directory #{tmpdir} for more clues
void
$ (runInstTool $ do
v <- liftE $ fromVersion dls instVer Cabal
liftE $ installCabalBin dls v optPlatform
liftE $ installCabalBin dls v instPlatform
)
>>= \case
VRight _ -> runLogger

View File

@ -140,12 +140,7 @@ installGHCBin bDls ver mpfReq = do
[rel|ghc-configure.log|]
(Just path)
Nothing
lEM $ liftIO $ execLogged [s|make|]
True
[[s|install|]]
[rel|ghc-make.log|]
(Just path)
Nothing
lEM $ liftIO $ make [[s|install|]] (Just path)
pure ()
@ -541,20 +536,11 @@ GhcWithLlvmCodeGen = YES|]
lift
$ $(logInfo)
[i|Building (this may take a while)... Run 'tail -f ~/.ghcup/logs/ghc-make.log' to see the progress.|]
lEM $ liftIO $ execLogged [s|make|]
True
(maybe [] (\j -> [[s|-j|] <> fS (show j)]) jobs)
[rel|ghc-make.log|]
(Just workdir)
Nothing
lEM $ liftIO $ make (maybe [] (\j -> [[s|-j|] <> fS (show j)]) jobs)
(Just workdir)
lift $ $(logInfo) [i|Installing...|]
lEM $ liftIO $ execLogged [s|make|]
True
[[s|install|]]
[rel|ghc-make.log|]
(Just workdir)
Nothing
lEM $ liftIO $ make [[s|install|]] (Just workdir)
markSrcBuilt ghcdir workdir = do
let dest = (ghcdir </> ghcUpSrcBuiltFile)

View File

@ -44,7 +44,7 @@ import Prelude hiding ( abs
)
import Safe
import System.IO.Error
import System.Posix.FilePath ( takeFileName )
import System.Posix.FilePath ( getSearchPath, takeFileName )
import System.Posix.Files.ByteString ( readSymbolicLink )
import URI.ByteString
@ -325,3 +325,12 @@ ghcToolFiles ver = do
-- this GHC was built from source. It contains the build config.
ghcUpSrcBuiltFile :: Path Rel
ghcUpSrcBuiltFile = [rel|.ghcup_src_built|]
-- | Calls gmake if it exists in PATH, otherwise make.
make :: [ByteString] -> Maybe (Path Abs) -> IO (Either ProcessError ())
make args workdir = do
spaths <- catMaybes . fmap parseAbs <$> getSearchPath
has_gmake <- isJust <$> searchPath spaths [rel|gmake|]
let mymake = if has_gmake then [s|gmake|] else [s|make|]
execLogged mymake True args [rel|ghc-make.log|] workdir Nothing