Skip to content
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

Preventing some code not compiling under UWP in Release mode to be ge… #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,4 @@ Session.vim

# VS Code
.vscode
/nuget/lib
22 changes: 22 additions & 0 deletions nuget/Vk.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>Vk</id>
<version>2.0.0</version>
<authors>Eric Mellinoe</authors>
<owners>Eric Mellinoe</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<iconUrl>https://raw.githubusercontent.com/xamarin/Xamarin.Forms/master/Assets/xamarin_128x128.png</iconUrl>
<description>Veldrid.View</description>
<copyright>� Eric Mellinoe. All rights reserved.</copyright>
<tags>velvrid vk</tags>
<dependencies>
<group targetFramework=".NETStandard1.4">
</group>
<group targetFramework="UAP10.0">
</group>
</dependencies>
</metadata>
</package>
11 changes: 11 additions & 0 deletions nuget/generate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

copy ..\bin\Release\vk\netstandard1.4\vk.dll .\lib\netstandard1.4
copy ..\bin\Release\vk\netstandard1.4\vk.pdb .\lib\netstandard1.4

copy ..\bin\Release\vk.uwp\netstandard1.4\vk.dll .\lib\uap10.0
copy ..\bin\Release\vk.uwp\netstandard1.4\vk.pdb .\lib\uap10.0

del Vk.*.nupkg

nuget pack Vk.nuspec

8 changes: 4 additions & 4 deletions src/vk.generator/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace Vk.Generator
{
public class CodeGenerator
{
public static void GenerateCodeFiles(VulkanSpecification spec, TypeNameMappings tnm, string path)
public static void GenerateCodeFiles(VulkanSpecification spec, TypeNameMappings tnm, string path, bool uwp)
{
if (!Directory.Exists(path))
{

}
GenerateAllTypes(spec, tnm, path);
GenerateAllTypes(spec, tnm, path, uwp);
}

private static void GenerateAllTypes(VulkanSpecification spec, TypeNameMappings tnm, string path)
private static void GenerateAllTypes(VulkanSpecification spec, TypeNameMappings tnm, string path, bool uwp)
{
using (StreamWriter sw = File.CreateText(Path.Combine(path, "Structures.gen.cs")))
{
Expand Down Expand Up @@ -55,7 +55,7 @@ private static void GenerateAllTypes(VulkanSpecification spec, TypeNameMappings
}
}

CommandDefinition[] allVariants = spec.Commands.SelectMany(cd => VariantGenerator.GenerateVariants(cd)).ToArray();
CommandDefinition[] allVariants = spec.Commands.SelectMany(cd => VariantGenerator.GenerateVariants(cd, uwp)).ToArray();
CommandDefinition[] allCommandsWithVariants = spec.Commands.Concat(allVariants).OrderBy(cd => cd.Name).ToArray();

using (StreamWriter commandWriter = File.CreateText(Path.Combine(path, "Commands.gen.cs")))
Expand Down
6 changes: 4 additions & 2 deletions src/vk.generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ public class Program
public static int Main(string[] args)
{
string outputPath = AppContext.BaseDirectory;
bool uwp = false;

ArgumentSyntax.Parse(args, s =>
{
s.DefineOption("o|out", ref outputPath, "The folder into which code is generated. Defaults to the application directory.");
s.DefineOption("uwp", ref uwp, "UWP.");
});

Configuration.CodeOutputPath = outputPath;
Expand Down Expand Up @@ -60,10 +62,10 @@ public static int Main(string[] args)
}
}

CodeGenerator.GenerateCodeFiles(vs, tnm, Configuration.CodeOutputPath);
CodeGenerator.GenerateCodeFiles(vs, tnm, Configuration.CodeOutputPath, uwp);
}

return 0;
}
}
}
}
3 changes: 2 additions & 1 deletion src/vk.generator/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"profiles": {
"vk.generator": {
"commandName": "Project"
"commandName": "Project",
"commandLineArgs": "--uwp"
}
}
}
8 changes: 4 additions & 4 deletions src/vk.generator/VariantGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace Vk.Generator
{
public static class VariantGenerator
{
public static CommandDefinition[] GenerateVariants(CommandDefinition cd)
public static CommandDefinition[] GenerateVariants(CommandDefinition cd, bool uwp)
{
ParameterDefinition[] parameters = cd.Parameters;
List<ParameterDefinition>[] parameterPossibilities = new List<ParameterDefinition>[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
{
parameterPossibilities[i] = new List<ParameterDefinition>() { parameters[i] };
parameterPossibilities[i].AddRange(GenerateVariantParameters(cd, parameters[i]));
parameterPossibilities[i].AddRange(GenerateVariantParameters(cd, parameters[i], uwp));
}

ParameterDefinition[][] definitions = parameterPossibilities.Select(l => l.ToArray()).ToArray();
Expand Down Expand Up @@ -47,7 +47,7 @@ private static IEnumerable<ParameterDefinition[]> GetCombinations(ParameterDefin
}
}

private static IEnumerable<ParameterDefinition> GenerateVariantParameters(CommandDefinition cd, ParameterDefinition pd)
private static IEnumerable<ParameterDefinition> GenerateVariantParameters(CommandDefinition cd, ParameterDefinition pd, bool uwp)
{
if (CanHaveVariant(pd))
{
Expand All @@ -63,7 +63,7 @@ private static IEnumerable<ParameterDefinition> GenerateVariantParameters(Comman
{
yield return RefVariant(pd);
yield return IntPtrVariant(pd);
if (pd.Name.EndsWith("Infos"))
if (pd.Name.EndsWith("Infos") && !uwp)
{
yield return ArrayVariant(pd, 1);
}
Expand Down
Loading