Kaynağa Gözat

Revamped build project and nuget-ification.

Eric Mellino 8 yıl önce
ebeveyn
işleme
2a02bc1b40

+ 8 - 0
Directory.Build.props

@@ -6,4 +6,12 @@
     <OutputPath>$([System.IO.Path]::GetFullPath('$(RepositoryRootDirectory)bin\$(Configuration)'))\$(MSBuildProjectName)</OutputPath>
     <BaseIntermediateOutputPath>$([System.IO.Path]::GetFullPath('$(RepositoryRootDirectory)bin\obj\$(MSBuildProjectName)'))\</BaseIntermediateOutputPath>
   </PropertyGroup>
+  <PropertyGroup>
+    <!-- NuGet Package common properties. -->
+    <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
+    <Copyright>Copyright 2017 (c) Eric Mellino. All rights reserved.</Copyright>
+    <Authors>Eric Mellino</Authors>
+    <ProjectUrl>https://github.com/mellinoe/ShaderGen</ProjectUrl>
+    <RepositoryUrl>https://github.com/mellinoe/ShaderGen</RepositoryUrl>
+  </PropertyGroup>
 </Project>

+ 2 - 2
src/AppTest/TargetProject/Directory.Build.targets

@@ -1,4 +1,4 @@
 <Project>
-  <Import Project="..\..\..\bin\$(Configuration)\ShaderGen.App\netcoreapp2.0\ShaderGen.targets"
-          Condition="Exists('..\..\..\bin\$(Configuration)\ShaderGen.App\netcoreapp2.0\ShaderGen.targets')" />
+  <Import Project="..\..\..\bin\$(Configuration)\ShaderGen.App\netcoreapp2.0\ShaderGen.Build.SourceRef.targets"
+          Condition="Exists('..\..\..\bin\$(Configuration)\ShaderGen.App\netcoreapp2.0\ShaderGen.Build.SourceRef.targets')" />
 </Project>

+ 4 - 1
src/AppTest/TargetProject/TargetProject.csproj

@@ -6,8 +6,11 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\..\ShaderGen.Attributes\ShaderGen.Attributes.csproj" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.4.0" />
   </ItemGroup>
 
+  <ItemGroup>
+    <ProjectReference Include="..\..\ShaderGen.Attributes\ShaderGen.Primitives.csproj" />
+  </ItemGroup>
+
 </Project>

+ 0 - 28
src/AppTest/TargetProject/vsout.glsl330

@@ -1,28 +0,0 @@
-#version 330 core
-
-struct TargetProject_VertexAndFragment_VertexInput
-{
-    vec3 Position;
-};
-
-struct TargetProject_VertexAndFragment_FragmentInput
-{
-    vec4 Position;
-};
-
-vec4 FS(TargetProject_VertexAndFragment_FragmentInput input_)
-{
-    return vec4(input_.Position.x, input_.Position.y, input_.Position.z, 1);
-}
-
-
-in vec4 Position;
-out vec4 _outputColor_;
-
-void main()
-{
-    TargetProject_VertexAndFragment_FragmentInput input_;
-    input_.Position = Position;
-    vec4 output_ = FS(input_);
-    _outputColor_ = output_;
-}

+ 0 - 29
src/AppTest/TargetProject/vsout.glsl450

@@ -1,29 +0,0 @@
-#version 450
-#extension GL_ARB_separate_shader_objects : enable
-#extension GL_ARB_shading_language_420pack : enable
-struct TargetProject_VertexAndFragment_VertexInput
-{
-    vec3 Position;
-};
-
-struct TargetProject_VertexAndFragment_FragmentInput
-{
-    vec4 Position;
-};
-
-vec4 FS(TargetProject_VertexAndFragment_FragmentInput input_)
-{
-    return vec4(input_.Position.x, input_.Position.y, input_.Position.z, 1);
-}
-
-
-layout(location = 0) in vec4 Position;
-layout(location = 0) out vec4 _outputColor_;
-
-void main()
-{
-    TargetProject_VertexAndFragment_FragmentInput input_;
-    input_.Position = Position;
-    vec4 output_ = FS(input_);
-    _outputColor_ = output_;
-}

+ 0 - 21
src/AppTest/TargetProject/vsout.hlsl

@@ -1,21 +0,0 @@
-struct TargetProject_VertexAndFragment_VertexInput
-{
-    float3 Position : POSITION0;
-};
-
-struct TargetProject_VertexAndFragment_FragmentInput
-{
-    float4 Position : POSITION0;
-};
-
-struct TargetProject_VertexAndFragment_FragmentInput__FRAGSEMANTICS
-{
-    float4 Position : SV_POSITION;
-};
-
-float4 FS(TargetProject_VertexAndFragment_FragmentInput__FRAGSEMANTICS input) : SV_Target
-{
-    return float4(input.Position.x, input.Position.y, input.Position.z, 1);
-}
-
-

+ 5 - 2
src/ShaderGen.App/ShaderGen.App.csproj

@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Publish">
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
@@ -6,7 +6,10 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Content Include="ShaderGen.targets">
+    <Content Include="..\ShaderGen.Build\ShaderGen.targets">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\ShaderGen.Build\ShaderGen.Build.SourceRef.targets">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
   </ItemGroup>

+ 0 - 0
src/ShaderGen/SamplerResource.cs → src/ShaderGen.Attributes/SamplerResource.cs


+ 0 - 0
src/ShaderGen/ShaderBuiltins.cs → src/ShaderGen.Attributes/ShaderBuiltins.cs


+ 11 - 0
src/ShaderGen.Attributes/ShaderGen.Attributes.csproj

@@ -3,6 +3,17 @@
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
     <RootNamespace>ShaderGen</RootNamespace>
+    <AssemblyVersion>1.0.0</AssemblyVersion>
+
+    <!-- Package stuff -->
+    <PackageId>ShaderGen.Attributes</PackageId>
+    <Description>C# attributes and primitives for generating shader code via ShaderGen.</Description>
+    <PackageTags>Shader GLSL HLSL SPIR-V Graphics OpenGL Vulkan Direct3D Game</PackageTags>
+    <PackageVersion>$(AssemblyVersion)</PackageVersion>
   </PropertyGroup>
 
+  <ItemGroup>
+    <PackageReference Include="System.Numerics.Vectors" Version="4.4.0" />
+  </ItemGroup>
+
 </Project>

+ 18 - 0
src/ShaderGen.Attributes/ShaderGen.Primitives.csproj

@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.0</TargetFramework>
+    <RootNamespace>ShaderGen</RootNamespace>
+    <AssemblyVersion>1.0.0</AssemblyVersion>
+    <!-- Package stuff -->
+    <PackageId>ShaderGen.Primitives</PackageId>
+    <Description>C# attributes and primitives for generating shader code via ShaderGen.</Description>
+    <PackageTags>Shader GLSL HLSL SPIR-V Graphics OpenGL Vulkan Direct3D Game</PackageTags>
+    <PackageVersion>$(AssemblyVersion)</PackageVersion>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="System.Numerics.Vectors" Version="4.4.0" />
+  </ItemGroup>
+
+</Project>

+ 0 - 0
src/ShaderGen/Texture2DResource.cs → src/ShaderGen.Attributes/Texture2DResource.cs


+ 0 - 0
src/ShaderGen/TextureCubeResource.cs → src/ShaderGen.Attributes/TextureCubeResource.cs


+ 12 - 0
src/ShaderGen.Build/Directory.Build.targets

@@ -0,0 +1,12 @@
+<Project>
+  <Target Name="GetFilesToPack" AfterTargets="CoreCompile">
+    <Message Importance="high" Text="Getting additional files to package." />
+    <Error Condition="!Exists('$(PublishedToolPath)\ShaderGen.App.dll')" Text="The ShaderGen.App project MUST be built before ShaderGen.Build.csproj." />
+    <ItemGroup>
+      <Content Include="$(PublishedToolPath)\**\*">
+        <Pack>true</Pack>
+        <PackagePath>build</PackagePath>
+      </Content>
+    </ItemGroup>
+  </Target>
+</Project>

+ 7 - 0
src/ShaderGen.Build/ShaderGen.Build.SourceRef.targets

@@ -0,0 +1,7 @@
+<Project>
+  <PropertyGroup>
+    <_SGExePath>$(MSBuildThisFileDirectory)ShaderGen.App.dll</_SGExePath>
+  </PropertyGroup>
+
+  <Import Project="$(MSBuildThisFileDirectory)ShaderGen.targets" />
+</Project>

+ 30 - 0
src/ShaderGen.Build/ShaderGen.Build.csproj

@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk" >
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+    <IncludeBuildOutput>false</IncludeBuildOutput>
+    <PublishedToolPath>$([System.IO.Path]::GetFullPath('$(RepositoryRootDirectory)bin\$(Configuration)'))\ShaderGen.App\netcoreapp2.0\publish</PublishedToolPath>
+
+    <!-- Nuget info -->
+    <PackageId>ShaderGen.Build</PackageId>
+    <Description>$(PublishedToolPath)</Description>
+    <!--<Description>Build-time plugin which generates shader code during a post-build event.</Description>-->
+    <PackageTags>Shader GLSL HLSL SPIR-V Graphics OpenGL Vulkan Direct3D Game</PackageTags>
+    <PackageVersion>1.0.0</PackageVersion>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Content Include="ShaderGen.Build.targets">
+      <Pack>true</Pack>
+      <PackagePath>build</PackagePath>
+    </Content>
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="$(MSBuildThisFileDirectory)..\ShaderGen.App\ShaderGen.App.csproj">
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
+    </ProjectReference>
+  </ItemGroup>
+
+</Project>

+ 7 - 0
src/ShaderGen.Build/ShaderGen.Build.targets

@@ -0,0 +1,7 @@
+<Project>
+  <PropertyGroup>
+    <_SGExePath>$(MSBuildThisFileDirectory)ShaderGen.App.dll</_SGExePath>
+  </PropertyGroup>
+
+  <Import Project="$(MSBuildThisFileDirectory)ShaderGen.targets" />
+</Project>

+ 1 - 6
src/ShaderGen.App/ShaderGen.targets → src/ShaderGen.Build/ShaderGen.targets

@@ -1,13 +1,8 @@
 <Project>
-  <PropertyGroup>
-    <_SGExePath>$(MSBuildThisFileDirectory)ShaderGen.App.dll</_SGExePath>
-    <_SGReferencesResponsePath>$(IntermediateOutputPath)_sgreferences.txt</_SGReferencesResponsePath>
-    <_SGSourcesResponsePath>$(IntermediateOutputPath)_sgsources.txt</_SGSourcesResponsePath>
-  </PropertyGroup>
-
   <Target Name="GenerateShaderCode" AfterTargets="AfterBuild">
     <Message Text="Generating shader code." />
 
+    <Error Condition="'$(_SGExePath)' == ''" Text="The ShaderGen tool was not located or set." />
     <Error Condition="'$(ShaderOutputPath)' == ''" Text="ShaderOutputPath must be set." />
     
     <WriteLinesToFile Lines="@(ReferencePath)" File="$(_SGReferencesResponsePath)" Overwrite="true" />

+ 1 - 1
src/ShaderGen.Tests/TestAssets/References.txt

@@ -1,4 +1,4 @@
-{appcontextbasedirectory}/ShaderGen.dll
+{appcontextbasedirectory}/ShaderGen.Primitives.dll
 {nupkgdir}/microsoft.codeanalysis.csharp/2.3.2/lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.dll 
 {nupkgdir}/microsoft.codeanalysis.common/2.3.2/lib/netstandard1.3/Microsoft.CodeAnalysis.dll 
 {nupkgdir}/netstandard.library/2.0.0/build/netstandard2.0/ref/Microsoft.Win32.Primitives.dll 

+ 15 - 1
src/ShaderGen.sln

@@ -8,12 +8,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShaderGen.Tests", "ShaderGe
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShaderGen.App", "ShaderGen.App\ShaderGen.App.csproj", "{C3DC24D3-98F7-4162-9D8D-822383A79668}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShaderGen.Attributes", "ShaderGen.Attributes\ShaderGen.Attributes.csproj", "{2DF9100D-B99D-4E6A-A3B2-3628044D151A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShaderGen.Primitives", "ShaderGen.Attributes\ShaderGen.Primitives.csproj", "{2DF9100D-B99D-4E6A-A3B2-3628044D151A}"
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AppTest", "AppTest", "{12D59BC2-33E0-460F-A788-6514D8350F81}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetProject", "AppTest\TargetProject\TargetProject.csproj", "{10F1C4EA-7708-491A-81A4-20B356A4F6DD}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShaderGen.Build", "ShaderGen.Build\ShaderGen.Build.csproj", "{F960509E-C4BF-4518-937E-98B96AF0757F}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -84,6 +86,18 @@ Global
 		{10F1C4EA-7708-491A-81A4-20B356A4F6DD}.Release|x64.Build.0 = Release|Any CPU
 		{10F1C4EA-7708-491A-81A4-20B356A4F6DD}.Release|x86.ActiveCfg = Release|Any CPU
 		{10F1C4EA-7708-491A-81A4-20B356A4F6DD}.Release|x86.Build.0 = Release|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Debug|x64.Build.0 = Debug|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Debug|x86.Build.0 = Debug|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Release|x64.ActiveCfg = Release|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Release|x64.Build.0 = Release|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Release|x86.ActiveCfg = Release|Any CPU
+		{F960509E-C4BF-4518-937E-98B96AF0757F}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 11 - 1
src/ShaderGen/ShaderGen.csproj

@@ -2,12 +2,22 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
+    <AssemblyVersion>1.0.0</AssemblyVersion>
+
+    <!-- Package stuff -->
+    <PackageId>ShaderGen</PackageId>
+    <Description>Translates C# code to HLSL and GLSL shader code.</Description>
+    <PackageTags>Shader GLSL HLSL SPIR-V Graphics OpenGL Vulkan Direct3D Game</PackageTags>
+    <PackageVersion>$(AssemblyVersion)</PackageVersion>
   </PropertyGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\ShaderGen.Attributes\ShaderGen.Attributes.csproj" />
     <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.2" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.4.0" />
   </ItemGroup>
 
+  <ItemGroup>
+    <ProjectReference Include="..\ShaderGen.Attributes\ShaderGen.Primitives.csproj" />
+  </ItemGroup>
+
 </Project>