on master help sign in
Merge branch 'pr/613' into webgl
1062ff1Evan Czaplicki
compiler/Build/Flags.hs+7−4
@@ -7,7 +7,8 @@ import System.Console.CmdArgs
7data Flags = Flags
7data Flags = Flags
8 { make :: Bool
8 { make :: Bool
9 , files :: [FilePath]
9 , files :: [FilePath]
10− , runtime :: Maybe FilePath
10+ , set_runtime :: Maybe FilePath
11+ , get_runtime :: Bool
11 , only_js :: Bool
12 , only_js :: Bool
12 , print_types :: Bool
13 , print_types :: Bool
13 , scripts :: [FilePath]
14 , scripts :: [FilePath]
@@ -28,8 +29,10 @@ flags = Flags
28 &= help "Do not import Prelude by default, used only when compiling standard libraries."
29 &= help "Do not import Prelude by default, used only when compiling standard libraries."
29 , scripts = [] &= typFile
30 , scripts = [] &= typFile
30 &= help "Load JavaScript files in generated HTML. Files will be included in the given order."
31 &= help "Load JavaScript files in generated HTML. Files will be included in the given order."
31− , runtime = Nothing &= typFile
32+ , set_runtime = Nothing &= typFile
32− &= help "Specify a custom location for Elm's runtime system."
33+ &= help "Specify a custom location for Elm's runtime system."
34+ , get_runtime = False
35+ &= help "Print the absolute path to the default Elm runtime."
33 , cache_dir = "cache" &= typFile
36 , cache_dir = "cache" &= typFile
34 &= help "Directory for files cached to make builds faster. Defaults to cache/ directory."
37 &= help "Directory for files cached to make builds faster. Defaults to cache/ directory."
35 , build_dir = "build" &= typFile
38 , build_dir = "build" &= typFile
@@ -37,7 +40,7 @@ flags = Flags
37 , src_dir = ["."] &= typFile
40 , src_dir = ["."] &= typFile
38 &= help "Additional source directories besides project root. Searched when using --make"
41 &= help "Additional source directories besides project root. Searched when using --make"
39 , print_types = False
42 , print_types = False
40− &= help "Print out infered types of top-level definitions."
43+ &= help "Print out inferred types of top-level definitions."
41 } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
44 } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
42 &= helpArg [explicit, name "help", name "h"]
45 &= helpArg [explicit, name "help", name "h"]
43 &= versionArg [explicit, name "version", name "v", summary (show Version.elmVersion)]
46 &= versionArg [explicit, name "version", name "v", summary (show Version.elmVersion)]
compiler/Compiler.hs+7−3
@@ -1,12 +1,13 @@
1{-# OPTIONS_GHC -W #-}
1{-# OPTIONS_GHC -W #-}
2module Main where
2module Main where
3
3
4−import Control.Monad (foldM)
4+import Control.Monad (foldM, when)
5import qualified Data.Maybe as Maybe
5import qualified Data.Maybe as Maybe
6import Text.Blaze.Html.Renderer.String (renderHtml)
6import Text.Blaze.Html.Renderer.String (renderHtml)
7import qualified Data.ByteString.Lazy.Char8 as BS
7import qualified Data.ByteString.Lazy.Char8 as BS
8import qualified System.Console.CmdArgs as CmdArgs
8import qualified System.Console.CmdArgs as CmdArgs
9import System.Directory
9import System.Directory
10+import System.Exit (exitSuccess)
10import System.FilePath
11import System.FilePath
11import GHC.Conc
12import GHC.Conc
12
13
@@ -24,7 +25,10 @@ main = do setNumCapabilities =<< getNumProcessors
24
25
25compileArgs :: Flag.Flags -> IO ()
26compileArgs :: Flag.Flags -> IO ()
26compileArgs flags =
27compileArgs flags =
28+ do when (Flag.get_runtime flags) $
29+ do putStrLn Path.runtime
30+ exitSuccess
27− case Flag.files flags of
31+ case Flag.files flags of
28 [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
32 [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
29 fs -> mapM_ (build flags) fs
33 fs -> mapM_ (build flags) fs
30
34
@@ -65,5 +69,5 @@ build flags rootFile =
65
69
66 makeHtml js moduleName = ("html", BS.pack $ renderHtml html)
70 makeHtml js moduleName = ("html", BS.pack $ renderHtml html)
67 where
71 where
68− rtsPath = Maybe.fromMaybe Path.runtime (Flag.runtime flags)
72+ rtsPath = Maybe.fromMaybe Path.runtime (Flag.set_runtime flags)
69 html = Html.generate rtsPath (takeBaseName rootFile) (sources js) moduleName ""
73 html = Html.generate rtsPath (takeBaseName rootFile) (sources js) moduleName ""