mirror of
https://github.com/sol/hpack.git
synced 2024-10-04 03:38:00 +03:00
Do not apply global options within conditionals (fixes #214)
This commit is contained in:
parent
a7d9820941
commit
5c0ff95778
@ -796,10 +796,12 @@ toExecutables :: FilePath -> String -> Section global -> [(String, Section Execu
|
||||
toExecutables dir packageName_ globalOptions = traverseNamedSections (toExecutable dir packageName_ globalOptions)
|
||||
|
||||
toExecutable :: FilePath -> String -> Section global -> Section ExecutableSection -> IO ([String], Section Executable)
|
||||
toExecutable dir packageName_ globalOptions = toExecutable_ >=> expandForeignSources dir . nubOtherModules
|
||||
toExecutable dir packageName_ globalOptions =
|
||||
toExecutable_ . mergeSections emptyExecutableSection globalOptions
|
||||
>=> expandForeignSources dir . nubOtherModules
|
||||
where
|
||||
toExecutable_ :: Section ExecutableSection -> IO (Section Executable)
|
||||
toExecutable_ sect_ = do
|
||||
toExecutable_ sect@Section{..} = do
|
||||
(executable, ghcOptions) <- fromExecutableSection sectionData
|
||||
conditionals <- mapM (traverse toExecutable_) sectionConditionals
|
||||
return sect {
|
||||
@ -808,9 +810,6 @@ toExecutable dir packageName_ globalOptions = toExecutable_ >=> expandForeignSou
|
||||
, sectionConditionals = conditionals
|
||||
}
|
||||
where
|
||||
sect :: Section ExecutableSection
|
||||
sect@Section{..} = mergeSections emptyExecutableSection globalOptions sect_
|
||||
|
||||
fromExecutableSection :: ExecutableSection -> IO (Executable, [GhcOption])
|
||||
fromExecutableSection ExecutableSection{..} = do
|
||||
modules <- maybe inferModules (return . fromList) executableSectionOtherModules
|
||||
|
@ -132,6 +132,21 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
|]
|
||||
|
||||
context "within conditional" $ do
|
||||
it "does not apply global options" $ do
|
||||
-- related bug: https://github.com/sol/hpack/issues/214
|
||||
[i|
|
||||
ghc-options: -Wall
|
||||
executables:
|
||||
foo:
|
||||
when:
|
||||
condition: os(windows)
|
||||
main: Foo.hs
|
||||
|] `shouldRenderTo` executable "foo" [i|
|
||||
ghc-options: -Wall
|
||||
if os(windows)
|
||||
main-is: Foo.hs
|
||||
|]
|
||||
|
||||
it "accepts executable-specific fields" $ do
|
||||
[i|
|
||||
executables:
|
||||
|
Loading…
Reference in New Issue
Block a user