Skip to content

Commit

Permalink
Only warn about custom-setup stanza for custom-setup type commercialh…
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Apr 8, 2017
1 parent 0bfddc5 commit d145fcf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
42 changes: 18 additions & 24 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,8 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
-- Avoid broken Setup.hs files causing problems for simple build
-- types, see:
-- https://github.com/commercialhaskell/stack/issues/370
case (packageSimpleType package, eeSetupExe) of
(True, Just setupExe) -> return $ Left setupExe
case (packageBuildType package, eeSetupExe) of
(Just C.Simple, Just setupExe) -> return $ Left setupExe
_ -> liftIO $ Right <$> getSetupHs pkgDir
inner $ \stripTHLoading args -> do
let cabalPackageArg
Expand All @@ -979,6 +979,18 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
: ["-hide-all-packages"]
)

warnCustomNoDeps =
case (taskType, packageBuildType package) of
(TTLocal{}, Just C.Custom) -> do
$logWarn $ T.pack $ concat
[ "Package "
, packageNameString $ packageName package
, " uses a custom Cabal build, but does not use a custom-setup stanza"
]
$logWarn "Using the explicit setup deps approach based on configuration"
$logWarn "Strongly recommend fixing the package's cabal file"
_ -> return ()

getPackageArgs setupDir =
case (packageSetupDeps package, mdeps) of
-- The package is using the Cabal custom-setup
Expand Down Expand Up @@ -1017,16 +1029,7 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
-- 'explicit-setup-deps' is requested in your
-- stack.yaml file.
(Nothing, Just deps) | explicitSetupDeps (packageName package) config -> do
case taskType of
TTLocal{} -> do
$logWarn $ T.pack $ concat
[ "Package "
, packageNameString $ packageName package
, " uses a custom Cabal build, but does not use a custom-setup stanza"
]
$logWarn "Using the explicit setup deps approach based on configuration"
$logWarn "Strongly recommend fixing the package's cabal file"
_ -> return ()
warnCustomNoDeps
-- Stack always builds with the global Cabal for various
-- reproducibility issues.
let depsMinusCabal
Expand Down Expand Up @@ -1055,16 +1058,7 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
-- sdist` or when explicitly requested in the
-- stack.yaml file.
(Nothing, _) -> do
case taskType of
TTLocal{} -> do
$logWarn $ T.pack $ concat
[ "Package "
, packageNameString $ packageName package
, " uses a custom Cabal build, but does not use a custom-setup stanza"
]
$logWarn "Not using the explicit setup deps approach based on configuration"
$logWarn "Strongly recommend fixing the package's cabal file"
_ -> return ()
warnCustomNoDeps
return $ cabalPackageArg ++
-- NOTE: This is different from
-- packageDBArgs above in that it does not
Expand Down Expand Up @@ -1400,7 +1394,7 @@ singleBuild runInBase ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} in
eres <- try $ cabal False ["copy"]
case eres of
Left err@CabalExitedUnsuccessfully{} ->
throwM $ CabalCopyFailed (packageSimpleType package) (show err)
throwM $ CabalCopyFailed (packageBuildType package == Just C.Simple) (show err)
_ -> return ()
when (packageHasLibrary package) $ cabal False ["register"]

Expand Down Expand Up @@ -1592,7 +1586,7 @@ singleTest runInBase topts testsToRun ac ee task installedMap = do
_ -> Map.singleton testName $ Just ec
else do
$logError $ T.pack $ show $ TestSuiteExeMissing
(packageSimpleType package)
(packageBuildType package == Just C.Simple)
exeName
(packageNameString (packageName package))
(T.unpack testName)
Expand Down
11 changes: 7 additions & 4 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,10 @@ getDefaultLocalProgramsBase configStackRoot configPlatform override =
-- location to the new one, which is undesirable.
Platform _ Windows ->
case Map.lookup "LOCALAPPDATA" $ unEnvOverride override of
Just t -> do
lad <- parseAbsDir $ T.unpack t
return $ lad </> $(mkRelDir "Programs") </> $(mkRelDir stackProgName)
Just t ->
case parseAbsDir $ T.unpack t of
Nothing -> throwString ("Failed to parse LOCALAPPDATA environment variable (expected absolute directory): " ++ show t)
Just lad -> return $ lad </> $(mkRelDir "Programs") </> $(mkRelDir stackProgName)
Nothing -> return defaultBase
_ -> return defaultBase

Expand Down Expand Up @@ -806,7 +807,9 @@ determineStackRootAndOwnership clArgs = do
mstackRoot <- liftIO $ lookupEnv stackRootEnvVar
case mstackRoot of
Nothing -> getAppUserDataDir stackProgName
Just x -> parseAbsDir x
Just x -> case parseAbsDir x of
Nothing -> throwString ("Failed to parse STACK_ROOT environment variable (expected absolute directory): " ++ show x)
Just parsed -> return parsed

(existingStackRootOrParentDir, userOwnsIt) <- do
mdirAndOwnership <- findInParents getDirAndOwnership stackRoot
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ packageFromPackageDescription packageConfig pkgFlags pkg =
False
(not . null . exposedModules)
(library pkg)
, packageSimpleType = buildType pkg == Just Simple
, packageBuildType = buildType pkg
, packageSetupDeps = msetupDeps
}
where
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Types/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Distribution.InstalledPackageInfo (PError)
import Distribution.License (License)
import Distribution.ModuleName (ModuleName)
import Distribution.Package hiding (Package,PackageName,packageName,packageVersion,PackageIdentifier)
import Distribution.PackageDescription (TestSuiteInterface)
import Distribution.PackageDescription (TestSuiteInterface, BuildType)
import Distribution.System (Platform (..))
import GHC.Generics (Generic)
import Path as FL
Expand Down Expand Up @@ -101,7 +101,7 @@ data Package =
,packageExes :: !(Set Text) -- ^ names of executables
,packageOpts :: !GetPackageOpts -- ^ Args to pass to GHC.
,packageHasExposedModules :: !Bool -- ^ Does the package have exposed modules?
,packageSimpleType :: !Bool -- ^ Does the package of build-type: Simple
,packageBuildType :: !(Maybe BuildType) -- ^ Package build-type.
,packageSetupDeps :: !(Maybe (Map PackageName VersionRange))
-- ^ If present: custom-setup dependencies
}
Expand Down
7 changes: 4 additions & 3 deletions src/test/Stack/GhciSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Distribution.License (License (BSD3))
import qualified Distribution.ModuleName as ModuleName
import Distribution.PackageDescription (BuildType(..))
import Stack.Types.Package
import Stack.Types.PackageName
import Stack.Types.Version
Expand Down Expand Up @@ -224,7 +225,7 @@ packages_singlePackage =
, packageExes = S.empty
, packageOpts = GetPackageOpts undefined
, packageHasExposedModules = True
, packageSimpleType = True
, packageBuildType = Just Simple
, packageSetupDeps = Nothing
}
}
Expand Down Expand Up @@ -259,7 +260,7 @@ packages_multiplePackages =
, packageExes = S.empty
, packageOpts = GetPackageOpts undefined
, packageHasExposedModules = True
, packageSimpleType = True
, packageBuildType = Just Simple
, packageSetupDeps = Nothing
}
}
Expand Down Expand Up @@ -290,7 +291,7 @@ packages_multiplePackages =
, packageExes = S.empty
, packageOpts = GetPackageOpts undefined
, packageHasExposedModules = True
, packageSimpleType = True
, packageBuildType = Just Simple
, packageSetupDeps = Nothing
}
}
Expand Down

0 comments on commit d145fcf

Please sign in to comment.