public bool Compile(CompilationPass pass, ICompiler compiler, CompileToolContext context) { var sourceRefs = new SourceReference[] { this._sourceRef }; var project = (IProjectScope)Parent; switch (pass) { case CompilationPass.Pass1RegisterIdentifiers: IIdentifierScope scope; var existingDef = project.Find(this._labelIdentifier, out scope); if (existingDef != null && scope == project) { context.AddMessage(new BinaryCompileMessage { Filename = this._filename, Line = 0, Message = "Identifier already exists in this scope", MessageLevel = Level.Error }); return false; } this._labelInstruction = new LabelInstruction(sourceRefs); project.Add(new BinaryFileLabel(this._labelIdentifier, this._labelInstruction, this._sourceRef)); break; case CompilationPass.Pass3GenerateCode: compiler.AddInstruction(this._labelInstruction, context); compiler.AddInstruction(new BinaryFileDataInstruction(this._filename, sourceRefs), context); break; } return true; }
static void ProjectService_BuildFinished(object sender, BuildEventArgs e) { // at the end of an successful build, mark all built projects as unmodified if (e.Results.Result == BuildResultCode.Success) { lock (unmodifiedProjects) { CompilationPass pass = new CompilationPass(); foreach (IBuildable b in e.Results.BuiltProjects) { IProject p = GetProjectFromBuildable(b); if (p != null) { unmodifiedProjects[p] = pass; } } } } // at the end of a cleaning build, mark all projects as requiring a rebuild if (e.Options.ProjectTarget == BuildTarget.Clean || e.Options.TargetForDependencies == BuildTarget.Clean) { lock (unmodifiedProjects) { unmodifiedProjects.Clear(); } } }
/// <summary> /// Returns true if "this" was recompiled after "comparisonPass". /// </summary> internal bool WasRecompiledAfter(CompilationPass comparisonPass) { Debug.Assert(comparisonPass != null); if (lastCompilationPass == null) return true; return lastCompilationPass.Index > comparisonPass.Index; }
public BuildFeedbackSink(IProject p, IBuildFeedbackSink sink, CompilationPass currentPass) { Debug.Assert(p != null); Debug.Assert(sink != null); Debug.Assert(currentPass != null); this.project = p; this.sink = sink; this.currentPass = currentPass; }
public async Task <bool> BuildAsync(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IProgressMonitor progressMonitor) { IProject p = wrapped as IProject; if (p == null) { return(await wrapped.BuildAsync(options, feedbackSink, progressMonitor)); } else { lock (service.unmodifiedProjects) { if (!service.unmodifiedProjects.TryGetValue(p, out lastCompilationPass)) { lastCompilationPass = null; } } if (lastCompilationPass != null && factory.Setting == BuildDetection.BuildModifiedAndDependent) { lock (cachedBuildDependencies) { var dependencies = options != null ? cachedBuildDependencies[options] : cachedBuildDependenciesForNullOptions; if (dependencies.OfType <Wrapper>().Any(w => w.WasRecompiledAfter(lastCompilationPass))) { lastCompilationPass = null; } } } if (lastCompilationPass != null) { feedbackSink.ReportMessage( StringParser.Parse("${res:MainWindow.CompilerMessages.SkipProjectNoChanges}", new StringTagPair("Name", p.Name)) ); return(true); } else { lastCompilationPass = factory.CurrentPass; var success = await wrapped.BuildAsync(options, feedbackSink, progressMonitor); if (success) { lock (service.unmodifiedProjects) { service.unmodifiedProjects[p] = factory.CurrentPass; } } return(success); } } }
void BuildService_BuildFinished(object sender, BuildEventArgs e) { // at the end of an successful build, mark all built projects as unmodified if (e.Results.Result == BuildResultCode.Success) { lock (unmodifiedProjects) { CompilationPass pass = new CompilationPass(); foreach (IProject p in e.Projects) { unmodifiedProjects[p] = pass; } } } // at the end of a cleaning build, mark all projects as requiring a rebuild if (e.Options.ProjectTarget == BuildTarget.Clean || e.Options.TargetForDependencies == BuildTarget.Clean) { lock (unmodifiedProjects) { unmodifiedProjects.Clear(); } } }
public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) { IProject p = wrapped as IProject; if (p == null) { wrapped.StartBuild(buildOptions, feedbackSink); } else { lock (unmodifiedProjects) { if (!unmodifiedProjects.TryGetValue(p, out lastCompilationPass)) { lastCompilationPass = null; } } if (lastCompilationPass != null && Setting == BuildOnExecuteSetting.BuildModifiedAndDependent) { lock (cachedBuildDependencies) { var dependencies = buildOptions != null ? cachedBuildDependencies[buildOptions] : cachedBuildDependenciesForNullOptions; if (dependencies.OfType <Wrapper>().Any(w => w.WasRecompiledAfter(lastCompilationPass))) { lastCompilationPass = null; } } } if (lastCompilationPass != null) { feedbackSink.ReportMessage( StringParser.Parse("${res:MainWindow.CompilerMessages.SkipProjectNoChanges}", new string[, ] { { "Name", p.Name } }) ); feedbackSink.Done(true); } else { lastCompilationPass = factory.CurrentPass; wrapped.StartBuild(buildOptions, new BuildFeedbackSink(p, feedbackSink, factory.CurrentPass)); } } }
static void BuildEngine_GuiBuildFinished(object sender, BuildEventArgs e) { // at the end of an successful build, mark all built projects as unmodified if (e.Results.Result == BuildResultCode.Success) { lock (unmodifiedProjects) { CompilationPass pass = new CompilationPass(); foreach (IBuildable b in e.Results.BuiltProjects) { IProject p = GetProjectFromBuildable(b); if (p != null) { unmodifiedProjects[p] = pass; } } } } // at the end of a cleaning build, mark all projects as requiring a rebuild if (e.Options.ProjectTarget == BuildTarget.Clean || e.Options.TargetForDependencies == BuildTarget.Clean) { lock (unmodifiedProjects) { unmodifiedProjects.Clear(); } } }
public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) { IProject p = wrapped as IProject; if (p == null) { wrapped.StartBuild(buildOptions, feedbackSink); } else { lock (unmodifiedProjects) { if (!unmodifiedProjects.TryGetValue(p, out lastCompilationPass)) { lastCompilationPass = null; } } if (lastCompilationPass != null && Setting == BuildOnExecuteSetting.BuildModifiedAndDependent) { lock (cachedBuildDependencies) { var dependencies = buildOptions != null ? cachedBuildDependencies[buildOptions] : cachedBuildDependenciesForNullOptions; if (dependencies.OfType<Wrapper>().Any(w=>w.WasRecompiledAfter(lastCompilationPass))) { lastCompilationPass = null; } } } if (lastCompilationPass != null) { feedbackSink.ReportMessage( StringParser.Parse("${res:MainWindow.CompilerMessages.SkipProjectNoChanges}", new StringTagPair("Name", p.Name)) ); feedbackSink.Done(true); } else { lastCompilationPass = factory.CurrentPass; wrapped.StartBuild(buildOptions, new BuildFeedbackSink(p, feedbackSink, factory.CurrentPass)); } } }
public async Task<bool> BuildAsync(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IProgressMonitor progressMonitor) { IProject p = wrapped as IProject; if (p == null) { return await wrapped.BuildAsync(options, feedbackSink, progressMonitor); } else { lock (service.unmodifiedProjects) { if (!service.unmodifiedProjects.TryGetValue(p, out lastCompilationPass)) { lastCompilationPass = null; } } if (lastCompilationPass != null && factory.Setting == BuildDetection.BuildModifiedAndDependent) { lock (cachedBuildDependencies) { var dependencies = options != null ? cachedBuildDependencies[options] : cachedBuildDependenciesForNullOptions; if (dependencies.OfType<Wrapper>().Any(w=>w.WasRecompiledAfter(lastCompilationPass))) { lastCompilationPass = null; } } } if (lastCompilationPass != null) { feedbackSink.ReportMessage( StringParser.Parse("${res:MainWindow.CompilerMessages.SkipProjectNoChanges}", new StringTagPair("Name", p.Name)) ); return true; } else { lastCompilationPass = factory.CurrentPass; var success = await wrapped.BuildAsync(options, feedbackSink, progressMonitor); if (success) { lock (service.unmodifiedProjects) { service.unmodifiedProjects[p] = factory.CurrentPass; } } return success; } } }