@@ -248,7 +248,7 @@ let AdjustForScriptCompile(tcConfigB:TcConfigBuilder,commandLineSourceFiles,lexR
248248
249249 List.rev ! allSources
250250
251- let ProcessCommandLineFlags ( tcConfigB : TcConfigBuilder , argv ) =
251+ let ProcessCommandLineFlags ( tcConfigB : TcConfigBuilder , setProcessThreadLocals , lcidFromCodePage , argv ) =
252252 let inputFilesRef = ref ([] : string list)
253253 let collect name =
254254 let lower = String.lowercase name
@@ -263,6 +263,13 @@ let ProcessCommandLineFlags (tcConfigB: TcConfigBuilder, argv) =
263263 ParseCompilerOptions ( collect, GetCoreFscCompilerOptions tcConfigB, List.tail ( PostProcessCompilerArgs abbrevArgs argv))
264264 let inputFiles = List.rev ! inputFilesRef
265265
266+ // Check if we have a codepage from the console
267+ match tcConfigB.lcid with
268+ | Some _ -> ()
269+ | None -> tcConfigB.lcid <- lcidFromCodePage
270+
271+ setProcessThreadLocals( tcConfigB)
272+
266273 (* step - get dll references *)
267274 let dllFiles , sourceFiles = List.partition Filename.isDll inputFiles
268275 match dllFiles with
@@ -313,17 +320,10 @@ let GetTcImportsFromCommandLine
313320 // The ParseCompilerOptions function calls imperative function to process "real" args
314321 // Rather than start processing, just collect names, then process them.
315322 try
316- let sourceFiles = ProcessCommandLineFlags ( tcConfigB, argv)
323+ let sourceFiles = ProcessCommandLineFlags ( tcConfigB, setProcessThreadLocals , lcidFromCodePage , argv)
317324
318325 let sourceFiles = AdjustForScriptCompile( tcConfigB, sourceFiles, lexResourceManager)
319326
320- // Check if we have a codepage from the console
321- match tcConfigB.lcid with
322- | Some _ -> ()
323- | None -> tcConfigB.lcid <- lcidFromCodePage
324-
325- setProcessThreadLocals( tcConfigB)
326-
327327 sourceFiles
328328
329329 with e ->
@@ -373,70 +373,94 @@ let GetTcImportsFromCommandLine
373373 if not tcConfigB.continueAfterParseFailure then
374374 AbortOnError( errorLogger, tcConfig, exiter)
375375
376- ReportTime tcConfig " Import mscorlib and FSharp.Core.dll"
377- let foundationalTcConfigP = TcConfigProvider.Constant( tcConfig)
378- let sysRes , otherRes , knownUnresolved = TcAssemblyResolutions.SplitNonFoundationalResolutions( tcConfig)
379- let tcGlobals , frameworkTcImports = TcImports.BuildFrameworkTcImports ( foundationalTcConfigP, sysRes, otherRes)
380-
381- // register framework tcImports to be disposed in future
382- disposables.Register frameworkTcImports
383-
384- // step - parse sourceFiles
385- ReportTime tcConfig " Parse inputs"
386- use unwindParsePhase = PushThreadBuildPhaseUntilUnwind ( BuildPhase.Parse)
387- let inputs =
388- try
389- sourceFiles
390- |> tcConfig.ComputeCanContainEntryPoint
391- |> List.zip sourceFiles
392- // PERF: consider making this parallel, once uses of global state relevant to parsing are cleaned up
393- |> List.choose ( fun ( filename : string , isLastCompiland : bool ) ->
394- let pathOfMetaCommandSource = Path.GetDirectoryName( filename)
395- match ParseOneInputFile( tcConfig, lexResourceManager,[ " COMPILED" ], filename, isLastCompiland, errorLogger, (* retryLocked*) false ) with
396- | Some( input) -> Some( input, pathOfMetaCommandSource)
397- | None -> None
398- )
399- with e ->
400- errorRecoveryNoRange e
401- SqmLoggerWithConfig tcConfig errorLogger.ErrorNumbers errorLogger.WarningNumbers
402- exiter.Exit 1
403-
404- if tcConfig.parseOnly then exiter.Exit 0
405- if not tcConfig.continueAfterParseFailure then
406- AbortOnError( errorLogger, tcConfig, exiter)
407-
408- if tcConfig.printAst then
409- inputs |> List.iter ( fun ( input , _filename ) -> printf " AST:\n " ; printfn " %+A " input; printf " \n " )
410-
411- let tcConfig = ( tcConfig, inputs) ||> List.fold ApplyMetaCommandsFromInputToTcConfig
412- let tcConfigP = TcConfigProvider.Constant( tcConfig)
413-
414- ReportTime tcConfig " Import non-system references"
415- let tcGlobals , tcImports =
416- let tcImports = TcImports.BuildNonFrameworkTcImports( tcConfigP, tcGlobals, frameworkTcImports, otherRes, knownUnresolved)
417- tcGlobals, tcImports
418-
419- // register tcImports to be disposed in future
420- disposables.Register tcImports
421-
422- if not tcConfig.continueAfterParseFailure then
376+ let tcGlobals , tcImports , frameworkTcImports , generatedCcu , typedAssembly , topAttrs , tcConfig =
377+
378+ ReportTime tcConfig " Import mscorlib"
379+
380+ #if INCREMENTAL_ BUILD_ OPTION
381+ if tcConfig.useIncrementalBuilder then
382+ ReportTime tcConfig " Incremental Parse and Typecheck"
383+ let builder =
384+ new IncrementalFSharpBuild.IncrementalBuilder( tcConfig, directoryBuildingFrom, assemblyName, NiceNameGenerator(), lexResourceManager, sourceFiles,
385+ ensureReactive= false ,
386+ errorLogger= errorLogger,
387+ keepGeneratedTypedAssembly= true )
388+ let tcState , topAttribs , typedAssembly , _tcEnv , tcImports , tcGlobals , tcConfig = builder.TypeCheck()
389+ tcGlobals, tcImports, tcImports, tcState.Ccu, typedAssembly, topAttribs, tcConfig
390+ else
391+ #else
392+ begin
393+ #endif
394+ ReportTime tcConfig " Import mscorlib and FSharp.Core.dll"
395+ let foundationalTcConfigP = TcConfigProvider.Constant( tcConfig)
396+ let sysRes , otherRes , knownUnresolved = TcAssemblyResolutions.SplitNonFoundationalResolutions( tcConfig)
397+ let tcGlobals , frameworkTcImports = TcImports.BuildFrameworkTcImports ( foundationalTcConfigP, sysRes, otherRes)
398+
399+ // register framework tcImports to be disposed in future
400+ disposables.Register frameworkTcImports
401+
402+ // step - parse sourceFiles
403+ ReportTime tcConfig " Parse inputs"
404+ use unwindParsePhase = PushThreadBuildPhaseUntilUnwind ( BuildPhase.Parse)
405+ let inputs =
406+ try
407+ sourceFiles
408+ |> tcConfig.ComputeCanContainEntryPoint
409+ |> List.zip sourceFiles
410+ // PERF: consider making this parallel, once uses of global state relevant to parsing are cleaned up
411+ |> List.choose ( fun ( filename : string , isLastCompiland : bool ) ->
412+ let pathOfMetaCommandSource = Path.GetDirectoryName( filename)
413+ match ParseOneInputFile( tcConfig, lexResourceManager,[ " COMPILED" ], filename, isLastCompiland, errorLogger, (* retryLocked*) false ) with
414+ | Some( input) -> Some( input, pathOfMetaCommandSource)
415+ | None -> None
416+ )
417+ with e ->
418+ errorRecoveryNoRange e
419+ SqmLoggerWithConfig tcConfig errorLogger.ErrorNumbers errorLogger.WarningNumbers
420+ exiter.Exit 1
421+
422+ if tcConfig.parseOnly then exiter.Exit 0
423+ if not tcConfig.continueAfterParseFailure then
424+ AbortOnError( errorLogger, tcConfig, exiter)
425+
426+ if tcConfig.printAst then
427+ inputs |> List.iter ( fun ( input , _filename ) -> printf " AST:\n " ; printfn " %+A " input; printf " \n " )
428+
429+ let tcConfig = ( tcConfig, inputs) ||> List.fold ApplyMetaCommandsFromInputToTcConfig
430+ let tcConfigP = TcConfigProvider.Constant( tcConfig)
431+
432+ ReportTime tcConfig " Import non-system references"
433+ let tcGlobals , tcImports =
434+ let tcImports = TcImports.BuildNonFrameworkTcImports( tcConfigP, tcGlobals, frameworkTcImports, otherRes, knownUnresolved)
435+ tcGlobals, tcImports
436+
437+ // register tcImports to be disposed in future
438+ disposables.Register tcImports
439+
440+ if not tcConfig.continueAfterParseFailure then
441+ AbortOnError( errorLogger, tcConfig, exiter)
442+
443+ if tcConfig.importAllReferencesOnly then exiter.Exit 0
444+
445+ ReportTime tcConfig " Typecheck"
446+ use unwindParsePhase = PushThreadBuildPhaseUntilUnwind ( BuildPhase.TypeCheck)
447+ let tcEnv0 = GetInitialTcEnv ( Some assemblyName, rangeStartup, tcConfig, tcImports, tcGlobals)
448+
449+ // typecheck
450+ let inputs = inputs |> List.map fst
451+ let tcState , topAttrs , typedAssembly , _tcEnvAtEnd =
452+ TypeCheck( tcConfig, tcImports, tcGlobals, errorLogger, assemblyName, NiceNameGenerator(), tcEnv0, inputs, exiter)
453+
454+ let generatedCcu = tcState.Ccu
423455 AbortOnError( errorLogger, tcConfig, exiter)
456+ ReportTime tcConfig " Typechecked"
424457
425- if tcConfig.importAllReferencesOnly then exiter.Exit 0
426-
427- ReportTime tcConfig " Typecheck"
428- use unwindParsePhase = PushThreadBuildPhaseUntilUnwind ( BuildPhase.TypeCheck)
429- let tcEnv0 = GetInitialTcEnv ( Some assemblyName, rangeStartup, tcConfig, tcImports, tcGlobals)
430-
431- // typecheck
432- let inputs = inputs |> List.map fst
433- let tcState , topAttrs , typedAssembly , _tcEnvAtEnd =
434- TypeCheck( tcConfig, tcImports, tcGlobals, errorLogger, assemblyName, NiceNameGenerator(), tcEnv0, inputs, exiter)
435-
436- let generatedCcu = tcState.Ccu
437- AbortOnError( errorLogger, tcConfig, exiter)
438- ReportTime tcConfig " Typechecked"
439-
458+ ( tcGlobals, tcImports, frameworkTcImports, generatedCcu, typedAssembly, topAttrs, tcConfig)
459+
460+ #if INCREMENTAL_ BUILD_ OPTION
461+ #else
462+ end
463+ #endif
440464 tcGlobals, tcImports, frameworkTcImports, generatedCcu, typedAssembly, topAttrs, tcConfig, outfile, pdbfile, assemblyName, errorLogger
441465
442466#if NO_ COMPILER_ BACKEND
0 commit comments