on master help sign in
Fix broken build.
commit569541e72a3d24afd0b783e27eb9b9c218cd060c authorevancz <info@elm-lang.org> dateSun 9 Jun 2013, 23:36 (13 years ago) parent776ef7c
1 file changed+24−20
compiler/Compiler.hs+24−20
compiler/Compiler.hs+24−20
@@ -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 getInterface 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− interface :: FilePath
80− interface = file "elmi"
81−
8283 alreadyCompiled :: IO Bool
8384 alreadyCompiled = do
84− exists <- doesFileExist interface
85+ exists <- doesFileExist (elmo flags filePath)
8586 if not exists then return False
8687 else do tsrc <- getModificationTime filePath
87− tint <- getModificationTime interface
88+ tint <- getModificationTime (elmo flags filePath)
8889 return (tsrc < tint)
8990
9091 number :: String
@@ -97,19 +98,16 @@ buildFile flags moduleNum numModules filePath =
9798 compile = do
9899 putStrLn (number ++ " Compiling " ++ name)
99100 source <- readFile filePath
100− (inter,obj) <-
101+ (interface,obj) <-
101102 if takeExtension filePath == ".js" then return ("",source) else
102103 case buildFromSource (no_prelude flags) source of
103104 Left err -> putStrLn err >> exitFailure
104− Right modul -> return (show modul, jsModule modul)
105+ Right modul -> do exs <- exportInfo modul
106+ return (exs, jsModule modul)
105107 createDirectoryIfMissing True (output_directory flags)
106− writeFile interface inter
107− writeFile (file "elmo") obj
108− return inter
108+ writeFile (elmo flags filePath) obj
109+ return obj
109110
110− getInterface :: IO Interface
111− getInterface = do
112− readFile interface
113111
114112getRuntime :: Flags -> IO FilePath
115113getRuntime flags =
@@ -125,19 +123,19 @@ build flags rootFile = do
125123 case only_js flags of
126124 True -> do
127125 putStr "Generating JavaScript ... "
128− writeFile (replaceExtension rootFile "js") (genJs js)
126+ writeFile (file flags rootFile "js") (genJs js)
129127 putStrLn "Done"
130128 False -> do
131129 putStr "Generating HTML ... "
132130 runtime <- getRuntime flags
133131 let html = genHtml $ createHtml runtime rootFile (sources js) ""
134− writeFile (replaceExtension rootFile "html") html
132+ writeFile (file flags rootFile "html") html
135133 putStrLn "Done"
136134
137135 where
138136 appendToOutput :: String -> FilePath -> IO String
139137 appendToOutput js filePath =
140− do src <- readFile (output_directory flags </> replaceExtension filePath "elmo")
138+ do src <- readFile (elmo flags filePath)
141139 return (src ++ js)
142140
143141 genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
@@ -153,3 +151,9 @@ buildFiles flags numModules interfaces (filePath:rest) = do
153151 let moduleName = intercalate "." (splitDirectories (dropExtensions filePath))
154152 interfaces' = Map.insert moduleName interface interfaces
155153 buildFiles flags numModules interfaces' rest
154+
155+
156+exportInfo :: Module -> IO String
157+exportInfo (Module names exs ims stmts) =
158+ do print exs
159+ return (show exs)