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.
commit6e56df59a59b686bce9774eea3845fd445024b64 authorevancz <info@elm-lang.org> dateFri 7 Jun 2013, 09:38 (13 years ago) parent28db384
3 files changed+17−16
Elm.cabal+1−2 Setup.hs+1 compiler/Compiler.hs+15−14
Elm.cabal+1−2
@@ -86,8 +86,7 @@ Library
8686Executable elm
8787 Main-is: Compiler.hs
8888 Hs-Source-Dirs: compiler, compiler/Gen, compiler/Model, compiler/Transform
89− extensions: CPP
90− cpp-options: -DELM_COMPILEDATADIR="dist/data"
89+ ghc-options: -rtsopts -prof -auto-all -caf-all
9190 other-modules: Ast,
9291 Located,
9392 CompileToJS,
Setup.hs+1
@@ -151,6 +151,7 @@ buildRuntime lbi = do
151151 createDirectoryIfMissing False (rtsDir lbi) -- dist should already exist
152152 writeFile (rts lbi) "Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {};\n\
153153 \Elm.Graphics = {}; ElmRuntime = {}; ElmRuntime.Render = {}\n"
154+ removeDirectoryRecursive ("dist" </> "js")
154155 mapM_ (appendJS lbi) =<< getFiles ".js" "libraries"
155156 mapM_ (appendElm lbi) =<< getFiles ".elm" "libraries"
156157 mapM_ (appendJS lbi) =<< getFiles ".js" "runtime"
compiler/Compiler.hs+15−14
@@ -67,24 +67,25 @@ compileArgs flags =
6767
6868type Interface = String
6969
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+
7077buildFile :: Flags -> Int -> Int -> FilePath -> IO Interface
7178buildFile flags moduleNum numModules filePath =
7279 do compiled <- alreadyCompiled
73− if compiled then readFile elmo else compile
80+ if compiled then readFile (elmo flags filePath) else compile
7481
7582 where
76− file :: String -> FilePath
77− file ext = output_directory flags </> replaceExtension filePath ext
78−
79− elmo :: FilePath
80− elmo = file "elmo"
81−
8283 alreadyCompiled :: IO Bool
8384 alreadyCompiled = do
84− exists <- doesFileExist elmo
85+ exists <- doesFileExist (elmo flags filePath)
8586 if not exists then return False
8687 else do tsrc <- getModificationTime filePath
87− tint <- getModificationTime elmo
88+ tint <- getModificationTime (elmo flags filePath)
8889 return (tsrc < tint)
8990
9091 number :: String
@@ -104,7 +105,7 @@ buildFile flags moduleNum numModules filePath =
104105 Right modul -> do exs <- exportInfo modul
105106 return (exs, jsModule modul)
106107 createDirectoryIfMissing True (output_directory flags)
107− writeFile elmo obj
108+ writeFile (elmo flags filePath) obj
108109 return obj
109110
110111
@@ -122,19 +123,19 @@ build flags rootFile = do
122123 case only_js flags of
123124 True -> do
124125 putStr "Generating JavaScript ... "
125− writeFile (replaceExtension rootFile "js") (genJs js)
126+ writeFile (file flags rootFile "js") (genJs js)
126127 putStrLn "Done"
127128 False -> do
128129 putStr "Generating HTML ... "
129130 runtime <- getRuntime flags
130131 let html = genHtml $ createHtml runtime rootFile (sources js) ""
131− writeFile (replaceExtension rootFile "html") html
132+ writeFile (file flags rootFile "html") html
132133 putStrLn "Done"
133134
134135 where
135136 appendToOutput :: String -> FilePath -> IO String
136137 appendToOutput js filePath =
137− do src <- readFile (output_directory flags </> replaceExtension filePath "elmo")
138+ do src <- readFile (elmo flags filePath)
138139 return (src ++ js)
139140
140141 genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
@@ -153,6 +154,6 @@ buildFiles flags numModules interfaces (filePath:rest) = do
153154
154155
155156exportInfo :: Module -> IO String
156−exportInfo (Module names ims exs stmts) =
157+exportInfo (Module names exs ims stmts) =
157158 do print exs
158159 return (show exs)