on master help sign in
avoid confusion between the compiler and codegens
commit18450ff1ec7d87e23f698756b5a0d0b1e197fb23 authorСухарик <suhr@i2pmail.org> dateFri 4 Sep 2015, 03:03 (11 years ago) parent0ed71c9
5 files changed+37−25
codegen/idris-c/Main.hs → codegen/idris-codegen-c/Main.hs+11−9 codegen/idris-javascript/Main.hs → codegen/idris-codegen-javascript/Main.hs+9−4 codegen/idris-node/Main.hs → codegen/idris-codegen-node/Main.hs+9−4 idris.cabal+6−6 src/IRTS/Compiler.hs+2−2
codegen/idris-c/Main.hs → codegen/idris-codegen-c/Main.hsrenamed+11−9
@@ -16,17 +16,19 @@ import Paths_idris
1616
1717import Util.System
1818
19−data Opts = Opts { inputs :: [FilePath],
19+data Opts = Opts { really :: Bool,
20+ inputs :: [FilePath],
2021 interface :: Bool,
2122 output :: FilePath }
2223
23−showUsage = do putStrLn "Usage: idris-c <ibc-files> [-o <output-file>]"
24+showUsage = do putStrLn "Usage: idris-codegen-c --yes-really <ibc-files> [-o <output-file>]"
2425 exitWith ExitSuccess
2526
2627getOpts :: IO Opts
2728getOpts = do xs <- getArgs
28− return $ process (Opts [] False "a.out") xs
29+ return $ process (Opts False [] False "a.out") xs
2930 where
31+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
3032 process opts ("-o":o:xs) = process (opts { output = o }) xs
3133 process opts ("--interface":xs) = process (opts { interface = True }) xs
3234 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
@@ -36,7 +38,7 @@ c_main :: Opts -> Idris ()
3638c_main opts = do runIO setupBundledCC
3739 elabPrims
3840 loadInputs (inputs opts) Nothing
39− mainProg <- if interface opts
41+ mainProg <- if interface opts
4042 then liftM Just elabMain
4143 else return Nothing
4244 ir <- compile (Via "c") (output opts) mainProg
@@ -44,9 +46,9 @@ c_main opts = do runIO setupBundledCC
4446
4547main :: IO ()
4648main = do opts <- getOpts
47− if (null (inputs opts))
49+ if (null (inputs opts))
4850 then showUsage
49− else runMain (c_main opts)
50−
51−
52−
51+ else if (not $ really opts)
52+ then do putStrLn "This is not what you may expect it is."
53+ showUsage
54+ else runMain (c_main opts)
codegen/idris-javascript/Main.hs → codegen/idris-codegen-javascript/Main.hsrenamed+9−4
@@ -13,17 +13,19 @@ import System.Exit
1313
1414import Paths_idris
1515
16−data Opts = Opts { inputs :: [FilePath]
16+data Opts = Opts { really :: Bool
17+ , inputs :: [FilePath]
1718 , output :: FilePath
1819 }
1920
20−showUsage = do putStrLn "Usage: idris-javascript <ibc-files> [-o <output-file>]"
21+showUsage = do putStrLn "Usage: idris-codegen-javascript --yes-really <ibc-files> [-o <output-file>]"
2122 exitWith ExitSuccess
2223
2324getOpts :: IO Opts
2425getOpts = do xs <- getArgs
25− return $ process (Opts [] "main.js") xs
26+ return $ process (Opts False [] "main.js") xs
2627 where
28+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
2729 process opts ("-o":o:xs) = process (opts { output = o }) xs
2830 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
2931 process opts [] = opts
@@ -39,4 +41,7 @@ main :: IO ()
3941main = do opts <- getOpts
4042 if (null (inputs opts))
4143 then showUsage
42− else runMain (jsMain opts)
44+ else if (not $ really opts)
45+ then do putStrLn "This is not what you may expect it is."
46+ showUsage
47+ else runMain (jsMain opts)
codegen/idris-node/Main.hs → codegen/idris-codegen-node/Main.hsrenamed+9−4
@@ -13,17 +13,19 @@ import System.Exit
1313
1414import Paths_idris
1515
16−data Opts = Opts { inputs :: [FilePath]
16+data Opts = Opts { really :: Bool
17+ , inputs :: [FilePath]
1718 , output :: FilePath
1819 }
1920
20−showUsage = do putStrLn "Usage: idris-node <ibc-files> [-o <output-file>]"
21+showUsage = do putStrLn "Usage: idris-codegen-node --yes-really <ibc-files> [-o <output-file>]"
2122 exitWith ExitSuccess
2223
2324getOpts :: IO Opts
2425getOpts = do xs <- getArgs
25− return $ process (Opts [] "main.js") xs
26+ return $ process (Opts False [] "main.js") xs
2627 where
28+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
2729 process opts ("-o":o:xs) = process (opts { output = o }) xs
2830 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
2931 process opts [] = opts
@@ -39,4 +41,7 @@ main :: IO ()
3941main = do opts <- getOpts
4042 if (null (inputs opts))
4143 then showUsage
42− else runMain (jsMain opts)
44+ else if (not $ really opts)
45+ then do putStrLn "This is not what you may expect it is."
46+ showUsage
47+ else runMain (jsMain opts)
idris.cabal+6−6
@@ -991,9 +991,9 @@ Executable idris
991991 ghc-prof-options: -auto-all -caf-all
992992 ghc-options: -threaded -rtsopts -funbox-strict-fields
993993
994−Executable idris-c
994+Executable idris-codegen-c
995995 Main-is: Main.hs
996− hs-source-dirs: codegen/idris-c
996+ hs-source-dirs: codegen/idris-codegen-c
997997
998998 Build-depends: idris
999999 , base
@@ -1004,9 +1004,9 @@ Executable idris-c
10041004 ghc-prof-options: -auto-all -caf-all
10051005 ghc-options: -threaded -rtsopts -funbox-strict-fields
10061006
1007−Executable idris-javascript
1007+Executable idris-codegen-javascript
10081008 Main-is: Main.hs
1009− hs-source-dirs: codegen/idris-javascript
1009+ hs-source-dirs: codegen/idris-codegen-javascript
10101010
10111011 Build-depends: idris
10121012 , base
@@ -1017,9 +1017,9 @@ Executable idris-javascript
10171017 ghc-prof-options: -auto-all -caf-all
10181018 ghc-options: -threaded -rtsopts -funbox-strict-fields
10191019
1020−Executable idris-node
1020+Executable idris-codegen-node
10211021 Main-is: Main.hs
1022− hs-source-dirs: codegen/idris-node
1022+ hs-source-dirs: codegen/idris-codegen-node
10231023
10241024 Build-depends: idris
10251025 , base
src/IRTS/Compiler.hs+2−2
@@ -135,8 +135,8 @@ generate codegen mainmod ir
135135 -- Built-in code generators (FIXME: lift these out!)
136136 Via "c" -> codegenC ir
137137 -- Any external code generator
138− Via cg -> do let cmd = "idris-" ++ cg
139− args = [mainmod, "-o", outputFile ir] ++ compilerFlags ir
138+ Via cg -> do let cmd = "idris-codegen-" ++ cg
139+ args = ["--yes-really", mainmod, "-o", outputFile ir] ++ compilerFlags ir
140140 exit <- rawSystem cmd args
141141 when (exit /= ExitSuccess) $
142142 putStrLn ("FAILURE: " ++ show cmd ++ " " ++ show args)