packages feed

haskell-packages 0.1 → 0.2

raw patch · 5 files changed

+76/−16 lines, 5 files

Files

README.md view
@@ -57,7 +57,9 @@ It doesn't matter what Cabal version you use together with haskell-packages, but if you want to invoke a haskell-packages compiler from Cabal (see [Usage](#usage)), you need to build our [fork of Cabal][Cabal]. Eventually it-will be merged into Cabal.+will be merged into Cabal. If you are using version `v0.1` of haskell-packages+(and not the `master` branch), then use the tag `haskell-packages-0.1` of the+forked Cabal repository.  [hse]: https://github.com/haskell-suite/haskell-src-exts [Cabal]: https://github.com/feuerbach/Cabal
haskell-packages.cabal view
@@ -2,16 +2,16 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                haskell-packages-version:             0.1+version:             0.2 synopsis:            Haskell suite library for package management and integration with Cabal-description:         See <http://haskell-suite.github.io/haskell-packages/>+description:         See <http://documentup.com/haskell-suite/haskell-packages> license:             MIT license-file:        LICENSE author:              Roman Cheplyaka maintainer:          Roman Cheplyaka <roma@ro-che.info> copyright:           (c) Roman Cheplyaka 2012 category:            Distribution-homepage:            http://haskell-suite.github.io/haskell-packages/+homepage:            http://documentup.com/haskell-suite/haskell-packages bug-reports:         https://github.com/haskell-suite/haskell-packages/issues build-type:          Simple cabal-version:       >=1.10@@ -25,7 +25,7 @@ source-repository this   type:     git   location: git://github.com/haskell-suite/haskell-packages.git-  tag:      v0.1+  tag:      v0.2  library   default-language:    Haskell2010
src/Distribution/HaskellSuite/Cabal.hs view
@@ -142,16 +142,21 @@   compilerCommand =     command "compile" (info compiler idm)   compiler =-    (\srcDirs buildDir lang exts cppOpts dbStack pkgids mods ->-        Compiler.compile t buildDir lang exts cppOpts dbStack pkgids =<< findModules srcDirs mods) <$>+    (\srcDirs buildDir lang exts cppOpts pkg dbStack deps mods ->+        Compiler.compile t buildDir lang exts cppOpts pkg dbStack deps =<< findModules srcDirs mods) <$>       (many $ strOption (short 'i' <> metavar "PATH")) <*>       (strOption (long "build-dir" <> metavar "PATH") <|> pure ".") <*>       (optional $ classifyLanguage <$> strOption (short 'G' <> metavar "language")) <*>       (many $ parseExtension <$> strOption (short 'X' <> metavar "extension")) <*>       cppOptsParser <*>+      (nullOption (long "package-name" <> metavar "NAME-VERSION" <> reader pkgNameReader)) <*>       pkgDbStackParser <*>       (many $ InstalledPackageId <$> strOption (long "package-id")) <*>       arguments str (metavar "MODULE")+    where+      pkgNameReader =+        maybe (Left $ ErrorMsg "invalid package name") Right .+        simpleParse  data ModuleNotFound = ModuleNotFound String   deriving Typeable
src/Distribution/HaskellSuite/Compiler.hs view
@@ -41,13 +41,14 @@  -- | Compilation function type CompileFn-  =  FilePath-  -> Maybe Language-  -> [Extension]-  -> CpphsOptions-  -> PackageDBStack-  -> [InstalledPackageId]-  -> [FilePath]+  =  FilePath -- ^ build directory+  -> Maybe Language -- ^ optional default language+  -> [Extension] -- ^ default extensions+  -> CpphsOptions -- ^ CPP options+  -> PackageId -- ^ name and version of the package being compiled+  -> PackageDBStack -- ^ package db stack to use+  -> [InstalledPackageId] -- ^ dependencies+  -> [FilePath] -- ^ list of files to compile   -> IO ()  -- | An abstraction over a Haskell compiler.
src/Distribution/HaskellSuite/Packages.hs view
@@ -26,7 +26,23 @@   , StandardDB(..)   , IsDBName(..) -  -- * Auxiliary functions+  -- * Relative paths in package databases+  -- | Traditionally, the paths in package databases are absolute.+  --+  -- haskell-packages allows relative file paths in databases, which is+  -- useful in some cases (e.g. relocatable global package database).+  --+  -- By default, 'readPackageDB' (for 'StandardDB') treats relative paths+  -- as being relative to the database path.+  --+  -- However, Cabal still passes absolute file names, and by default+  -- 'writePackageDB' stores them verbatim. To change this, use+  -- 'makePkgInfoRelative' in your implementation of 'writePackageDB'.+  , makePkgInfoRelative+  , makePkgInfoAbsolute+  , mapPaths++  -- * Direct database manipulation   -- | 'writeDB' and 'readDB' perform (de)serialization of a package   -- database using a simple JSON encoding. You may use these to implement   -- 'writePackageDB' and 'readPackageDB' for your own databases.@@ -62,6 +78,8 @@ import Distribution.Simple.Compiler (PackageDB(..)) import Distribution.License (License(..)) import Distribution.ModuleName(ModuleName)+import Distribution.Simple.Utils+import Distribution.Verbosity  -------------- -- Querying --@@ -189,11 +207,44 @@ instance IsDBName name => IsPackageDB (StandardDB name) where   dbName = retag (getDBName :: Tagged name String) -  readPackageDB init (StandardDB db) = readDB init db+  readPackageDB init (StandardDB db) =+    map (makePkgInfoAbsolute (dropFileName db)) <$> readDB init db   writePackageDB (StandardDB db) = writeDB db   globalDB = return Nothing   dbFromPath path = return $ StandardDB path +---------------------------------+-- Absolute and relative paths --+---------------------------------++-- | Make all paths in the package info relative to the given base+-- directory.+makePkgInfoRelative :: FilePath -> Info.InstalledPackageInfo -> Info.InstalledPackageInfo+makePkgInfoRelative base info =+  mapPaths (makeRelative base) info++-- | Make all relative paths in the package info absolute, interpreting+-- them relative to the given base directory.+makePkgInfoAbsolute :: FilePath -> Info.InstalledPackageInfo -> Info.InstalledPackageInfo+makePkgInfoAbsolute base info =+  flip mapPaths info $ \f ->+    if isRelative f+      then base </> f+      else f++-- | Apply a given function to all file paths contained in the package info+mapPaths+  :: (FilePath -> FilePath)+  -> (Info.InstalledPackageInfo -> Info.InstalledPackageInfo)+mapPaths f info = info+  { Info.importDirs = map f (Info.importDirs info)+  , Info.libraryDirs = map f (Info.libraryDirs info)+  , Info.includeDirs = map f (Info.includeDirs info)+  , Info.frameworkDirs = map f (Info.frameworkDirs info)+  , Info.haddockInterfaces = map f (Info.haddockInterfaces info)+  , Info.haddockHTMLs = map f (Info.haddockHTMLs info)+  }+ ------------------------- -- Auxiliary functions -- -------------------------@@ -221,6 +272,7 @@ initDB path = do   dbExists <- doesFileExist path   unless dbExists $ do+    createDirectoryIfMissingVerbose silent True (dropFileName path)     writeDB path []  haskellPackagesDir :: IO FilePath