Skip to content

Commit

Permalink
Add licenseFiles :: [FilePath]
Browse files Browse the repository at this point in the history
  • Loading branch information
L-TChen committed Jun 15, 2021
1 parent 7ead379 commit 1056324
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Cabal/src/Distribution/Simple/Build/PathsModule.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.Build.Macros
-- Module : Distribution.Simple.Build.PathsModule
-- Copyright : Isaac Jones 2003-2005,
-- Ross Paterson 2006,
-- Duncan Coutts 2007-2008
Expand Down Expand Up @@ -28,6 +28,7 @@ import Distribution.Simple.Compiler
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Utils (shortRelativePath)
import Distribution.System
import Distribution.Utils.Path
import Distribution.Version

import qualified Distribution.Simple.Build.PathsModule.Z as Z
Expand All @@ -41,6 +42,7 @@ generatePathsModule pkg_descr lbi clbi = Z.render Z.Z
{ Z.zPackageName = packageName pkg_descr
, Z.zVersionDigits = show $ versionNumbers $ packageVersion pkg_descr
, Z.zLicense = show $ pretty $ license pkg_descr
, Z.zLicenseFiles = show $ fmap getSymbolicPath (licenseFiles pkg_descr)
, Z.zSupportsCpp = supports_cpp
, Z.zSupportsNoRebindableSyntax = supports_rebindable_syntax
, Z.zAbsolute = absolute
Expand Down
9 changes: 8 additions & 1 deletion Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ data Z
= Z {zPackageName :: PackageName,
zVersionDigits :: String,
zLicense :: String,
zLicenseFiles :: String,
zSupportsCpp :: Bool,
zSupportsNoRebindableSyntax :: Bool,
zAbsolute :: Bool,
Expand Down Expand Up @@ -47,7 +48,8 @@ render z_root = execWriter $ do
tell "module Paths_"
tell (zManglePkgName z_root (zPackageName z_root))
tell " (\n"
tell " license, version,\n"
tell " license, licenseFiles,\n"
tell " version,\n"
tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"
tell " getDataFileName, getSysconfDir\n"
tell " ) where\n"
Expand Down Expand Up @@ -102,6 +104,11 @@ render z_root = execWriter $ do
tell (zLicense z_root)
tell "\"\n"
tell "\n"
tell "licenseFiles :: [FilePath]\n"
tell "licenseFiles = "
tell (zLicenseFiles z_root)
tell "\n"
tell "\n"
tell "getDataFileName :: FilePath -> IO FilePath\n"
tell "getDataFileName name = do\n"
tell " dir <- getDataDir\n"
Expand Down
1 change: 1 addition & 0 deletions cabal-dev-scripts/src/GenPathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ $(capture "decls" [d|
{ zPackageName :: PackageName
, zVersionDigits :: String
, zLicense :: String
, zLicenseFiles :: String
, zSupportsCpp :: Bool
, zSupportsNoRebindableSyntax :: Bool
, zAbsolute :: Bool
Expand Down
Empty file.
Empty file.
3 changes: 2 additions & 1 deletion cabal-testsuite/PackageTests/PathsModule/Executable/Main.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module Main where

import Paths_PathsModule (getBinDir, license)
import Paths_PathsModule (getBinDir, license, licenseFiles)

main :: IO ()
main = do
_ <- getBinDir
putStrLn license
mapM_ putStrLn licenseFiles
return ()
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: PathsModule
version: 0.1
license: BSD3
license-file: LICENSE-1 LICENSE-2
author: Johan Tibell
stability: stable
category: PackageTests
Expand Down
6 changes: 5 additions & 1 deletion templates/Paths_pkg.template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module Paths_{{ manglePkgName packageName }} (
license, version,
license, licenseFiles,
version,
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
getDataFileName, getSysconfDir
) where
Expand Down Expand Up @@ -53,6 +54,9 @@ version = Version {{ versionDigits }} []
license :: String
license = "{{ license }}"

licenseFiles :: [FilePath]
licenseFiles = {{ licenseFiles }}

getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
dir <- getDataDir
Expand Down

0 comments on commit 1056324

Please sign in to comment.