Skip to content
Closed
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
6 changes: 2 additions & 4 deletions Cabal/src/Distribution/Simple/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import Distribution.Simple.Compiler
)
import Distribution.Simple.Glob (matchDirFileGlob)
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup.Config
import Distribution.Simple.Setup.Copy
( CopyFlags (..)
)
Expand Down Expand Up @@ -347,10 +346,10 @@ installIncludeFiles verbosity libBi lbi buildPref destIncludeDir = do
let relincdirs = sameDirectory : mapMaybe symbolicPathRelative_maybe (includeDirs libBi)
incdirs =
[ root </> getSymbolicPath dir
| -- NB: both baseDir and buildPref are already interpreted,
| -- NB: both the package root and buildPref are interpreted below,
-- so we don't need to interpret these paths in the call to findInc.
dir <- relincdirs
, root <- [baseDir lbi, buildPref]
, root <- [interpretSymbolicPath (mbWorkDirLBI lbi) sameDirectory, buildPref]
]
incs <- traverse (findInc incdirs . getSymbolicPath) (installIncludes libBi)
sequence_
Expand All @@ -362,7 +361,6 @@ installIncludeFiles verbosity libBi lbi buildPref destIncludeDir = do
destDir = takeDirectory destFile
]
where
baseDir lbi' = packageRoot $ configCommonFlags $ configFlags lbi'
findInc fs f = go fs
where
go [] = dieWithException verbosity $ CantFindIncludeFile f fs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int clib(void) { return 1; }
3 changes: 3 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T11186/cbits/clib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ifndef CLIB_H
#define CLIB_H
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cabal-version: 2.4
name: install-includes-local
version: 0.1.0.0
build-type: Simple

library
build-depends: base
hs-source-dirs: src
exposed-modules: Lib
include-dirs: cbits
c-sources: cbits/clib.c
install-includes: cbits/clib.h
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Setup configure
Configuring install-includes-local-0.1.0.0...
# Setup build
Preprocessing library for install-includes-local-0.1.0.0...
Building library for install-includes-local-0.1.0.0...
# Setup copy
Installing library in <PATH>
# Setup register
Registering library for install-includes-local-0.1.0.0...
9 changes: 9 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T11186/setup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Setup configure
Configuring install-includes-local-0.1.0.0...
# Setup build
Preprocessing library for install-includes-local-0.1.0.0...
Building library for install-includes-local-0.1.0.0...
# Setup copy
Installing library in <PATH>
# Setup register
Registering library for install-includes-local-0.1.0.0...
13 changes: 13 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T11186/setup.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Test.Cabal.Prelude

-- Regression test for #11186: install-includes should accept a relative
-- ("local") path and install the header to the include directory.
main = setupAndCabalTest $ withPackageDb $ do
setup_install []
env <- getTestEnv
shouldExist $
testLibInstallDir env
</> "install-includes-local-0.1.0.0"
</> "include"
</> "cbits"
</> "clib.h"
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Regression/T11186/src/Lib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Lib where
13 changes: 13 additions & 0 deletions changelog.d/12257.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
synopsis: "Fix `install-includes` with a local (relative) path"
packages: [Cabal]
prs: 12257
issues: 11186
---

`install-includes` now locates header files relative to the package root (the
working directory) instead of resolving them through `packageRoot`, which could
resolve to the directory of the `.cabal` file (a subdirectory of the package
root when `--cabal-file` is used) or to a raw, uninterpreted `--working-dir`
path. Previously this could prevent a relative `install-includes` path from
being found when installing, e.g. from a source tarball.
Loading