Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into native
Browse files Browse the repository at this point in the history
  • Loading branch information
tomspilman committed Sep 13, 2024
2 parents 06f8e9c + 7a398b0 commit 35fa9b3
Show file tree
Hide file tree
Showing 59 changed files with 3,500 additions and 438 deletions.
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
Are you targeting develop? All PRs should target the develop branch unless otherwise noted.
-->

Fixes #

<!--
Please try to make sure that there is a bug logged for the issue being fixed if one is not present.
Especially for issues which are complex.
The bug should describe the problem and how to reproduce it.
-->

### Description of Change

<!--
Enter description of the fix in this section.
Please be as descriptive as possible, future contributors will need to know *why* these changes are being made.
For inspiration review the commit/PR history in the MonoGame repository.
-->




2 changes: 1 addition & 1 deletion MonoGame.Framework.Content.Pipeline/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
using System.Runtime.CompilerServices;

[assembly:InternalsVisibleTo("MonoGame.Effect")]

[assembly:InternalsVisibleTo("MonoGame.Tools.Tests")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ public class PipelineImporterContext : ContentImporterContext
{
private readonly PipelineManager _manager;

public PipelineImporterContext(PipelineManager manager)
private readonly PipelineBuildEvent _pipelineEvent;

public PipelineImporterContext(PipelineManager manager, PipelineBuildEvent pipelineEvent)
{
_manager = manager;
_pipelineEvent = pipelineEvent;
}

public override string IntermediateDirectory { get { return _manager.IntermediateDirectory; } }
public override string OutputDirectory { get { return _manager.OutputDirectory; } }
public override ContentBuildLogger Logger { get { return _manager.Logger; } }

public override void AddDependency(string filename)
{
{
_pipelineEvent.Dependencies.AddUnique(filename);
}
}
}
}
42 changes: 24 additions & 18 deletions MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private struct ProcessorInfo
/// </summary>
public bool CompressContent { get; set; }

/// <summary>
/// If true exceptions thrown from within an importer or processor are caught and then
/// <summary>
/// If true exceptions thrown from within an importer or processor are caught and then
/// thrown from the context. Default value is true.
/// </summary>
public bool RethrowExceptions { get; set; }
Expand All @@ -108,7 +108,7 @@ public PipelineManager(string projectDir, string outputDir, string intermediateD

RegisterCustomConverters();

// Load the previous content stats.
// Load the previous content stats.
ContentStats = new ContentStatsCollection();
ContentStats.PreviousStats = ContentStatsCollection.Read(intermediateDir);
}
Expand Down Expand Up @@ -157,9 +157,9 @@ private void ResolveAssemblies()
try
{
Assembly a;
if (string.IsNullOrEmpty(assemblyPath))
a = Assembly.GetExecutingAssembly();
else
if (string.IsNullOrEmpty(assemblyPath))
a = Assembly.GetExecutingAssembly();
else
a = Assembly.LoadFrom(assemblyPath);

exportedTypes = a.GetTypes();
Expand All @@ -182,7 +182,7 @@ private void ResolveAssemblies()

foreach (var t in exportedTypes)
{
if (t.IsAbstract)
if (t.IsAbstract)
continue;

if (t.GetInterface(@"IContentImporter") != null)
Expand Down Expand Up @@ -242,7 +242,7 @@ public Type[] GetImporterTypes()

List<Type> types = new List<Type>();

foreach (var item in _importers)
foreach (var item in _importers)
{
types.Add(item.type);
}
Expand All @@ -254,14 +254,14 @@ public Type[] GetProcessorTypes()
{
if (_processors == null)
ResolveAssemblies();

List<Type> types = new List<Type>();
foreach (var item in _processors)

foreach (var item in _processors)
{
types.Add(item.type);
}

return types.ToArray();
}

Expand Down Expand Up @@ -535,7 +535,7 @@ public PipelineBuildEvent BuildContent(string sourceFilepath, string outputFilep
{
sourceFilepath = PathHelper.Normalize(sourceFilepath);
ResolveOutputFilepath(sourceFilepath, ref outputFilepath);

ResolveImporterAndProcessor(sourceFilepath, ref importerName, ref processorName);

// Record what we're building and how.
Expand Down Expand Up @@ -570,12 +570,12 @@ private void BuildContent(PipelineBuildEvent pipelineEvent, PipelineBuildEvent c
// Keep track of all build events. (Required to resolve automatic names "AssetName_n".)
TrackPipelineBuildEvent(pipelineEvent);

var rebuild = pipelineEvent.NeedsRebuild(this, cachedEvent);
var rebuild = pipelineEvent.NeedsRebuild(this, cachedEvent);
if (rebuild)
Logger.LogMessage("{0}", pipelineEvent.SourceFile);
else
Logger.LogMessage("Skipping {0}", pipelineEvent.SourceFile);

Logger.Indent();
try
{
Expand Down Expand Up @@ -604,7 +604,7 @@ private void BuildContent(PipelineBuildEvent pipelineEvent, PipelineBuildEvent c
Parameters = assetCachedEvent.Parameters,
};

// Give the asset a chance to rebuild.
// Give the asset a chance to rebuild.
BuildContent(depEvent, assetCachedEvent, assetEventFilepath);
}
}
Expand Down Expand Up @@ -665,7 +665,10 @@ public object ProcessContent(PipelineBuildEvent pipelineEvent)
{
try
{
var importContext = new PipelineImporterContext(this);

var importContext = new PipelineImporterContext(this, pipelineEvent);
using var _ = ContextScopeFactory.BeginContext(importContext, pipelineEvent);

importedObject = importer.Import(pipelineEvent.SourceFile, importContext);
}
catch (PipelineException)
Expand All @@ -683,7 +686,8 @@ public object ProcessContent(PipelineBuildEvent pipelineEvent)
}
else
{
var importContext = new PipelineImporterContext(this);
var importContext = new PipelineImporterContext(this, pipelineEvent);
using var _ = ContextScopeFactory.BeginContext(importContext, pipelineEvent);
importedObject = importer.Import(pipelineEvent.SourceFile, importContext);
}

Expand Down Expand Up @@ -714,6 +718,7 @@ public object ProcessContent(PipelineBuildEvent pipelineEvent)
try
{
var processContext = new PipelineProcessorContext(this, pipelineEvent);
using var _ = ContextScopeFactory.BeginContext(processContext);
processedObject = processor.Process(importedObject, processContext);
}
catch (PipelineException)
Expand All @@ -732,6 +737,7 @@ public object ProcessContent(PipelineBuildEvent pipelineEvent)
else
{
var processContext = new PipelineProcessorContext(this, pipelineEvent);
using var _ = ContextScopeFactory.BeginContext(processContext);
processedObject = processor.Process(importedObject, processContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public override TOutput Convert<TInput, TOutput>( TInput input,
{
var processor = _manager.CreateProcessor(processorName, processorParameters);
var processContext = new PipelineProcessorContext(_manager, new PipelineBuildEvent { Parameters = processorParameters } );
using var _ = ContextScopeFactory.BeginContext(processContext);
var processedObject = processor.Process(input, processContext);

// Add its dependencies and built assets to ours.
_pipelineEvent.Dependencies.AddRangeUnique(processContext._pipelineEvent.Dependencies);
_pipelineEvent.BuildAsset.AddRangeUnique(processContext._pipelineEvent.BuildAsset);
Expand Down
Loading

0 comments on commit 35fa9b3

Please sign in to comment.