on master help sign in
Merge pull request #3462 from jfdm/install-doc-files
d1eccd8Jan de Muijnck-Hughes
CHANGELOG.md+7−3
@@ -40,10 +40,14 @@
40
40
41* Idris' documentation system now displays the documentation for auto
41* Idris' documentation system now displays the documentation for auto
42 implicits in the output of `:doc`. This is tested for in `docs005`.
42 implicits in the output of `:doc`. This is tested for in `docs005`.
43−
44* New command line flag `--info` that displays information about the installation.
43* New command line flag `--info` that displays information about the installation.
45−
46* New command line flag `--sourcepath <dir>` that allows adding directories to the source search path.
44* New command line flag `--sourcepath <dir>` that allows adding directories to the source search path.
45+* Allow 'installation' of a package's IdrisDoc documentation into a central location. The default location is the subdirectory `docs` of Idris' data directory.
46+ * New flag `--installdoc <ipkg>` provided to install documentation
47+ * New flag `--docdir` provided to show default documentation installation location.
48+ * New environment variable `IDRIS_DOC_PATH` to allow specification of an alternative installation path for documentation.
49+* Semantic meaning behind several environment variables has been clarified in documentation and code. See compilation section of the reference manual for more details.
50+
47## Miscellaneous updates
51## Miscellaneous updates
48
52
49* The test suite now uses [tasty-golden](https://hackage.haskell.org/package/tasty-golden). New tests must be registered in `test/TestData.hs`, as explained in the relevant `README.md`.
53* The test suite now uses [tasty-golden](https://hackage.haskell.org/package/tasty-golden). New tests must be registered in `test/TestData.hs`, as explained in the relevant `README.md`.
@@ -51,7 +55,7 @@
51
55
52## UI Changes
56## UI Changes
53
57
54−* The :e command can now handle an $EDITOR with arguments in it, like "emacs -nw"
58+* The :e command can now handle an $EDITOR with arguments in it, like "emacs -nw"
55
59
56
60
57# New in 0.12:
61# New in 0.12:
Setup.hs+1−2
@@ -254,7 +254,7 @@ idrisInstall verbosity copy pkg local = unless (execOnly (configFlags local)) $
254 target = datadir $ L.absoluteInstallDirs pkg local copy
254 target = datadir $ L.absoluteInstallDirs pkg local copy
255
255
256 installStdLib = do
256 installStdLib = do
257− let target' = target </> "libs"
257+ let target' = target -- </> "libs"
258 putStrLn $ "Installing libraries in " ++ target'
258 putStrLn $ "Installing libraries in " ++ target'
259 makeInstall "libs" target'
259 makeInstall "libs" target'
260
260
@@ -268,7 +268,6 @@ idrisInstall verbosity copy pkg local = unless (execOnly (configFlags local)) $
268 notice verbosity $ unwords ["Copying man page to", mandest]
268 notice verbosity $ unwords ["Copying man page to", mandest]
269 installOrdinaryFiles verbosity mandest [("man", "idris.1")]
269 installOrdinaryFiles verbosity mandest [("man", "idris.1")]
270
270
271−
272 makeInstall src target =
271 makeInstall src target =
273 make verbosity [ "-C", src, "install" , "TARGET=" ++ target, "IDRIS=" ++ idrisCmd local]
272 make verbosity [ "-C", src, "install" , "TARGET=" ++ target, "IDRIS=" ++ idrisCmd local]
274
273
docs/reference/compilation.rst+27−19
@@ -86,22 +86,30 @@ overridden through environment variables. The provided variables are:
86
86
87* `IDRIS_CC` Change the `C` compiler used by the `C` backend.
87* `IDRIS_CC` Change the `C` compiler used by the `C` backend.
88* `IDRIS_CFLAGS` Change the `C` flags passed to the `C` compiler.
88* `IDRIS_CFLAGS` Change the `C` flags passed to the `C` compiler.
89−* `TARGET` Change the target directory to generate files.
89+* `TARGET` Change the target directory i.e. `data dir` where Idris installs files when installing using Cabal/Stack.
90−* `IDRIS_LIBRARY_PATH` Change the location of where installed packages are found.
90+* `IDRIS_LIBRARY_PATH` Change the location of where installed packages are found/installed.
91−
91+* `IDRIS_DOC_PATH` Change the location of where generated idrisdoc for packages are installed.
92−Alternativly, and perhaps a cleaner approach is to configure these
92+
93+.. note::
94+
95+ In versions of Idris prior to 0.12.3 the environment variables
96+ `IDRIS_LIBRARY_PATH` and `TARGET` were both used to affect the
97+ installation of single packages and direct where Idris installed
98+ its data. The meaning of these variables has changed, and command
99+ line options are preferred when changing where individual packages
100+ are installed.
101+
102+The CLI option `--ibcsubdir` can be used to direct where generated IBC
103+files are placed. However, this means Idris will install files in a
104+non-standard location separate from the rest of the installed
105+packages. The CLI option `--idrispath <dir>` allows you to add a
106+directory to the library search path; this option can be used multiple
107+times and can be shortened to `-i <dir>`. Similary, the `--sourcepath
108+<dir>` option can be used to add directories to the source search
109+path. There is no shortened version for this option as `-s` is a
110+reserved flag.
111+
93−options using the CLI options. Idris also supports options to augment
112+Further, Idris also supports options to augment the paths used, and
94−the paths used, and pass options to the code generator backend.
113+pass options to the code generator backend. The option `--cg-opt
95−
96−The option `--cg-opt <ARG>` can be used to pass options to the code
114+<ARG>` can be used to pass options to the code generator. The format
97−generator. The format of `<ARG>` is dependent on the selected backend.
115+of `<ARG>` is dependent on the selected backend.
98−
99−Further, Idris does support multiple include paths. The CLI option
100−`-i <dir>` allows you to add a directory to the library search path; this
101−option can be used multiple times. This is a cleaner option when you
102−wish to add single directories to the `IDRIS_LIBRARY_PATH` than
103−ammending `IDRIS_LIBRARY_PATH` directly.
104−To add directories to the source search path, use the `--sourcepath <dir>` option.
105−
106−Moreover, rather than using `TARGET` the CLI option `--ibcsubdir` can
107−be used to direct where built IBC files are placed.
libs/Makefile−1
@@ -34,5 +34,4 @@ doc_clean:
34 $(MAKE) -C effects doc_clean
34 $(MAKE) -C effects doc_clean
35 $(MAKE) -C pruviloj doc_clean
35 $(MAKE) -C pruviloj doc_clean
36
36
37−
38.PHONY: build install clean doc doc_clean
37.PHONY: build install clean doc doc_clean
libs/base/Makefile+3−2
@@ -4,8 +4,9 @@ PKG := base
4build:
4build:
5 $(IDRIS) --build ${PKG}.ipkg
5 $(IDRIS) --build ${PKG}.ipkg
6
6
7−install:
7+install:
8 $(IDRIS) --install ${PKG}.ipkg
8 $(IDRIS) --install ${PKG}.ipkg
9+ ${IDRIS} --installdoc ${PKG}.ipkg
9
10
10clean:
11clean:
11 $(IDRIS) --clean ${PKG}.ipkg
12 $(IDRIS) --clean ${PKG}.ipkg
@@ -21,4 +22,4 @@ doc_clean:
21linecount:
22linecount:
22 find . -name '*.idr' | xargs wc -l
23 find . -name '*.idr' | xargs wc -l
23
24
24−.PHONY: build install clean rebuild linecount
25+.PHONY: build install clean rebuild linecount doc doc_clean
libs/contrib/Makefile+3−2
@@ -4,8 +4,9 @@ PKG := contrib
4build:
4build:
5 $(IDRIS) --build ${PKG}.ipkg
5 $(IDRIS) --build ${PKG}.ipkg
6
6
7−install:
7+install:
8 $(IDRIS) --install ${PKG}.ipkg
8 $(IDRIS) --install ${PKG}.ipkg
9+ ${IDRIS} --installdoc ${PKG}.ipkg
9
10
10clean:
11clean:
11 $(IDRIS) --clean ${PKG}.ipkg
12 $(IDRIS) --clean ${PKG}.ipkg
@@ -21,4 +22,4 @@ doc_clean:
21linecount:
22linecount:
22 find . -name '*.idr' | xargs wc -l
23 find . -name '*.idr' | xargs wc -l
23
24
24−.PHONY: build install clean rebuild linecount
25+.PHONY: build install clean rebuild linecount doc doc_clean
libs/effects/Makefile+1
@@ -9,6 +9,7 @@ clean:
9
9
10install:
10install:
11 $(IDRIS) --install ${PKG}.ipkg
11 $(IDRIS) --install ${PKG}.ipkg
12+ ${IDRIS} --installdoc ${PKG}.ipkg
12
13
13rebuild: clean build
14rebuild: clean build
14
15
libs/prelude/Makefile+2−1
@@ -4,8 +4,9 @@ PKG := prelude
4build:
4build:
5 $(IDRIS) --build ${PKG}.ipkg
5 $(IDRIS) --build ${PKG}.ipkg
6
6
7−install:
7+install:
8 $(IDRIS) --install ${PKG}.ipkg
8 $(IDRIS) --install ${PKG}.ipkg
9+ ${IDRIS} --installdoc ${PKG}.ipkg
9
10
10clean:
11clean:
11 $(IDRIS) --clean ${PKG}.ipkg
12 $(IDRIS) --clean ${PKG}.ipkg
libs/pruviloj/Makefile+1
@@ -9,6 +9,7 @@ clean:
9
9
10install:
10install:
11 $(IDRIS) --install ${PKG}.ipkg
11 $(IDRIS) --install ${PKG}.ipkg
12+ ${IDRIS} --installdoc ${PKG}.ipkg
12
13
13rebuild: clean build
14rebuild: clean build
14
15
main/Main.hs+2−1
@@ -18,7 +18,8 @@ processShowOptions opts = runIO $ do
18 when (ShowLoggingCats `elem` opts) $ showExitIdrisLoggingCategories
18 when (ShowLoggingCats `elem` opts) $ showExitIdrisLoggingCategories
19 when (ShowIncs `elem` opts) $ showExitIdrisFlagsInc
19 when (ShowIncs `elem` opts) $ showExitIdrisFlagsInc
20 when (ShowLibs `elem` opts) $ showExitIdrisFlagsLibs
20 when (ShowLibs `elem` opts) $ showExitIdrisFlagsLibs
21− when (ShowLibdir `elem` opts) $ showExitIdrisLibDir
21+ when (ShowLibDir `elem` opts) $ showExitIdrisLibDir
22+ when (ShowDocDir `elem` opts) $ showExitIdrisDocDir
22 when (ShowPkgs `elem` opts) $ showExitIdrisInstalledPackages
23 when (ShowPkgs `elem` opts) $ showExitIdrisInstalledPackages
23
24
24check :: [Opt] -> (Opt -> Maybe a) -> ([a] -> Idris ()) -> Idris ()
25check :: [Opt] -> (Opt -> Maybe a) -> ([a] -> Idris ()) -> Idris ()
src/IRTS/CodegenC.hs+2−2
@@ -66,8 +66,8 @@ codegenC' defs out exec incs objs libs flags exports iface dbg
66 let h = concatMap toDecl (map fst bc)
66 let h = concatMap toDecl (map fst bc)
67 let cc = concatMap (uncurry toC) bc
67 let cc = concatMap (uncurry toC) bc
68 let hi = concatMap ifaceC (concatMap getExp exports)
68 let hi = concatMap ifaceC (concatMap getExp exports)
69− d <- getDataDir
69+ d <- getIdrisCRTSDir
70− mprog <- readFile (d </> "rts" </> "idris_main" <.> "c")
70+ mprog <- readFile (d </> "idris_main" <.> "c")
71 let cout = headers incs ++ debug dbg ++ h ++ wrappers ++ cc ++
71 let cout = headers incs ++ debug dbg ++ h ++ wrappers ++ cc ++
72 (if (exec == Executable) then mprog else hi)
72 (if (exec == Executable) then mprog else hi)
73 case exec of
73 case exec of
src/IRTS/CodegenJavaScript.hs+16−16
@@ -121,27 +121,27 @@ codegenJS_all
121 -> OutputType
121 -> OutputType
122 -> IO ()
122 -> IO ()
123codegenJS_all target definitions includes libs filename exports outputType = do
123codegenJS_all target definitions includes libs filename exports outputType = do
124− let bytecode = map toBC definitions
124+ let bytecode = map toBC definitions
125− let info = initCompileInfo bytecode
125+ let info = initCompileInfo bytecode
126− let js = concatMap (translateDecl info) bytecode
126+ let js = concatMap (translateDecl info) bytecode
127− let full = concatMap processFunction js
127+ let full = concatMap processFunction js
128 let exportedNames = map translateName ((getExpNames exports) ++ [sUN "call__IO"])
128 let exportedNames = map translateName ((getExpNames exports) ++ [sUN "call__IO"])
129− let code = deadCodeElim exportedNames full
129+ let code = deadCodeElim exportedNames full
130− let ext = takeExtension filename
130+ let ext = takeExtension filename
131− let isHtml = target == JavaScript && ext == ".html"
131+ let isHtml = target == JavaScript && ext == ".html"
132− let htmlPrologue = T.pack "<!doctype html><html><head><script>\n"
132+ let htmlPrologue = T.pack "<!doctype html><html><head><script>\n"
133− let htmlEpilogue = T.pack "\n</script></head><body></body></html>"
133+ let htmlEpilogue = T.pack "\n</script></head><body></body></html>"
134− let (cons, opt) = optimizeConstructors code
134+ let (cons, opt) = optimizeConstructors code
135− let (header, rt) = case target of
135+ let (header, rt) = case target of
136− Node -> ("#!/usr/bin/env node\n", "-node")
136+ Node -> ("#!/usr/bin/env node\n", "-node")
137 JavaScript -> ("", "-browser")
137 JavaScript -> ("", "-browser")
138
138
139 included <- concat <$> getIncludes includes
139 included <- concat <$> getIncludes includes
140− path <- (++) <$> getDataDir <*> (pure "/jsrts/")
140+ path <- getIdrisJSRTSDir
141− idrRuntime <- readFile $ path ++ "Runtime-common.js"
141+ idrRuntime <- readFile $ path </> "Runtime-common.js"
142− tgtRuntime <- readFile $ concat [path, "Runtime", rt, ".js"]
142+ tgtRuntime <- readFile $ path </> concat ["Runtime", rt, ".js"]
143 jsbn <- if compileInfoNeedsBigInt info
143 jsbn <- if compileInfoNeedsBigInt info
144− then readFile $ path ++ "jsbn/jsbn.js"
144+ then readFile $ path </> "jsbn/jsbn.js"
145 else return ""
145 else return ""
146 let runtime = ( header
146 let runtime = ( header
147 ++ includeLibs libs
147 ++ includeLibs libs
src/IRTS/System.hs+34−13
@@ -7,11 +7,13 @@ Maintainer : The Idris Community.
7-}
7-}
8{-# LANGUAGE CPP #-}
8{-# LANGUAGE CPP #-}
9module IRTS.System( getDataFileName
9module IRTS.System( getDataFileName
10− , getDataDir
11− , getTargetDir
12 , getCC
10 , getCC
13 , getLibFlags
11 , getLibFlags
12+ , getIdrisDataDir
14 , getIdrisLibDir
13 , getIdrisLibDir
14+ , getIdrisDocDir
15+ , getIdrisCRTSDir
16+ , getIdrisJSRTSDir
15 , getIncFlags
17 , getIncFlags
16 , getEnvFlags
18 , getEnvFlags
17 , version
19 , version
@@ -31,13 +33,24 @@ import Paths_idris (version)
31import Paths_idris
33import Paths_idris
32#endif
34#endif
33
35
34−overrideDataDirWith :: String -> IO FilePath
36+getIdrisDataDir :: IO String
35−overrideDataDirWith envVar = do
37+getIdrisDataDir = do
36− envValue <- lookupEnv envVar
38+ envValue <- lookupEnv "TARGET"
37 case envValue of
39 case envValue of
38 Nothing -> do
40 Nothing -> do
39 ddir <- getDataDir
41 ddir <- getDataDir
40− return (ddir </> "libs")
42+ return ddir
43+ Just ddir -> return ddir
44+
45+overrideIdrisSubDirWith :: String -- ^ Sub directory in `getDataDir` location.
46+ -> String -- ^ Environment variable to get new location from.
47+ -> IO FilePath
48+overrideIdrisSubDirWith fp envVar = do
49+ envValue <- lookupEnv envVar
50+ case envValue of
51+ Nothing -> do
52+ ddir <- getIdrisDataDir
53+ return (ddir </> fp)
41 Just ddir -> return ddir
54 Just ddir -> return ddir
42
55
43getCC :: IO String
56getCC :: IO String
@@ -46,8 +59,6 @@ getCC = fromMaybe "gcc" <$> lookupEnv "IDRIS_CC"
46getEnvFlags :: IO [String]
59getEnvFlags :: IO [String]
47getEnvFlags = maybe [] (splitOn " ") <$> lookupEnv "IDRIS_CFLAGS"
60getEnvFlags = maybe [] (splitOn " ") <$> lookupEnv "IDRIS_CFLAGS"
48
61
49−getTargetDir :: IO String
50−getTargetDir = overrideDataDirWith "TARGET"
51
62
52#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)\
63#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)\
53 || defined(openbsd_HOST_OS) || defined(netbsd_HOST_OS)
64 || defined(openbsd_HOST_OS) || defined(netbsd_HOST_OS)
@@ -64,11 +75,21 @@ gmpLib = ["-lgmp"]
64gmpLib = []
75gmpLib = []
65#endif
76#endif
66
77
67−getLibFlags = do dir <- getDataDir
78+getLibFlags = do dir <- getIdrisCRTSDir
68− return $ ["-L" ++ (dir </> "rts"),
79+ return $ ["-L" ++ dir,
69 "-lidris_rts"] ++ extraLib ++ gmpLib ++ ["-lpthread"]
80 "-lidris_rts"] ++ extraLib ++ gmpLib ++ ["-lpthread"]
70
81
71−getIdrisLibDir = addTrailingPathSeparator <$> overrideDataDirWith "IDRIS_LIBRARY_PATH"
82+getIdrisLibDir = addTrailingPathSeparator <$> overrideIdrisSubDirWith "libs" "IDRIS_LIBRARY_PATH"
83+
84+getIdrisDocDir = addTrailingPathSeparator <$> overrideIdrisSubDirWith "docs" "IDRIS_DOC_PATH"
85+
86+getIdrisJSRTSDir = do
87+ ddir <- getIdrisDataDir
88+ return $ addTrailingPathSeparator (ddir </> "jsrts")
89+
90+getIdrisCRTSDir = do
91+ ddir <- getIdrisDataDir
92+ return $ addTrailingPathSeparator (ddir </> "rts")
72
93
73−getIncFlags = do dir <- getDataDir
94+getIncFlags = do dir <- getIdrisCRTSDir
74− return $ ("-I" ++ dir </> "rts") : extraInclude
95+ return $ ("-I" ++ dir) : extraInclude
src/Idris/AbsSyntax.hs+5−4
@@ -2545,7 +2545,7 @@ getPkgDir (Pkg str) = Just str
2545getPkgDir _ = Nothing
2545getPkgDir _ = Nothing
2546
2546
2547getPkg :: Opt -> Maybe (Bool, String)
2547getPkg :: Opt -> Maybe (Bool, String)
2548−getPkg (PkgBuild str) = Just (False, str)
2548+getPkg (PkgBuild str) = Just (False, str)
2549getPkg (PkgInstall str) = Just (True, str)
2549getPkg (PkgInstall str) = Just (True, str)
2550getPkg _ = Nothing
2550getPkg _ = Nothing
2551
2551
@@ -2563,9 +2563,10 @@ getPkgCheck _ = Nothing
2563
2563
2564-- | Returns None if given an Opt which is not PkgMkDoc
2564-- | Returns None if given an Opt which is not PkgMkDoc
2565-- Otherwise returns Just x, where x is the contents of PkgMkDoc
2565-- Otherwise returns Just x, where x is the contents of PkgMkDoc
2566−getPkgMkDoc :: Opt -- ^ Opt to extract
2566+getPkgMkDoc :: Opt -- ^ Opt to extract
2567− -> Maybe String -- ^ Result
2567+ -> Maybe (Bool, String) -- ^ Result
2568−getPkgMkDoc (PkgMkDoc str) = Just str
2568+getPkgMkDoc (PkgDocBuild str) = Just (False,str)
2569+getPkgMkDoc (PkgDocInstall str) = Just (True,str)
2569getPkgMkDoc _ = Nothing
2570getPkgMkDoc _ = Nothing
2570
2571
2571getPkgTest :: Opt -- ^ the option to extract
2572getPkgTest :: Opt -- ^ the option to extract
src/Idris/AbsSyntaxTree.hs+4−2
@@ -492,7 +492,8 @@ data Opt = Filename String
492 | IdemodeSocket
492 | IdemodeSocket
493 | ShowAll
493 | ShowAll
494 | ShowLibs
494 | ShowLibs
495− | ShowLibdir
495+ | ShowLibDir
496+ | ShowDocDir
496 | ShowIncs
497 | ShowIncs
497 | ShowPkgs
498 | ShowPkgs
498 | ShowLoggingCats
499 | ShowLoggingCats
@@ -524,7 +525,8 @@ data Opt = Filename String
524 | PkgClean String
525 | PkgClean String
525 | PkgCheck String
526 | PkgCheck String
526 | PkgREPL String
527 | PkgREPL String
527− | PkgMkDoc String -- IdrisDoc
528+ | PkgDocBuild String -- IdrisDoc
529+ | PkgDocInstall String
528 | PkgTest String
530 | PkgTest String
529 | PkgIndex FilePath
531 | PkgIndex FilePath
530 | WarnOnly
532 | WarnOnly
src/Idris/CmdOptions.hs+10−8
@@ -129,7 +129,8 @@ parseFlags = many $
129 <|> flag' ShowLoggingCats (long "listlogcats" <> help "Display logging categories")
129 <|> flag' ShowLoggingCats (long "listlogcats" <> help "Display logging categories")
130 <|> flag' ShowLibs (long "link" <> help "Display link flags")
130 <|> flag' ShowLibs (long "link" <> help "Display link flags")
131 <|> flag' ShowPkgs (long "listlibs" <> help "Display installed libraries")
131 <|> flag' ShowPkgs (long "listlibs" <> help "Display installed libraries")
132− <|> flag' ShowLibdir (long "libdir" <> help "Display library directory")
132+ <|> flag' ShowLibDir (long "libdir" <> help "Display library directory")
133+ <|> flag' ShowDocDir (long "docdir" <> help "Display idrisdoc install directory")
133 <|> flag' ShowIncs (long "include" <> help "Display the includes flags")
134 <|> flag' ShowIncs (long "include" <> help "Display the includes flags")
134
135
135 <|> flag' Verbose (short 'V' <> long "verbose" <> help "Loud verbosity")
136 <|> flag' Verbose (short 'V' <> long "verbose" <> help "Loud verbosity")
@@ -144,13 +145,14 @@ parseFlags = many $
144 <|> (Port <$> option portReader (long "port" <> metavar "PORT" <> help "REPL TCP port - pass \"none\" to not bind any port"))
145 <|> (Port <$> option portReader (long "port" <> metavar "PORT" <> help "REPL TCP port - pass \"none\" to not bind any port"))
145
146
146 -- Package commands
147 -- Package commands
147− <|> (PkgBuild <$> strOption (long "build" <> metavar "IPKG" <> help "Build package"))
148+ <|> (PkgBuild <$> strOption (long "build" <> metavar "IPKG" <> help "Build package"))
148− <|> (PkgInstall <$> strOption (long "install" <> metavar "IPKG" <> help "Install package"))
149+ <|> (PkgInstall <$> strOption (long "install" <> metavar "IPKG" <> help "Install package"))
149− <|> (PkgREPL <$> strOption (long "repl" <> metavar "IPKG" <> help "Launch REPL, only for executables"))
150+ <|> (PkgREPL <$> strOption (long "repl" <> metavar "IPKG" <> help "Launch REPL, only for executables"))
150− <|> (PkgClean <$> strOption (long "clean" <> metavar "IPKG" <> help "Clean package"))
151+ <|> (PkgClean <$> strOption (long "clean" <> metavar "IPKG" <> help "Clean package"))
151− <|> (PkgMkDoc <$> strOption (long "mkdoc" <> metavar "IPKG" <> help "Generate IdrisDoc for package"))
152+ <|> (PkgDocBuild <$> strOption (long "mkdoc" <> metavar "IPKG" <> help "Generate IdrisDoc for package"))
153+ <|> (PkgDocInstall <$> strOption (long "installdoc" <> metavar "IPKG" <> help "Install IdrisDoc for package"))
152− <|> (PkgCheck <$> strOption (long "checkpkg" <> metavar "IPKG" <> help "Check package only"))
154+ <|> (PkgCheck <$> strOption (long "checkpkg" <> metavar "IPKG" <> help "Check package only"))
153− <|> (PkgTest <$> strOption (long "testpkg" <> metavar "IPKG" <> help "Run tests for package"))
155+ <|> (PkgTest <$> strOption (long "testpkg" <> metavar "IPKG" <> help "Run tests for package"))
154
156
155 -- Misc options
157 -- Misc options
156 <|> (BCAsm <$> strOption (long "bytecode"))
158 <|> (BCAsm <$> strOption (long "bytecode"))
src/Idris/Info.hs+17−1
@@ -6,7 +6,11 @@ License : BSD3
6Maintainer : The Idris Community.
6Maintainer : The Idris Community.
7-}
7-}
8module Idris.Info
8module Idris.Info
9+ ( getIdrisDataDir
10+ , getIdrisCRTSDir
11+ , getIdrisJSRTSDir
9− ( getIdrisLibDir
12+ , getIdrisLibDir
13+ , getIdrisDocDir
10 , getIdrisFlagsLib
14 , getIdrisFlagsLib
11 , getIdrisFlagsInc
15 , getIdrisFlagsInc
12 , getIdrisFlagsEnv
16 , getIdrisFlagsEnv
@@ -33,6 +37,18 @@ import Version_idris (gitHash)
33
37
34import Paths_idris
38import Paths_idris
35
39
40+getIdrisDataDir :: IO String
41+getIdrisDataDir = S.getIdrisDataDir
42+
43+getIdrisCRTSDir :: IO String
44+getIdrisCRTSDir = S.getIdrisCRTSDir
45+
46+getIdrisJSRTSDir :: IO String
47+getIdrisJSRTSDir = S.getIdrisJSRTSDir
48+
49+getIdrisDocDir :: IO String
50+getIdrisDocDir = S.getIdrisDocDir
51+
36getIdrisLibDir :: IO String
52getIdrisLibDir :: IO String
37getIdrisLibDir = S.getIdrisLibDir
53getIdrisLibDir = S.getIdrisLibDir
38
54
src/Idris/Info/Show.hs+48
@@ -4,6 +4,26 @@ import System.Exit
4
4
5import Idris.Info
5import Idris.Info
6
6
7+showIdrisCRTSDir :: IO ()
8+showIdrisCRTSDir = do
9+ ldir <- getIdrisCRTSDir
10+ putStrLn ldir
11+
12+showExitIdrisCRTSDir :: IO ()
13+showExitIdrisCRTSDir = do
14+ showIdrisCRTSDir
15+ exitSuccess
16+
17+showIdrisJSRTSDir :: IO ()
18+showIdrisJSRTSDir = do
19+ ldir <- getIdrisJSRTSDir
20+ putStrLn ldir
21+
22+showExitIdrisJSRTSDir :: IO ()
23+showExitIdrisJSRTSDir = do
24+ showIdrisJSRTSDir
25+ exitSuccess
26+
7showIdrisFlagsLibs :: IO ()
27showIdrisFlagsLibs :: IO ()
8showIdrisFlagsLibs = do
28showIdrisFlagsLibs = do
9 libFlags <- getIdrisFlagsLib
29 libFlags <- getIdrisFlagsLib
@@ -14,6 +34,16 @@ showExitIdrisFlagsLibs = do
14 showIdrisFlagsLibs
34 showIdrisFlagsLibs
15 exitSuccess
35 exitSuccess
16
36
37+showIdrisDataDir :: IO ()
38+showIdrisDataDir = do
39+ ldir <- getIdrisDataDir
40+ putStrLn ldir
41+
42+showExitIdrisDataDir :: IO ()
43+showExitIdrisDataDir = do
44+ showIdrisDataDir
45+ exitSuccess
46+
17showIdrisLibDir :: IO ()
47showIdrisLibDir :: IO ()
18showIdrisLibDir = do
48showIdrisLibDir = do
19 ldir <- getIdrisLibDir
49 ldir <- getIdrisLibDir
@@ -24,6 +54,16 @@ showExitIdrisLibDir = do
24 showIdrisLibDir
54 showIdrisLibDir
25 exitSuccess
55 exitSuccess
26
56
57+showIdrisDocDir :: IO ()
58+showIdrisDocDir = do
59+ ldir <- getIdrisDocDir
60+ putStrLn ldir
61+
62+showExitIdrisDocDir :: IO ()
63+showExitIdrisDocDir = do
64+ showIdrisDocDir
65+ exitSuccess
66+
27showIdrisFlagsInc :: IO ()
67showIdrisFlagsInc :: IO ()
28showIdrisFlagsInc = do
68showIdrisFlagsInc = do
29 incFlags <- getIdrisFlagsInc
69 incFlags <- getIdrisFlagsInc
@@ -68,8 +108,16 @@ showIdrisInfo = do
68 putStrLn "Paths:"
108 putStrLn "Paths:"
69 ldir <- getIdrisLibDir
109 ldir <- getIdrisLibDir
70 udir <- getIdrisUserDataDir
110 udir <- getIdrisUserDataDir
111+ ddir <- getIdrisDocDir
112+ idir <- getIdrisDataDir
113+ crdir <- getIdrisCRTSDir
114+ jrdir <- getIdrisJSRTSDir
115+ putStrLn $ unwords ["-", "Data Dir:", idir]
71 putStrLn $ unwords ["-", "Library Dir:", ldir]
116 putStrLn $ unwords ["-", "Library Dir:", ldir]
117+ putStrLn $ unwords ["-", "C RTS Dir:", crdir]
118+ putStrLn $ unwords ["-", "JS RTS Dir:", jrdir]
72 putStrLn $ unwords ["-", "User Dir:", udir]
119 putStrLn $ unwords ["-", "User Dir:", udir]
120+ putStrLn $ unwords ["-", "Documentation Dir:", ddir]
73
121
74 putStrLn "Flags:"
122 putStrLn "Flags:"
75 lflag <- getIdrisFlagsLib
123 lflag <- getIdrisFlagsLib
src/Idris/Package.hs+22−15
@@ -190,10 +190,10 @@ cleanPkg copts fp = do
190--
190--
191-- Issue number #1572 on the issue tracker
191-- Issue number #1572 on the issue tracker
192-- https://github.com/idris-lang/Idris-dev/issues/1572
192-- https://github.com/idris-lang/Idris-dev/issues/1572
193−documentPkg :: [Opt] -- ^ Command line options.
193+documentPkg :: [Opt] -- ^ Command line options.
194− -> FilePath -- ^ Path to ipkg file.
194+ -> (Bool,FilePath) -- ^ (Should we install?, Path to ipkg file).
195 -> IO ()
195 -> IO ()
196−documentPkg copts fp = do
196+documentPkg copts (install,fp) = do
197 pkgdesc <- parseDesc fp
197 pkgdesc <- parseDesc fp
198 cd <- getCurrentDirectory
198 cd <- getCurrentDirectory
199 let pkgDir = cd </> takeDirectory fp
199 let pkgDir = cd </> takeDirectory fp
@@ -223,7 +223,13 @@ documentPkg copts fp = do
223 putStrLn $ pshow idrisInit err
223 putStrLn $ pshow idrisInit err
224 exitWith (ExitFailure 1)
224 exitWith (ExitFailure 1)
225 Right ist -> do
225 Right ist -> do
226+ iDocDir <- getIdrisDocDir
227+ pkgDocDir <- makeAbsolute (iDocDir </> pkgname pkgdesc)
228+ let out_dir = if install then pkgDocDir else outputDir
229+ when install $ do
230+ putStrLn $ unwords ["Attempting to install IdrisDocs for", pkgname pkgdesc, "in:", out_dir]
231+
226− docRes <- generateDocs ist mods outputDir
232+ docRes <- generateDocs ist mods out_dir
227 case docRes of
233 case docRes of
228 Right _ -> return ()
234 Right _ -> return ()
229 Left msg -> do
235 Left msg -> do
@@ -279,7 +285,7 @@ installPkg :: [String] -- ^ Alternate install location
279 -> PkgDesc -- ^ iPKG file.
285 -> PkgDesc -- ^ iPKG file.
280 -> IO ()
286 -> IO ()
281installPkg altdests pkgdesc = inPkgDir pkgdesc $ do
287installPkg altdests pkgdesc = inPkgDir pkgdesc $ do
282− d <- getTargetDir
288+ d <- getIdrisLibDir
283 let destdir = case altdests of
289 let destdir = case altdests of
284 [] -> d
290 [] -> d
285 (d':_) -> d'
291 (d':_) -> d'
@@ -302,11 +308,11 @@ buildMods opts ns = do let f = map (toPath . showCG) ns
302
308
303testLib :: Bool -> String -> String -> IO Bool
309testLib :: Bool -> String -> String -> IO Bool
304testLib warn p f
310testLib warn p f
305− = do d <- getDataDir
311+ = do d <- getIdrisCRTSDir
306 gcc <- getCC
312 gcc <- getCC
307 (tmpf, tmph) <- tempfile ""
313 (tmpf, tmph) <- tempfile ""
308 hClose tmph
314 hClose tmph
309− let libtest = d </> "rts" </> "libtest.c"
315+ let libtest = d </> "libtest.c"
310 e <- rawSystem gcc [libtest, "-l" ++ f, "-o", tmpf]
316 e <- rawSystem gcc [libtest, "-l" ++ f, "-o", tmpf]
311 case e of
317 case e of
312 ExitSuccess -> return True
318 ExitSuccess -> return True
@@ -416,14 +422,15 @@ mergeOptions copts popts =
416 normaliseOpts = filter filtOpt
422 normaliseOpts = filter filtOpt
417
423
418 filtOpt :: Opt -> Bool
424 filtOpt :: Opt -> Bool
419− filtOpt (PkgBuild _) = False
425+ filtOpt (PkgBuild _) = False
420− filtOpt (PkgInstall _) = False
426+ filtOpt (PkgInstall _) = False
421− filtOpt (PkgClean _) = False
427+ filtOpt (PkgClean _) = False
422− filtOpt (PkgCheck _) = False
428+ filtOpt (PkgCheck _) = False
423− filtOpt (PkgREPL _) = False
429+ filtOpt (PkgREPL _) = False
430+ filtOpt (PkgDocBuild _) = False
424− filtOpt (PkgMkDoc _) = False
431+ filtOpt (PkgDocInstall _) = False
425− filtOpt (PkgTest _) = False
432+ filtOpt (PkgTest _) = False
426− filtOpt _ = True
433+ filtOpt _ = True
427
434
428 chkOpt :: Opt -> Either String Opt
435 chkOpt :: Opt -> Either String Opt
429 chkOpt o@(OLogging _) = Right o
436 chkOpt o@(OLogging _) = Right o