on master help sign in
Try to fix build artifact caching across "git checkout"
3521750Evan Czaplicki
builder/src/Deps/Verify.hs+3−3
@@ -334,7 +334,7 @@ crush pkg info results =
334
334
335
335
336crushHelp :: Set Module.Raw -> Module.Raw -> Compiler.Artifacts -> Maybe Module.Interface
336crushHelp :: Set Module.Raw -> Module.Raw -> Compiler.Artifacts -> Maybe Module.Interface
337−crushHelp exposed name (Compiler.Artifacts elmi _ _) =
337+crushHelp exposed name (Compiler.Artifacts _ elmi _ _) =
338 if Set.member name exposed then
338 if Set.member name exposed then
339 Just elmi
339 Just elmi
340
340
@@ -347,7 +347,7 @@ crushHelp exposed name (Compiler.Artifacts elmi _ _) =
347
347
348
348
349addDocs :: Compiler.Artifacts -> [Docs.Module] -> [Docs.Module]
349addDocs :: Compiler.Artifacts -> [Docs.Module] -> [Docs.Module]
350−addDocs (Compiler.Artifacts _ _ maybeDocs) docsList =
350+addDocs (Compiler.Artifacts _ _ _ maybeDocs) docsList =
351 case maybeDocs of
351 case maybeDocs of
352 Nothing ->
352 Nothing ->
353 docsList
353 docsList
@@ -361,7 +361,7 @@ addDocs (Compiler.Artifacts _ _ maybeDocs) docsList =
361
361
362
362
363addGraph :: Compiler.Artifacts -> Obj.Graph -> Obj.Graph
363addGraph :: Compiler.Artifacts -> Obj.Graph -> Obj.Graph
364−addGraph (Compiler.Artifacts _ elmo _) graph =
364+addGraph (Compiler.Artifacts _ _ elmo _) graph =
365 Obj.union elmo graph
365 Obj.union elmo graph
366
366
367
367
builder/src/Elm/Project.hs+1−1
@@ -78,7 +78,7 @@ compileForRepl noColors localizer source maybeName =
78 (dirty, ifaces) <- Plan.plan Nothing summary graph
78 (dirty, ifaces) <- Plan.plan Nothing summary graph
79 answers <- Compile.compile project Nothing ifaces dirty
79 answers <- Compile.compile project Nothing ifaces dirty
80 results <- Artifacts.write root answers
80 results <- Artifacts.write root answers
81− let (Compiler.Artifacts elmi _ _) = results ! N.replModule
81+ let (Compiler.Artifacts _ elmi _ _) = results ! N.replModule
82 traverse (Output.generateReplFile noColors localizer summary graph elmi) maybeName
82 traverse (Output.generateReplFile noColors localizer summary graph elmi) maybeName
83
83
84
84
builder/src/File/Artifacts.hs+6−3
@@ -15,6 +15,7 @@ import Data.Map (Map)
15import qualified Data.Map as Map
15import qualified Data.Map as Map
16import qualified Data.Maybe as Maybe
16import qualified Data.Maybe as Maybe
17import qualified Data.Text.Encoding as Text
17import qualified Data.Text.Encoding as Text
18+import qualified System.Directory as Dir
18
19
19import qualified Elm.Compiler as Compiler
20import qualified Elm.Compiler as Compiler
20import qualified Elm.Compiler.Module as Module
21import qualified Elm.Compiler.Module as Module
@@ -48,11 +49,13 @@ ignore answers =
48write :: FilePath -> Map Module.Raw Answer -> Task.Task (Map Module.Raw Compiler.Artifacts)
49write :: FilePath -> Map Module.Raw Answer -> Task.Task (Map Module.Raw Compiler.Artifacts)
49write root answers =
50write root answers =
50 let
51 let
51− writer name result@(Compiler.Artifacts elmi elmo _) =
52+ writer name result@(Compiler.Artifacts time elmi elmo _) =
52 do mvar <- newEmptyMVar
53 do mvar <- newEmptyMVar
53 void $ forkIO $
54 void $ forkIO $
54− do Binary.encodeFile (Path.elmi root name) elmi
55+ do let ifacePath = Path.elmi root name
56+ Binary.encodeFile ifacePath elmi
55 Binary.encodeFile (Path.elmo root name) elmo
57 Binary.encodeFile (Path.elmo root name) elmo
58+ Dir.setModificationTime ifacePath time
56 putMVar mvar result
59 putMVar mvar result
57 return mvar
60 return mvar
58 in
61 in
@@ -63,7 +66,7 @@ write root answers =
63writeDocs :: Map Module.Raw Compiler.Artifacts -> FilePath -> Task.Task Docs.Documentation
66writeDocs :: Map Module.Raw Compiler.Artifacts -> FilePath -> Task.Task Docs.Documentation
64writeDocs results path =
67writeDocs results path =
65 let
68 let
66− getDocs (Compiler.Artifacts _ _ docs) =
69+ getDocs (Compiler.Artifacts _ _ _ docs) =
67 docs
70 docs
68 in
71 in
69 case Maybe.mapMaybe getDocs (Map.elems results) of
72 case Maybe.mapMaybe getDocs (Map.elems results) of
builder/src/File/Compile.hs+3−4
@@ -84,16 +84,15 @@ compileModule tell project maybeDocsPath answersMVar ifacesMVar name info =
84 let docs = toDocsFlag name project maybeDocsPath
84 let docs = toDocsFlag name project maybeDocsPath
85 let imports = makeImports project info
85 let imports = makeImports project info
86 ifaces <- readMVar ifacesMVar
86 ifaces <- readMVar ifacesMVar
87− let context = Compiler.Context pkg docs imports ifaces
87+ let time = Plan._time info
88 let source = Plan._src info
88 let source = Plan._src info
89− case Compiler.compile context source of
89+ case Compiler.compile docs pkg imports ifaces time source of
90 (_warnings, Left errors) ->
90 (_warnings, Left errors) ->
91 do tell (Progress.CompileFileEnd name Progress.Bad)
91 do tell (Progress.CompileFileEnd name Progress.Bad)
92 let path = Plan._path info
92 let path = Plan._path info
93− let time = Plan._time info
94 putMVar mvar (Bad path time source errors)
93 putMVar mvar (Bad path time source errors)
95
94
96− (_warnings, Right result@(Compiler.Artifacts elmi _ _)) ->
95+ (_warnings, Right result@(Compiler.Artifacts _ elmi _ _)) ->
97 do tell (Progress.CompileFileEnd name Progress.Good)
96 do tell (Progress.CompileFileEnd name Progress.Good)
98 let canonicalName = Module.Canonical pkg name
97 let canonicalName = Module.Canonical pkg name
99 lock <- takeMVar ifacesMVar
98 lock <- takeMVar ifacesMVar
builder/src/File/Plan.hs+1−1
@@ -158,7 +158,7 @@ isFresh srcTime cachedFile =
158 andM
158 andM
159 [ Dir.doesFileExist cachedFile
159 [ Dir.doesFileExist cachedFile
160 , do cacheTime <- Dir.getModificationTime cachedFile
160 , do cacheTime <- Dir.getModificationTime cachedFile
161− return (cacheTime >= srcTime)
161+ return (cacheTime == srcTime)
162 ]
162 ]
163
163
164
164
builder/src/Generate/Output.hs+1−1
@@ -88,7 +88,7 @@ getInterfaces :: Summary.Summary -> Map.Map Module.Raw Compiler.Artifacts -> I.I
88getInterfaces (Summary.Summary _ project _ interfaces _) artifacts =
88getInterfaces (Summary.Summary _ project _ interfaces _) artifacts =
89 let
89 let
90 pkg = Project.getName project
90 pkg = Project.getName project
91− addArtifact home (Compiler.Artifacts elmi _ _) ifaces =
91+ addArtifact home (Compiler.Artifacts _ elmi _ _) ifaces =
92 Map.insert (ModuleName.Canonical pkg home) elmi ifaces
92 Map.insert (ModuleName.Canonical pkg home) elmi ifaces
93 in
93 in
94 Map.foldrWithKey addArtifact interfaces artifacts
94 Map.foldrWithKey addArtifact interfaces artifacts
compiler/src/Compile.hs+7−4
@@ -9,6 +9,7 @@ module Compile
9
9
10import qualified Data.ByteString as BS
10import qualified Data.ByteString as BS
11import qualified Data.Map as Map
11import qualified Data.Map as Map
12+import qualified Data.Time.Clock as Time
12
13
13import qualified AST.Canonical as Can
14import qualified AST.Canonical as Can
14import qualified AST.Optimized as Opt
15import qualified AST.Optimized as Opt
@@ -45,14 +46,15 @@ type ImportDict =
45
46
46data Artifacts =
47data Artifacts =
47 Artifacts
48 Artifacts
49+ { _time :: Time.UTCTime
48− { _elmi :: I.Interface
50+ , _elmi :: I.Interface
49 , _elmo :: Opt.Graph
51 , _elmo :: Opt.Graph
50 , _docs :: Maybe Docs.Module
52 , _docs :: Maybe Docs.Module
51 }
53 }
52
54
53
55
54−compile :: DocsFlag -> Pkg.Name -> ImportDict -> I.Interfaces -> BS.ByteString -> Result i Artifacts
56+compile :: DocsFlag -> Pkg.Name -> ImportDict -> I.Interfaces -> Time.UTCTime -> BS.ByteString -> Result i Artifacts
55−compile flag pkg importDict interfaces source =
57+compile flag pkg importDict interfaces time source =
56 do
58 do
57 valid <- Result.mapError Error.Syntax $
59 valid <- Result.mapError Error.Syntax $
58 Parse.program pkg source
60 Parse.program pkg source
@@ -76,7 +78,8 @@ compile flag pkg importDict interfaces source =
76
78
77 Result.ok $
79 Result.ok $
78 Artifacts
80 Artifacts
81+ { _time = time
79− { _elmi = I.fromModule annotations canonical
82+ , _elmi = I.fromModule annotations canonical
80 , _elmo = graph
83 , _elmo = graph
81 , _docs = documentation
84 , _docs = documentation
82 }
85 }
compiler/src/Elm/Compiler.hs+11−13
@@ -1,7 +1,6 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2module Elm.Compiler
2module Elm.Compiler
3 ( version
3 ( version
4− , Context(..)
5 , Compile.DocsFlag(..)
4 , Compile.DocsFlag(..)
6 , Compile.Artifacts(..)
5 , Compile.Artifacts(..)
7 , compile
6 , compile
@@ -16,6 +15,7 @@ module Elm.Compiler
16import qualified Data.ByteString as BS
15import qualified Data.ByteString as BS
17import qualified Data.Map as Map
16import qualified Data.Map as Map
18import qualified Data.Text as Text
17import qualified Data.Text as Text
18+import qualified Data.Time.Clock as Time
19
19
20import qualified Compile
20import qualified Compile
21import qualified Elm.Compiler.Module as M
21import qualified Elm.Compiler.Module as M
@@ -44,18 +44,16 @@ version =
44-- COMPILE
44-- COMPILE
45
45
46
46
47−data Context =
47+compile
48− Context
48+ :: Compile.DocsFlag
49− { _package :: Pkg.Name
49+ -> Pkg.Name
50− , _docsFlag :: Compile.DocsFlag
51− , _imports :: Map.Map M.Raw M.Canonical
50+ -> Map.Map M.Raw M.Canonical
52− , _interfaces :: M.Interfaces
51+ -> M.Interfaces
53− }
52+ -> Time.UTCTime
54−
53+ -> BS.ByteString
55−
56−compile :: Context -> BS.ByteString -> ([Warning.Warning], Either [Error.Error] Compile.Artifacts)
54+ -> ( [Warning.Warning], Either [Error.Error] Compile.Artifacts )
57−compile (Context pkg docsFlag importDict interfaces) source =
55+compile docsFlag pkg importDict interfaces time source =
58− Result.run $ Compile.compile docsFlag pkg importDict interfaces source
56+ Result.run $ Compile.compile docsFlag pkg importDict interfaces time source
59
57
60
58
61
59