Skip to content
Permalink
Browse files

[Assets] Removed PackageProfile

  • Loading branch information
xen2 committed Sep 19, 2018
1 parent e59316a commit 17d9b2688bb6dc0edbd147c1acc8ef0343031267
@@ -12,17 +12,15 @@ Meta:
Description: Xenko Game Package
LicenseUrl: http://xenko.com/license.txt
ProjectUrl: http://xenko.com
Profile:
Name: Shared
AssetFolders:
- Path: sources/engine/Xenko.Assets/AssetPackage/Assets/Shared
- Path: sources/engine/Xenko.Engine/Rendering
- Path: sources/engine/Xenko.Graphics/Shaders
- Path: sources/editor/Xenko.Assets.Presentation/Shaders
- Path: sources/engine/Xenko.Particles/Shaders
- Path: sources/engine/Xenko.Video/Shaders
ResourceFolders:
- sources/engine/Xenko.Assets/AssetPackage/Resources
AssetFolders:
- Path: sources/engine/Xenko.Assets/AssetPackage/Assets/Shared
- Path: sources/engine/Xenko.Engine/Rendering
- Path: sources/engine/Xenko.Graphics/Shaders
- Path: sources/editor/Xenko.Assets.Presentation/Shaders
- Path: sources/engine/Xenko.Particles/Shaders
- Path: sources/engine/Xenko.Video/Shaders
ResourceFolders:
- sources/engine/Xenko.Assets/AssetPackage/Resources
TemplateFolders:
- Path: sources/editor/Xenko.Assets.Presentation/Templates/Core
Group: Core
@@ -30,7 +30,7 @@ class BundlePacker
/// <param name="useIncrementalBundles">Specifies if incremental bundles should be used, or writing a complete new one.</param>
/// <exception cref="System.InvalidOperationException">
/// </exception>
public void Build(Logger logger, PackageSession packageSession, PackageProfile profile, string indexName, string outputDirectory, ISet<ObjectId> disableCompressionIds, bool useIncrementalBundles)
public void Build(Logger logger, PackageSession packageSession, string indexName, string outputDirectory, ISet<ObjectId> disableCompressionIds, bool useIncrementalBundles)
{
if (logger == null) throw new ArgumentNullException("logger");
if (packageSession == null) throw new ArgumentNullException("packageSession");
@@ -177,11 +177,10 @@ public void Build(Logger logger, PackageSession packageSession, PackageProfile p

var outputGroupBundleBackends = new Dictionary<string, BundleOdbBackend>();

if (profile != null && profile.OutputGroupDirectories != null)
var rootPackage = packageSession.LocalPackages.First();
if (rootPackage.OutputGroupDirectories != null)
{
var rootPackage = packageSession.LocalPackages.First();

foreach (var item in profile.OutputGroupDirectories)
foreach (var item in rootPackage.OutputGroupDirectories)
{
var path = Path.Combine(rootPackage.RootDirectory, item.Value);
var vfsPath = "/data_group_" + item.Key;
@@ -156,7 +156,7 @@ private BuildResultCode BuildMaster()

// Fill list of bundles
var bundlePacker = new BundlePacker();
bundlePacker.Build(builderOptions.Logger, projectSession, package.Profile, indexName, outputDirectory, builder.DisableCompressionIds, context.GetCompilationMode() != CompilationMode.AppStore);
bundlePacker.Build(builderOptions.Logger, projectSession, indexName, outputDirectory, builder.DisableCompressionIds, context.GetCompilationMode() != CompilationMode.AppStore);

return result;
}
@@ -55,8 +55,8 @@ public void TestMoveAssetWithUFile()

// Create a project with an asset reference a raw file
var project = new Package { FullPath = projectDir };
project.Profile.AssetFolders.Clear();
project.Profile.AssetFolders.Add(new AssetFolder("."));
project.AssetFolders.Clear();
project.AssetFolders.Add(new AssetFolder("."));
var asset = new AssetObjectTest() { RawAsset = new UFile(rawAssetPath) };
var assetItem = new AssetItem(assetPath, asset);
project.Assets.Add(assetItem);
@@ -790,7 +790,7 @@
// // string testGenerated1 = Path.Combine(dirPath, "TestTracking.xkpkg");

// // var project = new Package { FullPath = testGenerated1 };
// // project.Profiles.Add(new PackageProfile(new AssetFolder(".")));
// // project.AssetFolders.Add(new AssetFolder("."));
// // var asset1 = new AssetObjectTest();
// // var assetItem1 = new AssetItem("asset-1", asset1);
// // project.Assets.Add(assetItem1);
@@ -27,8 +27,8 @@ public void TestBasicPackageCreateSaveLoad()
// Force the PackageId to be the same each time we run the test
// Usually the PackageId is unique and generated each time we create a new project
var project = new Package { FullPath = testGenerated1 };
project.Profile.AssetFolders.Clear();
project.Profile.AssetFolders.Add(new AssetFolder("."));
project.AssetFolders.Clear();
project.AssetFolders.Add(new AssetFolder("."));

var session = new PackageSession(project);
// Write the solution when saving
@@ -46,8 +46,7 @@ public void TestBasicPackageCreateSaveLoad()

// Reload the raw package and if UFile and UDirectory were saved relative
var rawPackage = AssetFileSerializer.Load<Package>(testGenerated1).Asset;
Assert.NotNull(rawPackage.Profile);
var rawSourceFolder = rawPackage.Profile.AssetFolders.FirstOrDefault();
var rawSourceFolder = rawPackage.AssetFolders.FirstOrDefault();
Assert.NotNull(rawSourceFolder);
Assert.Equal(".", (string)rawSourceFolder.Path);

@@ -56,10 +55,10 @@ public void TestBasicPackageCreateSaveLoad()
AssertResult(project2Result);
var project2 = project2Result.Session.LocalPackages.FirstOrDefault();
Assert.NotNull(project2);
Assert.True(project2.Profile.AssetFolders.Count > 0);
Assert.True(project2.AssetFolders.Count > 0);
Assert.Equal(project2.Container, project2Result.Session.CurrentProject); // Check that the current package is setup when loading a single package
var sourceFolder = project.Profile.AssetFolders.First().Path;
Assert.Equal(sourceFolder, project2.Profile.AssetFolders.First().Path);
var sourceFolder = project.AssetFolders.First().Path;
Assert.Equal(sourceFolder, project2.AssetFolders.First().Path);

// Reload the package from the sln
var sessionResult = PackageSession.Load(session.SolutionPath);
@@ -106,9 +105,7 @@ public void TestPackageLoadingWithAssets()
Assert.NotEqual(AssetId.Empty, project.Assets.First().Id);

// Check for UPathRelativeTo
var profile = project.Profile;
Assert.NotNull(profile);
var folder = profile.AssetFolders.FirstOrDefault();
var folder = project.AssetFolders.FirstOrDefault();
Assert.NotNull(folder);
Assert.NotNull(folder.Path);
Assert.NotNull(folder.Path.IsAbsolute);
@@ -63,7 +63,7 @@ internal AssetItem([NotNull] UFile location, [NotNull] Asset asset, Package pack

/// <summary>
/// Gets the directory where the assets will be stored on the disk relative to the <see cref="Package"/>. The directory
/// will update the list found in <see cref="PackageProfile.AssetFolders"/>
/// will update the list found in <see cref="Package.AssetFolders"/>
/// </summary>
/// <value>The directory.</value>
public UDirectory SourceFolder { get; set; }
@@ -18,7 +18,6 @@ public class CompilerContext : IDisposable
public CompilerContext()
{
Properties = new PropertyCollection();
PackageProperties = PackageProfile.SettingsContainer.CreateSettingsProfile(false, null, false);
}

/// <summary>
@@ -32,8 +31,6 @@ public CompilerContext()
/// <value>The attributes.</value>
public PropertyCollection Properties { get; private set; }

public SettingsProfile PackageProperties { get; private set; }

public CompilerContext Clone()
{
var context = (CompilerContext)MemberwiseClone();
@@ -42,7 +39,6 @@ public CompilerContext Clone()

public void Dispose()
{
PackageProperties.Dispose();
}
}
}
@@ -93,6 +93,9 @@ public Package()
Bundles = new BundleCollection(this);
IsDirty = true;
settings = new Lazy<PackageUserSettings>(() => new PackageUserSettings(this));

AssetFolders.Add(new AssetFolder("Assets"));
ResourceFolders.Add("Resources");
}

// Note: Please keep this code in sync with Asset class
@@ -123,11 +126,25 @@ public Package()
public PackageMeta Meta { get; set; } = new PackageMeta();

/// <summary>
/// Gets the profile.
/// Gets the asset directories to lookup.
/// </summary>
/// <value>The asset directories.</value>
[DataMember(40, DataMemberMode.Assign)]
public AssetFolderCollection AssetFolders { get; set; } = new AssetFolderCollection();

/// <summary>
/// Gets the resource directories to lookup.
/// </summary>
/// <value>The resource directories.</value>
[DataMember(45, DataMemberMode.Assign)]
public List<UDirectory> ResourceFolders { get; set; } = new List<UDirectory>();

/// <summary>
/// Gets the output group directories.
/// </summary>
/// <value>The profiles.</value>
/// <value>The output group directories.</value>
[DataMember(50, DataMemberMode.Assign)]
public PackageProfile Profile { get; set; } = PackageProfile.NewShared();
public Dictionary<string, UDirectory> OutputGroupDirectories { get; set; } = new Dictionary<string, UDirectory>();

/// <summary>
/// Gets or sets the list of folders that are explicitly created but contains no assets.
@@ -343,7 +360,7 @@ public AssetItem FindAssetFromProxyObject(object proxyObject)

public UDirectory GetDefaultAssetFolder()
{
var folder = Profile?.AssetFolders.FirstOrDefault();
var folder = AssetFolders.FirstOrDefault();
return folder?.Path ?? ("Assets");
}

@@ -390,7 +407,7 @@ public void SetPackagePath(UFile newPath, bool copyAssets = true)
var currentRootDirectory = RootDirectory;
if (previousRootDirectory != null && currentRootDirectory != null)
{
foreach (var sourceFolder in Profile.AssetFolders)
foreach (var sourceFolder in AssetFolders)
{
if (sourceFolder.Path.IsAbsolute)
{
@@ -1175,7 +1192,7 @@ internal void UpdateSourceFolders(IReadOnlyCollection<AssetItem> assets)
}

// Use by default the first asset folders if not defined on the asset item
var defaultFolder = Profile.AssetFolders.Count > 0 ? Profile.AssetFolders.First().Path : UDirectory.This;
var defaultFolder = AssetFolders.Count > 0 ? AssetFolders.First().Path : UDirectory.This;
var assetFolders = new HashSet<UDirectory>(GetDistinctAssetFolderPaths());
foreach (var asset in assets)
{
@@ -1199,7 +1216,7 @@ internal void UpdateSourceFolders(IReadOnlyCollection<AssetItem> assets)
if (!assetFolders.Contains(assetFolderAbsolute))
{
assetFolders.Add(assetFolderAbsolute);
Profile.AssetFolders.Add(new AssetFolder(assetFolderAbsolute));
AssetFolders.Add(new AssetFolder(assetFolderAbsolute));
IsDirty = true;
}
}
@@ -1240,7 +1257,7 @@ private void LoadTemplates(ILogger log)
private List<UDirectory> GetDistinctAssetFolderPaths()
{
var existingAssetFolders = new List<UDirectory>();
foreach (var folder in Profile.AssetFolders)
foreach (var folder in AssetFolders)
{
var folderPath = RootDirectory != null ? UPath.Combine(RootDirectory, folder.Path) : folder.Path;
if (!existingAssetFolders.Contains(folderPath))
@@ -1392,7 +1409,9 @@ protected override void UpgradeAsset(AssetMigrationContext context, PackageVersi
profile.ResourceFolders[i].Path = (string)resourcePath;
}

asset.Profile = profile;
asset.AssetFolders = profile.AssetFolders;
asset.ResourceFolders = profile.ResourceFolders;
asset.OutputGroupDirectories = profile.OutputGroupDirectories;
}
}

This file was deleted.

@@ -9,7 +9,7 @@
namespace Xenko.Core.Assets
{
/// <summary>
/// A collection of <see cref="PackageProfile"/>.
/// A collection of <see cref="PackageDependency"/>.
/// </summary>
[DataContract("PackageDependencyCollection")]
public sealed class PackageDependencyCollection : KeyedCollection<string, PackageDependency>

This file was deleted.

@@ -150,7 +150,7 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
session.LoadMissingAssets(parameters.Logger, project.LoadedDependencies);

// Add Effects as an asset folder in order to load xksl
package.Profile.AssetFolders.Add(new AssetFolder("Effects"));
package.AssetFolders.Add(new AssetFolder("Effects"));

var packageParameters = new PackageTemplateGeneratorParameters
{
@@ -104,9 +104,6 @@ public sealed override bool Run(PackageTemplateGeneratorParameters parameters)
var name = parameters.Name;
var package = parameters.Package;

// Generate executable projects for each platform
var sharedProfile = package.Profile;

// TODO: this is not a safe way to get a game project see PDX-1128
var gameProject = package.Container as SolutionProject;

@@ -144,9 +141,6 @@ private static string GetDefaultNamespace(PackageTemplateGeneratorParameters par

if (string.IsNullOrWhiteSpace(defaultNamespace))
{
// Get the shared profile
var sharedProfile = package.Profile;

// Get the game project
var gameProjectRef = (package.Container as SolutionProject)?.FullPath;
if (gameProjectRef != null)

0 comments on commit 17d9b26

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