on master help sign in
Fix broken build.
569541eevancz
compiler/Compiler.hs+24−20
@@ -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 getInterface 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− interface :: FilePath
80− interface = file "elmi"
81−
82 alreadyCompiled :: IO Bool
83 alreadyCompiled :: IO Bool
83 alreadyCompiled = do
84 alreadyCompiled = do
84− exists <- doesFileExist interface
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 interface
88+ tint <- getModificationTime (elmo flags filePath)
88 return (tsrc < tint)
89 return (tsrc < tint)
89
90
90 number :: String
91 number :: String
@@ -97,19 +98,16 @@ buildFile flags moduleNum numModules filePath =
97 compile = do
98 compile = do
98 putStrLn (number ++ " Compiling " ++ name)
99 putStrLn (number ++ " Compiling " ++ name)
99 source <- readFile filePath
100 source <- readFile filePath
100− (inter,obj) <-
101+ (interface,obj) <-
101 if takeExtension filePath == ".js" then return ("",source) else
102 if takeExtension filePath == ".js" then return ("",source) else
102 case buildFromSource (no_prelude flags) source of
103 case buildFromSource (no_prelude flags) source of
103 Left err -> putStrLn err >> exitFailure
104 Left err -> putStrLn err >> exitFailure
105+ Right modul -> do exs <- exportInfo modul
104− Right modul -> return (show modul, jsModule modul)
106+ return (exs, jsModule modul)
105 createDirectoryIfMissing True (output_directory flags)
107 createDirectoryIfMissing True (output_directory flags)
106− writeFile interface inter
108+ writeFile (elmo flags filePath) obj
107− writeFile (file "elmo") obj
108− return inter
109+ return obj
109
110
110− getInterface :: IO Interface
111− getInterface = do
112− readFile interface
113
111
114getRuntime :: Flags -> IO FilePath
112getRuntime :: Flags -> IO FilePath
115getRuntime flags =
113getRuntime flags =
@@ -125,19 +123,19 @@ build flags rootFile = do
125 case only_js flags of
123 case only_js flags of
126 True -> do
124 True -> do
127 putStr "Generating JavaScript ... "
125 putStr "Generating JavaScript ... "
128− writeFile (replaceExtension rootFile "js") (genJs js)
126+ writeFile (file flags rootFile "js") (genJs js)
129 putStrLn "Done"
127 putStrLn "Done"
130 False -> do
128 False -> do
131 putStr "Generating HTML ... "
129 putStr "Generating HTML ... "
132 runtime <- getRuntime flags
130 runtime <- getRuntime flags
133 let html = genHtml $ createHtml runtime rootFile (sources js) ""
131 let html = genHtml $ createHtml runtime rootFile (sources js) ""
134− writeFile (replaceExtension rootFile "html") html
132+ writeFile (file flags rootFile "html") html
135 putStrLn "Done"
133 putStrLn "Done"
136
134
137 where
135 where
138 appendToOutput :: String -> FilePath -> IO String
136 appendToOutput :: String -> FilePath -> IO String
139 appendToOutput js filePath =
137 appendToOutput js filePath =
140− do src <- readFile (output_directory flags </> replaceExtension filePath "elmo")
138+ do src <- readFile (elmo flags filePath)
141 return (src ++ js)
139 return (src ++ js)
142
140
143 genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
141 genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
@@ -153,3 +151,9 @@ buildFiles flags numModules interfaces (filePath:rest) = do
153 let moduleName = intercalate "." (splitDirectories (dropExtensions filePath))
151 let moduleName = intercalate "." (splitDirectories (dropExtensions filePath))
154 interfaces' = Map.insert moduleName interface interfaces
152 interfaces' = Map.insert moduleName interface interfaces
155 buildFiles flags numModules interfaces' rest
153 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)