Commit d021ffc3 authored by Alp Mestanogullari's avatar Alp Mestanogullari Committed by Andrey Mokhov

Generic library rules (#571)

* wip

* debugging output

* Compute ProjectVersion on demand ONLY!

* remove debugging output, boot with --hadrian

* go back to using -c everywhere in .travis.yml

* prioritise libgmp.a rule over catch-all *.a rule, to avoid conflict

* add missing import

* tentative fix for the appveyor script

* use backslashes in appveyor.yml

* less 'cd'ing around in appveyor.yml

* address most of @snowleopard's feedback

* address last bit of feedback
parent 5276bf54
......@@ -17,10 +17,8 @@ matrix:
- PATH="/opt/cabal/2.0/bin:$PATH"
script:
# boot & configure ghc source tree
- ./boot && ./configure
# Run internal Hadrian tests
- hadrian/build.sh selftest
# Run internal Hadrian tests, after boot and configure.
- hadrian/build.sh -c selftest
- os: linux
env: MODE="--flavour=quickest"
......@@ -38,11 +36,8 @@ matrix:
- PATH="/opt/cabal/2.0/bin:$PATH"
script:
# boot & configure ghc source tree
- ./boot && ./configure
# Build GHC, letting hadrian boot & configure the ghc source tree
- hadrian/build.sh -j $MODE --no-progress --progress-colour=never --profile=-
- hadrian/build.sh -c -j $MODE --no-progress --progress-colour=never --profile=-
- os: linux
env: MODE="--flavour=quickest --integer-simple"
......@@ -60,11 +55,8 @@ matrix:
- PATH="/opt/cabal/2.2/bin:$PATH"
script:
# boot & configure ghc source tree
- ./boot && ./configure
# build GHC
- hadrian/build.sh -j $MODE --no-progress --progress-colour=never --profile=-
# boot, configure and build GHC
- hadrian/build.sh -c -j $MODE --no-progress --progress-colour=never --profile=-
# Test GHC binary
- _build/stage1/bin/ghc -e 1+2
......@@ -78,9 +70,6 @@ matrix:
- brew upgrade python
script:
# boot and configure ghc source tree
- ./boot && ./configure
# Due to timeout limit of OS X build on Travis CI,
# we will ignore selftest and build only stage1
- hadrian/build.sh -j -c $MODE --no-progress --progress-colour=never --profile=-
......
......@@ -34,11 +34,9 @@ build_script:
- cd ..
- hadrian\stack exec -- python3 boot
- hadrian\stack exec -- bash configure --enable-distro-toolchain
- cd hadrian
# Build GHC
- build -j --flavour=quickest --integer-simple --no-progress --progress-colour=never --profile=-
- hadrian\build -j --flavour=quickest --integer-simple --no-progress --progress-colour=never --profile=-
# Test GHC binary
- cd ..
- _build/stage1/bin/ghc -e 1+2
- _build\stage1\bin\ghc -e 1+2
......@@ -118,6 +118,7 @@ executable hadrian
, directory >= 1.2 && < 1.4
, extra >= 1.4.7
, mtl == 2.2.*
, parsec >= 3.1 && < 3.2
, QuickCheck >= 2.6 && < 2.11
, shake == 0.16.*
, transformers >= 0.4 && < 0.6
......
......@@ -98,12 +98,15 @@ packageRules = do
let contexts = liftM3 Context allStages knownPackages allWays
vanillaContexts = liftM2 vanillaContext allStages knownPackages
forM_ contexts $ mconcat
[ Rules.Compile.compilePackage readPackageDb
, Rules.Library.buildPackageLibrary ]
-- TODO: we might want to look into converting more and more
-- rules to the style introduced in Rules.Library in
-- https://github.com/snowleopard/hadrian/pull/571,
-- where "catch-all" rules are used to "catch" the need
-- for library files, and we then use parsec parsers to
-- extract all sorts of information needed to build them, like
-- the package, the stage, the way, etc.
let dynamicContexts = liftM3 Context [Stage1 ..] knownPackages [dynamic]
forM_ dynamicContexts Rules.Library.buildDynamicLib
forM_ contexts (Rules.Compile.compilePackage readPackageDb)
Rules.Program.buildProgram readPackageDb
......@@ -118,7 +121,6 @@ packageRules = do
[ Rules.PackageData.buildPackageData
, Rules.Dependencies.buildPackageDependencies readPackageDb
, Rules.Documentation.buildPackageDocumentation
, Rules.Library.buildPackageGhciLibrary
, Rules.Generate.generatePackageCode ]
buildRules :: Rules ()
......@@ -129,6 +131,7 @@ buildRules = do
Rules.Generate.generateRules
Rules.Gmp.gmpRules
Rules.Libffi.libffiRules
Rules.Library.libraryRules
packageRules
oracleRules :: Rules ()
......
......@@ -12,6 +12,7 @@ import Utilities
configureRules :: Rules ()
configureRules = do
-- TODO: consider other files we should track here (rts/rts.cabal etc)
[configFile, "settings", configH, "compiler/ghc.cabal"] &%> \outs -> do
skip <- not <$> cmdConfigure
if skip
......@@ -40,4 +41,4 @@ configureRules = do
need ["configure.ac"]
putBuild "| Running boot..."
verbosity <- getVerbosity
quietly $ cmd [EchoStdout (verbosity >= Loud)] "python3 boot"
quietly $ cmd [EchoStdout (verbosity >= Loud)] "python3 boot --hadrian"
......@@ -66,8 +66,9 @@ gmpRules = do
copyFile (gmpPath -/- "gmp.h") header
copyFile (gmpPath -/- "gmp.h") (gmpPath -/- gmpLibraryInTreeH)
-- Build in-tree GMP library
root <//> gmpLibrary %> \lib -> do
-- Build in-tree GMP library, prioritised so that it matches "before"
-- the generic .a library rule in Rules.Library, whenever applicable.
priority 2.0 $ root <//> gmpLibrary %> \lib -> do
gmpPath <- gmpBuildPath
build $ target gmpContext (Make gmpPath) [gmpPath -/- "Makefile"] [lib]
putSuccess "| Successfully built custom library 'gmp'"
......
......@@ -51,7 +51,9 @@ libffiRules = do
libffiPath <- libffiBuildPath
need [libffiPath -/- libffiLibrary]
root <//> libffiLibrary %> \_ -> do
-- we set a higher priority because this overlaps
-- with the static lib rule from Rules.Library.libraryRules.
priority 2.0 $ root <//> libffiLibrary %> \_ -> do
useSystemFfi <- flag UseSystemFfi
rtsPath <- rtsBuildPath
if useSystemFfi
......
This diff is collapsed.
......@@ -22,8 +22,6 @@ packageArgs = do
gmpBuildPath <- expr gmpBuildPath
let includeGmp = "-I" ++ gmpBuildPath -/- "include"
version <- getSetting ProjectVersion
mconcat
[ package base
? mconcat [ builder CabalFlags ? arg ('+':integerLibraryName)
......@@ -119,7 +117,9 @@ packageArgs = do
arg ("--configure-option=CFLAGS=" ++ includeGmp)
, arg ("--gcc-options=" ++ includeGmp) ] ]
, package runGhc
? builder Ghc ? input "//Main.hs" ? pure ["-cpp", "-DVERSION=" ++ show version]
? builder Ghc
? input "//Main.hs"
? (\version -> ["-cpp", "-DVERSION=" ++ show version]) <$> getSetting ProjectVersion
, package rts
? builder CabalFlags ? (any (wayUnit Profiling) rtsWays) ? arg "profiling"
]
module Way (
WayUnit (..), Way, wayUnit, removeWayUnit, wayFromUnits, allWays,
WayUnit (..), Way, wayUnit, addWayUnit, removeWayUnit, wayFromUnits, allWays,
vanilla, profiling, dynamic, profilingDynamic, threaded, debug, logging,
threadedDebug, threadedProfiling, threadedLogging, threadedDynamic,
......
......@@ -57,6 +57,10 @@ wayToUnits (Way set) = map toEnum . Set.elems $ set
wayUnit :: WayUnit -> Way -> Bool
wayUnit unit (Way set) = fromEnum unit `Set.member` set
-- | Add a 'WayUnit' to a 'Way'
addWayUnit :: WayUnit -> Way -> Way
addWayUnit unit (Way set) = Way . Set.insert (fromEnum unit) $ set
-- | Remove a 'WayUnit' from 'Way'.
removeWayUnit :: WayUnit -> Way -> Way
removeWayUnit unit (Way set) = Way . Set.delete (fromEnum unit) $ set
......
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