-
Notifications
You must be signed in to change notification settings - Fork 32
Reworked Platform Props Exporting #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...osoft.msbuildforunity/Editor/ProjectGenerator/Scripts/Exporters/IPlatformPropsExporter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
|
||
| #if UNITY_EDITOR | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace Microsoft.Build.Unity.ProjectGeneration.Exporters | ||
| { | ||
| /// <summary> | ||
| /// Exporter for the platform props file. | ||
| /// </summary> | ||
| public interface IPlatformPropsExporter | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the TargetFramework of the platform. | ||
| /// </summary> | ||
| string TargetFramework { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets a set of define constants for the platform. | ||
| /// </summary> | ||
| HashSet<string> DefineConstants { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets a set of assembly search paths for the platform. | ||
| /// </summary> | ||
| HashSet<string> AssemblySearchPaths { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets a set of references for the platform. | ||
| /// </summary> | ||
| Dictionary<string, Uri> References { get; } | ||
|
|
||
| /// <summary> | ||
| /// Writes out the data. | ||
| /// </summary> | ||
| void Write(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Specialized exporter for the Player|WSA platform. | ||
| /// </summary> | ||
| public interface IWSAPlayerPlatformPropsExporter : IPlatformPropsExporter | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the target UWP version. | ||
| /// </summary> | ||
| string TargetUWPVersion { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the minimum UWP version. | ||
| /// </summary> | ||
| string MinimumUWPVersion { get; set; } | ||
| } | ||
| } | ||
| #endif |
11 changes: 11 additions & 0 deletions
11
....msbuildforunity/Editor/ProjectGenerator/Scripts/Exporters/IPlatformPropsExporter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
...nity/Editor/ProjectGenerator/Scripts/Exporters/TemplatedExporter/TemplatedExporterPart.cs
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
...or/ProjectGenerator/Scripts/Exporters/TemplatedExporter/TemplatedPlatformPropsExporter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
|
||
| #if UNITY_EDITOR | ||
| using Microsoft.Build.Unity.ProjectGeneration.Templates; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
|
|
||
| namespace Microsoft.Build.Unity.ProjectGeneration.Exporters.TemplatedExporter | ||
| { | ||
| /// <summary> | ||
| /// A class for exporting platform props using templates. | ||
| /// </summary> | ||
| internal class TemplatedPlatformPropsExporter : TemplatedExporterBase, IPlatformPropsExporter | ||
| { | ||
| private const string TargetFrameworkToken = "TARGET_FRAMEWORK"; | ||
| private const string DefineConstantsToken = "PLATFORM_COMMON_DEFINE_CONSTANTS"; | ||
| private const string AssemblySearchPathsToken = "PLATFORM_COMMON_ASSEMBLY_SEARCH_PATHS"; | ||
|
|
||
| private const string CommonReferenceSubTemplate = "PLATFORM_COMMON_REFERENCE"; | ||
| private const string CommonReferencesSubTemplateReferenceToken = "REFERENCE"; | ||
| private const string CommonReferencesSubTemplateHintPathToken = "HINT_PATH"; | ||
|
|
||
| public string TargetFramework { get; set; } | ||
|
|
||
| public HashSet<string> DefineConstants { get; } = new HashSet<string>(); // Guess at default size | ||
|
|
||
| public HashSet<string> AssemblySearchPaths { get; } = new HashSet<string>(); // Guess at default size | ||
|
|
||
| public Dictionary<string, Uri> References { get; } = new Dictionary<string, Uri>(250); // Guess at default size | ||
|
|
||
| public TemplatedPlatformPropsExporter(FileTemplate fileTemplate, FileInfo exportPath) | ||
| : base(fileTemplate, exportPath) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| protected override void Export(TemplatedWriter writer) | ||
| { | ||
| writer.Write(TargetFrameworkToken, TargetFramework, optional: true); | ||
|
|
||
| writer.Write(DefineConstantsToken, DefineConstants); | ||
| writer.Write(AssemblySearchPathsToken, AssemblySearchPaths); | ||
|
|
||
| foreach (KeyValuePair<string, Uri> reference in References) | ||
| { | ||
| TemplatedWriter subTemplateWriter = writer.CreateWriterFor(CommonReferenceSubTemplate); | ||
| subTemplateWriter.Write(CommonReferencesSubTemplateReferenceToken, reference.Key); | ||
| subTemplateWriter.Write(CommonReferencesSubTemplateHintPathToken, reference.Value.LocalPath); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| #endif |
11 changes: 11 additions & 0 deletions
11
...ojectGenerator/Scripts/Exporters/TemplatedExporter/TemplatedPlatformPropsExporter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we going to need a custom exporter for each platform/player combination? Are there specific things needed on IWSAPlayerPlatformPropsExporter that wouldn't pertain to other platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and yes Min/Max target UWP platform.