mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 20:51:43 +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
|
||||||
import Core.Context.Log
|
import Core.Context.Log
|
||||||
import Core.Options
|
import Core.Options
|
||||||
|
import Core.Directory
|
||||||
|
|
||||||
import System
|
import System
|
||||||
|
|
||||||
@ -19,10 +20,6 @@ findCC
|
|||||||
| Just cc => pure cc
|
| Just cc => pure cc
|
||||||
pure "cc"
|
pure "cc"
|
||||||
|
|
||||||
fullprefix_dir : Dirs -> String -> String
|
|
||||||
fullprefix_dir dirs sub
|
|
||||||
= prefix_dir dirs </> "idris2-" ++ showVersion False version </> sub
|
|
||||||
|
|
||||||
export
|
export
|
||||||
compileCObjectFile : {auto c : Ref Ctxt Defs}
|
compileCObjectFile : {auto c : Ref Ctxt Defs}
|
||||||
-> {default False asLibrary : Bool}
|
-> {default False asLibrary : Bool}
|
||||||
@ -31,14 +28,15 @@ compileCObjectFile : {auto c : Ref Ctxt Defs}
|
|||||||
-> Core (Maybe String)
|
-> Core (Maybe String)
|
||||||
compileCObjectFile {asLibrary} sourceFile objectFile =
|
compileCObjectFile {asLibrary} sourceFile objectFile =
|
||||||
do cc <- coreLift findCC
|
do cc <- coreLift findCC
|
||||||
dirs <- getDirs
|
refcDir <- findDataFile "refc"
|
||||||
|
cDir <- findDataFile "c"
|
||||||
|
|
||||||
let libraryFlag = if asLibrary then "-fpic " else ""
|
let libraryFlag = if asLibrary then "-fpic " else ""
|
||||||
|
|
||||||
let runccobj = cc ++ " -Werror -c " ++ libraryFlag ++ sourceFile ++
|
let runccobj = cc ++ " -Werror -c " ++ libraryFlag ++ sourceFile ++
|
||||||
" -o " ++ objectFile ++ " " ++
|
" -o " ++ objectFile ++
|
||||||
"-I" ++ fullprefix_dir dirs "refc " ++
|
" -I" ++ refcDir ++
|
||||||
"-I" ++ fullprefix_dir dirs "include"
|
" -I" ++ cDir
|
||||||
|
|
||||||
log "compiler.refc.cc" 10 runccobj
|
log "compiler.refc.cc" 10 runccobj
|
||||||
0 <- coreLift $ system runccobj
|
0 <- coreLift $ system runccobj
|
||||||
@ -55,14 +53,16 @@ compileCFile : {auto c : Ref Ctxt Defs}
|
|||||||
compileCFile {asShared} objectFile outFile =
|
compileCFile {asShared} objectFile outFile =
|
||||||
do cc <- coreLift findCC
|
do cc <- coreLift findCC
|
||||||
dirs <- getDirs
|
dirs <- getDirs
|
||||||
|
refcDir <- findDataFile "refc"
|
||||||
|
supportFile <- findLibraryFile "libidris2_support.a"
|
||||||
|
|
||||||
let sharedFlag = if asShared then "-shared " else ""
|
let sharedFlag = if asShared then "-shared " else ""
|
||||||
|
|
||||||
let runcc = cc ++ " -Werror " ++ sharedFlag ++ objectFile ++
|
let runcc = cc ++ " -Werror " ++ sharedFlag ++ objectFile ++
|
||||||
" -o " ++ outFile ++ " " ++
|
" -o " ++ outFile ++ " " ++
|
||||||
(fullprefix_dir dirs "lib" </> "libidris2_support.a") ++ " " ++
|
supportFile ++ " " ++
|
||||||
"-lidris2_refc " ++
|
"-lidris2_refc " ++
|
||||||
"-L" ++ fullprefix_dir dirs "refc " ++
|
"-L" ++ refcDir ++ " " ++
|
||||||
clibdirs (lib_dirs dirs) ++
|
clibdirs (lib_dirs dirs) ++
|
||||||
"-lgmp -lm"
|
"-lgmp -lm"
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ cleandep: clean
|
|||||||
|
|
||||||
install: build
|
install: build
|
||||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
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 755 $(DYLIBTARGET) ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
||||||
install -m 644 $(LIBTARGET) ${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
|
.PHONY: install
|
||||||
|
|
||||||
install: build
|
install: build
|
||||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/refc
|
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/support/refc
|
||||||
install -m 644 $(LIBTARGET) *.h ${PREFIX}/idris2-${IDRIS2_VERSION}/refc
|
install -m 644 $(LIBTARGET) *.h ${PREFIX}/idris2-${IDRIS2_VERSION}/support/refc
|
||||||
|
Loading…
Reference in New Issue
Block a user