4import Control.Monad (foldM, when)
5import qualified Data.Maybe as Maybe
6import Text.Blaze.Html.Renderer.String (renderHtml)
7import qualified Data.ByteString.Lazy.Char8 as BS
8import qualified System.Console.CmdArgs as CmdArgs
10import System.Exit (exitSuccess)
14import Build.Dependencies (getBuildRecipe, Recipe(..))
15import qualified Generate.Html as Html
16import qualified Metadata.Prelude as Prelude
17import qualified Build.Utils as Utils
18import qualified Build.Flags as Flag
19import qualified Build.File as File
20import qualified Elm.Internal.Paths as Path
23main = do setNumCapabilities =<< getNumProcessors
24 compileArgs =<< CmdArgs.cmdArgs Flag.flags
26compileArgs :: Flag.Flags -> IO ()
28 do when (Flag.get_runtime flags) $
29 do putStrLn Path.runtime
31 case Flag.files flags of
32 [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
33 fs -> mapM_ (build flags) fs
35build :: Flag.Flags -> FilePath -> IO ()
37 do let noPrelude = Flag.no_prelude flags
38 builtIns <- Prelude.interfaces noPrelude
40 (Recipe elmFiles jsFiles) <-
42 then Utils.run (getBuildRecipe (Flag.src_dir flags) builtIns rootFile)
43 else return (Recipe [rootFile] [])
45 moduleName <- File.build flags builtIns elmFiles
47 let elmos = map (Utils.elmo flags) elmFiles
48 js <- foldM appendToOutput BS.empty (elmos ++ jsFiles)
52 then do putStr "Generating JavaScript ... "
54 else do putStr "Generating HTML ... "
55 return (makeHtml js moduleName)
57 let targetFile = Utils.buildPath flags rootFile extension
58 createDirectoryIfMissing True (takeDirectory targetFile)
59 BS.writeFile targetFile code
63 appendToOutput :: BS.ByteString -> FilePath -> IO BS.ByteString
64 appendToOutput js filePath = do
65 src <- BS.readFile filePath
66 return (BS.append src js)
68 sources js = map Html.Link (Flag.scripts flags) ++ [ Html.Source js ]
70 makeHtml js moduleName = ("html", BS.pack $ renderHtml html)
72 rtsPath = Maybe.fromMaybe Path.runtime (Flag.set_runtime flags)
73 html = Html.generate rtsPath (takeBaseName rootFile) (sources js) moduleName ""
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list