Skip to content
Permalink
Browse files

[Assets] Removed PackageProfile.Name

  • Loading branch information
xen2 committed Sep 1, 2018
1 parent 62266f4 commit e21932d153708d23c0f8204b9f55734643ce6519
@@ -116,7 +116,6 @@ private BuildResultCode BuildMaster()
// Create context
context = new AssetCompilerContext
{
Profile = package.Profile.Name,
Platform = builderOptions.Platform,
CompilationContext = typeof(AssetCompilationContext),
BuildConfiguration = builderOptions.ProjectConfiguration
@@ -143,8 +142,8 @@ private BuildResultCode BuildMaster()
var remoteBuilderHelper = new PackageBuilderRemoteHelper(projectSession.AssemblyContainer, builderOptions);

// Create the builder
var indexName = "index." + package.Profile.Name;
builder = new Builder(builderOptions.Logger, buildDirectory, package.Profile.Name, indexName) { ThreadCount = builderOptions.ThreadCount, TryExecuteRemote = remoteBuilderHelper.TryExecuteRemote };
var indexName = "index." + package.Meta.Name;
builder = new Builder(builderOptions.Logger, buildDirectory, indexName) { ThreadCount = builderOptions.ThreadCount, TryExecuteRemote = remoteBuilderHelper.TryExecuteRemote };

builder.MonitorPipeNames.AddRange(builderOptions.MonitorPipeNames);

@@ -92,7 +92,7 @@ public static void TestVeryLargeNumberOfEmptyCommands(Logger logger)
VirtualFileSystem.MountFileSystem(VirtualFileSystem.ApplicationDatabasePath, dbPath);

logger.ActivateLog(LogMessageType.Debug);
var builder = new Builder(logger, appPath, "Windows", "index") { BuilderName = "TestBuilder" };
var builder = new Builder(logger, appPath, "index") { BuilderName = "TestBuilder" };
var steps = new List<BuildStep>();
const int StepsPerLevel = 5;
const int MaxLevel = 5;
@@ -56,7 +56,7 @@ public void TestCompileAsset()
var assetBuildResult = assetBuilder.Prepare(context);
// Since MyAsset2 is a CompileAsset reference, it should not be compiled, so we should have only 1 asset (MyAsset1) to compile.
Assert.Equal(1, assetBuildResult.BuildSteps.Count);
var builder = new Builder(GlobalLogger.GetLogger("Test"), "", "", "");
var builder = new Builder(GlobalLogger.GetLogger("Test"), "", "");
builder.Root.Add(assetBuildResult.BuildSteps);
builder.Run(Builder.Mode.Build, false);
RethrowAssertsFromThread(ex);
@@ -104,7 +104,7 @@ public void TestCompileContent()
var assetBuildResult = assetBuilder.Prepare(context);
// Since MyAsset3 is a CompileContent reference, it should be compiled, so we should have only 2 asset (MyAsset1 and MyAsset3) to compile.
Assert.Equal(2, assetBuildResult.BuildSteps.Count);
var builder = new Builder(GlobalLogger.GetLogger("Test"), "", "", "");
var builder = new Builder(GlobalLogger.GetLogger("Test"), "", "");
builder.Root.Add(assetBuildResult.BuildSteps);
builder.Run(Builder.Mode.Build, false);
RethrowAssertsFromThread(ex);
@@ -153,7 +153,7 @@ public void TestRuntime()
var assetBuildResult = assetBuilder.Prepare(context);
// Since MyAsset4 is a Runtime reference, it should be compiled, so we should have 2 asset (MyAsset1 and MyAsset4) to compile.
Assert.Equal(2, assetBuildResult.BuildSteps.Count);
var builder = new Builder(GlobalLogger.GetLogger("Test"), "", "", "");
var builder = new Builder(GlobalLogger.GetLogger("Test"), "", "");
builder.Root.Add(assetBuildResult.BuildSteps);
builder.Run(Builder.Mode.Build, false);
RethrowAssertsFromThread(ex);
@@ -790,7 +790,7 @@
// // string testGenerated1 = Path.Combine(dirPath, "TestTracking.xkpkg");

// // var project = new Package { FullPath = testGenerated1 };
// // project.Profiles.Add(new PackageProfile("Shared", new AssetFolder(".")));
// // project.Profiles.Add(new PackageProfile(new AssetFolder(".")));
// // var asset1 = new AssetObjectTest();
// // var assetItem1 = new AssetItem("asset-1", asset1);
// // project.Assets.Add(assetItem1);
@@ -20,8 +20,6 @@ public sealed class PackageProfile

private readonly AssetFolderCollection assetFolders;

public const string SharedName = "Shared";

/// <summary>
/// Initializes a new instance of the <see cref="PackageProfile"/> class.
/// </summary>
@@ -31,42 +29,21 @@ public PackageProfile()
OutputGroupDirectories = new Dictionary<string, UDirectory>();
}

/// <summary>
/// Initializes a new instance of the <see cref="PackageProfile"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <exception cref="System.ArgumentNullException">name</exception>
public PackageProfile(string name) : this()
{
if (name == null) throw new ArgumentNullException("name");
Name = name;
}

/// <summary>
/// Initializes a new instance of the <see cref="PackageProfile" /> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="folders">The folders.</param>
/// <exception cref="System.ArgumentNullException">name</exception>
public PackageProfile(string name, params AssetFolder[] folders)
public PackageProfile(params AssetFolder[] folders)
: this()
{
if (name == null) throw new ArgumentNullException("name");
Name = name;
foreach (var folder in folders)
{
AssetFolders.Add(folder);
}
}


/// <summary>
/// Gets or sets the name of this profile.
/// </summary>
/// <value>The name.</value>
[DataMember(10)]
public string Name { get; set; }

/// <summary>
/// Gets or sets the platform.
/// </summary>
@@ -101,7 +78,7 @@ public PackageProfile(string name, params AssetFolder[] folders)
/// <returns>PackageProfile.</returns>
public static PackageProfile NewShared()
{
var sharedProfile = new PackageProfile(SharedName) { Platform = PlatformType.Shared };
var sharedProfile = new PackageProfile() { Platform = PlatformType.Shared };
sharedProfile.AssetFolders.Add(new AssetFolder("Assets"));
sharedProfile.ResourceFolders.Add("Resources");
return sharedProfile;
@@ -109,11 +109,6 @@ public enum Mode
/// </summary>
private readonly string buildPath;

/// <summary>
/// The build profile
/// </summary>
private readonly string buildProfile;

/// <summary>
/// Cancellation token source used for cancellation.
/// </summary>
@@ -145,11 +140,10 @@ public enum Mode
/// </summary>
private string IndexFileFullPath => indexName != null ? VirtualFileSystem.ApplicationDatabasePath + VirtualFileSystem.DirectorySeparatorChar + indexName : null;

public Builder(ILogger logger, string buildPath, string buildProfile, string indexName)
public Builder(ILogger logger, string buildPath, string indexName)
{
MonitorPipeNames = new List<string>();
startTime = DateTime.Now;
this.buildProfile = buildProfile;
this.indexName = indexName;
Logger = logger;
this.buildPath = buildPath ?? throw new ArgumentNullException(nameof(buildPath));
@@ -52,7 +52,7 @@ public static Builder CreateBuilder(bool createIndexFile)
var logger = new LoggerResult();
logger.ActivateLog(LogMessageType.Debug);
var indexName = createIndexFile ? VirtualFileSystem.ApplicationDatabaseIndexName : null;
var builder = new Builder(logger, BuildPath, "Windows", indexName) { BuilderName = "TestBuilder" };
var builder = new Builder(logger, BuildPath, indexName) { BuilderName = "TestBuilder" };
return builder;
}

@@ -33,7 +33,7 @@ public AssetBuilderService([NotNull] string buildDirectory)
// Mount database (otherwise it will be mounted by DynamicBuilder thread, and it might happen too late)
Builder.OpenObjectDatabase(buildDirectory, IndexName);

var builderInstance = new Builder(GlobalLogger.GetLogger("AssetBuilderService"), buildDirectory, "Windows", IndexName)
var builderInstance = new Builder(GlobalLogger.GetLogger("AssetBuilderService"), buildDirectory, IndexName)
{
BuilderName = "AssetBuilderService Builder",
ThreadCount = threadCount,
@@ -34,11 +34,6 @@ public ProfileViewModel(SessionViewModel session, Package package, PackageProfil
}
}

/// <summary>
/// Gets the name of this profile.
/// </summary>
public string Name => profile.Name;

/// <summary>
/// Gets the platform of this profile, if defined.
/// </summary>
@@ -54,9 +54,9 @@ public void Dispose()
}

/// <inheritdoc/>
public T GetConfiguration<T>(string profile = null) where T : Configuration
public T GetConfiguration<T>() where T : Configuration
{
var configuration = CurrentGameSettings?.TryGet<T>(profile);
var configuration = CurrentGameSettings?.TryGet<T>();
return configuration;
}

@@ -15,6 +15,6 @@ public interface IGameSettingsAccessor
/// <typeparam name="T">The requestted <see cref="Configuration"/></typeparam>
/// <param name="profile">If not null, it will filter the results giving priority to the specified profile</param>
/// <returns>The requested <see cref="Configuration"/> or null if not found</returns>
T GetConfiguration<T>(string profile = null) where T : Configuration;
T GetConfiguration<T>() where T : Configuration;
}
}
@@ -38,7 +38,7 @@ public static GraphicsPlatform GetGraphicsPlatform(this AssetCompilerContext con

// Ohterwise, use game settings, or default as fallback
var settings = package.GetGameSettingsAsset();
return settings == null ? context.Platform.GetDefaultGraphicsPlatform() : RenderingSettings.GetGraphicsPlatform(context.Platform, settings.GetOrCreate<RenderingSettings>(context.Profile).PreferredGraphicsPlatform);
return settings == null ? context.Platform.GetDefaultGraphicsPlatform() : RenderingSettings.GetGraphicsPlatform(context.Platform, settings.GetOrCreate<RenderingSettings>().PreferredGraphicsPlatform);
}

public static GraphicsPlatform GetDefaultGraphicsPlatform(this PlatformType platformType)
@@ -102,23 +102,8 @@ public partial class GameSettingsAsset : Asset
/// <typeparam name="T">The <see cref="Configuration"/> to get</typeparam>
/// <param name="profile">If not null, will filter the results by profile first</param>
/// <returns></returns>
public T TryGet<T>(string profile = null) where T : Configuration
public T TryGet<T>() where T : Configuration
{
if (profile != null)
{
foreach (var configurationOverride in Overrides)
{
if (configurationOverride.SpecificFilter == -1) continue;
var filter = PlatformFilters[configurationOverride.SpecificFilter];
if (filter == profile)
{
var x = configurationOverride.Configuration;
if (x?.GetType() == typeof(T))
return (T)x;
}
}
}

foreach (var x in Defaults)
{
if (x?.GetType() == typeof(T))
@@ -128,35 +113,15 @@ public partial class GameSettingsAsset : Asset
return null;
}

public T GetOrCreate<T>(string profile = null) where T : Configuration, new()
public T GetOrCreate<T>() where T : Configuration, new()
{
Configuration first = null;
if (profile != null)
{
foreach (var configurationOverride in Overrides)
{
if (configurationOverride.SpecificFilter == -1) continue;
var filter = PlatformFilters[configurationOverride.SpecificFilter];
if (filter == profile)
{
var x = configurationOverride.Configuration;
if (x != null && x.GetType() == typeof(T))
{
first = x;
break;
}
}
}
}
if (first == null)
foreach (var x in Defaults)
{
foreach (var x in Defaults)
if (x != null && x.GetType() == typeof(T))
{
if (x != null && x.GetType() == typeof(T))
{
first = x;
break;
}
first = x;
break;
}
}
var settings = (T)first;
@@ -98,7 +98,6 @@ public static void Build(ILogger log, Package package, string outputDirectory =
files.Add(NewFile(resourceFolder.MakeRelative(rootDir) + "/**/*.*", "Resources"));
}

newPackage.Profile.Name = package.Profile.Name;
if (package.Profile.AssetFolders.Count > 0)
newPackage.Profile.AssetFolders.Add(new AssetFolder(assetTarget));
if (package.Profile.ResourceFolders.Count > 0)
@@ -92,7 +92,7 @@ public static void UpdatePackagePlatforms(TemplateGeneratorParameters parameters
if (platformProfile == null)
{
platformProfile = new PackageProfile(platform.Platform.Name) { Platform = platform.Platform.Type };
platformProfile = new PackageProfile() { Platform = platform.Platform.Type };
platformProfile.AssetFolders.Add(new AssetFolder("Assets/" + platform.Platform.Name));
}
else

0 comments on commit e21932d

Please sign in to comment.
You can’t perform that action at this time.