on master help sign in
Merge pull request #3076 from jfdm/make-ibcsubdir-work-for-ipkgs
546d22cJan de Muijnck-Hughes
CHANGELOG.md+5−3
@@ -3,9 +3,11 @@
3* Improved startup performance by reducing the processing of an already imported
3* Improved startup performance by reducing the processing of an already imported
4 module that has changed accessibility.
4 module that has changed accessibility.
5
5
6−* A limited set of command line options can be used to override package declared
6+* A limited set of command line options can be used to override
7− options. Overridable options are currently, logging level and categories,
7+ package declared options. Overridable options are currently, logging
8− default totality check, warn reach, IBC output folder, and idris path.
8+ level and categories, default totality check, warn reach, IBC output
9+ folder, and idris path. Note overriding IBC output folder, only
10+ affects the installation of Idris packages.
9
11
10* Remove deprecated options `--ideslave` and `--ideslave-socket`. These options
12* Remove deprecated options `--ideslave` and `--ideslave-socket`. These options
11 were replaced with `--ide-mode` and `--ide-mode-socket` in 0.9.17
13 were replaced with `--ide-mode` and `--ide-mode-socket` in 0.9.17
src/Idris/REPL.hs+2−1
@@ -2,7 +2,8 @@
2 PatternGuards, CPP #-}
2 PatternGuards, CPP #-}
3
3
4module Idris.REPL(getClient, getPkg, getPkgCheck, getPkgClean, getPkgMkDoc,
4module Idris.REPL(getClient, getPkg, getPkgCheck, getPkgClean, getPkgMkDoc,
5+ getPkgREPL, getPkgTest, getPort, getIBCSubDir,
5− getPkgREPL, getPkgTest, getPort, idris, idrisMain, loadInputs,
6+ idris, idrisMain, loadInputs,
6 opt, runClient, runMain, ver) where
7 opt, runClient, runMain, ver) where
7
8
8import Idris.AbsSyntax
9import Idris.AbsSyntax
src/Pkg/Package.hs+46−38
@@ -17,8 +17,8 @@ import Control.Monad.Trans.Except (runExceptT)
17
17
18import Data.List
18import Data.List
19import Data.List.Split(splitOn)
19import Data.List.Split(splitOn)
20−
20+import Data.Maybe(fromMaybe)
21−import Data.Either
21+import Data.Either(partitionEithers)
22
22
23import Idris.Core.TT
23import Idris.Core.TT
24import Idris.REPL
24import Idris.REPL
@@ -79,7 +79,7 @@ buildPkg copts warnonly (install, fp) = do
79 case errSpan ist of
79 case errSpan ist of
80 Just _ -> exitWith (ExitFailure 1)
80 Just _ -> exitWith (ExitFailure 1)
81 _ -> return ()
81 _ -> return ()
82− when install $ installPkg pkgdesc
82+ when install $ installPkg (opt getIBCSubDir copts) pkgdesc
83
83
84-- --------------------------------------------------------- [ Check Packages ]
84-- --------------------------------------------------------- [ Check Packages ]
85
85
@@ -254,14 +254,21 @@ testPkg copts fp = do
254-- ----------------------------------------------------------- [ Installation ]
254-- ----------------------------------------------------------- [ Installation ]
255
255
256-- | Install package
256-- | Install package
257+installPkg :: [String] -- ^ Alternate install location
257−installPkg :: PkgDesc -> IO ()
258+ -> PkgDesc -- ^ iPKG file.
259+ -> IO ()
258−installPkg pkgdesc
260+installPkg altdests pkgdesc = inPkgDir pkgdesc $ do
259− = inPkgDir pkgdesc $
261+ d <- getTargetDir
262+ let destdir = case altdests of
263+ [] -> d
264+ (d':_) -> d'
260− do case (execout pkgdesc) of
265+ case (execout pkgdesc) of
266+ Nothing -> do
261− Nothing -> do mapM_ (installIBC (pkgname pkgdesc)) (modules pkgdesc)
267+ mapM_ (installIBC destdir (pkgname pkgdesc)) (modules pkgdesc)
262− installIdx (pkgname pkgdesc)
268+ installIdx destdir (pkgname pkgdesc)
263− Just o -> return () -- do nothing, keep executable locally, for noe
269+ Just o -> return () -- do nothing, keep executable locally, for noe
270+
264− mapM_ (installObj (pkgname pkgdesc)) (objs pkgdesc)
271+ mapM_ (installObj destdir (pkgname pkgdesc)) (objs pkgdesc)
265
272
266-- ---------------------------------------------------------- [ Helper Methods ]
273-- ---------------------------------------------------------- [ Helper Methods ]
267-- Methods for building, testing, installing, and removal of idris
274-- Methods for building, testing, installing, and removal of idris
@@ -305,33 +312,34 @@ rmExe p = do
305toIBCFile (UN n) = str n ++ ".ibc"
312toIBCFile (UN n) = str n ++ ".ibc"
306toIBCFile (NS n ns) = foldl1' (</>) (reverse (toIBCFile n : map str ns))
313toIBCFile (NS n ns) = foldl1' (</>) (reverse (toIBCFile n : map str ns))
307
314
308−installIBC :: String -> Name -> IO ()
315+installIBC :: String -> String -> Name -> IO ()
316+installIBC dest p m = do
309−installIBC p m = do let f = toIBCFile m
317+ let f = toIBCFile m
310− d <- getTargetDir
311− let destdir = d </> p </> getDest m
318+ let destdir = dest </> p </> getDest m
312− putStrLn $ "Installing " ++ f ++ " to " ++ destdir
319+ putStrLn $ "Installing " ++ f ++ " to " ++ destdir
313− createDirectoryIfMissing True destdir
320+ createDirectoryIfMissing True destdir
314− copyFile f (destdir </> takeFileName f)
321+ copyFile f (destdir </> takeFileName f)
315− return ()
322+ return ()
323+ where
316− where getDest (UN n) = ""
324+ getDest (UN n) = ""
317− getDest (NS n ns) = foldl1' (</>) (reverse (getDest n : map str ns))
325+ getDest (NS n ns) = foldl1' (</>) (reverse (getDest n : map str ns))
318−
326+
319−installIdx :: String -> IO ()
327+installIdx :: String -> String -> IO ()
320−installIdx p = do d <- getTargetDir
328+installIdx dest p = do
321− let f = pkgIndex p
329+ let f = pkgIndex p
322− let destdir = d </> p
330+ let destdir = dest </> p
323− putStrLn $ "Installing " ++ f ++ " to " ++ destdir
331+ putStrLn $ "Installing " ++ f ++ " to " ++ destdir
324− createDirectoryIfMissing True destdir
332+ createDirectoryIfMissing True destdir
325− copyFile f (destdir </> takeFileName f)
333+ copyFile f (destdir </> takeFileName f)
326− return ()
334+ return ()
327−
335+
328−installObj :: String -> String -> IO ()
336+installObj :: String -> String -> String -> IO ()
329−installObj p o = do d <- getTargetDir
337+installObj dest p o = do
330− let destdir = addTrailingPathSeparator (d </> p)
338+ let destdir = addTrailingPathSeparator (dest </> p)
331− putStrLn $ "Installing " ++ o ++ " to " ++ destdir
339+ putStrLn $ "Installing " ++ o ++ " to " ++ destdir
332− createDirectoryIfMissing True destdir
340+ createDirectoryIfMissing True destdir
333− copyFile o (destdir </> takeFileName o)
341+ copyFile o (destdir </> takeFileName o)
334− return ()
342+ return ()
335
343
336#ifdef mingw32_HOST_OS
344#ifdef mingw32_HOST_OS
337mkDirCmd = "mkdir "
345mkDirCmd = "mkdir "