mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 12:42:02 +03:00
Make RefC search for files in data dirs
Previously, the RefC files were located in IDRIS2_PREFIX. This is decoupled to allow users to change the prefix (for ad-hoc library install locations, for example).
This commit is contained in:
parent
c3ec522077
commit
9b2811f263
@ -3,6 +3,7 @@ module Compiler.RefC.CC
|
||||
import Core.Context
|
||||
import Core.Context.Log
|
||||
import Core.Options
|
||||
import Core.Directory
|
||||
|
||||
import System
|
||||
|
||||
@ -19,10 +20,6 @@ findCC
|
||||
| Just cc => pure cc
|
||||
pure "cc"
|
||||
|
||||
fullprefix_dir : Dirs -> String -> String
|
||||
fullprefix_dir dirs sub
|
||||
= prefix_dir dirs </> "idris2-" ++ showVersion False version </> sub
|
||||
|
||||
export
|
||||
compileCObjectFile : {auto c : Ref Ctxt Defs}
|
||||
-> {default False asLibrary : Bool}
|
||||
@ -31,14 +28,15 @@ compileCObjectFile : {auto c : Ref Ctxt Defs}
|
||||
-> Core (Maybe String)
|
||||
compileCObjectFile {asLibrary} sourceFile objectFile =
|
||||
do cc <- coreLift findCC
|
||||
dirs <- getDirs
|
||||
refcDir <- findDataFile "refc"
|
||||
cDir <- findDataFile "c"
|
||||
|
||||
let libraryFlag = if asLibrary then "-fpic " else ""
|
||||
|
||||
let runccobj = cc ++ " -Werror -c " ++ libraryFlag ++ sourceFile ++
|
||||
" -o " ++ objectFile ++ " " ++
|
||||
"-I" ++ fullprefix_dir dirs "refc " ++
|
||||
"-I" ++ fullprefix_dir dirs "include"
|
||||
" -o " ++ objectFile ++
|
||||
" -I" ++ refcDir ++
|
||||
" -I" ++ cDir
|
||||
|
||||
log "compiler.refc.cc" 10 runccobj
|
||||
0 <- coreLift $ system runccobj
|
||||
@ -55,14 +53,16 @@ compileCFile : {auto c : Ref Ctxt Defs}
|
||||
compileCFile {asShared} objectFile outFile =
|
||||
do cc <- coreLift findCC
|
||||
dirs <- getDirs
|
||||
refcDir <- findDataFile "refc"
|
||||
supportFile <- findLibraryFile "libidris2_support.a"
|
||||
|
||||
let sharedFlag = if asShared then "-shared " else ""
|
||||
|
||||
let runcc = cc ++ " -Werror " ++ sharedFlag ++ objectFile ++
|
||||
" -o " ++ outFile ++ " " ++
|
||||
(fullprefix_dir dirs "lib" </> "libidris2_support.a") ++ " " ++
|
||||
supportFile ++ " " ++
|
||||
"-lidris2_refc " ++
|
||||
"-L" ++ fullprefix_dir dirs "refc " ++
|
||||
"-L" ++ refcDir ++ " " ++
|
||||
clibdirs (lib_dirs dirs) ++
|
||||
"-lgmp -lm"
|
||||
|
||||
|
@ -54,7 +54,7 @@ cleandep: clean
|
||||
|
||||
install: build
|
||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/include
|
||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/support/c
|
||||
install -m 755 $(DYLIBTARGET) ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
||||
install -m 644 $(LIBTARGET) ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
||||
install -m 644 *.h ${PREFIX}/idris2-${IDRIS2_VERSION}/include
|
||||
install -m 644 *.h ${PREFIX}/idris2-${IDRIS2_VERSION}/support/c
|
||||
|
@ -43,5 +43,5 @@ cleandep: clean
|
||||
.PHONY: install
|
||||
|
||||
install: build
|
||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/refc
|
||||
install -m 644 $(LIBTARGET) *.h ${PREFIX}/idris2-${IDRIS2_VERSION}/refc
|
||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/support/refc
|
||||
install -m 644 $(LIBTARGET) *.h ${PREFIX}/idris2-${IDRIS2_VERSION}/support/refc
|
||||
|
Loading…
Reference in New Issue
Block a user