@@ -67,24 +67,25 @@ compileArgs flags =
68type Interface = String
68type Interface = String
70+file :: Flags -> FilePath -> String -> FilePath
71+file flags filePath ext = output_directory flags </> replaceExtension filePath ext
73+elmo :: Flags -> FilePath -> FilePath
74+elmo flags filePath = file flags filePath "elmo"
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
76− file :: String -> FilePath
77− file ext = output_directory flags </> replaceExtension filePath ext
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)
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
@@ -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"
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)
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
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)