on master help sign in
Make --install respect TARGET for .ibc AND objects
844f927Leif Warner
src/Pkg/Package.hs+3−4
@@ -20,7 +20,7 @@ import Idris.AbsSyntax
20
20
21import Pkg.PParser
21import Pkg.PParser
22
22
23−import Paths_idris
23+import Paths_idris (getDataDir)
24
24
25-- To build a package:
25-- To build a package:
26-- * read the package description
26-- * read the package description
@@ -98,8 +98,7 @@ toIBCFile (NS n ns) = foldl1' (</>) (reverse (toIBCFile n : ns))
98
98
99installIBC :: String -> Name -> IO ()
99installIBC :: String -> Name -> IO ()
100installIBC p m = do let f = toIBCFile m
100installIBC p m = do let f = toIBCFile m
101− target <- environment "TARGET"
101+ d <- getTargetDir
102− d <- maybe getDataDir return target
103 let destdir = d </> p </> getDest m
102 let destdir = d </> p </> getDest m
104 putStrLn $ "Installing " ++ f ++ " to " ++ destdir
103 putStrLn $ "Installing " ++ f ++ " to " ++ destdir
105 createDirectoryIfMissing True destdir
104 createDirectoryIfMissing True destdir
@@ -109,7 +108,7 @@ installIBC p m = do let f = toIBCFile m
109 getDest (NS n ns) = foldl1' (</>) (reverse (getDest n : ns))
108 getDest (NS n ns) = foldl1' (</>) (reverse (getDest n : ns))
110
109
111installObj :: String -> String -> IO ()
110installObj :: String -> String -> IO ()
112−installObj p o = do d <- getDataDir
111+installObj p o = do d <- getTargetDir
113 let destdir = addTrailingPathSeparator (d </> p)
112 let destdir = addTrailingPathSeparator (d </> p)
114 putStrLn $ "Installing " ++ o ++ " to " ++ destdir
113 putStrLn $ "Installing " ++ o ++ " to " ++ destdir
115 createDirectoryIfMissing True destdir
114 createDirectoryIfMissing True destdir
src/Util/System.hs+4−1
@@ -1,5 +1,5 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−module Util.System(tempfile,withTempdir,environment,getCC,
2+module Util.System(tempfile,withTempdir,getTargetDir,getCC,
3 getLibFlags,getIdrisLibDir,getIncFlags,rmFile,
3 getLibFlags,getIdrisLibDir,getIncFlags,rmFile,
4 getMvn,getExecutablePom,catchIO) where
4 getMvn,getExecutablePom,catchIO) where
5
5
@@ -64,6 +64,9 @@ environment x = catchIO (do e <- getEnv x
64 return (Just e))
64 return (Just e))
65 (\_ -> return Nothing)
65 (\_ -> return Nothing)
66
66
67+getTargetDir :: IO String
68+getTargetDir = environment "TARGET" >>= maybe getDataDir return
69+
67rmFile :: FilePath -> IO ()
70rmFile :: FilePath -> IO ()
68rmFile f = do putStrLn $ "Removing " ++ f
71rmFile f = do putStrLn $ "Removing " ++ f
69 catchIO (removeFile f)
72 catchIO (removeFile f)