Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Drop support for lib0 libraries
Browse files Browse the repository at this point in the history
See #573
  • Loading branch information
snowleopard committed Apr 16, 2018
1 parent 32e26b0 commit 4983458
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 34 deletions.
15 changes: 3 additions & 12 deletions src/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ module Context (
withHsPackage,

-- * Paths
contextDir, buildPath, buildDir,
pkgInplaceConfig, pkgSetupConfigFile,
pkgHaddockFile, pkgLibraryFile, pkgLibraryFile0, pkgGhciLibraryFile,
pkgConfFile, objectPath, contextPath, getContextPath,
libDir, libPath
contextDir, buildPath, buildDir, pkgInplaceConfig, pkgSetupConfigFile,
pkgHaddockFile, pkgLibraryFile, pkgGhciLibraryFile, pkgConfFile, objectPath,
contextPath, getContextPath, libDir, libPath
) where

import Base
Expand Down Expand Up @@ -101,13 +99,6 @@ pkgLibraryFile context@Context {..} = do
extension <- libsuf way
pkgFile context "libHS" extension

-- | Path to the auxiliary library file of a given 'Context', e.g.:
-- @_build/stage1/compiler/build/libHSghc-8.1-0.a@.
pkgLibraryFile0 :: Context -> Action FilePath
pkgLibraryFile0 context@Context {..} = do
extension <- libsuf way
pkgFile context "libHS" ("-0" ++ extension)

-- | Path to the GHCi library file of a given 'Context', e.g.:
-- @_build/stage1/libraries/array/build/HSarray-0.5.1.0.o@.
pkgGhciLibraryFile :: Context -> Action FilePath
Expand Down
20 changes: 8 additions & 12 deletions src/Rules/Library.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Expression hiding (way, package)
import Flavour
import GHC.Packages
import Oracles.ModuleFiles
import Oracles.Setting
import Rules.Gmp
import Settings
import Target
Expand Down Expand Up @@ -60,8 +59,8 @@ buildDynamicLib :: Context -> Rules ()
buildDynamicLib context@Context{..} = do
root <- buildRootRules
pkgId <- case pkgCabalFile package of
Just file -> liftIO $ parseCabalPkgId file
Nothing -> return (pkgName package)
Just file -> liftIO $ parseCabalPkgId file
Nothing -> return $ pkgName package
let libPrefix = root -/- buildDir context -/- "libHS" ++ pkgId
-- OS X
libPrefix ++ "*.dylib" %> buildDynamicLibUnix
Expand All @@ -79,20 +78,17 @@ buildPackageLibrary :: Context -> Rules ()
buildPackageLibrary context@Context {..} = do
root <- buildRootRules
pkgId <- case pkgCabalFile package of
Just file -> liftIO (parseCabalPkgId file)
Nothing -> return (pkgName package)
Just file -> liftIO (parseCabalPkgId file)
Nothing -> return (pkgName package)
let libPrefix = root -/- buildDir context -/- "libHS" ++ pkgId
archive = libPrefix ++ (waySuffix way <.> "a")
archive %%> \a -> do
objs <- libraryObjects context
asuf <- libsuf way
let isLib0 = ("//*-0" ++ asuf) ?== a
removeFile a
if isLib0 then build $ target context (Ar Pack stage) [] [a] -- TODO: Scan for dlls
else build $ target context (Ar Pack stage) objs [a]
build $ target context (Ar Pack stage) objs [a]

synopsis <- pkgSynopsis context
unless isLib0 . putSuccess $ renderLibrary
putSuccess $ renderLibrary
(quote (pkgName package) ++ " (" ++ show stage ++ ", way "
++ show way ++ ").") a synopsis

Expand All @@ -101,13 +97,13 @@ buildPackageLibrary context@Context {..} = do
buildPackageGhciLibrary :: Context -> Rules ()
buildPackageGhciLibrary context@Context {..} = priority 2 $ do
root <- buildRootRules
-- TODO: Get rid of code duplication for 'pkgId'.
pkgId <- case pkgCabalFile package of
Just file -> liftIO $ parseCabalPkgId file
Nothing -> return $ pkgName package

let libPrefix = root -/- buildDir context -/- "HS" ++ pkgId
o = libPrefix ++ "*" ++ (waySuffix way <.> "o")
o %> \obj -> do
libPrefix ++ "*" ++ (waySuffix way <.> "o") %> \obj -> do
objs <- allObjects context
need objs
build $ target context (Ld stage) objs [obj]
Expand Down
11 changes: 1 addition & 10 deletions src/Utilities.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import Hadrian.Utilities

import Context
import Expression hiding (stage)
import GHC.Packages
import Oracles.Setting (windowsHost)
import Settings
import Target

Expand Down Expand Up @@ -67,18 +65,11 @@ stage1Dependencies =
libraryTargets :: Bool -> Context -> Action [FilePath]
libraryTargets includeGhciLib context = do
libFile <- pkgLibraryFile context
lib0File <- pkgLibraryFile0 context
lib0 <- buildDll0 context
ghciLib <- pkgGhciLibraryFile context
ghci <- if includeGhciLib
then interpretInContext context $ getPackageData PD.buildGhciLib
else return False
return $ [ libFile ] ++ [ lib0File | lib0 ] ++ [ ghciLib | ghci ]

where buildDll0 :: Context -> Action Bool
buildDll0 Context {..} = do
windows <- windowsHost
return $ windows && stage == Stage1 && package == compiler
return $ [ libFile ] ++ [ ghciLib | ghci ]

-- | Coarse-grain 'need': make sure all given libraries are fully built.
needLibrary :: [Context] -> Action ()
Expand Down

0 comments on commit 4983458

Please sign in to comment.