Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,15 @@ instance Semigroup DoctestFlags where
-- documentation in @<dist>/doc/html/<package id>-docs@.
data HaddockTarget = ForHackage | ForDevelopment deriving (Eq, Show, Generic)

instance Binary HaddockTarget

instance Text HaddockTarget where
disp ForHackage = Disp.text "for-hackage"
disp ForDevelopment = Disp.text "for-development"

parse = Parse.choice [ Parse.string "for-hackage" >> return ForHackage
, Parse.string "for-development" >> return ForDevelopment]

data HaddockFlags = HaddockFlags {
haddockProgramPaths :: [(String, FilePath)],
haddockProgramArgs :: [(String, [String])],
Expand Down Expand Up @@ -1507,7 +1516,7 @@ defaultHaddockFlags = HaddockFlags {
haddockHoogle = Flag False,
haddockHtml = Flag False,
haddockHtmlLocation = NoFlag,
haddockForHackage = Flag ForDevelopment,
haddockForHackage = NoFlag,
haddockExecutables = Flag False,
haddockTestSuites = Flag False,
haddockBenchmarks = Flag False,
Expand Down
9 changes: 8 additions & 1 deletion cabal-install/Distribution/Client/ProjectConfig/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ convertLegacyPerPackageFlags configFlags installFlags haddockFlags =
haddockHtml = packageConfigHaddockHtml,
haddockHtmlLocation = packageConfigHaddockHtmlLocation,
haddockForeignLibs = packageConfigHaddockForeignLibs,
haddockForHackage = packageConfigHaddockForHackage,
haddockExecutables = packageConfigHaddockExecutables,
haddockTestSuites = packageConfigHaddockTestSuites,
haddockBenchmarks = packageConfigHaddockBenchmarks,
Expand Down Expand Up @@ -671,7 +672,7 @@ convertToLegacyPerPackageConfig PackageConfig {..} =
haddockHoogle = packageConfigHaddockHoogle,
haddockHtml = packageConfigHaddockHtml,
haddockHtmlLocation = packageConfigHaddockHtmlLocation,
haddockForHackage = mempty, --TODO: added recently
haddockForHackage = packageConfigHaddockForHackage,
haddockForeignLibs = packageConfigHaddockForeignLibs,
haddockExecutables = packageConfigHaddockExecutables,
haddockTestSuites = packageConfigHaddockTestSuites,
Expand Down Expand Up @@ -952,6 +953,12 @@ legacyPackageConfigFieldDescrs =
(\flags conf -> conf { legacyHaddockFlags = flags })
. mapFieldNames
("haddock-"++)
. addFields
[ simpleField "for-hackage"
-- TODO: turn this into a library function
(fromFlagOrDefault Disp.empty . fmap disp) (Parse.option mempty (fmap toFlag parse))
haddockForHackage (\v conf -> conf { haddockForHackage = v })
]
. filterFields
[ "hoogle", "html", "html-location"
, "foreign-libraries"
Expand Down
5 changes: 3 additions & 2 deletions cabal-install/Distribution/Client/ProjectConfig/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import Distribution.Simple.Compiler
( Compiler, CompilerFlavor
, OptimisationLevel(..), ProfDetailLevel, DebugInfoLevel(..) )
import Distribution.Simple.Setup
( Flag, AllowNewer(..), AllowOlder(..) )
( Flag, AllowNewer(..), AllowOlder(..), HaddockTarget(..) )
import Distribution.Simple.InstallDirs
( PathTemplate )
import Distribution.Utils.NubList
Expand Down Expand Up @@ -261,7 +261,8 @@ data PackageConfig
packageConfigHaddockCss :: Flag FilePath, --TODO: [required eventually] use this
packageConfigHaddockHscolour :: Flag Bool, --TODO: [required eventually] use this
packageConfigHaddockHscolourCss :: Flag FilePath, --TODO: [required eventually] use this
packageConfigHaddockContents :: Flag PathTemplate --TODO: [required eventually] use this
packageConfigHaddockContents :: Flag PathTemplate, --TODO: [required eventually] use this
packageConfigHaddockForHackage :: Flag HaddockTarget
Copy link
Member

@hvr hvr May 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fwiw, this looks somewhat inconsistent; we got a field named ForHackage which would imply a Bool, but then this holds an enum which redundantly says ForHackage (or ForDevelopment).

Why isn't this simply a Flag Bool?


PS: To answer my own question, now I see that this has been inherited from Distribution.Simple.Setup (haddockForHackage :: Flag HaddockTarget); so this PR just went along with the pre-existing design decision...

...and actually in #2852 this was still a Flag Bool... it was 0975372 which lateron introduced the HaddockTarget data type w/o addressing the introduced naming inconsistency...

}
deriving (Eq, Show, Generic)

Expand Down
3 changes: 2 additions & 1 deletion cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,7 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
elabHaddockHtml = perPkgOptionFlag pkgid False packageConfigHaddockHtml
elabHaddockHtmlLocation = perPkgOptionMaybe pkgid packageConfigHaddockHtmlLocation
elabHaddockForeignLibs = perPkgOptionFlag pkgid False packageConfigHaddockForeignLibs
elabHaddockForHackage = perPkgOptionFlag pkgid Cabal.ForDevelopment packageConfigHaddockForHackage
elabHaddockExecutables = perPkgOptionFlag pkgid False packageConfigHaddockExecutables
elabHaddockTestSuites = perPkgOptionFlag pkgid False packageConfigHaddockTestSuites
elabHaddockBenchmarks = perPkgOptionFlag pkgid False packageConfigHaddockBenchmarks
Expand Down Expand Up @@ -3204,7 +3205,7 @@ setupHsHaddockFlags (ElaboratedConfiguredPackage{..}) _ verbosity builddir =
haddockHoogle = toFlag elabHaddockHoogle,
haddockHtml = toFlag elabHaddockHtml,
haddockHtmlLocation = maybe mempty toFlag elabHaddockHtmlLocation,
haddockForHackage = mempty, --TODO: new flag
haddockForHackage = toFlag elabHaddockForHackage,
haddockForeignLibs = toFlag elabHaddockForeignLibs,
haddockExecutables = toFlag elabHaddockExecutables,
haddockTestSuites = toFlag elabHaddockTestSuites,
Expand Down
2 changes: 2 additions & 0 deletions cabal-install/Distribution/Client/ProjectPlanning/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import Distribution.ModuleName (ModuleName)
import Distribution.Simple.LocalBuildInfo (ComponentName(..))
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.InstallDirs (PathTemplate)
import Distribution.Simple.Setup (HaddockTarget)
import Distribution.Version

import qualified Distribution.Solver.Types.ComponentDeps as CD
Expand Down Expand Up @@ -258,6 +259,7 @@ data ElaboratedConfiguredPackage
elabHaddockHtml :: Bool,
elabHaddockHtmlLocation :: Maybe String,
elabHaddockForeignLibs :: Bool,
elabHaddockForHackage :: HaddockTarget,
elabHaddockExecutables :: Bool,
elabHaddockTestSuites :: Bool,
elabHaddockBenchmarks :: Bool,
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ haddockOptions showOrParseArgs
, name `elem` ["hoogle", "html", "html-location"
,"executables", "tests", "benchmarks", "all", "internal", "css"
,"hyperlink-source", "hscolour-css"
,"contents-location"]
,"contents-location", "for-hackage"]
]
where
fmapOptFlags :: (OptFlags -> OptFlags) -> OptDescr a -> OptDescr a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ prop_roundtrip_printparse_specific config =


----------------------------
-- Individual Parser tests
-- Individual Parser tests
--

prop_parsePackageLocationTokenQ :: PackageLocationString -> Bool
Expand Down Expand Up @@ -390,7 +390,7 @@ instance Arbitrary ProjectConfigShared where
postShrink_Constraints = map (\uc -> (uc, projectConfigConstraintSource))

projectConfigConstraintSource :: ConstraintSource
projectConfigConstraintSource =
projectConfigConstraintSource =
ConstraintSourceProjectConfig "TODO"

instance Arbitrary ProjectConfigProvenance where
Expand Down Expand Up @@ -433,6 +433,7 @@ instance Arbitrary PackageConfig where
<*> arbitrary
<*> arbitraryFlag arbitraryShortToken
<*> arbitrary
<*> arbitrary
where
arbitraryProgramName :: Gen String
arbitraryProgramName =
Expand All @@ -448,7 +449,7 @@ instance Arbitrary PackageConfig where
x25 x26 x27 x28 x29
x30 x31 x32 x33 x33_1 x34
x35 x36 x37 x38 x39
x40) =
x40 x41) =
[ PackageConfig
(postShrink_Paths x00')
(postShrink_Args x01') x02' x03' x04'
Expand All @@ -463,7 +464,7 @@ instance Arbitrary PackageConfig where
x30' x31' x32' x33' x33_1' x34'
x35' x36' (fmap getNonEmpty x37') x38'
(fmap getNonEmpty x39')
x40'
x40' x41'
| (((x00', x01', x02', x03', x04'),
(x05', x06', x07', x08', x09'),
(x10', x11', x12', x13', x14'),
Expand All @@ -472,7 +473,7 @@ instance Arbitrary PackageConfig where
(x25', x26', x27', x28', x29'),
(x30', x31', x32', (x33', x33_1'), x34'),
(x35', x36', x37', x38', x39'),
(x40')))
(x40', x41')))
<- shrink
(((preShrink_Paths x00, preShrink_Args x01, x02, x03, x04),
(x05, x06, x07, x08, x09),
Expand All @@ -485,7 +486,7 @@ instance Arbitrary PackageConfig where
(x25, x26, x27, x28, x29),
(x30, x31, x32, (x33, x33_1), x34),
(x35, x36, fmap NonEmpty x37, x38, fmap NonEmpty x39),
(x40)))
(x40, x41)))
]
where
preShrink_Paths = Map.map NonEmpty
Expand All @@ -501,6 +502,8 @@ instance Arbitrary PackageConfig where
. Map.map (map getNonEmpty . getNonEmpty)
. Map.mapKeys getNoShrink

instance Arbitrary HaddockTarget where
arbitrary = elements [ForHackage, ForDevelopment]

instance Arbitrary SourceRepo where
arbitrary = (SourceRepo RepoThis
Expand Down