Skip to content

Commit

Permalink
Make DNNE build incrementally (#172)
Browse files Browse the repository at this point in the history
* MSBuild is annoying and this is required to make it build incrementally
  • Loading branch information
jtschuster authored Jul 19, 2023
1 parent 03330ad commit b691fd4
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/msbuild/DNNE.targets
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,33 @@ DNNE.targets
<DnneSupportedTFM Condition="!$([MSBuild]::IsOsPlatform('Windows')) AND '$(DnneIsNetFramework)' == 'true'">false</DnneSupportedTFM>

<DnneCompiledToBinPath>$(DnneGeneratedBinPath)/$(DnneNativeExportsBinaryName)$(DnneNativeBinaryExt)</DnneCompiledToBinPath>
<DnneGeneratedSourceFileName>$(DnneGeneratedOutputPath)/$(TargetName).g.c</DnneGeneratedSourceFileName>
</PropertyGroup>

<ItemGroup>
<DnneGeneratedSourceFile Include="$(DnneGeneratedOutputPath)/$(TargetName).g.c" />
<DnneNativeExportsOutputs Include="$(DnneNativeExportsBinaryPath)$(DnneNativeExportsBinaryName)$(DnneNativeBinaryExt);$(DnneNativeExportsBinaryPath)$(DnneNativeExportsBinaryName).h;$(DnneNativeExportsBinaryPath)dnne.h" />
<DnneGeneratedSourceFile Include="$(DnneGeneratedSourceFileName)" />

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

<DnneNativeExportsInput Include="$(DnneGeneratedSourceFileName)" >
<OutputFileName>$(DnneNativeExportsBinaryName).h</OutputFileName>
</DnneNativeExportsInput>

<DnneNativeExportsInput Include="$(DnnePlatformSourcePath)/dnne.h" >
<OutputFileName>dnne.h</OutputFileName>
</DnneNativeExportsInput>

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

<!-- Add outputs and general glob to help with project cleanup -->
<Clean Include="@(DnneNativeExportsOutputs);$(DnneNativeExportsBinaryPath)$(DnneNativeExportsBinaryName).*"/>
<Clean Include="@(DnneNativeExportsInput->'$(DnneNativeExportsBinaryPath)%(OutputFileName)');$(DnneNativeExportsBinaryPath)$(DnneNativeExportsBinaryName).*"/>
</ItemGroup>

<Target
Expand Down Expand Up @@ -92,7 +111,7 @@ DNNE.targets
they flow through project references.
-->
<ItemGroup Condition="'$(DnneBuildExports)' == 'true' AND '$(DnneAddGeneratedBinaryToProject)' == 'true'">
<None Include="@(DnneNativeExportsOutputs->'%(FullPath)')">
<None Include="@(DnneNativeExportsInput->'$(DnneNativeExportsBinaryPath)%(OutputFileName)')">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
Expand All @@ -112,8 +131,8 @@ DNNE.targets
<Target
Name="DnneBuildNativeExports"
Condition="('$(DesignTimeBuild)' != 'true' OR '$(BuildingProject)' == 'true') AND '$(DnneSupportedTFM)' == 'true' AND '$(DnneBuildExports)' == 'true'"
Inputs="@(DnneGeneratedSourceFile)"
Outputs="@(DnneNativeExportsOutputs)"
Inputs="@(DnneNativeExportsInput)"
Outputs="@(DnneNativeExportsInput->'$(DnneNativeExportsBinaryPath)%(OutputFileName)')"
AfterTargets="DnneGenerateNativeExports"
DependsOnTargets="ResolvePackageAssets;ResolveFrameworkReferences">
<Message Text="Building native exports binary from @(DnneGeneratedSourceFile)" Importance="$(DnneMSBuildLogging)" />
Expand Down Expand Up @@ -173,14 +192,9 @@ DNNE.targets
Deploy the official 'dnne.h' header.
-->
<Copy
SourceFiles="$(DnneCompiledToBinPath);$(__DnneGeneratedSourceFile);$(DnnePlatformSourcePath)/dnne.h"
DestinationFiles="@(DnneNativeExportsOutputs)" />
SourceFiles="@(DnneNativeExportsInput)"
DestinationFiles="@(DnneNativeExportsInput->'$(DnneNativeExportsBinaryPath)%(OutputFileName)')" />

<!-- Import libs exist only on the Windows platform -->
<Copy
Condition="$([MSBuild]::IsOsPlatform('Windows'))"
SourceFiles="$(DnneGeneratedBinPath)/$(DnneNativeExportsBinaryName).lib"
DestinationFolder="$(DnneNativeExportsBinaryPath)" />
</Target>

<!--
Expand Down

0 comments on commit b691fd4

Please sign in to comment.