Skip to content
Permalink
Browse files

[Assets] Simplified Package.Profiles into Package.Profile

  • Loading branch information
xen2 committed Aug 31, 2018
1 parent 284cccd commit 9f8f407d4d5796fc3dbf562849ec4f8ea37c1e47
Showing with 207 additions and 462 deletions.
  1. +3 −3 Targets/Xenko.targets
  2. +11 −11 Xenko.xkpkg
  3. +5 −20 sources/assets/Xenko.Core.Assets.CompilerApp/PackageBuilder.cs
  4. +0 −1 sources/assets/Xenko.Core.Assets.CompilerApp/PackageBuilderApp.cs
  5. +0 −4 sources/assets/Xenko.Core.Assets.CompilerApp/PackageBuilderOptions.cs
  6. +2 −1 sources/assets/Xenko.Core.Assets.Tests/TestAssetReferenceAnalysis.cs
  7. +10 −13 sources/assets/Xenko.Core.Assets.Tests/TestPackage.cs
  8. +30 −45 sources/assets/Xenko.Core.Assets/Package.cs
  9. +0 −38 sources/assets/Xenko.Core.Assets/PackageProfile.cs
  10. +1 −1 sources/editor/Xenko.Assets.Presentation/AssetEditors/ProjectWatcher.cs
  11. +2 −2 ...o.Assets.Presentation/AssetEditors/ScriptEditor/BindScriptTextEditorWorkspaceProjectIdBehavior.cs
  12. +15 −15 sources/editor/Xenko.Assets.Presentation/Templates/NewGameTemplateGenerator.cs
  13. +0 −3 sources/editor/Xenko.Assets.Presentation/Templates/NewPackageTemplateGenerator.cs
  14. +5 −13 sources/editor/Xenko.Assets.Presentation/Templates/ProjectLibraryTemplateGenerator.cs
  15. +1 −0 sources/editor/Xenko.Assets.Presentation/Templates/ScriptTemplateGenerator.cs
  16. +2 −2 sources/editor/Xenko.Assets.Presentation/Templates/TemplateSampleGenerator.cs
  17. +18 −18 sources/editor/Xenko.Assets.Presentation/Templates/UpdatePlatformsTemplateGenerator.cs
  18. +1 −1 sources/editor/Xenko.Assets.Presentation/ViewModel/CodeViewModel.cs
  19. +1 −4 sources/editor/Xenko.Assets.Presentation/ViewModel/GameSettingsViewModel.cs
  20. +11 −60 sources/editor/Xenko.Core.Assets.Editor/ViewModel/PackageViewModel.cs
  21. +1 −1 sources/editor/Xenko.Core.Assets.Editor/ViewModel/ProjectViewModel.cs
  22. +4 −4 sources/editor/Xenko.Core.Assets.Editor/ViewModel/SessionViewModel.cs
  23. +1 −1 sources/editor/Xenko.GameStudio/GameStudioWindow.xaml.cs
  24. +1 −1 sources/engine/Xenko.Assets/Analysis/GamePackageSessionAnalysis.cs
  25. +55 −58 sources/engine/Xenko.Assets/GameSettingsAssetCompiler.cs
  26. +2 −3 sources/engine/Xenko.Assets/Scripts/VisualScriptAsset.cs
  27. +13 −18 sources/engine/Xenko.Assets/Tasks/PackageArchive.cs
  28. +4 −11 sources/engine/Xenko.Assets/Templates/ProjectTemplateGeneratorHelper.cs
  29. +1 −2 sources/engine/Xenko.Assets/XenkoPackageUpgrader.NamespaceRenaming.cs
  30. +3 −75 sources/engine/Xenko.Assets/XenkoPackageUpgrader.cs
  31. +0 −3 sources/tools/Xenko.ProjectGenerator/PackageUnitTestGenerator.cs
  32. +0 −23 sources/tools/Xenko.ProjectGenerator/Program.cs
  33. +4 −7 sources/tools/Xenko.VisualStudio.Commands/XenkoCommands.cs
@@ -1,4 +1,4 @@
<Project InitialTargets="XenkoCheckRequirements" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project InitialTargets="XenkoCheckRequirements" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Check requirements when running this build file -->
<Target Name="XenkoCheckRequirements">
<Error Condition="'$(XenkoPlatform)' == ''" Text="The property %24(XenkoPlatform) must be defined by the project"/>
@@ -320,7 +320,7 @@

<!-- Get the real graphics platform from .xkpkg -->
<Exec WorkingDirectory="$(TargetDir)" ConsoleToMSBuild="true"
Command="&quot;$(XenkoCompileAssetCommand)&quot; --platform=$(XenkoPlatform) --profile=$(XenkoBuildProfile) --package-file=&quot;$(XenkoCurrentPackagePath)&quot; --get-graphics-platform">
Command="&quot;$(XenkoCompileAssetCommand)&quot; --platform=$(XenkoPlatform) --package-file=&quot;$(XenkoCurrentPackagePath)&quot; --get-graphics-platform">
<Output TaskParameter="ConsoleOutput" PropertyName="XenkoGraphicsApiComputed" />
</Exec>

@@ -362,7 +362,7 @@
<Error Condition="'$(XenkoBuildProfile)' == ''" Text="The asset compiler is requiring the property (XenkoBuildProfile) to be defined"/>
<Error Condition="!Exists('$(XenkoCurrentPackagePath)')" Text="Unable to find package decription from path [$(XenkoCurrentPackagePath)]"/>
<PropertyGroup>
<XenkoCompileAssetCommandProxy>$(XenkoCompileAssetCommandProxy) $(XenkoCompileAssetOptions) --disable-auto-compile --project-configuration &quot;$(Configuration)&quot; --platform=$(XenkoPlatform) --profile=$(XenkoBuildProfile) --project-configuration=$(Configuration) --output-path=&quot;$(XenkoCompileAssetOutputPath)&quot; --build-path=&quot;$(XenkoCompileAssetBuildPath)&quot; --package-file=&quot;$(XenkoCurrentPackagePath)&quot; --log-pipe=&quot;$(XenkoBuildEngineLogPipeUrl)&quot;</XenkoCompileAssetCommandProxy>
<XenkoCompileAssetCommandProxy>$(XenkoCompileAssetCommandProxy) $(XenkoCompileAssetOptions) --disable-auto-compile --project-configuration &quot;$(Configuration)&quot; --platform=$(XenkoPlatform) --project-configuration=$(Configuration) --output-path=&quot;$(XenkoCompileAssetOutputPath)&quot; --build-path=&quot;$(XenkoCompileAssetBuildPath)&quot; --package-file=&quot;$(XenkoCurrentPackagePath)&quot; --log-pipe=&quot;$(XenkoBuildEngineLogPipeUrl)&quot;</XenkoCompileAssetCommandProxy>
<XenkoCompileAssetCommandProxy Condition="'$(XenkoBuildEngineLogVerbose)' != ''">$(XenkoCompileAssetCommandProxy) --verbose</XenkoCompileAssetCommandProxy>
<XenkoCompileAssetCommandProxy Condition="'$(XenkoBuildEngineLogDebug)' != ''">$(XenkoCompileAssetCommandProxy) --debug</XenkoCompileAssetCommandProxy>
</PropertyGroup>
@@ -12,17 +12,17 @@ Meta:
Description: Xenko Game Package
LicenseUrl: http://xenko.com/license.txt
ProjectUrl: http://xenko.com
Profiles:
- 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
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
TemplateFolders:
- Path: sources/editor/Xenko.Assets.Presentation/Templates/Core
Group: Core
@@ -101,14 +101,6 @@ private BuildResultCode BuildMaster()
// Check build configuration
var package = projectSession.LocalPackages.Last();

// Check build profile
var buildProfile = package.Profiles.FirstOrDefault(pair => pair.Name == builderOptions.BuildProfile);
if (buildProfile == null)
{
builderOptions.Logger.Error($"Unable to find profile [{builderOptions.BuildProfile}] in package [{package.FullPath}]");
return BuildResultCode.BuildError;
}

// Setup variables
var buildDirectory = builderOptions.BuildDirectory;
var outputDirectory = builderOptions.OutputDirectory;
@@ -124,7 +116,7 @@ private BuildResultCode BuildMaster()
// Create context
context = new AssetCompilerContext
{
Profile = builderOptions.BuildProfile,
Profile = package.Profile.Name,
Platform = builderOptions.Platform,
CompilationContext = typeof(AssetCompilationContext),
BuildConfiguration = builderOptions.ProjectConfiguration
@@ -151,8 +143,8 @@ private BuildResultCode BuildMaster()
var remoteBuilderHelper = new PackageBuilderRemoteHelper(projectSession.AssemblyContainer, builderOptions);

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

builder.MonitorPipeNames.AddRange(builderOptions.MonitorPipeNames);

@@ -165,7 +157,7 @@ private BuildResultCode BuildMaster()

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

return result;
}
@@ -203,13 +195,6 @@ private BuildResultCode BuildGetGraphicsPlatform()
var settings = simplePackage.GetGameSettingsAsset();
var renderingSettings = settings.GetOrCreate<RenderingSettings>();

var buildProfile = simplePackage.Profiles.FirstOrDefault(pair => pair.Name == builderOptions.BuildProfile);
if (buildProfile == null)
{
builderOptions.Logger.Error($"Package {builderOptions.PackageFile} did not contain platform {builderOptions.BuildProfile}");
return BuildResultCode.BuildError;
}

Console.WriteLine(RenderingSettings.GetGraphicsPlatform(builderOptions.Platform, renderingSettings.PreferredGraphicsPlatform));
return BuildResultCode.Successful;
}
@@ -409,7 +394,7 @@ public async Task<ResultStatus> TryExecuteRemote(Command command, BuilderContext
}

var address = "net.pipe://localhost/" + Guid.NewGuid();
var arguments = $"--slave=\"{address}\" --build-path=\"{builderOptions.BuildDirectory}\" --profile=\"{builderOptions.BuildProfile}\"";
var arguments = $"--slave=\"{address}\" --build-path=\"{builderOptions.BuildDirectory}\"";

using (var debugger = VisualStudioDebugger.GetAttached())
{
@@ -88,7 +88,6 @@ public int Run(string[] args)
{ "d|debug", "Show debug logs (imply verbose)", v => options.Debug = v != null },
{ "log", "Enable file logging", v => options.EnableFileLogging = v != null },
{ "disable-auto-compile", "Disable auto-compile of projects", v => options.DisableAutoCompileProjects = v != null},
{ "p|profile=", "Profile name", v => options.BuildProfile = v },
{ "project-configuration=", "Project configuration", v => options.ProjectConfiguration = v },
{ "platform=", "Platform name", v => options.Platform = (PlatformType)Enum.Parse(typeof(PlatformType), v) },
{ "graphics-platform=", "Graphics Platform name", v => options.GraphicsPlatform = (GraphicsPlatform)Enum.Parse(typeof(GraphicsPlatform), v) },
@@ -17,7 +17,6 @@ public class PackageBuilderOptions
public bool Debug = false;
// This should not be a list
public bool DisableAutoCompileProjects { get; set; }
public string BuildProfile;
public string ProjectConfiguration { get; set; }
public string OutputDirectory { get; set; }
public string BuildDirectory { get; set; }
@@ -89,9 +88,6 @@ public void ValidateOptions()

if (SlavePipe == null)
{
if (string.IsNullOrWhiteSpace(BuildProfile))
throw new ArgumentException("This tool requires a selected profile.", "profile");

if (string.IsNullOrWhiteSpace(PackageFile))
{
if (string.IsNullOrWhiteSpace(SolutionFile) || PackageId == Guid.Empty)
@@ -55,7 +55,8 @@ public void TestMoveAssetWithUFile()

// Create a project with an asset reference a raw file
var project = new Package { FullPath = projectDir };
project.Profiles.Add(new PackageProfile("Shared", new AssetFolder(".")));
project.Profile.AssetFolders.Clear();
project.Profile.AssetFolders.Add(new AssetFolder("."));
var asset = new AssetObjectTest() { RawAsset = new UFile(rawAssetPath) };
var assetItem = new AssetItem(assetPath, asset);
project.Assets.Add(assetItem);
@@ -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 { Id = Guid.Empty, FullPath = testGenerated1 };
var sharedProfile = new PackageProfile("Shared", new AssetFolder("."));
project.Profiles.Add(sharedProfile);
project.Profile.AssetFolders.Clear();
project.Profile.AssetFolders.Add(new AssetFolder("."));
var projectReference = new ProjectReference(Guid.Empty, Path.Combine(dirPath, "test.csproj"), ProjectType.Executable);
sharedProfile.ProjectReferences.Add(projectReference);

@@ -48,24 +48,22 @@ public void TestBasicPackageCreateSaveLoad()

// Reload the raw package and if UFile and UDirectory were saved relative
var rawPackage = AssetFileSerializer.Load<Package>(testGenerated1).Asset;
var rawPackageSharedProfile = rawPackage.Profiles.FirstOrDefault();
Assert.NotNull(rawPackageSharedProfile);
var rawSourceFolder = rawPackage.Profiles.First().AssetFolders.FirstOrDefault();
Assert.NotNull(rawPackage.Profile);
var rawSourceFolder = rawPackage.Profile.AssetFolders.FirstOrDefault();
Assert.NotNull(rawSourceFolder);
Assert.Equal(".", (string)rawSourceFolder.Path);
Assert.Equal("test.csproj", (string)rawPackageSharedProfile.ProjectReferences[0].Location);
Assert.Equal("test.csproj", (string)rawPackage.Profile.ProjectReferences[0].Location);

// Reload the package directly from the xkpkg
var project2Result = PackageSession.Load(testGenerated1);
AssertResult(project2Result);
var project2 = project2Result.Session.LocalPackages.FirstOrDefault();
Assert.NotNull(project2);
Assert.Equal(project.Id, project2.Id);
Assert.True(project2.Profiles.Count > 0);
Assert.True(project2.Profiles.First().AssetFolders.Count > 0);
Assert.True(project2.Profile.AssetFolders.Count > 0);
Assert.Equal(project2, project2Result.Session.CurrentPackage); // Check that the current package is setup when loading a single package
var sourceFolder = project.Profiles.First().AssetFolders.First().Path;
Assert.Equal(sourceFolder, project2.Profiles.First().AssetFolders.First().Path);
var sourceFolder = project.Profile.AssetFolders.First().Path;
Assert.Equal(sourceFolder, project2.Profile.AssetFolders.First().Path);

// Reload the package from the sln
var sessionResult = PackageSession.Load(session.SolutionPath);
@@ -74,9 +72,8 @@ public void TestBasicPackageCreateSaveLoad()
var sessionReload = sessionResult.Session;
Assert.Single(sessionReload.LocalPackages);
Assert.Equal(project.Id, sessionReload.LocalPackages.First().Id);
Assert.Single(sessionReload.LocalPackages.First().Profiles);

var sharedProfileReload = sessionReload.LocalPackages.First().Profiles.First();
var sharedProfileReload = sessionReload.LocalPackages.First().Profile;
Assert.Single(sharedProfileReload.ProjectReferences);
Assert.Equal(projectReference, sharedProfileReload.ProjectReferences[0]);
}
@@ -119,7 +116,7 @@ public void TestPackageLoadingWithAssets()
Assert.NotEqual(AssetId.Empty, project.Assets.First().Id);

// Check for UPathRelativeTo
var profile = project.Profiles.FirstOrDefault();
var profile = project.Profile;
Assert.NotNull(profile);
var folder = profile.AssetFolders.FirstOrDefault();
Assert.NotNull(folder);

0 comments on commit 9f8f407

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