Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Perez Rodriguez <joperezr@microsoft.com>2020-06-30 22:24:39 +0300
committerGitHub <noreply@github.com>2020-06-30 22:24:39 +0300
commit4a683afec06f01e21651e7da1e6996277665e0ce (patch)
tree333475bff69f627632ae90156e3e03c146ab4767 /eng/illink.targets
parenta034f6d419d2d0f3ab5ddfb4825956075e7455ee (diff)
Adding generation of substitution files for trimming out resources when feature switch is present (#38397)
* Adding generation of substitution files for trimming out resources when feature switch is present * Adding support for CoreLib as well and fix issue with SR returning empty string * Cache result of AppContext Switch lookup * Fixing allConfigurations leg and addressing feedback * Fixing thread safety issue by removing caching * Addressing feedback * Apply suggestions from code review Co-authored-by: Jan Kotas <jkotas@microsoft.com> * Addressing feedback and adding tests * Fix typo Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Diffstat (limited to 'eng/illink.targets')
-rw-r--r--eng/illink.targets37
1 files changed, 34 insertions, 3 deletions
diff --git a/eng/illink.targets b/eng/illink.targets
index 082d7e85c58..fc38a10979f 100644
--- a/eng/illink.targets
+++ b/eng/illink.targets
@@ -40,7 +40,6 @@
<ILLinkTrimXmlLibraryBuild Condition="'$(ILLinkTrimXmlLibraryBuild)' == '' and Exists('$(MSBuildProjectDirectory)/ILLinkTrim_LibraryBuild.xml')">$(MSBuildProjectDirectory)/ILLinkTrim_LibraryBuild.xml</ILLinkTrimXmlLibraryBuild>
<ILLinkDescriptorsXmlIntermediatePath>$(IntermediateOutputPath)ILLink.Descriptors.xml</ILLinkDescriptorsXmlIntermediatePath>
- <ILLinkSubstitutionsXml Condition="'$(ILLinkSubstitutionsXml)' == '' and Exists('$(MSBuildProjectDirectory)/ILLink.Substitutions.xml')">$(MSBuildProjectDirectory)/ILLink.Substitutions.xml</ILLinkSubstitutionsXml>
<ILLinkSubstitutionsXmlIntermediatePath>$(IntermediateOutputPath)ILLink.Substitutions.xml</ILLinkSubstitutionsXmlIntermediatePath>
<!-- if building a PDB, tell illink to rewrite the symbols file -->
@@ -49,7 +48,6 @@
<ItemGroup>
<None Include="$(ILLinkTrimXmlLibraryBuild)" Condition="'$(ILLinkTrimXmlLibraryBuild)' != ''" />
- <None Include="$(ILLinkSubstitutionsXml)" Condition="'$(ILLinkSubstitutionsXml)' != ''" />
<None Include="@(ILLinkSubstitutionsXmls)" />
</ItemGroup>
@@ -105,8 +103,41 @@
</ItemGroup>
</Target>
+ <PropertyGroup>
+ <ILLinkResourcesSubstitutionIntermediatePath>$(IntermediateOutputPath)ILLink.Resources.Substitutions.xml</ILLinkResourcesSubstitutionIntermediatePath>
+ <GenerateResourcesSubstitutions Condition="'$(GenerateResourcesSubstitutions)' == '' and '$(StringResourcesPath)' != ''">true</GenerateResourcesSubstitutions>
+ </PropertyGroup>
+
+ <ItemGroup Condition="'$(GenerateResourcesSubstitutions)' == 'true'">
+ <ILLinkSubstitutionsXmls Include="$(ILLinkResourcesSubstitutionIntermediatePath)" />
+ </ItemGroup>
+
+ <!-- If a library uses string resources, the following target generates a substitution xml that will be embedded on the
+ library so that if a consumer wants to run the linker they can specify a feature switch to strip out all resources
+ from the assembly. -->
+ <Target Name="GenerateResourcesSubstitutionFile"
+ Condition="'$(GenerateResourcesSubstitutions)' == 'true'"
+ Inputs="$(MSBuildProjectFullPath)"
+ Outputs="$(ILLinkResourcesSubstitutionIntermediatePath)">
+
+ <PropertyGroup>
+ <ILLinkResourcesSubstitutionTemplate>$(MSBuildThisFileDirectory)ILLink.Substitutions.Resources.template</ILLinkResourcesSubstitutionTemplate>
+ </PropertyGroup>
+
+ <WriteLinesToFile File="$(ILLinkResourcesSubstitutionIntermediatePath)"
+ Lines="$([System.IO.File]::ReadAllText('$(ILLinkResourcesSubstitutionTemplate)')
+ .Replace('{AssemblyName}', '$(AssemblyName)')
+ .Replace('{StringResourcesName}', '$(StringResourcesName)'))"
+ Overwrite="true" />
+
+ <ItemGroup>
+ <FileWrites Include="$(ILLinkResourcesSubstitutionIntermediatePath)" />
+ </ItemGroup>
+ </Target>
+
<Target Name="_CombineILLinkSubstitutionsXmls"
- Condition="'$(ILLinkSubstitutionsXml)' == '' and '@(ILLinkSubstitutionsXmls)' != ''"
+ DependsOnTargets="GenerateResourcesSubstitutionFile"
+ Condition="'@(ILLinkSubstitutionsXmls)' != ''"
Inputs="@(ILLinkSubstitutionsXmls)"
Outputs="$(ILLinkSubstitutionsXmlIntermediatePath)">
<PropertyGroup>