-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
more flexible da flavour #215
Changes from 1 commit
a8f52c6
4f3459f
57010e9
84a1599
e550d56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,15 +31,12 @@ main = do | |
<> Opts.progDesc "Build (and possibly upload) ghc-lib and ghc-lib-parser tarballs." | ||
<> Opts.header "CI - CI script for ghc-lib" | ||
) | ||
Options { ghcFlavor, daMergeBaseSha, daPatches, daFlavor, stackOptions } <- Opts.execParser opts | ||
version <- buildDists ghcFlavor stackOptions daMergeBaseSha daPatches daFlavor | ||
Options { ghcFlavor, stackOptions } <- Opts.execParser opts | ||
version <- buildDists ghcFlavor stackOptions | ||
putStrLn version | ||
|
||
data Options = Options | ||
{ ghcFlavor :: GhcFlavor | ||
, daMergeBaseSha :: String | ||
, daPatches :: [String] | ||
, daFlavor :: String | ||
, stackOptions :: StackOptions | ||
} deriving (Show) | ||
|
||
|
@@ -51,7 +48,15 @@ data StackOptions = StackOptions | |
, ghcOptions :: Maybe String -- If 'Just _', pass '--ghc-options="xxx"' to 'stack build' (for ghc verbose, try 'v3'). | ||
} deriving (Show) | ||
|
||
data GhcFlavor = Ghc8101 | Ghc881 | Ghc882 | Ghc883 | Da | GhcMaster String | ||
data GhcFlavor = Ghc8101 | ||
| Ghc881 | ||
| Ghc882 | ||
| Ghc883 | ||
| Da { mergeBaseSha :: String | ||
, patches :: [String] | ||
, flavor :: String | ||
} | ||
| GhcMaster String | ||
deriving (Eq, Show) | ||
|
||
-- Last tested gitlab.haskell.org/ghc/ghc.git at | ||
|
@@ -70,13 +75,13 @@ stackResolverOpt = \case | |
Just resolver -> "--resolver " ++ resolver | ||
Nothing -> "" | ||
|
||
ghcFlavorOpt :: String -> GhcFlavor -> String | ||
ghcFlavorOpt daFlavor = \case | ||
ghcFlavorOpt :: GhcFlavor -> String | ||
ghcFlavorOpt = \case | ||
Ghc8101 -> "--ghc-flavor ghc-8.10.1" | ||
Ghc881 -> "--ghc-flavor ghc-8.8.1" | ||
Ghc882 -> "--ghc-flavor ghc-8.8.2" | ||
Ghc883 -> "--ghc-flavor ghc-8.8.3" | ||
Da -> "--ghc-flavor " <> daFlavor | ||
Da { flavor } -> "--ghc-flavor " <> flavor | ||
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 good. That is the flag that gets pushed "downstream" into |
||
GhcMaster _hash -> "--ghc-flavor ghc-master" | ||
-- The git SHA1 hash is not passed to ghc-lib-gen at this time. | ||
|
||
|
@@ -104,29 +109,12 @@ genVersionStr = \case | |
|
||
parseOptions :: Opts.Parser Options | ||
parseOptions = Options | ||
<$> Opts.option readFlavor | ||
( Opts.long "ghc-flavor" | ||
<> Opts.help "The ghc-flavor to test against" | ||
) | ||
<*> Opts.strOption | ||
( Opts.long "da-merge-base-sha" | ||
<> Opts.help "DA flavour only. Base commit to use from the GHC repo." | ||
<> Opts.showDefault | ||
<> Opts.value "ghc-8.8.1-release" | ||
) | ||
<*> (Opts.some | ||
(Opts.strOption | ||
( Opts.long "da-patch" | ||
<> Opts.help "DA flavour only. Commits to merge in from the DA GHC fork, referenced as 'upstream'. Can be specified multiple times. If no patch is specified, default will be equivalent to `--da-patch upstream/da-master-8.8.1 --da-patch upstream/da-unit-ids-8.8.1`. Specifying any patch will overwrite the default (i.e. replace, not add)." | ||
) | ||
) | ||
Opts.<|> pure ["upstream/da-master-8.8.1", "upstream/da-unit-ids-8.8.1"]) | ||
<*> Opts.strOption | ||
( Opts.long "da-gen-flavor" | ||
<> Opts.help "DA flavor only. Flavor to pass on to ghc-lib-gen." | ||
<> Opts.showDefault | ||
<> Opts.value "da-ghc-8.8.1" | ||
) | ||
<$> (parseDaOptions | ||
Opts.<|> | ||
(Opts.option readFlavor | ||
( Opts.long "ghc-flavor" | ||
<> Opts.help "The ghc-flavor to test against" | ||
))) | ||
<*> parseStackOptions | ||
where | ||
readFlavor :: Opts.ReadM GhcFlavor | ||
|
@@ -135,9 +123,29 @@ parseOptions = Options | |
"ghc-8.8.1" -> Right Ghc881 | ||
"ghc-8.8.2" -> Right Ghc882 | ||
"ghc-8.8.3" -> Right Ghc883 | ||
"da" -> Right Da | ||
"ghc-master" -> Right (GhcMaster current) | ||
hash -> Right (GhcMaster hash) | ||
parseDaOptions :: Opts.Parser GhcFlavor | ||
parseDaOptions = | ||
Opts.flag' Da ( Opts.long "da" <> Opts.help "Enables DA custom build." ) | ||
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. Maybe 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. That is my understanding of the documentation, and seems to be confirmed in usage:
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. Which makes me think maybe the other flags don't need the 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. If they don't need the 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. There's no "upload" facilities any more right? Can the help comment be updated accordingly please? 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. Oh right. 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. Dropped |
||
<*> Opts.strOption | ||
( Opts.long "da-merge-base-sha" | ||
<> Opts.help "DA flavour only. Base commit to use from the GHC repo." | ||
<> Opts.showDefault | ||
<> Opts.value "ghc-8.8.1-release" | ||
) | ||
<*> (Opts.some | ||
(Opts.strOption | ||
( Opts.long "da-patch" | ||
<> Opts.help "DA flavour only. Commits to merge in from the DA GHC fork, referenced as 'upstream'. Can be specified multiple times. If no patch is specified, default will be equivalent to `--da-patch upstream/da-master-8.8.1 --da-patch upstream/da-unit-ids-8.8.1`. Specifying any patch will overwrite the default (i.e. replace, not add)." | ||
)) | ||
Opts.<|> | ||
pure ["upstream/da-master-8.8.1", "upstream/da-unit-ids-8.8.1"]) | ||
<*> Opts.strOption | ||
( Opts.long "da-gen-flavor" | ||
<> Opts.help "DA flavor only. Flavor to pass on to ghc-lib-gen." | ||
<> Opts.showDefault | ||
<> Opts.value "da-ghc-8.8.1") | ||
|
||
parseStackOptions :: Opts.Parser StackOptions | ||
parseStackOptions = StackOptions | ||
|
@@ -162,13 +170,10 @@ parseStackOptions = StackOptions | |
<> Opts.help "If specified, pass '--ghc-options=\"xxx\"' to stack" | ||
)) | ||
|
||
buildDists :: GhcFlavor -> StackOptions -> String -> [String] -> String -> IO String | ||
buildDists :: GhcFlavor -> StackOptions -> IO String | ||
buildDists | ||
ghcFlavor | ||
StackOptions {stackYaml, resolver, verbosity, cabalVerbose, ghcOptions} | ||
daMergeBaseSha | ||
daPatches | ||
daFlavor | ||
= | ||
do | ||
let stackConfig = fromMaybe "stack.yaml" stackYaml | ||
|
@@ -197,12 +202,12 @@ buildDists | |
Ghc881 -> cmd "cd ghc && git fetch --tags && git checkout ghc-8.8.1-release" | ||
Ghc882 -> cmd "cd ghc && git fetch --tags && git checkout ghc-8.8.2-release" | ||
Ghc883 -> cmd "cd ghc && git fetch --tags && git checkout ghc-8.8.3-release" | ||
Da -> do | ||
cmd $ "cd ghc && git fetch --tags && git checkout " <> daMergeBaseSha | ||
Da { mergeBaseSha, patches } -> 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. Exactly what I had in mind! 🎉 |
||
cmd $ "cd ghc && git fetch --tags && git checkout " <> mergeBaseSha | ||
-- Apply Digital Asset extensions. | ||
cmd "cd ghc && git remote add upstream https://github.com/digital-asset/ghc.git" | ||
cmd "cd ghc && git fetch upstream" | ||
cmd $ "cd ghc && git -c user.name='Cookie Monster' -c user.email=cookie.monster@seasame-street.com merge --no-edit " <> Data.List.intercalate " " daPatches | ||
cmd $ "cd ghc && git -c user.name=\"Cookie Monster\" -c user.email=cookie.monster@seasame-street.com merge --no-edit " <> Data.List.intercalate " " patches | ||
GhcMaster hash -> cmd $ "cd ghc && git checkout " ++ hash | ||
cmd "cd ghc && git submodule update --init --recursive" | ||
|
||
|
@@ -236,7 +241,7 @@ buildDists | |
_ -> pure () | ||
|
||
-- Feedback on the compiler used for ghc-lib-gen. | ||
stack $ "exec -- ghc-lib-gen ghc --ghc-lib-parser " ++ ghcFlavorOpt daFlavor ghcFlavor | ||
stack $ "exec -- ghc-lib-gen ghc --ghc-lib-parser " ++ ghcFlavorOpt ghcFlavor | ||
patchVersion version "ghc/ghc-lib-parser.cabal" | ||
mkTarball pkg_ghclib_parser | ||
renameDirectory pkg_ghclib_parser "ghc-lib-parser" | ||
|
@@ -247,7 +252,7 @@ buildDists | |
cmd "cd ghc && git checkout ." | ||
appendFile "ghc/hadrian/stack.yaml" $ unlines ["ghc-options:"," \"$everything\": -O0 -j"] | ||
-- Feedback on the compiler used for ghc-lib-gen. | ||
stack $ "exec -- ghc-lib-gen ghc --ghc-lib " ++ ghcFlavorOpt daFlavor ghcFlavor | ||
stack $ "exec -- ghc-lib-gen ghc --ghc-lib " ++ ghcFlavorOpt ghcFlavor | ||
patchVersion version "ghc/ghc-lib.cabal" | ||
patchConstraint version "ghc/ghc-lib.cabal" | ||
mkTarball pkg_ghclib | ||
|
@@ -278,7 +283,7 @@ buildDists | |
-- explanation) | ||
unlines ["extra-deps: [transformers-0.5.6.2]"] | ||
#endif | ||
Da -> | ||
Da {} -> | ||
unlines ["flags: {mini-compile: {daml-unit-ids: true}}"] | ||
_ -> "" | ||
|
||
|
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.
Shouldn't comment on style matters but I think this will fit on a single line eh?
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.
I'm fine with whatever style you prefer on this project. I've updated this one (though you need longer-than-80-chars lines for it to fit ;-) ); don't hesitate to point out others. In particular, I have no idea how the
parseOptions
function "should" be indented.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.
"Consistency is the hobgoblin of little minds" 🤣