on master help sign in
Switch to only generating elmo files. Turn off the CPP flags in .cabal and remove all generated JS files on each build for now.
6e56df5evancz
Elm.cabal+1−2
@@ -86,8 +86,7 @@ Library
86Executable elm
86Executable elm
87 Main-is: Compiler.hs
87 Main-is: Compiler.hs
88 Hs-Source-Dirs: compiler, compiler/Gen, compiler/Model, compiler/Transform
88 Hs-Source-Dirs: compiler, compiler/Gen, compiler/Model, compiler/Transform
89− extensions: CPP
89+ ghc-options: -rtsopts -prof -auto-all -caf-all
90− cpp-options: -DELM_COMPILEDATADIR="dist/data"
91 other-modules: Ast,
90 other-modules: Ast,
92 Located,
91 Located,
93 CompileToJS,
92 CompileToJS,
Setup.hs+1
@@ -151,6 +151,7 @@ buildRuntime lbi = do
151 createDirectoryIfMissing False (rtsDir lbi) -- dist should already exist
151 createDirectoryIfMissing False (rtsDir lbi) -- dist should already exist
152 writeFile (rts lbi) "Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {};\n\
152 writeFile (rts lbi) "Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {};\n\
153 \Elm.Graphics = {}; ElmRuntime = {}; ElmRuntime.Render = {}\n"
153 \Elm.Graphics = {}; ElmRuntime = {}; ElmRuntime.Render = {}\n"
154+ removeDirectoryRecursive ("dist" </> "js")
154 mapM_ (appendJS lbi) =<< getFiles ".js" "libraries"
155 mapM_ (appendJS lbi) =<< getFiles ".js" "libraries"
155 mapM_ (appendElm lbi) =<< getFiles ".elm" "libraries"
156 mapM_ (appendElm lbi) =<< getFiles ".elm" "libraries"
156 mapM_ (appendJS lbi) =<< getFiles ".js" "runtime"
157 mapM_ (appendJS lbi) =<< getFiles ".js" "runtime"
compiler/Compiler.hs+15−14
@@ -67,24 +67,25 @@ compileArgs flags =
67
67
68type Interface = String
68type Interface = String
69
69
70+file :: Flags -> FilePath -> String -> FilePath
71+file flags filePath ext = output_directory flags </> replaceExtension filePath ext
72+
73+elmo :: Flags -> FilePath -> FilePath
74+elmo flags filePath = file flags filePath "elmo"
75+
76+
70buildFile :: Flags -> Int -> Int -> FilePath -> IO Interface
77buildFile :: Flags -> Int -> Int -> FilePath -> IO Interface
71buildFile flags moduleNum numModules filePath =
78buildFile flags moduleNum numModules filePath =
72 do compiled <- alreadyCompiled
79 do compiled <- alreadyCompiled
73− if compiled then readFile elmo else compile
80+ if compiled then readFile (elmo flags filePath) else compile
74
81
75 where
82 where
76− file :: String -> FilePath
77− file ext = output_directory flags </> replaceExtension filePath ext
78−
79− elmo :: FilePath
80− elmo = file "elmo"
81−
82 alreadyCompiled :: IO Bool
83 alreadyCompiled :: IO Bool
83 alreadyCompiled = do
84 alreadyCompiled = do
84− exists <- doesFileExist elmo
85+ exists <- doesFileExist (elmo flags filePath)
85 if not exists then return False
86 if not exists then return False
86 else do tsrc <- getModificationTime filePath
87 else do tsrc <- getModificationTime filePath
87− tint <- getModificationTime elmo
88+ tint <- getModificationTime (elmo flags filePath)
88 return (tsrc < tint)
89 return (tsrc < tint)
89
90
90 number :: String
91 number :: String
@@ -104,7 +105,7 @@ buildFile flags moduleNum numModules filePath =
104 Right modul -> do exs <- exportInfo modul
105 Right modul -> do exs <- exportInfo modul
105 return (exs, jsModule modul)
106 return (exs, jsModule modul)
106 createDirectoryIfMissing True (output_directory flags)
107 createDirectoryIfMissing True (output_directory flags)
107− writeFile elmo obj
108+ writeFile (elmo flags filePath) obj
108 return obj
109 return obj
109
110
110
111
@@ -122,19 +123,19 @@ build flags rootFile = do
122 case only_js flags of
123 case only_js flags of
123 True -> do
124 True -> do
124 putStr "Generating JavaScript ... "
125 putStr "Generating JavaScript ... "
125− writeFile (replaceExtension rootFile "js") (genJs js)
126+ writeFile (file flags rootFile "js") (genJs js)
126 putStrLn "Done"
127 putStrLn "Done"
127 False -> do
128 False -> do
128 putStr "Generating HTML ... "
129 putStr "Generating HTML ... "
129 runtime <- getRuntime flags
130 runtime <- getRuntime flags
130 let html = genHtml $ createHtml runtime rootFile (sources js) ""
131 let html = genHtml $ createHtml runtime rootFile (sources js) ""
131− writeFile (replaceExtension rootFile "html") html
132+ writeFile (file flags rootFile "html") html
132 putStrLn "Done"
133 putStrLn "Done"
133
134
134 where
135 where
135 appendToOutput :: String -> FilePath -> IO String
136 appendToOutput :: String -> FilePath -> IO String
136 appendToOutput js filePath =
137 appendToOutput js filePath =
137− do src <- readFile (output_directory flags </> replaceExtension filePath "elmo")
138+ do src <- readFile (elmo flags filePath)
138 return (src ++ js)
139 return (src ++ js)
139
140
140 genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
141 genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
@@ -153,6 +154,6 @@ buildFiles flags numModules interfaces (filePath:rest) = do
153
154
154
155
155exportInfo :: Module -> IO String
156exportInfo :: Module -> IO String
156−exportInfo (Module names ims exs stmts) =
157+exportInfo (Module names exs ims stmts) =
157 do print exs
158 do print exs
158 return (show exs)
159 return (show exs)