on master help sign in
Get rid of Build.Info file, move compiler version to Elm.Internal.Version and use Elm's version conventions
26a8c82Evan Czaplicki
Elm.cabal−2
@@ -85,7 +85,6 @@ Library
85 Build.Dependencies,
85 Build.Dependencies,
86 Build.File,
86 Build.File,
87 Build.Flags,
87 Build.Flags,
88− Build.Info,
89 Build.Print,
88 Build.Print,
90 Build.Source,
89 Build.Source,
91 Build.Utils,
90 Build.Utils,
@@ -165,7 +164,6 @@ Executable elm
165 Build.Dependencies,
164 Build.Dependencies,
166 Build.File,
165 Build.File,
167 Build.Flags,
166 Build.Flags,
168− Build.Info,
169 Build.Print,
167 Build.Print,
170 Build.Source,
168 Build.Source,
171 Build.Utils,
169 Build.Utils,
compiler/Build/Flags.hs+3−3
@@ -1,7 +1,7 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2module Build.Flags where
2module Build.Flags where
3
3
4−import qualified Build.Info as Info
4+import qualified Elm.Internal.Version as Version
5import System.Console.CmdArgs
5import System.Console.CmdArgs
6
6
7data Flags = Flags
7data Flags = Flags
@@ -40,5 +40,5 @@ flags = Flags
40 &= help "Print out infered types of top-level definitions."
40 &= help "Print out infered types of top-level definitions."
41 } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
41 } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
42 &= helpArg [explicit, name "help", name "h"]
42 &= helpArg [explicit, name "help", name "h"]
43− &= versionArg [explicit, name "version", name "v", summary Info.version]
43+ &= versionArg [explicit, name "version", name "v", summary (show Version.elmVersion)]
44− &= summary ("The Elm Compiler " ++ Info.version ++ ", (c) Evan Czaplicki 2011-2013")
44+ &= summary ("The Elm Compiler " ++ show Version.elmVersion ++ ", (c) Evan Czaplicki 2011-2013")
compiler/Build/Info.hsdeleted−11
@@ -1,11 +0,0 @@
1−module Build.Info where
2−
3−import qualified Paths_Elm as This
4−import qualified Data.Version as Version
5−
6−version :: String
7−version = Version.showVersion This.version
8−
9−runtime :: IO FilePath
10−runtime = This.getDataFileName "elm-runtime.js"
11−
compiler/Compiler.hs+7−10
@@ -2,6 +2,7 @@ module Main where
2
2
3import Control.Monad (foldM)
3import Control.Monad (foldM)
4import qualified Data.Map as Map
4import qualified Data.Map as Map
5+import qualified Data.Maybe as Maybe
5import qualified Text.Blaze.Html.Renderer.Utf8 as Blaze
6import qualified Text.Blaze.Html.Renderer.Utf8 as Blaze
6import qualified Data.ByteString.Lazy.Char8 as BS
7import qualified Data.ByteString.Lazy.Char8 as BS
7import qualified System.Console.CmdArgs as CmdArgs
8import qualified System.Console.CmdArgs as CmdArgs
@@ -13,9 +14,9 @@ import Build.Dependencies (getSortedDependencies)
13import qualified Generate.Html as Html
14import qualified Generate.Html as Html
14import qualified Metadata.Prelude as Prelude
15import qualified Metadata.Prelude as Prelude
15import qualified Build.Utils as Utils
16import qualified Build.Utils as Utils
16−import qualified Build.Info as Info
17import qualified Build.Flags as Flag
17import qualified Build.Flags as Flag
18import qualified Build.File as File
18import qualified Build.File as File
19+import qualified Elm.Internal.Paths as Path
19
20
20main :: IO ()
21main :: IO ()
21main = do setNumCapabilities =<< getNumProcessors
22main = do setNumCapabilities =<< getNumProcessors
@@ -46,7 +47,7 @@ build flags rootFile =
46 then do putStr "Generating JavaScript ... "
47 then do putStr "Generating JavaScript ... "
47 return ("js", js)
48 return ("js", js)
48 else do putStr "Generating HTML ... "
49 else do putStr "Generating HTML ... "
49− makeHtml js moduleName
50+ return (makeHtml js moduleName)
50
51
51 let targetFile = Utils.buildPath flags rootFile extension
52 let targetFile = Utils.buildPath flags rootFile extension
52 createDirectoryIfMissing True (takeDirectory targetFile)
53 createDirectoryIfMissing True (takeDirectory targetFile)
@@ -61,11 +62,7 @@ build flags rootFile =
61
62
62 sources js = map Html.Link (Flag.scripts flags) ++ [ Html.Source js ]
63 sources js = map Html.Link (Flag.scripts flags) ++ [ Html.Source js ]
63
64
64− makeHtml js moduleName = do
65+ makeHtml js moduleName = ("html", Blaze.renderHtml html)
66+ where
65− rtsPath <- case Flag.runtime flags of
67+ rtsPath = Maybe.fromMaybe Path.runtime (Flag.runtime flags)
66− Just fp -> return fp
67− Nothing -> Info.runtime
68−
69− let html = Html.generate
70− rtsPath (takeBaseName rootFile) (sources js) moduleName ""
68+ html = Html.generate rtsPath (takeBaseName rootFile) (sources js) moduleName ""
71− return ("html", Blaze.renderHtml html)
compiler/Elm/Internal/Utils.hs+1−1
@@ -25,4 +25,4 @@ interfaces = unsafePerformIO $ Prelude.interfaces
25
25
26-- |This function extracts the module name of a given source program.
26-- |This function extracts the module name of a given source program.
27moduleName :: String -> Maybe String
27moduleName :: String -> Maybe String
28−moduleName = Parser.getModuleName
28+moduleName = Parser.getModuleName
compiler/Elm/Internal/Version.hs+6
@@ -8,6 +8,12 @@ import Data.Char (isDigit)
8import qualified Data.List as List
8import qualified Data.List as List
9import Data.Typeable
9import Data.Typeable
10import qualified Data.Text as T
10import qualified Data.Text as T
11+import qualified Paths_Elm as This
12+import qualified Data.Version as Version
13+
14+elmVersion :: Version
15+elmVersion = V ns ""
16+ where (Version.Version ns _) =This.version
11
17
12-- Data representation
18-- Data representation
13
19
compiler/InterfaceSerialization.hs+4−4
@@ -6,8 +6,7 @@ module InterfaceSerialization ( loadInterface
6import qualified Data.ByteString.Lazy as L
6import qualified Data.ByteString.Lazy as L
7import qualified Data.Binary as Binary
7import qualified Data.Binary as Binary
8
8
9−import Paths_Elm (version)
9+import qualified Elm.Internal.Version as Version
10−import Data.Version (showVersion)
11import System.Directory (doesFileExist)
10import System.Directory (doesFileExist)
12import System.IO (hPutStrLn, stderr)
11import System.IO (hPutStrLn, stderr)
13import System.Exit (exitFailure)
12import System.Exit (exitFailure)
@@ -42,11 +41,12 @@ interfaceDecode filePath bytes = do
42validVersion :: FilePath -> (String, ModuleInterface) ->
41validVersion :: FilePath -> (String, ModuleInterface) ->
43 Either String (String, ModuleInterface)
42 Either String (String, ModuleInterface)
44validVersion filePath (name, interface) =
43validVersion filePath (name, interface) =
45− if iVersion interface == showVersion version then
44+ if iVersion interface == Version.elmVersion then
46 Right (name, interface)
45 Right (name, interface)
47 else
46 else
48 Left $ concat
47 Left $ concat
49 [ "Error reading build artifact: ", filePath, "\n"
48 [ "Error reading build artifact: ", filePath, "\n"
50− , " It was generated by a different version of the compiler: ", iVersion interface, "\n"
49+ , " It was generated by a different version of the compiler: "
50+ , show (iVersion interface), "\n"
51 , " Please remove the file and try again.\n"
51 , " Please remove the file and try again.\n"
52 ]
52 ]
compiler/SourceSyntax/Module.hs+3−3
@@ -14,7 +14,7 @@ import SourceSyntax.Type
14import System.FilePath (joinPath)
14import System.FilePath (joinPath)
15import Control.Monad (liftM)
15import Control.Monad (liftM)
16
16
17−import qualified Build.Info as Info
17+import qualified Elm.Internal.Version as Version
18
18
19data Module tipe var =
19data Module tipe var =
20 Module [String] Exports Imports [Declaration tipe var]
20 Module [String] Exports Imports [Declaration tipe var]
@@ -61,7 +61,7 @@ type Interfaces = Map.Map String ModuleInterface
61type ADT = (String, [String], [(String,[Type])])
61type ADT = (String, [String], [(String,[Type])])
62
62
63data ModuleInterface = ModuleInterface {
63data ModuleInterface = ModuleInterface {
64− iVersion :: String,
64+ iVersion :: Version.Version,
65 iTypes :: Map.Map String Type,
65 iTypes :: Map.Map String Type,
66 iImports :: [(String, ImportMethod)],
66 iImports :: [(String, ImportMethod)],
67 iAdts :: [ADT],
67 iAdts :: [ADT],
@@ -71,7 +71,7 @@ data ModuleInterface = ModuleInterface {
71
71
72metaToInterface metaModule =
72metaToInterface metaModule =
73 ModuleInterface
73 ModuleInterface
74− { iVersion = Info.version
74+ { iVersion = Version.elmVersion
75 , iTypes = types metaModule
75 , iTypes = types metaModule
76 , iImports = imports metaModule
76 , iImports = imports metaModule
77 , iAdts = datatypes metaModule
77 , iAdts = datatypes metaModule