Add --libdir option

This makes it easier for more complicated packages (e.g. network, which
needs to install a C shared library) to know where to put things without
having to work out the prefix themselves.
This commit is contained in:
Edwin Brady 2019-09-19 13:04:39 +01:00
parent a38cce4c90
commit 65b3ddb81b
6 changed files with 34 additions and 11 deletions

View File

@ -29,8 +29,8 @@ base: prelude
make -C libs/base IDRIS2=../../idris2
network: prelude
make -C libs/network IDRIS2_VERSION=${IDRIS2_VERSION} IDRIS2=../../idris2
make -C libs/network test IDRIS2_VERSION=${IDRIS2_VERSION} IDRIS2=../../idris2
make -C libs/network IDRIS2=../../idris2
make -C libs/network test IDRIS2=../../idris2
libs : prelude base network

View File

@ -28,7 +28,7 @@ endif
DYLIBTARGET = $(LIBNAME)$(SHLIB_SUFFIX)
LIBTARGET = $(LIBNAME).a
TARGET=${HOME}/.idris2
TARGET=`${IDRIS2} --libdir`
build: $(DYLIBTARGET) $(IDRIS_SRCS)
@if [ -z "${IDRIS2}" ]; then echo 'variable $$IDRIS2 is not set, aborting'; exit 1; fi
@ -40,8 +40,8 @@ $(DYLIBTARGET) : $(OBJS)
install:
@if [ -z "${IDRIS2}" ]; then echo 'variable $$IDRIS2 is not set, aborting'; exit 1; fi
${IDRIS2} --install network.ipkg
@if ! [ -d $(TARGET)/idris2-${IDRIS2_VERSION}/network/lib ]; then mkdir $(TARGET)/idris2-${IDRIS2_VERSION}/network/lib; fi
install $(DYLIBTARGET) $(HDRS) $(TARGET)/idris2-${IDRIS2_VERSION}/network/lib
@if ! [ -d $(TARGET)/network/lib ]; then mkdir $(TARGET)/network/lib; fi
install $(DYLIBTARGET) $(HDRS) $(TARGET)/network/lib
clean :
rm -rf $(OBJS) $(LIBTARGET) $(DYLIBTARGET) build

View File

@ -12,7 +12,6 @@ data PkgCommand
| Clean
| REPL
export
Show PkgCommand where
show Build = "--build"
@ -20,6 +19,14 @@ Show PkgCommand where
show Clean = "--clean"
show REPL = "--repl"
public export
data DirCommand
= LibDir -- show top level package directory
export
Show DirCommand where
show LibDir = "--libdir"
||| CLOpt - possible command line options
public export
data CLOpt
@ -46,6 +53,8 @@ data CLOpt
PkgPath String |
||| Build or install a given package, depending on PkgCommand
Package PkgCommand String |
||| Show locations of data/library directories
Directory DirCommand |
||| The input Idris file
InputFile String |
||| Whether or not to run in IdeMode (easily parsable for other tools)
@ -103,6 +112,8 @@ options = [MkOpt ["--check", "-c"] [] [CheckOnly]
MkOpt ["--clean"] ["package file"] (\f => [Package Clean f])
(Just "Clean intermediate files/executables for the given package"),
MkOpt ["--libdir"] [] [Directory LibDir]
(Just "Show library directory"),
MkOpt ["--quiet", "-q"] [] [Quiet]
(Just "Quiet mode; display fewer messages"),
MkOpt ["--version", "-v"] [] [Version]

View File

@ -122,7 +122,8 @@ stMain opts
done <- processPackageOpts opts
when (not done) $
do preOptions opts
do True <- preOptions opts
| False => pure ()
u <- newRef UST initUState
updateREPLOpts

View File

@ -207,6 +207,7 @@ processOptions (Just (fc, opts))
= do let Right clopts = getOpts (words opts)
| Left err => throw (GenericMsg fc err)
preOptions clopts
pure ()
build : {auto c : Ref Ctxt Defs} ->
{auto s : Ref Syn SyntaxInfo} ->

View File

@ -23,12 +23,17 @@ addPkgDir p
addExtraDir (dir_prefix (dirs (options defs)) ++ dirSep ++
"idris2-" ++ version ++ dirSep ++ p)
-- Options to be processed before type checking
dirOption : Dirs -> DirCommand -> Core ()
dirOption dirs LibDir
= coreLift $ putStrLn
(dir_prefix dirs ++ dirSep ++ "idris2-" ++ version ++ dirSep)
-- Options to be processed before type checking. Return whether to continue.
export
preOptions : {auto c : Ref Ctxt Defs} ->
{auto o : Ref ROpts REPLOpts} ->
List CLOpt -> Core ()
preOptions [] = pure ()
List CLOpt -> Core Bool
preOptions [] = pure True
preOptions (Quiet :: opts)
= do setOutput (REPL True)
preOptions opts
@ -47,8 +52,13 @@ preOptions (SetCG e :: opts)
preOptions (PkgPath p :: opts)
= do addPkgDir p
preOptions opts
preOptions (Directory d :: opts)
= do defs <- get Ctxt
dirOption (dirs (options defs)) d
pure False
preOptions (Timing :: opts)
= setLogTimings True
= do setLogTimings True
preOptions opts
preOptions (_ :: opts) = preOptions opts
-- Options to be processed after type checking. Returns whether execution