-
Notifications
You must be signed in to change notification settings - Fork 37
WIP: Relocation based build (inplace free) #445
Changes from 156 commits
f10e62b
c4a297b
1f76250
713617c
cc3ca47
e955497
315b632
b0359ed
1636836
500336f
c99ef5b
0ecb089
89bd0fe
523139e
e41f939
1afd1c2
88a2a2c
3206db3
2fcbde2
a2805b6
8d43007
8ba790d
6977e5f
e096710
966e0c2
7442787
361f4b6
d2a2833
7b38480
afb84ba
fc3c06f
dbb69d9
79dd24c
91ad2d2
dfb361b
93b6f2a
ae97422
256e1f3
a05791b
3ade23d
f49ab6c
d26a5b6
97c60bc
1067d26
cfaf8ea
54ed0e4
9cc5092
e1321ac
926ff3a
8559f25
2ba1ef1
73c9b77
0dcb5dc
9aa2ace
66c776d
daec6c9
191430b
1934788
37b6b91
7d95f46
944c894
90dd2fb
a02a9ff
25fedd8
02df95c
3765f80
311b9a6
0b3d01a
32c4489
e5cf931
e87768a
e264555
a283101
4905eef
8c6ac16
9869a60
8819da9
799e5bd
2d6bf90
8e83afd
efc8bc7
ee6f407
d3a0dc0
19d984b
011ea7a
afac41c
44e1988
b16999a
649f455
9b38535
acc5e7b
615192d
e75834c
06c2969
ab61392
776ad49
40c3424
12a0c56
d732756
d512b30
94d8ab9
c5e465c
b38fcd4
5de0279
f34c547
788214a
2d72f8e
a0d0728
02e9db0
fe47851
7b37f15
0253a7d
15f2c7f
01f5ebd
3a357f7
aa81fd1
da424b3
764d008
610351a
36a0356
1e9fd7c
66b1c43
b920077
3387b7f
681128e
d5a7983
8ebbd32
7d5bfac
6633cb7
c14cf2c
cc5f8a9
e2ab408
5907f14
cde14be
aab96a3
e5fbb95
92f4077
d47fab7
796a118
6cfbc68
2bcd5ab
9f17f3a
70b8c95
9f4362a
274b135
b1e3969
e648dc3
466e4a3
4bcdcbe
711a083
a8f4526
648b2d2
7260f74
142e89c
225139d
6474251
ff7fc80
20b0604
165bb85
5597d62
b94742a
341d962
cdf1c4c
9de3df3
38a9163
e75827e
ab0a138
c26cba3
38d20e1
6f9a823
b73601a
ad87a29
00b6927
cf8934a
268696c
0f5c3ca
987c77c
7272bcb
4ae7d9a
858ffed
f38d55f
e027f8f
c6ffd66
bef861d
acb0955
09a801b
bbed8e3
d1e5501
4c3cf61
940822b
5cdc9fb
0d20aa0
d403356
6de8bcc
d1faf55
70bbb77
b9cef84
4983bd6
ef6f26c
1a6d1f9
8a9d800
c6836fa
27896d4
d32a251
b990b24
8e0ff6a
fbbab87
26840be
2f66255
1239701
323212d
6c401cf
4374154
4af3d50
580c8a8
7b47daf
84810b6
13989a1
b81a0fb
19980b7
6b1d22d
65872d2
0355054
f7db9b4
e3d27af
9505159
f0a39fd
674a286
025197c
40709cc
709c178
b5d8e2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "shake"] | ||
path = shake | ||
url = https://github.com/ndmitchell/shake.git | ||
[submodule "happy"] | ||
path = happy | ||
url = https://github.com/simonmar/happy.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
{-# LANGUAGE InstanceSigs #-} | ||
module Builder ( | ||
-- * Data types | ||
ArMode (..), CcMode (..), GhcMode (..), GhcPkgMode (..), HaddockMode (..), | ||
ArMode (..), CcMode (..), GhcCabalMode (..), GhcMode (..), GhcPkgMode (..), HaddockMode (..), | ||
SphinxMode (..), TarMode (..), Builder (..), | ||
|
||
builderPath', | ||
|
||
-- * Builder properties | ||
builderProvenance, systemBuilderPath, builderPath, isSpecified, needBuilder, | ||
runBuilder, runBuilderWith, runBuilderWithCmdOptions, getBuilderPath, | ||
|
@@ -46,15 +48,23 @@ instance NFData CcMode | |
-- * Compile a C source file. | ||
-- * Extract source dependencies by passing @-M@ command line argument. | ||
-- * Link object files & static libraries into an executable. | ||
data GhcMode = CompileHs | CompileCWithGhc | FindHsDependencies | LinkHs | ||
data GhcMode = Settings | CompileHs | CompileCWithGhc | FindHsDependencies | LinkHs | ||
deriving (Eq, Generic, Show) | ||
|
||
instance Binary GhcMode | ||
instance Hashable GhcMode | ||
instance NFData GhcMode | ||
|
||
-- | GHC cabal mode. Can configure, copy and register pacakges. | ||
data GhcCabalMode = Conf | Copy | Reg | HsColour | Check | Sdist | ||
deriving (Eq, Generic, Show) | ||
|
||
instance Binary GhcCabalMode | ||
instance Hashable GhcCabalMode | ||
instance NFData GhcCabalMode | ||
|
||
-- | GhcPkg can initialise a package database and register packages in it. | ||
data GhcPkgMode = Init | Update deriving (Eq, Generic, Show) | ||
data GhcPkgMode = Init | Update | Clone | Dependencies deriving (Eq, Generic, Show) | ||
|
||
instance Binary GhcPkgMode | ||
instance Hashable GhcPkgMode | ||
|
@@ -82,13 +92,13 @@ data Builder = Alex | |
| GenApply | ||
| GenPrimopCode | ||
| Ghc GhcMode Stage | ||
| GhcCabal | ||
| GhcCabal GhcCabalMode Stage | ||
| GhcPkg GhcPkgMode Stage | ||
| Haddock HaddockMode | ||
| Happy | ||
| Hpc | ||
| HsCpp | ||
| Hsc2Hs | ||
| Hsc2Hs Stage | ||
| Ld | ||
| Make FilePath | ||
| Nm | ||
|
@@ -100,6 +110,8 @@ data Builder = Alex | |
| Tar TarMode | ||
| Unlit | ||
| Xelatex | ||
| CabalFlags Stage -- ^ a virtual builder to use the Arg predicate logic | ||
-- to collect cabal flags. +x, -x | ||
deriving (Eq, Generic, Show) | ||
|
||
instance Binary Builder | ||
|
@@ -116,17 +128,20 @@ builderProvenance = \case | |
GenPrimopCode -> context Stage0 genprimopcode | ||
Ghc _ Stage0 -> Nothing | ||
Ghc _ stage -> context (pred stage) ghc | ||
GhcCabal -> context Stage0 ghcCabal | ||
GhcCabal _ _ -> context Stage1 ghcCabal | ||
GhcPkg _ Stage0 -> Nothing | ||
GhcPkg _ _ -> context Stage0 ghcPkg | ||
Haddock _ -> context Stage2 haddock | ||
Hpc -> context Stage1 hpcBin | ||
Hsc2Hs -> context Stage0 hsc2hs | ||
Haddock _ -> context Stage1 haddock | ||
Hpc -> context Stage0 hpcBin | ||
Hsc2Hs _ -> context Stage0 hsc2hs | ||
Unlit -> context Stage0 unlit | ||
_ -> Nothing | ||
where | ||
context s p = Just $ vanillaContext s p | ||
|
||
builderPath' :: Builder -> Action FilePath | ||
builderPath' = builderPath | ||
|
||
instance H.Builder Builder where | ||
builderPath :: Builder -> Action FilePath | ||
builderPath builder = case builderProvenance builder of | ||
|
@@ -138,10 +153,35 @@ instance H.Builder Builder where | |
path <- H.builderPath builder | ||
case builder of | ||
Configure dir -> need [dir -/- "configure"] | ||
Hsc2Hs -> need [path, templateHscPath] | ||
Hsc2Hs stage -> templateHscPath stage >>= \tmpl -> need [path, tmpl] | ||
Make dir -> need [dir -/- "Makefile"] | ||
_ -> when (isJust $ builderProvenance builder) $ need [path] | ||
|
||
-- TODO: We would need to encode that asking a builder, | ||
-- depending on the "ask" mode, has different return types. | ||
-- For now it's the stdout string. | ||
-- | ||
-- This however means that the string -> datatype logic | ||
-- needs to reside at the callsite. | ||
askBuilderWith :: Builder -> BuildInfo -> Action String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These needs some documentation. The name doesn't do much to suggest what this is supposed to do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have to check if this is still used of if we can just get rid of it altogether. The idea was that you can not only use a builder to do something, but also ask a builder. E.g. ask There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree that having a more descriptive type would help a lot |
||
askBuilderWith builder BuildInfo {..} = case builder of | ||
Ghc Settings _ -> do | ||
needBuilder builder | ||
path <- H.builderPath builder | ||
need [path] | ||
Stdout stdout <- cmd [path] ["--info"] | ||
return stdout | ||
|
||
GhcPkg Dependencies _ -> do | ||
let input = fromSingleton msgIn buildInputs | ||
msgIn = "[askBuilder] Exactly one input file expected." | ||
needBuilder builder | ||
path <- H.builderPath builder | ||
need [path] | ||
Stdout stdout <- cmd [path] ["--no-user-package-db", "field", input, "depends"] | ||
return stdout | ||
_ -> error $ "Builder " ++ show builder ++ " can not be asked!" | ||
|
||
runBuilderWith :: Builder -> BuildInfo -> Action () | ||
runBuilderWith builder BuildInfo {..} = do | ||
path <- builderPath builder | ||
|
@@ -190,7 +230,12 @@ instance H.Builder Builder where | |
unit $ cmd [Cwd output] [path] buildArgs | ||
unit $ cmd [Cwd output] [path] buildArgs | ||
|
||
_ -> cmd echo [path] buildArgs | ||
GhcPkg Clone _ -> do | ||
-- input is "virtual" here. it's essentially a package name | ||
Stdout pkgDesc <- cmd [path] ["--expand-pkgroot", "--no-user-package-db", "describe", input ] | ||
cmd (Stdin pkgDesc) [path] (buildArgs ++ ["-"]) | ||
|
||
_ -> cmd echo [path] buildOptions buildArgs | ||
|
||
-- TODO: Some builders are required only on certain platforms. For example, | ||
-- 'Objdump' is only required on OpenBSD and AIX. Add support for platform | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module Builder where | ||
|
||
import Stage | ||
import Hadrian.Builder.Ar | ||
import Hadrian.Builder.Sphinx | ||
import Hadrian.Builder.Tar | ||
import Development.Shake | ||
|
||
data CcMode = CompileC | FindCDependencies | ||
data GhcMode = Settings | CompileHs | CompileCWithGhc | FindHsDependencies | LinkHs | ||
data GhcCabalMode = Conf | Copy | Reg | HsColour | Check | Sdist | ||
data GhcPkgMode = Init | Update | Clone | Dependencies | ||
data HaddockMode = BuildPackage | BuildIndex | ||
data Builder = Alex | ||
| Ar ArMode Stage | ||
| DeriveConstants | ||
| Cc CcMode Stage | ||
| Configure FilePath | ||
| GenApply | ||
| GenPrimopCode | ||
| Ghc GhcMode Stage | ||
| GhcCabal GhcCabalMode Stage | ||
| GhcPkg GhcPkgMode Stage | ||
| Haddock HaddockMode | ||
| Happy | ||
| Hpc | ||
| HsCpp | ||
| Hsc2Hs Stage | ||
| Ld | ||
| Make FilePath | ||
| Nm | ||
| Objdump | ||
| Patch | ||
| Perl | ||
| Ranlib | ||
| Sphinx SphinxMode | ||
| Tar TarMode | ||
| Unlit | ||
| Xelatex | ||
| CabalFlags Stage | ||
|
||
instance Eq Builder | ||
|
||
builderPath' :: Builder -> Action FilePath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to me that these would be better in another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is likely due to history. Initially I tried not to move files around as much as possible, and rather tried to have minimal boot files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document what
Clone
does?