Skip to content

Remove UnknownBuildType from BuildType #5003

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

Merged
merged 1 commit into from
Jan 7, 2018
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
8 changes: 0 additions & 8 deletions Cabal/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,6 @@ checkFields pkg =
"No 'build-type' specified. If you do not need a custom Setup.hs or "
++ "./configure script then use 'build-type: Simple'."

, case buildType pkg of
UnknownBuildType unknown -> Just $
PackageBuildWarning $
quote unknown ++ " is not a known 'build-type'. "
++ "The known build types are: "
++ commaSep (map display knownBuildTypes)
_ -> Nothing

, check (isJust (setupBuildInfo pkg) && buildType pkg /= Custom) $
PackageBuildWarning $
"Ignoring the 'custom-setup' section because the 'build-type' is "
Expand Down
32 changes: 13 additions & 19 deletions Cabal/Distribution/Types/BuildType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ data BuildType
-- information used by later phases.
| Make -- ^ calls @Distribution.Make.defaultMain@
| Custom -- ^ uses user-supplied @Setup.hs@ or @Setup.lhs@ (default)
| UnknownBuildType String
-- ^ a package that uses an unknown build type cannot actually
-- be built. Doing it this way rather than just giving a
-- parse error means we get better error messages and allows
-- you to inspect the rest of the package description.
deriving (Generic, Show, Read, Eq, Typeable, Data)

instance Binary BuildType
Expand All @@ -38,25 +33,24 @@ knownBuildTypes :: [BuildType]
knownBuildTypes = [Simple, Configure, Make, Custom]

instance Pretty BuildType where
pretty (UnknownBuildType other) = Disp.text other
pretty other = Disp.text (show other)
pretty = Disp.text . show

instance Parsec BuildType where
parsec = do
name <- P.munch1 isAlphaNum
return $ case name of
"Simple" -> Simple
"Configure" -> Configure
"Custom" -> Custom
"Make" -> Make
_ -> UnknownBuildType name
case name of
"Simple" -> return Simple
"Configure" -> return Configure
"Custom" -> return Custom
"Make" -> return Make
_ -> fail ("unknown build-type: '" ++ name ++ "'")

instance Text BuildType where
parse = do
name <- Parse.munch1 isAlphaNum
return $ case name of
"Simple" -> Simple
"Configure" -> Configure
"Custom" -> Custom
"Make" -> Make
_ -> UnknownBuildType name
case name of
"Simple" -> return Simple
"Configure" -> return Configure
"Custom" -> return Custom
"Make" -> return Make
_ -> fail ("unknown build-type: '" ++ name ++ "'")
1 change: 1 addition & 0 deletions Cabal/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Use better defaulting for `build-type`; rename `PackageDescription`'s
`buildType` field to `buildTypeRaw` and introduce new `buildType`
function (#4958)
* Removed `UnknownBuildType` constructor from `BuildType` (#5003).
* Added `HexFloatLiterals` to `KnownExtension`.
* Cabal will no longer try to build an empty set of `inputModules`
(#4890).
Expand Down
13 changes: 2 additions & 11 deletions cabal-install/Distribution/Client/SetupWrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Distribution.Types.Dependency
import Distribution.PackageDescription
( GenericPackageDescription(packageDescription)
, PackageDescription(..), specVersion, buildType
, BuildType(..), knownBuildTypes, defaultRenaming )
, BuildType(..), defaultRenaming )
import Distribution.PackageDescription.Parsec
( readGenericPackageDescription )
import Distribution.Simple.Configure
Expand Down Expand Up @@ -294,7 +294,6 @@ getSetup verbosity options mpkg = do
(orLaterVersion (specVersion pkg))
}
buildType' = buildType pkg
checkBuildType buildType'
(version, method, options'') <-
getSetupMethod verbosity options' pkg buildType'
return Setup { setupMethod = method
Expand All @@ -308,12 +307,6 @@ getSetup verbosity options mpkg = do
>>= readGenericPackageDescription verbosity
>>= return . packageDescription

checkBuildType (UnknownBuildType name) =
die' verbosity $ "The build-type '" ++ name ++ "' is not known. Use one of: "
++ intercalate ", " (map display knownBuildTypes) ++ "."
checkBuildType _ = return ()


-- | Decide if we're going to be able to do a direct internal call to the
-- entry point in the Cabal library or if we're going to have to compile
-- and execute an external Setup.hs script.
Expand Down Expand Up @@ -429,7 +422,6 @@ buildTypeAction Configure = Simple.defaultMainWithHooksArgs
Simple.autoconfUserHooks
buildTypeAction Make = Make.defaultMainArgs
buildTypeAction Custom = error "buildTypeAction Custom"
buildTypeAction (UnknownBuildType _) = error "buildTypeAction UnknownBuildType"


-- | @runProcess'@ is a version of @runProcess@ where we have
Expand Down Expand Up @@ -699,8 +691,7 @@ getExternalSetupMethod verbosity options pkg bt = do
then "autoconfUserHooks\n"
else "defaultUserHooks\n"
Make -> "import Distribution.Make; main = defaultMain\n"
Custom -> error "buildTypeScript Custom"
UnknownBuildType _ -> error "buildTypeScript UnknownBuildType"
Custom -> error "buildTypeScript Custom"

installedCabalVersion :: SetupScriptOptions -> Compiler -> ProgramDb
-> IO (Version, Maybe InstalledPackageId
Expand Down
3 changes: 1 addition & 2 deletions cabal-install/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,7 @@ actAsSetupAction actAsSetupFlags args _globalFlags =
Configure -> Simple.defaultMainWithHooksArgs
Simple.autoconfUserHooks args
Make -> Make.defaultMainArgs args
Custom -> error "actAsSetupAction Custom"
(UnknownBuildType _) -> error "actAsSetupAction UnknownBuildType"
Custom -> error "actAsSetupAction Custom"

manpageAction :: [CommandSpec action] -> Flag Verbosity -> [String] -> Action
manpageAction commands flagVerbosity extraArgs _ = do
Expand Down