diff --git a/Cabal/Distribution/Simple/Build/PathsModule.hs b/Cabal/Distribution/Simple/Build/PathsModule.hs index 3149eecb64e7452dd57c29046802394890605826..e190f7a5c93c6cb690f28d5d48dfbf83eff85ebe 100644 --- a/Cabal/Distribution/Simple/Build/PathsModule.hs +++ b/Cabal/Distribution/Simple/Build/PathsModule.hs @@ -242,6 +242,9 @@ generate pkg_descr lbi clbi = -- | Generates the name of the environment variable controlling the path -- component of interest. +-- +-- Note: The format of these strings is part of Cabal's public API; +-- changing this function constitutes a *backwards-compatibility* break. pkgPathEnvVar :: PackageDescription -> String -- ^ path component; one of \"bindir\", \"libdir\", -- \"datadir\", \"libexecdir\", or \"sysconfdir\" diff --git a/Cabal/doc/developing-packages.markdown b/Cabal/doc/developing-packages.markdown index 64cc60dadfb8ef9a31074c2f467a92c89eaf5a29..806ce2cb72cf7582ca35ff04e086066862651ee5 100644 --- a/Cabal/doc/developing-packages.markdown +++ b/Cabal/doc/developing-packages.markdown @@ -2071,6 +2071,15 @@ getLibexecDir :: IO FilePath getSysconfDir :: IO FilePath ~~~~~~~~~~~~~~~ +The actual location of all these directories can be individually +overridden at runtime using environment variables of the form +`pkg_name_var`, where `pkg_name` is the name of the package with +all hyphens converted into underscores, and `var` is either +`bindir`, `libdir`, `datadir`, `libexedir` or `sysconfdir`. +For example, the configured data directory for `pretty-show` +is controlled with the `pretty_show_datadir` environment variable. + + ### Accessing the package version ### The aforementioned auto generated `Paths_`_pkgname_ module also diff --git a/cabal-install/Distribution/Client/ProjectBuilding.hs b/cabal-install/Distribution/Client/ProjectBuilding.hs index 1dc4e2e0278df34fd14b5b8990002dddd3fd0929..d2da5479983a5c15851c5808d0e1dd04bbe6c544 100644 --- a/cabal-install/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/Distribution/Client/ProjectBuilding.hs @@ -1184,7 +1184,22 @@ buildInplaceUnpackedPackage verbosity --TODO: [required eventually] this doesn't track file --non-existence, so we could fail to rebuild if someone --adds a new file which changes behavior. - allSrcFiles <- allPackageSourceFiles verbosity scriptOptions srcdir + allSrcFiles <- + let trySdist = allPackageSourceFiles verbosity scriptOptions srcdir + -- This is just a hack, to get semi-reasonable file + -- listings for the monitor + tryFallback = do + warn verbosity $ + "Couldn't use sdist to compute source files; falling " ++ + "back on recursive file scan." + filter (not . ("dist" `isPrefixOf`)) + `fmap` getDirectoryContentsRecursive srcdir + in if elabSetupScriptCliVersion pkg >= Version [1,17] [] + then do r <- trySdist + if null r + then tryFallback + else return r + else tryFallback updatePackageBuildFileMonitor packageFileMonitor srcdir timestamp pkg buildStatus diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 8584e3af1f17fcf060b4c72d0edcbcd0e6ee5bfb..c2903ab25bb211b01ec2964389829f33366a7f61 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -2352,7 +2352,11 @@ setupHsBuildFlags _ _ verbosity builddir = setupHsBuildArgs :: ElaboratedConfiguredPackage -> [String] setupHsBuildArgs elab@(ElaboratedConfiguredPackage { elabPkgOrComp = ElabPackage _ }) + -- Fix for #3335, don't pass build arguments if it's not supported + | elabSetupScriptCliVersion elab >= Version [1,17] [] = map (showComponentTarget (packageId elab)) (elabBuildTargets elab) + | otherwise + = [] setupHsBuildArgs (ElaboratedConfiguredPackage { elabPkgOrComp = ElabComponent _ }) = [] diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal index a755cf790c0e389d7a52a1ad00917b5671d242ca..7cb6c779a2d07816151830b949da593733c86dcf 100644 --- a/cabal-install/cabal-install.cabal +++ b/cabal-install/cabal-install.cabal @@ -122,6 +122,11 @@ Extra-Source-Files: tests/IntegrationTests/regression/t3199/Main.hs tests/IntegrationTests/regression/t3199/Setup.hs tests/IntegrationTests/regression/t3199/test-3199.cabal + tests/IntegrationTests/regression/t3335.sh + tests/IntegrationTests/regression/t3335/A.hs + tests/IntegrationTests/regression/t3335/Setup.hs + tests/IntegrationTests/regression/t3335/cabal.project + tests/IntegrationTests/regression/t3335/t3335.cabal tests/IntegrationTests/sandbox-reinstalls/p/Main.hs tests/IntegrationTests/sandbox-reinstalls/p/p.cabal tests/IntegrationTests/sandbox-reinstalls/q/Q.hs diff --git a/cabal-install/tests/IntegrationTests/common.sh b/cabal-install/tests/IntegrationTests/common.sh index a48b33c066ec2d74416f999d5b343f1fb561e686..f26b1efc8e71a1ea2fcb074a50ea6dfb66f36dc1 100644 --- a/cabal-install/tests/IntegrationTests/common.sh +++ b/cabal-install/tests/IntegrationTests/common.sh @@ -10,3 +10,19 @@ die() { echo "die: $@" exit 1 } + +require_ghc_le() { + GHCVER="$(echo main = print __GLASGOW_HASKELL__ | runghc -XCPP)" + if [ "$GHCVER" -gt "$1" ]; then + echo "Skipping test that needs GHC <= $1 (actual version $GHCVER)" + exit 0 + fi +} + +require_ghc_ge() { + GHCVER="$(echo main = print __GLASGOW_HASKELL__ | runghc -XCPP)" + if [ "$GHCVER" -lt "$1" ]; then + echo "Skipping test that needs GHC >= $1 (actual version $GHCVER)" + exit 0 + fi +} diff --git a/cabal-install/tests/IntegrationTests/regression/t3335.sh b/cabal-install/tests/IntegrationTests/regression/t3335.sh new file mode 100644 index 0000000000000000000000000000000000000000..1b2d7668e9a0b24836d5940ad1dda9fb05f4c905 --- /dev/null +++ b/cabal-install/tests/IntegrationTests/regression/t3335.sh @@ -0,0 +1,6 @@ +. ./common.sh + +require_ghc_le 706 + +cd t3335 +cabal new-build t3335 diff --git a/cabal-install/tests/IntegrationTests/regression/t3335/A.hs b/cabal-install/tests/IntegrationTests/regression/t3335/A.hs new file mode 100644 index 0000000000000000000000000000000000000000..d843c00b78275c5bbdfcde9920a811bb01038a2d --- /dev/null +++ b/cabal-install/tests/IntegrationTests/regression/t3335/A.hs @@ -0,0 +1 @@ +module A where diff --git a/cabal-install/tests/IntegrationTests/regression/t3335/Setup.hs b/cabal-install/tests/IntegrationTests/regression/t3335/Setup.hs new file mode 100644 index 0000000000000000000000000000000000000000..9a994af677b0dfd41b4e3b76b3e7e604003d64e1 --- /dev/null +++ b/cabal-install/tests/IntegrationTests/regression/t3335/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/cabal-install/tests/IntegrationTests/regression/t3335/cabal.project b/cabal-install/tests/IntegrationTests/regression/t3335/cabal.project new file mode 100644 index 0000000000000000000000000000000000000000..e6fdbadb4398bc0e333947b5fb8021778310d943 --- /dev/null +++ b/cabal-install/tests/IntegrationTests/regression/t3335/cabal.project @@ -0,0 +1 @@ +packages: . diff --git a/cabal-install/tests/IntegrationTests/regression/t3335/t3335.cabal b/cabal-install/tests/IntegrationTests/regression/t3335/t3335.cabal new file mode 100644 index 0000000000000000000000000000000000000000..967d41b232b4065268a1456454a2288f4cf5a34c --- /dev/null +++ b/cabal-install/tests/IntegrationTests/regression/t3335/t3335.cabal @@ -0,0 +1,16 @@ +name: t3335 +version: 0.1.0.0 +license: BSD3 +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +category: Test +build-type: Custom +cabal-version: >=1.10 + +library + exposed-modules: A + build-depends: base + default-language: Haskell2010 + +custom-setup + setup-depends: Cabal == 1.16.*, base