Skip to content

Commit

Permalink
Warn if builddir is going to be ignored.
Browse files Browse the repository at this point in the history
builddir can only be specified from the command line.

Closes: #7941
  • Loading branch information
andreabedini committed May 22, 2023
1 parent f19ce68 commit 74c46ae
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ import Distribution.Simple.Compiler
import Distribution.Simple.Program
( ConfiguredProgram(..) )
import Distribution.Simple.Setup
( Flag(Flag), toFlag, flagToMaybe, flagToList
( Flag(..), toFlag, flagToMaybe, flagToList
, fromFlag, fromFlagOrDefault )
import Distribution.Client.Setup
( defaultSolver, defaultMaxBackjumps )
Expand Down
2 changes: 2 additions & 0 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ rebuildProjectConfig verbosity
pure (os, arch, compilerInfo compiler)

projectConfig <- instantiateProjectConfigSkeletonFetchingCompiler fetchCompiler mempty projectConfigSkeleton
when (projectConfigDistDir (projectConfigShared $ projectConfig) /= NoFlag) $
liftIO $ warn verbosity "The builddir option is not supported in project and config files. It will be ignored."
localPackages <- phaseReadLocalPackages (projectConfig <> cliConfig)
return (projectConfig, localPackages)

Expand Down
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/Project/WarnBuilddir/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# cabal v2-build
Warning: The builddir option is not supported in project and config files. It will be ignored.
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following would be built:
- main-0.1 (lib) (first run)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages: .
builddir: something
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude

main = cabalTest $ do
cabal "v2-build" ["--dry-run", "all"]
14 changes: 14 additions & 0 deletions cabal-testsuite/PackageTests/Project/WarnBuilddir/main.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cabal-version: 3.0

name: main
version: 0.1
build-type: Simple
category: Test
maintainer: Joe
synopsis: Test input
description: Test input
license: BSD-3-Clause

library
build-depends: base
default-language: Haskell2010
2 changes: 1 addition & 1 deletion doc/cabal-project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ package, and thus apply globally:
to the root of the project (i.e., where the ``cabal.project``
file lives.)

This option cannot be specified via a ``cabal.project`` file.
This option can only be specified from the command line.

.. _cmdoption-project-dir:
.. option:: --project-dir=DIR
Expand Down

0 comments on commit 74c46ae

Please sign in to comment.