diff options
author | Alp Mestanogullari <alp@well-typed.com> | 2020-05-28 08:07:26 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-05-29 01:42:36 -0400 |
commit | f9a513e064bd8a33ad6f8aa5fb8673931507eca1 (patch) | |
tree | 212a36b1dcfd582a8bbd86dba6600e821e64880d | |
parent | 998450f4c67e8f701455927c9619b8d53f2b733b (diff) | |
download | haskell-f9a513e064bd8a33ad6f8aa5fb8673931507eca1.tar.gz |
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.
-rw-r--r-- | hadrian/README.md | 13 | ||||
-rw-r--r-- | hadrian/src/CommandLine.hs | 13 | ||||
-rw-r--r-- | hadrian/src/Rules/BinaryDist.hs | 13 |
3 files changed, 38 insertions, 1 deletions
diff --git a/hadrian/README.md b/hadrian/README.md index d0efb853f7..6a9346b997 100644 --- a/hadrian/README.md +++ b/hadrian/README.md @@ -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 diff --git a/hadrian/src/CommandLine.hs b/hadrian/src/CommandLine.hs index 82f25efb6a..5446fda574 100644 --- a/hadrian/src/CommandLine.hs +++ b/hadrian/src/CommandLine.hs @@ -1,7 +1,8 @@ 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 diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs index d52e0c847c..6b1bad005c 100644 --- a/hadrian/src/Rules/BinaryDist.hs +++ b/hadrian/src/Rules/BinaryDist.hs @@ -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 |