Commit f9a513e0 authored by Alp Mestanogullari's avatar Alp Mestanogullari 🦑 Committed by Marge Bot

hadrian: introduce 'install' target

Its logic is very simple. It `need`s the `binary-dist-dir` target
and runs suitable `configure` and `make install` commands for the
user. A new `--prefix` command line argument is introduced to
specify where GHC should be installed.
parent 998450f4
Pipeline #20062 passed with stages
in 767 minutes and 25 seconds
......@@ -258,6 +258,19 @@ $ ./configure [--prefix=PATH] && make install
workflow, for now.
### Building and installing GHC
You can get Hadrian to build _and_ install a binary distribution in one go
with the following command:
``` sh
$ build install --prefix=/some/absolute/path
```
This builds everything that would be shipped in a bindist, without creating
the archive, and just runs `./configure --prefix=PATH` and `make install`
to get GHC installed installed at `/some/absolute/path`.
#### Building Stage3
It is possible to define a build flavour that builds a Stage3 compiler, which is
......
module CommandLine (
optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2,
cmdIntegerSimple, cmdProgressInfo, cmdConfigure, cmdCompleteSetting,
cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs
cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs,
cmdPrefix
) where
import Data.Either
......@@ -30,6 +31,7 @@ data CommandLineArgs = CommandLineArgs
, buildRoot :: BuildRoot
, testArgs :: TestArgs
, docTargets :: DocTargets
, prefix :: Maybe FilePath
, completeStg :: Maybe String }
deriving (Eq, Show)
......@@ -45,6 +47,7 @@ defaultCommandLineArgs = CommandLineArgs
, buildRoot = BuildRoot "_build"
, testArgs = defaultTestArgs
, docTargets = Set.fromList [minBound..maxBound]
, prefix = Nothing
, completeStg = Nothing }
-- | These arguments are used by the `test` target.
......@@ -207,6 +210,9 @@ readBrokenTests way =
let newTests = words tests ++ brokenTests (testArgs flags)
in flags { testArgs = (testArgs flags) {brokenTests = newTests} }
readPrefix :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readPrefix ms = Right $ \flags -> flags { prefix = ms }
readCompleteStg :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readCompleteStg ms = Right $ \flags -> flags { completeStg = ms }
......@@ -281,6 +287,8 @@ optDescrs =
, Option [] ["broken-test"] (OptArg readBrokenTests "TEST_NAME")
"consider these tests to be broken"
, Option ['a'] ["test-accept"] (NoArg readTestAccept) "Accept new output of tests"
, Option [] ["prefix"] (OptArg readPrefix "PATH")
"Destination path for the bindist 'install' rule"
, Option [] ["complete-setting"] (OptArg readCompleteStg "SETTING")
"Setting key to autocomplete, for the 'autocomplete' target."
]
......@@ -332,6 +340,9 @@ cmdConfigure = configure <$> cmdLineArgs
cmdFlavour :: Action (Maybe String)
cmdFlavour = flavour <$> cmdLineArgs
cmdPrefix :: Action (Maybe String)
cmdPrefix = prefix <$> cmdLineArgs
cmdCompleteSetting :: Action (Maybe String)
cmdCompleteSetting = completeStg <$> cmdLineArgs
......
......@@ -2,6 +2,7 @@ module Rules.BinaryDist where
import Hadrian.Haskell.Cabal
import CommandLine
import Context
import Expression
import Oracles.Setting
......@@ -98,6 +99,18 @@ other, the install script:
bindistRules :: Rules ()
bindistRules = do
root <- buildRootRules
phony "install" $ do
need ["binary-dist-dir"]
version <- setting ProjectVersion
targetPlatform <- setting TargetPlatformFull
let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty
prefixErr = "You must specify a path with --prefix when using the"
++ " 'install' rule"
installPrefix <- fromMaybe (error prefixErr) <$> cmdPrefix
runBuilder (Configure bindistFilesDir) ["--prefix="++installPrefix] [] []
runBuilder (Make bindistFilesDir) ["install"] [] []
phony "binary-dist-dir" $ do
-- We 'need' all binaries and libraries
targets <- mapM pkgTarget =<< stagePackages Stage1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment