Unverified Commit 0059b9f2 authored by Andrey Mokhov's avatar Andrey Mokhov Committed by GitHub

Clean up remaining bits of the install rule (#660)

#531 removed install rules (`src/Rules/Install.hs`), but left a lot of supporting code that is now unused.

Hopefully, this clean up completes the removal of install rules. If they are ever coming back to Hadrian in any shape, some useful code can be recovered here.

See #540.
parent 8ec50a58
......@@ -24,7 +24,6 @@ system-ghc-pkg = @GhcPkgCmd@
tar = @TarCmd@
patch = @PatchCmd@
perl = @PerlCmd@
ln-s = @LN_S@
xelatex = @XELATEX@
# Python 3 is required to run test driver.
......@@ -127,17 +126,3 @@ ffi-lib-dir = @FFILibDir@
with-libdw = @UseLibdw@
have-lib-mingw-ex = @HaveLibMingwEx@
# Installation:
#=======================
install-prefix = @prefix@
install-bindir = @prefix@/bin
install-libdir = @prefix@/lib
install-datarootdir = @prefix@/share
install = @INSTALL@
install-program = @INSTALL@ -m 755
install-script = @INSTALL@ -m 755
install-data = @INSTALL@ -m 644
install-dir = @INSTALL@ -m 755 -d
......@@ -186,11 +186,9 @@ verboseCommands = return True
## Miscellaneous
By setting `stage1Only = True` you can disable building Stage2 GHC (i.e. the
`ghc-stage2` executable) and Stage2 utilities, such as `haddock`. Note that all
Stage0 and Stage1 libraries (including `compiler`) will still be built. Enabling
this flag during installation leads to installing `ghc-stage1` instead of
`ghc-stage2`, and `ghc-pkg` that was build with the Stage0 compiler.
By setting `stage1Only = True` you can disable building Stage2 GHC and Stage2
utilities such as `haddock`. Note that all Stage0 and Stage1 libraries will
still be built.
To change the default behaviour of Hadrian with respect to building split
objects, override the `splitObjects` setting of the `Flavour` record:
......
......@@ -10,9 +10,8 @@ module Builder (
runBuilder, runBuilderWith, runBuilderWithCmdOptions, getBuilderPath,
builderEnvironment,
-- * Ad hoc builder invokation
applyPatch, installDirectory, installData, installScript, installProgram,
linkSymbolic
-- * Ad hoc builder invocation
applyPatch
) where
import Development.Shake.Classes
......@@ -25,7 +24,6 @@ import Hadrian.Builder.Tar
import Hadrian.Oracles.Path
import Hadrian.Oracles.TextFile
import Hadrian.Utilities
import qualified System.Directory.Extra as IO
import Base
import Context
......@@ -340,46 +338,3 @@ applyPatch dir patch = do
path <- builderPath Patch
putBuild $ "| Apply patch " ++ file
quietly $ cmd [Cwd dir, FileStdin file] [path, "-p0"]
-- | Install a directory.
installDirectory :: FilePath -> Action ()
installDirectory dir = do
path <- fixAbsolutePathOnWindows =<< setting InstallDir
putBuild $ "| Install directory " ++ dir
quietly $ cmd path dir
-- | Install data files to a directory and track them.
installData :: [FilePath] -> FilePath -> Action ()
installData fs dir = do
path <- fixAbsolutePathOnWindows =<< setting InstallData
need fs
forM_ fs $ \f -> putBuild $ "| Install data " ++ f ++ " to " ++ dir
quietly $ cmd path fs dir
-- | Install an executable file to a directory and track it.
installProgram :: FilePath -> FilePath -> Action ()
installProgram f dir = do
path <- fixAbsolutePathOnWindows =<< setting InstallProgram
need [f]
putBuild $ "| Install program " ++ f ++ " to " ++ dir
quietly $ cmd path f dir
-- | Install an executable script to a directory and track it.
installScript :: FilePath -> FilePath -> Action ()
installScript f dir = do
path <- fixAbsolutePathOnWindows =<< setting InstallScript
need [f]
putBuild $ "| Install script " ++ f ++ " to " ++ dir
quietly $ cmd path f dir
-- | Create a symbolic link from source file to target file (when symbolic links
-- are supported) and track the source file.
linkSymbolic :: FilePath -> FilePath -> Action ()
linkSymbolic source target = do
lns <- setting LnS
unless (null lns) $ do
need [source] -- Guarantee source is built before printing progress info.
let dir = takeDirectory target
liftIO $ IO.createDirectoryIfMissing True dir
putProgressInfo =<< renderAction "Create symbolic link" source target
quietly $ cmd lns source target
module CommandLine (
optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, cmdIntegerSimple,
cmdProgressColour, cmdProgressInfo, cmdConfigure, cmdSplitObjects,
cmdInstallDestDir, lookupBuildRoot, TestArgs(..), TestSpeed(..),
defaultTestArgs
lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs
) where
import Data.Either
......@@ -20,7 +19,6 @@ data CommandLineArgs = CommandLineArgs
{ configure :: Bool
, flavour :: Maybe String
, freeze1 :: Bool
, installDestDir :: Maybe String
, integerSimple :: Bool
, progressColour :: UseColour
, progressInfo :: ProgressInfo
......@@ -35,7 +33,6 @@ defaultCommandLineArgs = CommandLineArgs
{ configure = False
, flavour = Nothing
, freeze1 = False
, installDestDir = Nothing
, integerSimple = False
, progressColour = Auto
, progressInfo = Brief
......@@ -91,9 +88,6 @@ readBuildRoot ms =
readFreeze1 :: Either String (CommandLineArgs -> CommandLineArgs)
readFreeze1 = Right $ \flags -> flags { freeze1 = True }
readInstallDestDir :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readInstallDestDir ms = Right $ \flags -> flags { installDestDir = ms }
readIntegerSimple :: Either String (CommandLineArgs -> CommandLineArgs)
readIntegerSimple = Right $ \flags -> flags { integerSimple = True }
......@@ -126,7 +120,7 @@ readSplitObjects :: Either String (CommandLineArgs -> CommandLineArgs)
readSplitObjects = Right $ \flags -> flags { splitObjects = True }
readTestCompiler :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestCompiler compiler = maybe (Left "Cannot parse compiler") (Right . set) compiler
readTestCompiler compiler = maybe (Left "Cannot parse compiler") (Right . set) compiler
where
set compiler = \flags -> flags { testArgs = (testArgs flags) { testCompiler = compiler } }
......@@ -139,10 +133,10 @@ readTestConfig config =
in flags { testArgs = (testArgs flags) { testConfigs = configs } }
readTestConfigFile :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestConfigFile filepath =
readTestConfigFile filepath =
maybe (Left "Cannot parse test-speed") (Right . set) filepath
where
set filepath flags = flags { testArgs = (testArgs flags) { testConfigFile = filepath } }
set filepath flags = flags { testArgs = (testArgs flags) { testConfigFile = filepath } }
readTestJUnit :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestJUnit filepath = Right $ \flags -> flags { testArgs = (testArgs flags) { testJUnit = filepath } }
......@@ -175,13 +169,13 @@ readTestVerbose :: Maybe String -> Either String (CommandLineArgs -> CommandLine
readTestVerbose verbose = Right $ \flags -> flags { testArgs = (testArgs flags) { testVerbosity = verbose } }
readTestWay :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestWay way =
readTestWay way =
case way of
Nothing -> Right id
Just way -> Right $ \flags ->
Just way -> Right $ \flags ->
let newWays = way : testWays (testArgs flags)
in flags { testArgs = (testArgs flags) {testWays = newWays} }
-- | Standard 'OptDescr' descriptions of Hadrian's command line arguments.
optDescrs :: [OptDescr (Either String (CommandLineArgs -> CommandLineArgs))]
optDescrs =
......@@ -193,8 +187,6 @@ optDescrs =
"Build flavour (Default, Devel1, Devel2, Perf, Prof, Quick or Quickest)."
, Option [] ["freeze1"] (NoArg readFreeze1)
"Freeze Stage1 GHC."
, Option [] ["install-destdir"] (OptArg readInstallDestDir "DESTDIR")
"Installation destination directory."
, Option [] ["integer-simple"] (NoArg readIntegerSimple)
"Build GHC with integer-simple library."
, Option [] ["progress-colour"] (OptArg readProgressColour "MODE")
......@@ -225,7 +217,7 @@ optDescrs =
"A verbosity value between 0 and 5. 0 is silent, 4 and higher activates extra output."
, Option [] ["test-way"] (OptArg readTestWay "TEST_WAY")
"only run these ways" ]
-- | A type-indexed map containing Hadrian command line arguments to be passed
-- to Shake via 'shakeExtra'.
cmdLineArgsMap :: IO (Map.HashMap TypeRep Dynamic)
......@@ -253,9 +245,6 @@ lookupBuildRoot = buildRoot . lookupExtra defaultCommandLineArgs
lookupFreeze1 :: Map.HashMap TypeRep Dynamic -> Bool
lookupFreeze1 = freeze1 . lookupExtra defaultCommandLineArgs
cmdInstallDestDir :: Action (Maybe String)
cmdInstallDestDir = installDestDir <$> cmdLineArgs
cmdIntegerSimple :: Action Bool
cmdIntegerSimple = integerSimple <$> cmdLineArgs
......
......@@ -12,7 +12,7 @@ module GHC (
testsuitePackages,
-- * Package information
programName, nonHsMainPackage, autogenPath, installStage,
programName, nonHsMainPackage, autogenPath,
-- * Miscellaneous
programPath, buildDll0, rtsContext, rtsBuildPath, libffiContext,
......@@ -134,16 +134,6 @@ programName Context {..} = do
| p == iserv -> "ghc-iserv"
_ -> pkgName package
-- | The build stage whose results are used when installing a package, or
-- @Nothing@ if the package is not installed, e.g. because it is a user package.
-- The current implementation installs the /latest/ build stage of a package.
installStage :: Package -> Action (Maybe Stage)
installStage pkg
| not (isGhcPackage pkg) = return Nothing -- Only GHC packages are installed
| otherwise = do
stages <- filterM (fmap (pkg `elem`) . defaultPackages) [Stage0 ..]
return $ if null stages then Nothing else Just (maximum stages)
-- | The 'FilePath' to a program executable in a given 'Context'.
programPath :: Context -> Action FilePath
programPath context@Context {..} = do
......
......@@ -3,7 +3,7 @@ module Oracles.Setting (
getSettingList, anyTargetPlatform, anyTargetOs, anyTargetArch, anyHostOs,
ghcWithInterpreter, ghcEnableTablesNextToCode, useLibFFIForAdjustors,
ghcCanonVersion, cmdLineLengthLimit, iosHost, osxHost, windowsHost,
topDirectory, relocatableBuild, installDocDir, installGhcLibDir, libsuf
topDirectory, libsuf
) where
import Hadrian.Expression
......@@ -24,16 +24,24 @@ data Setting = BuildArch
| BuildVendor
| CcClangBackend
| CcLlvmBackend
| CursesLibDir
| DynamicExtension
| FfiIncludeDir
| FfiLibDir
| GhcMajorVersion
| GhcMinorVersion
| GhcPatchLevel
| GhcVersion
| GhcSourcePath
| GmpIncludeDir
| GmpLibDir
| HostArch
| HostOs
| HostPlatform
| HostVendor
| IconvIncludeDir
| IconvLibDir
| LlvmTarget
| ProjectGitCommitId
| ProjectName
| ProjectVersion
......@@ -47,27 +55,6 @@ data Setting = BuildArch
| TargetPlatform
| TargetPlatformFull
| TargetVendor
| LlvmTarget
| FfiIncludeDir
| FfiLibDir
| GmpIncludeDir
| GmpLibDir
| IconvIncludeDir
| IconvLibDir
| CursesLibDir
-- Paths to where GHC is installed (ref: mk/install.mk)
| InstallPrefix
| InstallBinDir
| InstallLibDir
| InstallDataRootDir
-- Command lines for invoking the @install@ utility
| Install
| InstallData
| InstallProgram
| InstallScript
| InstallDir
-- Command line for creating a symbolic link
| LnS
data SettingList = ConfCcArgs Stage
| ConfCppArgs Stage
......@@ -84,16 +71,24 @@ setting key = lookupValueOrError configFile $ case key of
BuildVendor -> "build-vendor"
CcClangBackend -> "cc-clang-backend"
CcLlvmBackend -> "cc-llvm-backend"
CursesLibDir -> "curses-lib-dir"
DynamicExtension -> "dynamic-extension"
FfiIncludeDir -> "ffi-include-dir"
FfiLibDir -> "ffi-lib-dir"
GhcMajorVersion -> "ghc-major-version"
GhcMinorVersion -> "ghc-minor-version"
GhcPatchLevel -> "ghc-patch-level"
GhcVersion -> "ghc-version"
GhcSourcePath -> "ghc-source-path"
GmpIncludeDir -> "gmp-include-dir"
GmpLibDir -> "gmp-lib-dir"
HostArch -> "host-arch"
HostOs -> "host-os"
HostPlatform -> "host-platform"
HostVendor -> "host-vendor"
IconvIncludeDir -> "iconv-include-dir"
IconvLibDir -> "iconv-lib-dir"
LlvmTarget -> "llvm-target"
ProjectGitCommitId -> "project-git-commit-id"
ProjectName -> "project-name"
ProjectVersion -> "project-version"
......@@ -107,24 +102,6 @@ setting key = lookupValueOrError configFile $ case key of
TargetPlatform -> "target-platform"
TargetPlatformFull -> "target-platform-full"
TargetVendor -> "target-vendor"
LlvmTarget -> "llvm-target"
FfiIncludeDir -> "ffi-include-dir"
FfiLibDir -> "ffi-lib-dir"
GmpIncludeDir -> "gmp-include-dir"
GmpLibDir -> "gmp-lib-dir"
IconvIncludeDir -> "iconv-include-dir"
IconvLibDir -> "iconv-lib-dir"
CursesLibDir -> "curses-lib-dir"
InstallPrefix -> "install-prefix"
InstallBinDir -> "install-bindir"
InstallLibDir -> "install-libdir"
InstallDataRootDir -> "install-datarootdir"
Install -> "install"
InstallDir -> "install-dir"
InstallProgram -> "install-program"
InstallScript -> "install-script"
InstallData -> "install-data"
LnS -> "ln-s"
settingList :: SettingList -> Action [String]
settingList key = fmap words $ lookupValueOrError configFile $ case key of
......@@ -190,36 +167,10 @@ ghcCanonVersion = do
let leadingZero = [ '0' | length ghcMinorVersion == 1 ]
return $ ghcMajorVersion ++ leadingZero ++ ghcMinorVersion
-- ref: https://ghc.haskell.org/trac/ghc/wiki/Building/Installing#HowGHCfindsitsfiles
-- | On Windows we normally build a relocatable installation, which assumes that
-- the library directory @libdir@ is in a fixed location relative to the GHC
-- binary, namely @../lib@.
relocatableBuild :: Action Bool
relocatableBuild = windowsHost
installDocDir :: Action String
installDocDir = do
version <- setting ProjectVersion
dataDir <- setting InstallDataRootDir
return $ dataDir -/- ("doc/ghc-" ++ version)
-- | Path to the GHC source tree.
topDirectory :: Action FilePath
topDirectory = fixAbsolutePathOnWindows =<< setting GhcSourcePath
-- ref: mk/install.mk:101
-- TODO: CroosCompilePrefix
-- | Unix: override @libdir@ and @datadir@ to put GHC-specific files in a
-- subdirectory with the version number included.
installGhcLibDir :: Action String
installGhcLibDir = do
rBuild <- relocatableBuild
libdir <- setting InstallLibDir
if rBuild then return libdir
else do
version <- setting ProjectVersion
return $ libdir -/- ("ghc-" ++ version)
-- TODO: find out why we need version number in the dynamic suffix
-- The current theory: dynamic libraries are eventually placed in a single
-- giant directory in the load path of the dynamic linker, and hence we must
......
module Settings (
getArgs, getLibraryWays, getRtsWays, flavour, knownPackages,
findPackageByName, isLibrary, stagePackages,
programContext, getIntegerPackage, getDestDir
findPackageByName, isLibrary, stagePackages, programContext,
getIntegerPackage
) where
import CommandLine
......@@ -64,7 +64,3 @@ knownPackages = sort $ ghcPackages ++ userPackages
-- Note: this is slow but we keep it simple as there are just ~50 packages
findPackageByName :: PackageName -> Maybe Package
findPackageByName name = find (\pkg -> pkgName pkg == name) knownPackages
-- | Install's DESTDIR setting.
getDestDir :: Action FilePath
getDestDir = fromMaybe "" <$> cmdInstallDestDir
......@@ -13,9 +13,8 @@ makeBuilderArgs = do
libffiPath <- expr libffiBuildPath
let t = show $ max 4 (threads - 2) -- Don't use all Shake's threads
mconcat
[ builder (Make gmpPath ) ? pure ["MAKEFLAGS=-j" ++ t]
, builder (Make libffiPath ) ? pure ["MAKEFLAGS=-j" ++ t, "install"]
]
[ builder (Make gmpPath ) ? pure ["MAKEFLAGS=-j" ++ t]
, builder (Make libffiPath) ? pure ["MAKEFLAGS=-j" ++ t, "install"] ]
validateBuilderArgs :: Args
validateBuilderArgs = builder (Make "testsuite/tests") ? do
......@@ -35,8 +34,8 @@ validateBuilderArgs = builder (Make "testsuite/tests") ? do
fullpath :: Package -> Action FilePath
fullpath pkg = programPath =<< programContext Stage1 pkg
-- | Support for speed of validation
-- | Support for speed of validation
setTestSpeed :: TestSpeed -> String
setTestSpeed Fast = "fasttest"
setTestSpeed Average = "test"
setTestSpeed Slow = "slowtest"
setTestSpeed Slow = "slowtest"
......@@ -145,7 +145,7 @@ getTestArgs = do
-- | inputs for these directory also. boilerplate soes not account for this
-- | problem, but simply returns an error. How should we handle such cases?
setBinaryDirectory :: String -> Action FilePath
setBinaryDirectory "stage0" = setting InstallBinDir
setBinaryDirectory "stage0" = takeDirectory <$> setting SystemGhc
setBinaryDirectory "stage1" = liftM2 (-/-) topDirectory (stageBinPath Stage0)
setBinaryDirectory "stage2" = liftM2 (-/-) topDirectory (stageBinPath Stage1)
setBinaryDirectory compiler = pure $ parentPath compiler
......
......@@ -193,8 +193,6 @@ rtsPackageArgs = package rts ? do
libffiName <- expr libffiLibraryName
ffiIncludeDir <- getSetting FfiIncludeDir
ffiLibraryDir <- getSetting FfiLibDir
ghclibDir <- expr installGhcLibDir
destDir <- expr getDestDir
let cArgs = mconcat
[ arg "-Irts"
, rtsWarnings
......@@ -298,13 +296,6 @@ rtsPackageArgs = package rts ? do
, "-DFFI_LIB_DIR=" ++ show ffiLibraryDir
, "-DFFI_LIB=" ++ show libffiName ]
, builder HsCpp ?
input "//package.conf.in" ?
output "//package.conf.install.raw" ?
pure [ "-DINSTALLING"
, "-DLIB_DIR=\"" ++ destDir ++ ghclibDir ++ "\""
, "-DINCLUDE_DIR=\"" ++ destDir ++ ghclibDir -/- "include\"" ]
, builder HsCpp ? flag HaveLibMingwEx ? arg "-DHAVE_LIBMINGWEX" ]
-- Compile various performance-critical pieces *without* -fPIC -dynamic
......
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