Commit 5d0ce9bd authored by Bertram Felgenhauer's avatar Bertram Felgenhauer
Browse files

add data-dir field to package config

Cabal will look for data files to install relative to the directory given
in the data-dir field, allowing package authors to better structure their
source tree. There's no behavioural change by default.
parent d37a1907
......@@ -129,6 +129,7 @@ data PackageDescription
library :: Maybe Library,
executables :: [Executable],
dataFiles :: [FilePath],
dataDir :: FilePath,
extraSrcFiles :: [FilePath],
extraTmpFiles :: [FilePath]
}
......@@ -159,6 +160,7 @@ emptyPackageDescription
library = Nothing,
executables = [],
dataFiles = [],
dataDir = "",
extraSrcFiles = [],
extraTmpFiles = []
}
......
......@@ -143,6 +143,9 @@ pkgDescrFieldDescrs =
, listField "data-files"
showFilePath parseFilePathQ
dataFiles (\val pkg -> pkg{dataFiles=val})
, simpleField "data-dir"
showFilePath parseFilePathQ
dataDir (\val pkg -> pkg{dataDir=val})
, listField "extra-source-files"
showFilePath parseFilePathQ
extraSrcFiles (\val pkg -> pkg{extraSrcFiles=val})
......
......@@ -104,7 +104,7 @@ install pkg_descr lbi flags = do
flip mapM_ (dataFiles pkg_descr) $ \ file -> do
let dir = takeDirectory file
createDirectoryIfMissingVerbose verbosity True (dataPref </> dir)
copyFileVerbose verbosity file (dataPref </> file)
copyFileVerbose verbosity (dataDir pkg_descr </> file) (dataPref </> file)
when docExists $ do
createDirectoryIfMissingVerbose verbosity True htmlPref
copyDirectoryRecursiveVerbose verbosity
......
......@@ -150,8 +150,9 @@ prepareTree verbosity pkg_descr mb_lbi tmpDir pps = do
Nothing -> findFile (hsSourceDirs exeBi) mainPath
Just pp -> return pp
copyFileTo verbosity targetDir srcMainFile
flip mapM_ (dataFiles pkg_descr) $ \ file -> do
let dir = takeDirectory file
flip mapM_ (dataFiles pkg_descr) $ \ filename -> do
let file = dataDir pkg_descr </> filename
dir = takeDirectory file
createDirectoryIfMissingVerbose verbosity True (targetDir </> dir)
copyFileVerbose verbosity file (targetDir </> file)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment