mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-09-22 06:29:37 +03:00
Merge pull request #2697 from melted/temp_ext
Allow an extension on tempfiles
This commit is contained in:
commit
0400a881c2
@ -66,7 +66,7 @@ codegenC' defs out exec incs objs libs flags exports iface dbg
|
||||
MavenProject -> putStrLn ("FAILURE: output type not supported")
|
||||
Raw -> writeSource out cout
|
||||
_ -> do
|
||||
(tmpn, tmph) <- tempfile
|
||||
(tmpn, tmph) <- tempfile ".c"
|
||||
hPutStr tmph cout
|
||||
hFlush tmph
|
||||
hClose tmph
|
||||
@ -78,7 +78,7 @@ codegenC' defs out exec incs objs libs flags exports iface dbg
|
||||
gccFlags iface ++
|
||||
-- # Any flags defined here which alter the RTS API must also be added to config.mk
|
||||
["-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS",
|
||||
"-I."] ++ objs ++ ["-x", "c"] ++ envFlags ++
|
||||
"-I."] ++ objs ++ envFlags ++
|
||||
(if (exec == Executable) then [] else ["-c"]) ++
|
||||
[tmpn] ++
|
||||
(if not iface then concatMap words libFlags else []) ++
|
||||
|
@ -1189,7 +1189,7 @@ process fn (Execute tm)
|
||||
= idrisCatch
|
||||
(do ist <- getIState
|
||||
(m, _) <- elabVal recinfo ERHS (elabExec fc tm)
|
||||
(tmpn, tmph) <- runIO tempfile
|
||||
(tmpn, tmph) <- runIO $ tempfile ""
|
||||
runIO $ hClose tmph
|
||||
t <- codegen
|
||||
-- gcc adds .exe when it builds windows programs
|
||||
|
@ -164,7 +164,7 @@ testPkg fp
|
||||
do m_ist <- inPkgDir pkgdesc $
|
||||
do make (makefile pkgdesc)
|
||||
-- Get a temporary file to save the tests' source in
|
||||
(tmpn, tmph) <- tempIdr
|
||||
(tmpn, tmph) <- tempfile ".idr"
|
||||
hPutStrLn tmph $
|
||||
"module Test_______\n" ++
|
||||
concat ["import " ++ show m ++ "\n"
|
||||
@ -175,7 +175,7 @@ testPkg fp
|
||||
concat [show t ++ "\n "
|
||||
| t <- idris_tests pkgdesc]
|
||||
hClose tmph
|
||||
(tmpn', tmph') <- tempfile
|
||||
(tmpn', tmph') <- tempfile ""
|
||||
hClose tmph'
|
||||
m_ist <- idris (Filename tmpn : NoREPL : Verbose : Output tmpn' : idris_opts pkgdesc)
|
||||
rawSystem tmpn' []
|
||||
@ -187,9 +187,6 @@ testPkg fp
|
||||
case errSpan ist of
|
||||
Just _ -> exitWith (ExitFailure 1)
|
||||
_ -> return ()
|
||||
where tempIdr :: IO (FilePath, Handle)
|
||||
tempIdr = do dir <- getTemporaryDirectory
|
||||
openTempFile (normalise dir) "idristests.idr"
|
||||
|
||||
-- | Install package
|
||||
installPkg :: PkgDesc -> IO ()
|
||||
@ -214,7 +211,7 @@ testLib :: Bool -> String -> String -> IO Bool
|
||||
testLib warn p f
|
||||
= do d <- getDataDir
|
||||
gcc <- getCC
|
||||
(tmpf, tmph) <- tempfile
|
||||
(tmpf, tmph) <- tempfile ""
|
||||
hClose tmph
|
||||
let libtest = d </> "rts" </> "libtest.c"
|
||||
e <- rawSystem gcc [libtest, "-l" ++ f, "-o", tmpf]
|
||||
|
@ -37,9 +37,10 @@ throwIO = CE.throw
|
||||
isWindows :: Bool
|
||||
isWindows = os `elem` ["win32", "mingw32", "cygwin32"]
|
||||
|
||||
tempfile :: IO (FilePath, Handle)
|
||||
tempfile = do dir <- getTemporaryDirectory
|
||||
openTempFile (normalise dir) "idris"
|
||||
-- | Create a temp file with the extensiom ext (in the format ".xxx")
|
||||
tempfile :: String -> IO (FilePath, Handle)
|
||||
tempfile ext = do dir <- getTemporaryDirectory
|
||||
openTempFile (normalise dir) $ "idris" ++ ext
|
||||
|
||||
-- | Read a source file, same as readFile but make sure the encoding is utf-8.
|
||||
readSource :: FilePath -> IO String
|
||||
|
Loading…
Reference in New Issue
Block a user