Skip to content

Commit

Permalink
Fix issue with generating and building generated content. (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronRobinsonMSFT authored Oct 8, 2024
1 parent 4c5bd0a commit 5200cb1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
2 changes: 1 addition & 1 deletion sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DNNE" Version="2.0.6" />
<PackageReference Include="DNNE" Version="2.0.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/dnne-gen/dnne-gen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>DNNE</RootNamespace>
<RollForward>major</RollForward>
<RollForward>Major</RollForward>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion src/dnne-pkg/dnne-pkg.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<PropertyGroup>
<PackageId>DNNE</PackageId>
<Version>2.0.6</Version>
<Version>2.0.7</Version>
<Authors>AaronRobinsonMSFT</Authors>
<Owners>AaronRobinsonMSFT</Owners>
<Description>Package used to generated native exports for .NET assemblies.</Description>
Expand Down
46 changes: 37 additions & 9 deletions src/msbuild/DNNE.targets
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,32 @@ DNNE.targets
</PropertyGroup>

<ItemGroup>
<DnneGeneratedSourceFile Include="$(DnneGeneratedSourceFileName)" />
<DnneGeneratedSourceFile
Include="$(DnneGeneratedSourceFileName)"
Condition="'$(DnneGenerateExports)' == 'true'" />

<DnneNativeExportsInput Include="$(DnneCompiledToBinPath)">
<OutputFileName>$(DnneNativeExportsBinaryName)$(DnneNativeBinaryExt)</OutputFileName>
</DnneNativeExportsInput>

<DnneNativeExportsInput Include="$(DnneGeneratedSourceFileName)" >
<DnneNativeExportsInput
Include="$(DnneGeneratedSourceFileName)"
Condition="'$(DnneGenerateExports)' == 'true'" >
<OutputFileName>$(DnneNativeExportsBinaryName).h</OutputFileName>
</DnneNativeExportsInput>

<DnneNativeExportsInput Include="$(DnnePlatformSourcePath)/dnne.h" >
<DnneNativeExportsInput
Include="$(DnnePlatformSourcePath)/dnne.h"
Condition="'$(DnneGenerateExports)' == 'true'" >
<OutputFileName>dnne.h</OutputFileName>
</DnneNativeExportsInput>

<DnneNativeExportsInput
Include="$(DnneCompiledToBinPath)"
Condition="'$(DnneBuildExports)' == 'true'" >
<OutputFileName>$(DnneNativeExportsBinaryName)$(DnneNativeBinaryExt)</OutputFileName>
</DnneNativeExportsInput>

<!-- Import libs exist only on the Windows platform -->
<DnneNativeExportsInput
Include="$(DnneGeneratedBinPath)/$(DnneNativeExportsBinaryName).lib"
Condition="$([MSBuild]::IsOsPlatform('Windows'))" >
Condition="$([MSBuild]::IsOsPlatform('Windows')) AND '$(DnneBuildExports)' == 'true'" >
<OutputFileName>$(DnneNativeExportsBinaryName).lib</OutputFileName>
</DnneNativeExportsInput>

Expand All @@ -87,7 +95,7 @@ DNNE.targets

<Target
Name="DnneGenerateNativeExports"
Condition="('$(DesignTimeBuild)' != 'true' OR '$(BuildingProject)' == 'true') AND '$(DnneSupportedTFM)' == 'true' AND '$(DnneBuildExports)' == 'true'"
Condition="('$(DesignTimeBuild)' != 'true' OR '$(BuildingProject)' == 'true') AND '$(DnneSupportedTFM)' == 'true' AND '$(DnneGenerateExports)' == 'true'"
Inputs="@(IntermediateAssembly)"
Outputs="@(DnneGeneratedSourceFile)"
AfterTargets="CoreCompile">
Expand Down Expand Up @@ -199,6 +207,26 @@ DNNE.targets

</Target>

<!--
This target is used to deploy the header file assets when DNNE is _not_ building an export binary.
-->
<Target
Name="DnneCopyGeneratedHeaders"
Condition="('$(DesignTimeBuild)' != 'true' OR '$(BuildingProject)' == 'true') AND '$(DnneSupportedTFM)' == 'true' AND '$(DnneGenerateExports)' == 'true' AND '$(DnneBuildExports)' != 'true'"
Inputs="@(DnneNativeExportsInput)"
Outputs="@(DnneNativeExportsInput->'$(DnneNativeExportsBinaryPath)%(OutputFileName)')"
AfterTargets="DnneGenerateNativeExports" >

<!--
The dnne-gen tool generates a C99 file that can act as both compilation unit and header.
Deploy the official 'dnne.h' header.
-->
<Copy
SourceFiles="@(DnneNativeExportsInput)"
DestinationFiles="@(DnneNativeExportsInput->'$(DnneNativeExportsBinaryPath)%(OutputFileName)')" />

</Target>

<!--
The Target below is used to mitigate a limitation when referencing
application projects. The work to improve this is tracked with:
Expand Down

0 comments on commit 5200cb1

Please sign in to comment.