Skip to content

Commit e92ef99

Browse files
committed
Merge pull request #489 from dsyme/fix-timestamps
Fix timestamps
2 parents c1ca061 + 0dd0d01 commit e92ef99

File tree

3 files changed

+64
-45
lines changed

3 files changed

+64
-45
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
language: csharp
22

3+
os:
4+
- linux
5+
- osx
6+
7+
mono:
8+
- latest
9+
- 4.0.5
10+
311
sudo: false
412

513
install:

src/fsharp/vs/IncrementalBuild.fs

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -675,42 +675,20 @@ module internal IncrementalBuild =
675675
| VectorBuildRule ve -> visitVector optSlot ve acc
676676

677677
/// Compute the max timestamp on all available inputs
678-
let ComputeMaxTimeStamp (Target(output, optSlot)) bt acc =
679-
let rec VisitVector optSlot (ve: VectorBuildRule) acc =
680-
match ve with
681-
| VectorInput _ ->acc
682-
| VectorScanLeft(_id,_taskname,accumulatorExpr,inputExpr,_func) ->
683-
// Check each slot for an action that may be performed.
684-
VisitVector None inputExpr (VisitScalar accumulatorExpr acc)
685-
686-
| VectorMap(_id, _taskname, inputExpr, _func) ->
687-
VisitVector optSlot inputExpr acc
688-
689-
| VectorStamp(_id, _taskname, inputExpr, func) ->
690-
let acc =
691-
match GetVectorWidthByExpr(bt,ve) with
692-
| Some(cardinality) ->
693-
let CheckStamp acc slot =
694-
match GetVectorExprResult(bt,inputExpr,slot) with
695-
| Available(ires,_,_) -> max acc (func ires)
696-
| _ -> acc
697-
[0..cardinality-1] |> List.fold CheckStamp acc
698-
| None -> acc
699-
VisitVector optSlot inputExpr acc
700-
701-
| VectorMultiplex(_id, _taskname, inputExpr, _func) ->
702-
VisitScalar inputExpr acc
703-
704-
and VisitScalar (se:ScalarBuildRule) acc =
705-
match se with
706-
| ScalarInput _ ->acc
707-
| ScalarDemultiplex(_id,_taskname,inputExpr,_func) -> VisitVector None inputExpr acc
708-
| ScalarMap(_id,_taskname,inputExpr,_func) -> VisitScalar inputExpr acc
709-
678+
let ComputeMaxTimeStamp output (bt: PartialBuild) acc =
710679
let expr = bt.Rules.RuleList |> List.find (fun (s,_) -> s = output) |> snd
711-
match expr with
712-
| ScalarBuildRule se -> VisitScalar se acc
713-
| VectorBuildRule ve -> VisitVector optSlot ve acc
680+
match expr with
681+
| VectorBuildRule (VectorStamp(_id, _taskname, inputExpr, func) as ve) ->
682+
match GetVectorWidthByExpr(bt,ve) with
683+
| Some(cardinality) ->
684+
let CheckStamp acc slot =
685+
match GetVectorExprResult(bt,inputExpr,slot) with
686+
| Available(ires,_,_) -> max acc (func ires)
687+
| _ -> acc
688+
[0..cardinality-1] |> List.fold CheckStamp acc
689+
| None -> acc
690+
691+
| _ -> failwith "expected a VectorStamp"
714692

715693

716694
/// Given the result of a single action, apply that action to the Build
@@ -794,7 +772,6 @@ module internal IncrementalBuild =
794772
let MaxTimeStampInDependencies target bt =
795773
ComputeMaxTimeStamp target bt DateTime.MinValue
796774

797-
798775
/// Get a scalar vector. Result must be available
799776
let GetScalarResult<'T>(node:Scalar<'T>,bt): ('T*DateTime) option =
800777
match GetTopLevelExprByName(bt,node.Name) with
@@ -905,10 +882,8 @@ module internal IncrementalBuild =
905882
/// Creates a new vector with the same items but with
906883
/// timestamp specified by the passed-in function.
907884
let Stamp (taskname:string) (task:'I -> DateTime) (input:Vector<'I>): Vector<'I> =
908-
let BoxingTouch i =
909-
task(unbox i)
910885
let input = input.Expr
911-
let expr = VectorStamp(NextId(),taskname,input,BoxingTouch)
886+
let expr = VectorStamp(NextId(),taskname,input,unbox >> task)
912887
{ new Vector<'I>
913888
interface IVector with
914889
override __.Name = taskname
@@ -1211,7 +1186,7 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
12111186
errorLogger.Warning(e)
12121187
DateTime.Now
12131188
yield (Choice1Of2 r.resolvedPath,originalTimeStamp)
1214-
for pr in projectReferences do
1189+
for pr in projectReferences do
12151190
yield Choice2Of2 pr, defaultArg (pr.GetLogicalTimeStamp()) DateTime.Now]
12161191

12171192
// The IncrementalBuilder needs to hold up to one item that needs to be disposed, which is the tcImports for the incremental
@@ -1534,6 +1509,8 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
15341509
// Outputs
15351510
let buildDescription = new BuildDescriptionScope ()
15361511

1512+
do buildDescription.DeclareVectorOutput stampedFileNamesNode
1513+
do buildDescription.DeclareVectorOutput stampedReferencedAssembliesNode
15371514
do buildDescription.DeclareVectorOutput parseTreesNode
15381515
do buildDescription.DeclareVectorOutput tcStatesNode
15391516
do buildDescription.DeclareScalarOutput initialTcAccNode
@@ -1550,10 +1527,10 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
15501527
let file = if FileSystem.IsPathRootedShim(referenceText) then referenceText else Path.Combine(projectDirectory,referenceText)
15511528
yield file
15521529

1553-
for r in nonFrameworkResolutions do
1530+
for r in nonFrameworkResolutions do
15541531
yield r.resolvedPath
15551532

1556-
for (_,f,_) in sourceFiles do
1533+
for (_,f,_) in sourceFiles do
15571534
yield f ]
15581535

15591536
let buildInputs = [ VectorInput (fileNamesNode, sourceFiles)
@@ -1567,8 +1544,8 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
15671544
partialBuild <- newPartialBuild
15681545
newPartialBuild
15691546

1570-
let MaxTimeStampInDependencies (output:INode) optSlot =
1571-
IncrementalBuild.MaxTimeStampInDependencies (Target(output.Name, optSlot)) partialBuild
1547+
let MaxTimeStampInDependencies (output:INode) =
1548+
IncrementalBuild.MaxTimeStampInDependencies output.Name partialBuild
15721549

15731550
member this.IncrementUsageCount() =
15741551
assertNotDisposed()
@@ -1664,7 +1641,9 @@ type IncrementalBuilder(frameworkTcImportsCache: FrameworkImportsCache, tcConfig
16641641
| None -> failwith "Build was not evaluated, expcted the results to be ready after 'Eval'."
16651642

16661643
member __.GetLogicalTimeStampForProject() =
1667-
MaxTimeStampInDependencies finalizedTypeCheckNode None
1644+
let t1 = MaxTimeStampInDependencies stampedFileNamesNode
1645+
let t2 = MaxTimeStampInDependencies stampedReferencedAssembliesNode
1646+
max t1 t2
16681647

16691648
member __.GetSlotOfFileName(filename:string) =
16701649
// Get the slot of the given file and force it to build.

tests/service/ProjectAnalysisTests.fs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4336,6 +4336,9 @@ let ``Test project34 should report correct accessibility for System.Data.Listene
43364336

43374337
listenerFuncEntity.Accessibility.IsPrivate |> shouldEqual true
43384338

4339+
4340+
//------------------------------------------------------
4341+
43394342
module Project35 =
43404343
open System.IO
43414344

@@ -4412,6 +4415,35 @@ let ``Test project35 CurriedParameterGroups should be available for nested funct
44124415

44134416
| _ -> failwith "Unexpected symbol type"
44144417

4418+
//------------------------------------------------------
4419+
4420+
module Project35b =
4421+
open System.IO
4422+
4423+
let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fsx")
4424+
let fileSource1 = """
4425+
#r "System.dll"
4426+
#r "notexist.dll"
4427+
"""
4428+
File.WriteAllText(fileName1, fileSource1)
4429+
let cleanFileName a = if a = fileName1 then "file1" else "??"
4430+
4431+
let fileNames = [fileName1]
4432+
let options = checker.GetProjectOptionsFromScript(fileName1, fileSource1) |> Async.RunSynchronously
4433+
4434+
4435+
[<Test>]
4436+
let ``Test project35b Dependency files`` () =
4437+
let parseFileResults = checker.ParseFileInProject(Project35b.fileName1, Project35b.fileSource1, Project35b.options) |> Async.RunSynchronously
4438+
for d in parseFileResults.DependencyFiles do
4439+
printfn "dependency: %s" d
4440+
// parseFileResults.DependencyFiles.Length |> shouldEqual 3
4441+
parseFileResults.DependencyFiles |> List.exists (fun s -> s.Contains "notexist.dll") |> shouldEqual true
4442+
parseFileResults.DependencyFiles |> List.exists (fun s -> s.Contains Project35b.fileName1) |> shouldEqual true
4443+
/// parseFileResults.DependencyFiles |> List.exists (fun s -> s.Contains "FSharp.Compiler.Interactive.Settings.dll") |> shouldEqual true
4444+
4445+
//------------------------------------------------------
4446+
44154447
module Project36 =
44164448
open System.IO
44174449

0 commit comments

Comments
 (0)