@@ -16,17 +16,21 @@ 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 "A code generator which is intended to be called by the compiler, not by a user."
25+ putStrLn "To call the code generator manually, pass the --yes-really option.\n"
26+ putStrLn "Usage: idris-codegen-c [--yes-really] <ibc-files> [-o <output-file>]"
2427 exitWith ExitSuccess
2528
2629getOpts :: IO Opts
2730getOpts = do xs <- getArgs
28− return $ process (Opts [] False "a.out") xs
31+ return $ process (Opts False [] False "a.out") xs
2932 where
33+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
3034 process opts ("-o":o:xs) = process (opts { output = o }) xs
3135 process opts ("--interface":xs) = process (opts { interface = True }) xs
3236 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
@@ -36,7 +40,7 @@ c_main :: Opts -> Idris ()
3640c_main opts = do runIO setupBundledCC
3741 elabPrims
3842 loadInputs (inputs opts) Nothing
39− mainProg <- if interface opts
43+ mainProg <- if interface opts
4044 then liftM Just elabMain
4145 else return Nothing
4246 ir <- compile (Via "c") (output opts) mainProg
@@ -44,9 +48,10 @@ c_main opts = do runIO setupBundledCC
4448
4549main :: IO ()
4650main = do opts <- getOpts
47− if (null (inputs opts))
51+ if (null (inputs opts))
4852 then showUsage
49− else runMain (c_main opts)
50−
51−
52−
53+ else if (not $ really opts)
54+ then do putStrLn "This code generator is intended to be called by the Idris compiler. \
55+ \Please pass Idris the '--codegen' flag to choose a backend."
56+ exitWith ExitSuccess
57+ else runMain (c_main opts)