on master help sign in
Get rid of dead code around a elm-compiler command line tool
commitda4d613864fe511b9e93d5999f31879aabd27645 authorEvan Czaplicki <info@elm-lang.org> dateTue 4 Nov 2014, 17:05 (12 years ago) parentf8571eb
4 files changed+1−268
compiler/Build/Flags.hs−64 compiler/Build/Print.hs−28 compiler/Compiler.hs−77 elm-compiler.cabal+1−99
compiler/Build/Flags.hsdeleted−64
@@ -1,64 +0,0 @@
1−{-# LANGUAGE DeriveDataTypeable #-}
2−module Build.Flags where
3−
4−import qualified Elm.Compiler.Version as Compiler
5−import System.Console.CmdArgs
6−
7−
8−data Flags = Flags
9− { make :: Bool
10− , files :: [FilePath]
11− , set_runtime :: Maybe FilePath
12− , get_runtime :: Bool
13− , bundle_runtime :: Bool
14− , only_js :: Bool
15− , print_types :: Bool
16− , scripts :: [FilePath]
17− , no_prelude :: Bool
18− , cache_dir :: FilePath
19− , build_dir :: FilePath
20− , src_dir :: [FilePath]
21− }
22− deriving (Data,Typeable,Show,Eq)
23−
24−flags :: Flags
25−flags = Flags
26− { files = def &= args &= typ "FILES"
27−
28− , make = False
29− &= help "automatically compile dependencies."
30−
31− , only_js = False
32− &= help "Compile only to JavaScript."
33−
34− , no_prelude = False
35− &= help "Do not import Prelude by default, used only when compiling standard libraries."
36−
37− , scripts = [] &= typFile
38− &= help "Load JavaScript files in generated HTML. Files will be included in the given order."
39−
40− , set_runtime = Nothing &= typFile
41− &= help "Specify a custom location for Elm's runtime system."
42−
43− , get_runtime = False
44− &= help "Print the absolute path to the default Elm runtime."
45−
46− , bundle_runtime = False
47− &= help "Bundle the runtime with the generated html or js to create a standalone file."
48−
49− , cache_dir = "cache" &= typFile
50− &= help "Directory for files cached to make builds faster. Defaults to cache/ directory."
51−
52− , build_dir = "build" &= typFile
53− &= help "Directory for generated HTML and JS files. Defaults to build/ directory."
54−
55− , src_dir = ["."] &= typFile
56− &= help "Additional source directories besides project root. Searched when using --make"
57−
58− , print_types = False
59− &= help "Print out inferred types of top-level definitions."
60−
61− } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
62− &= helpArg [explicit, name "help", name "h"]
63− &= versionArg [explicit, name "version", name "v", summary Compiler.version]
64− &= summary ("The Elm Compiler " ++ Compiler.version ++ ", (c) Evan Czaplicki 2011-2014")
compiler/Build/Print.hsdeleted−28
@@ -1,28 +0,0 @@
1−module Build.Print where
2−
3−import System.IO (hPutStrLn, stderr)
4−import System.Exit (exitFailure)
5−
6−import qualified Data.Map as Map
7−import qualified Data.List as List
8−import qualified AST.Module as Module
9−import qualified AST.PrettyPrint as Pretty
10−import qualified Text.PrettyPrint as P
11−
12−types :: Module.Types -> IO ()
13−types ts =
14− do putStrLn ""
15− mapM_ printType (Map.toList ts)
16− putStrLn ""
17− where
18− printType (n,t) = do
19− print $ P.hsep [ Pretty.variable n
20− , P.text ":"
21− , Pretty.pretty t ]
22−
23−errors :: [P.Doc] -> IO ()
24−errors errs =
25− mapM_ print (List.intersperse (P.text " ") errs)
26−
27−failure :: String -> IO a
28−failure msg = hPutStrLn stderr msg >> exitFailure
compiler/Compiler.hsdeleted−77
@@ -1,77 +0,0 @@
1−{-# OPTIONS_GHC -Wall #-}
2−module Main where
3−
4−import GHC.Conc (getNumProcessors, setNumCapabilities)
5−
6−
7−main :: IO ()
8−main =
9− do setNumCapabilities =<< getNumProcessors
10− error "currently out of order"
11−
12−{--
13−compileArgs :: Flag.Flags -> IO ()
14−compileArgs flags =
15− do when (Flag.get_runtime flags) $ do
16− putStrLn Utils.runtime
17− exitSuccess
18− case Flag.files flags of
19− [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
20− fs -> mapM_ (build flags) fs
21−
22−build :: Flag.Flags -> FilePath -> IO ()
23−build flags rootFile =
24− do let noPrelude = Flag.no_prelude flags
25− builtIns <- Prelude.interfaces noPrelude
26−
27− (Recipe elmFiles jsFiles) <-
28− if Flag.make flags
29− then Utils.run (getBuildRecipe (Flag.src_dir flags) builtIns rootFile)
30− else return (Recipe [rootFile] [])
31−
32− moduleName <- File.build flags builtIns elmFiles
33−
34− let elmos = map (Utils.elmo flags) elmFiles
35− js <- foldM appendToOutput BS.empty (elmos ++ jsFiles)
36−
37− (extension, code) <-
38− if Flag.only_js flags
39− then do putStr "Generating JavaScript ... "
40− makeJs js
41− else do putStr "Generating HTML ... "
42− makeHtml js moduleName
43−
44− let targetFile = Utils.buildPath flags rootFile extension
45− createDirectoryIfMissing True (takeDirectory targetFile)
46− BS.writeFile targetFile code
47− putStrLn "Done"
48−
49− where
50− appendToOutput :: BS.ByteString -> FilePath -> IO BS.ByteString
51− appendToOutput js filePath = do
52− src <- BS.readFile filePath
53− return (BS.append src js)
54−
55− getRuntime :: IO Html.JSSource
56− getRuntime =
57− let runtimePath = Maybe.fromMaybe Utils.runtime (Flag.set_runtime flags) in
58− case Flag.bundle_runtime flags of
59− False -> return (Html.Link runtimePath)
60− True -> Html.Source `fmap` BS.readFile runtimePath
61−
62− makeJs :: BS.ByteString -> IO (String, BS.ByteString)
63− makeJs js =
64− do runtime <- getRuntime
65− case runtime of
66− Html.Link _ -> return ("js", js)
67− Html.Source rts -> return ("js", BS.append rts js)
68−
69− makeHtml :: BS.ByteString -> String -> IO (String, BS.ByteString)
70− makeHtml js moduleName =
71− do runtime <- getRuntime
72− return ("html", BS.pack $ renderHtml (html runtime))
73− where
74− sources js = map Html.Link (Flag.scripts flags) ++ [ Html.Source js ]
75− html runtime =
76− Html.generate runtime (takeBaseName rootFile) (sources js) moduleName ""
77−--}
elm-compiler.cabal+1−99
@@ -37,7 +37,7 @@ Library
3737 -threaded -O2 -W
3838
3939 Hs-Source-Dirs:
40− src
40+ compiler
4141
4242 exposed-modules:
4343 Elm.Compiler,
@@ -99,104 +99,6 @@ Library
9999 Type.State,
100100 Type.Type,
101101 Type.Unify,
102− Build.Flags,
103− Build.Print,
104− Build.Source,
105− Paths_elm_compiler
106−
107− Build-depends:
108− aeson >= 0.7 && < 0.9,
109− aeson-pretty >= 0.7 && < 0.8,
110− base >=4.2 && <5,
111− binary >= 0.7.0.0 && < 0.8,
112− blaze-html >= 0.5 && < 0.8,
113− blaze-markup >= 0.5.1 && < 0.7,
114− bytestring >= 0.9 && < 0.11,
115− cheapskate >= 0.1 && < 0.2,
116− cmdargs >= 0.7 && < 0.11,
117− containers >= 0.3 && < 0.6,
118− directory >= 1.0 && < 2.0,
119− filepath >= 1 && < 2.0,
120− highlighting-kate >= 0.5 && < 0.6,
121− indents >= 0.3 && < 0.4,
122− language-ecmascript >=0.15 && < 0.17,
123− language-glsl >= 0.0.2 && < 0.2,
124− mtl >= 2 && < 3,
125− parsec >= 3.1.1 && < 3.5,
126− pretty >= 1.0 && < 2.0,
127− text >= 1 && < 2,
128− transformers >= 0.2 && < 0.5,
129− union-find >= 0.2 && < 0.3,
130− unordered-containers >= 0.1 && < 0.3
131−
132−
133−Executable elm-compiler
134− ghc-options:
135− -threaded -O2 -W
136−
137− Hs-Source-Dirs:
138− src
139−
140− Main-is:
141− Compiler.hs
142−
143− other-modules:
144− Elm.Compiler.Version,
145− AST.Annotation,
146− AST.Declaration,
147− AST.Expression.General,
148− AST.Expression.Source,
149− AST.Expression.Valid,
150− AST.Expression.Canonical,
151− AST.Helpers,
152− AST.Literal,
153− AST.Module,
154− AST.Pattern,
155− AST.PrettyPrint,
156− AST.Type,
157− AST.Variable,
158− Generate.JavaScript,
159− Generate.JavaScript.Helpers,
160− Generate.JavaScript.Ports,
161− Generate.JavaScript.Variable,
162− Generate.Markdown,
163− Generate.Cases,
164− Transform.Canonicalize,
165− Transform.Canonicalize.Environment,
166− Transform.Canonicalize.Setup,
167− Transform.Canonicalize.Type,
168− Transform.Canonicalize.Variable,
169− Transform.Check,
170− Transform.Expression,
171− Transform.Declaration,
172− Transform.Definition,
173− Transform.Interface,
174− Transform.SortDefinitions,
175− Transform.Substitute,
176− Metadata.Prelude,
177− Parse.Binop,
178− Parse.Declaration,
179− Parse.Expression,
180− Parse.Helpers,
181− Parse.Literal,
182− Parse.Module,
183− Parse.Parse,
184− Parse.Pattern,
185− Parse.Type,
186− Type.Constrain.Expression,
187− Type.Constrain.Literal,
188− Type.Constrain.Pattern,
189− Type.Environment,
190− Type.ExtraChecks,
191− Type.Fragment,
192− Type.Inference,
193− Type.PrettyPrint,
194− Type.Solve,
195− Type.State,
196− Type.Type,
197− Type.Unify,
198− Build.Flags,
199− Build.Print,
200102 Build.Source,
201103 Paths_elm_compiler
202104