Commit c0537226 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Add flag --print-id for ./Setup register, outputs installed package ID



Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 47984faa
...@@ -85,6 +85,7 @@ import System.FilePath ((</>), (<.>), isAbsolute) ...@@ -85,6 +85,7 @@ import System.FilePath ((</>), (<.>), isAbsolute)
import System.Directory import System.Directory
( getCurrentDirectory, removeDirectoryRecursive ) ( getCurrentDirectory, removeDirectoryRecursive )
import Control.Monad (when)
import Data.Maybe import Data.Maybe
( isJust, fromMaybe, maybeToList ) ( isJust, fromMaybe, maybeToList )
import Data.List import Data.List
...@@ -103,6 +104,9 @@ register pkg@PackageDescription { library = Just lib } lbi regFlags ...@@ -103,6 +104,9 @@ register pkg@PackageDescription { library = Just lib } lbi regFlags
installedPkgInfo <- generateRegistrationInfo installedPkgInfo <- generateRegistrationInfo
verbosity pkg lib lbi clbi inplace distPref verbosity pkg lib lbi clbi inplace distPref
when (fromFlag (regPrintId regFlags)) $ do
putStrLn (display (IPI.installedPackageId installedPkgInfo))
-- Three different modes: -- Three different modes:
case () of case () of
_ | modeGenerateRegFile -> writeRegistrationFile installedPkgInfo _ | modeGenerateRegFile -> writeRegistrationFile installedPkgInfo
......
...@@ -929,6 +929,7 @@ data RegisterFlags = RegisterFlags { ...@@ -929,6 +929,7 @@ data RegisterFlags = RegisterFlags {
regGenPkgConf :: Flag (Maybe FilePath), regGenPkgConf :: Flag (Maybe FilePath),
regInPlace :: Flag Bool, regInPlace :: Flag Bool,
regDistPref :: Flag FilePath, regDistPref :: Flag FilePath,
regPrintId :: Flag Bool,
regVerbosity :: Flag Verbosity regVerbosity :: Flag Verbosity
} }
deriving Show deriving Show
...@@ -940,6 +941,7 @@ defaultRegisterFlags = RegisterFlags { ...@@ -940,6 +941,7 @@ defaultRegisterFlags = RegisterFlags {
regGenPkgConf = NoFlag, regGenPkgConf = NoFlag,
regInPlace = Flag False, regInPlace = Flag False,
regDistPref = Flag defaultDistPref, regDistPref = Flag defaultDistPref,
regPrintId = Flag False,
regVerbosity = Flag normal regVerbosity = Flag normal
} }
...@@ -977,6 +979,11 @@ registerCommand = makeCommand name shortDesc longDesc ...@@ -977,6 +979,11 @@ registerCommand = makeCommand name shortDesc longDesc
"instead of registering, generate a package registration file" "instead of registering, generate a package registration file"
regGenPkgConf (\v flags -> flags { regGenPkgConf = v }) regGenPkgConf (\v flags -> flags { regGenPkgConf = v })
(optArg' "PKG" Flag flagToList) (optArg' "PKG" Flag flagToList)
,option "" ["print-ipid"]
"print the installed package ID calculated for this package"
regPrintId (\v flags -> flags { regPrintId = v })
trueArg
] ]
unregisterCommand :: CommandUI RegisterFlags unregisterCommand :: CommandUI RegisterFlags
...@@ -1014,6 +1021,7 @@ instance Monoid RegisterFlags where ...@@ -1014,6 +1021,7 @@ instance Monoid RegisterFlags where
regGenScript = mempty, regGenScript = mempty,
regGenPkgConf = mempty, regGenPkgConf = mempty,
regInPlace = mempty, regInPlace = mempty,
regPrintId = mempty,
regDistPref = mempty, regDistPref = mempty,
regVerbosity = mempty regVerbosity = mempty
} }
...@@ -1022,6 +1030,7 @@ instance Monoid RegisterFlags where ...@@ -1022,6 +1030,7 @@ instance Monoid RegisterFlags where
regGenScript = combine regGenScript, regGenScript = combine regGenScript,
regGenPkgConf = combine regGenPkgConf, regGenPkgConf = combine regGenPkgConf,
regInPlace = combine regInPlace, regInPlace = combine regInPlace,
regPrintId = combine regPrintId,
regDistPref = combine regDistPref, regDistPref = combine regDistPref,
regVerbosity = combine regVerbosity regVerbosity = combine regVerbosity
} }
......
Supports Markdown
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