Skip to content

Commit

Permalink
Use --dependency= on Cabal 1.22 and newer
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jun 19, 2015
1 parent d0c1a2f commit e3b1822
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ addFinal lp = do
, taskConfigOpts = TaskConfigOpts missing $ \missing' ->
let allDeps = Set.union present missing'
in configureOpts
(getConfig ctx)
(getEnvConfig ctx)
(baseConfigOpts ctx)
allDeps
True -- wanted
Expand Down Expand Up @@ -283,7 +283,7 @@ installPackage name ps = do
let allDeps = Set.union present missing'
destLoc = piiLocation ps <> minLoc
in configureOpts
(getConfig ctx)
(getEnvConfig ctx)
(baseConfigOpts ctx)
allDeps
(psWanted ps)
Expand Down Expand Up @@ -349,7 +349,7 @@ checkDirtiness :: PackageSource
checkDirtiness ps installed package present = do
ctx <- ask
let configOpts = configureOpts
(getConfig ctx)
(getEnvConfig ctx)
(baseConfigOpts ctx)
present
(psWanted ps)
Expand Down
17 changes: 11 additions & 6 deletions src/Stack/Build/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,14 @@ data BaseConfigOpts = BaseConfigOpts
}

-- | Render a @BaseConfigOpts@ to an actual list of options
configureOpts :: Config
configureOpts :: EnvConfig
-> BaseConfigOpts
-> Set GhcPkgId -- ^ dependencies
-> Bool -- ^ wanted?
-> Location
-> Map FlagName Bool
-> [Text]
configureOpts config bco deps wanted loc flags = map T.pack $ concat
configureOpts econfig bco deps wanted loc flags = map T.pack $ concat
[ ["--user", "--package-db=clear", "--package-db=global"]
, map (("--package-db=" ++) . toFilePath) $ case loc of
Snap -> [bcoSnapDB bco]
Expand Down Expand Up @@ -423,6 +423,7 @@ configureOpts config bco deps wanted loc flags = map T.pack $ concat
, map (("--extra-lib-dirs=" ++) . T.unpack) (Set.toList (configExtraLibDirs config))
]
where
config = getConfig econfig
bopts = bcoBuildOpts bco
toFilePathNoTrailingSlash =
loop . toFilePath
Expand All @@ -438,16 +439,20 @@ configureOpts config bco deps wanted loc flags = map T.pack $ concat
Local -> bcoLocalInstallRoot bco

depOptions = map toDepOption $ Set.toList deps
where
toDepOption =
if envConfigCabalVersion econfig >= $(mkVersion "1.22")
then toDepOption1_22
else toDepOption1_18

{- TODO does this work with some versions of Cabal?
toDepOption gid = T.pack $ concat
toDepOption1_22 gid = concat
[ "--dependency="
, packageNameString $ packageIdentifierName $ ghcPkgIdPackageIdentifier gid
, "="
, ghcPkgIdString gid
]
-}
toDepOption gid = concat

toDepOption1_18 gid = concat
[ "--constraint="
, packageNameString name
, "=="
Expand Down

0 comments on commit e3b1822

Please sign in to comment.