|
| 1 | +<Project> |
| 2 | + |
| 3 | + <!-- strip the library the same way as the cmake build for coreclr does it: |
| 4 | + - on mac, leave a .dylib.dwarf file next to the library. |
| 5 | + - on linux leave a .so.dbg file next to to the library |
| 6 | + --> |
| 7 | + <Target Name="StripLibraryLikeCoreCLRSetupPaths" |
| 8 | + DependsOnTargets="CopyNativeBinary" |
| 9 | + Condition="'$(IsRuntimeComponent)' == 'true' and '$(TargetsWindows)' != 'true'"> |
| 10 | + <PropertyGroup> |
| 11 | + <StrippedOutputPath>$(OutputPath)stripped\</StrippedOutputPath> |
| 12 | + <StripSourceFile>$(StrippedOutputPath)$(TargetName)$(NativeBinaryExt)</StripSourceFile> |
| 13 | + <StrippedExt Condition="'$(StrippedExt)' == '' and ('$(TargetsOSX)' == 'true' or '$(TargetsAppleMobile)' == 'true')">.dylib.dwarf</StrippedExt> |
| 14 | + <StrippedExt Condition="'$(TargetsUnix)' == 'true' and '$(StrippedExt)' == ''">.so.dbg</StrippedExt> |
| 15 | + <StripDestinationFile>$(StrippedOutputPath)$(TargetName)$(StrippedExt)</StripDestinationFile> |
| 16 | + </PropertyGroup> |
| 17 | + </Target> |
| 18 | + |
| 19 | + <!-- |
| 20 | + Hack: temporarily turn on StripSymbols whlie SetupOSSpecificProps runs, then turn it off |
| 21 | + again before LinkNative runs. The problem is that SetupOSSpecificProps only probes for |
| 22 | + $(ObjCopyName) and $(ObjCopyNameAlternative) if symbol stripping is turned on. But we don't |
| 23 | + want LinkNative to actually do any stripping since we have our own way that we'd like it to |
| 24 | + work. |
| 25 | + --> |
| 26 | + <Target Name="TempStripSymbolsOn" |
| 27 | + BeforeTargets="SetupOSSpecificProps"> |
| 28 | + <PropertyGroup> |
| 29 | + <StripSymbols>true</StripSymbols> |
| 30 | + </PropertyGroup> |
| 31 | + </Target> |
| 32 | + |
| 33 | + <Target Name="TempStripSymbolsOff" |
| 34 | + AfterTargets="SetupOSSpecificProps" |
| 35 | + BeforeTargets="LinkNative"> |
| 36 | + <PropertyGroup> |
| 37 | + <StripSymbols>false</StripSymbols> |
| 38 | + </PropertyGroup> |
| 39 | + </Target> |
| 40 | + |
| 41 | + <Target Name="StripLibraryLikeCoreCLRBuild" |
| 42 | + DependsOnTargets="SetupOSSpecificProps;CopyNativeBinary;StripLibraryLikeCoreCLRSetupPaths" |
| 43 | + Condition="'$(IsRuntimeComponent)' == 'true' and '$(TargetsWindows)' != 'true'" |
| 44 | + Inputs="$(PublishDir)$(TargetName)$(NativeBinaryExt)" |
| 45 | + Outputs="$(StripSourceFile);$(StripDestinationFile)"> |
| 46 | + <Error Text="Do not set StripSymbols to true - runtime components stripping is controlled by native-library.targets" Condition="'$(StripSymbols)' == 'true'" /> |
| 47 | + |
| 48 | + <Message Importance="Normal" Text="Stripping $(PublishDir)$(TargetName)$(NativeBinaryExt) into $(StripSourceFile) and $(StripDestinationFile)" /> |
| 49 | + |
| 50 | + <!-- copy from the published/ subfolder to the stripped/ subfolder --> |
| 51 | + <Copy SourceFiles="$(PublishDir)$(TargetName)$(NativeBinaryExt)" |
| 52 | + DestinationFolder="$(StrippedOutputPath)" |
| 53 | + SkipUnchangedFiles="true" /> |
| 54 | + |
| 55 | + <PropertyGroup> |
| 56 | + <_StripLike Condition="'$(TargetsOSX)' == 'true' or '$(TargetsAppleMobile)' == 'true'">apple</_StripLike> |
| 57 | + <_StripLike Condition="'$(_StripLike)' == ''">gnu</_StripLike> |
| 58 | + </PropertyGroup> |
| 59 | + |
| 60 | + <Exec Command="dsymutil --flat $(LikeCoreCLRDSymUtilMinimizeOpt) $(StripSourceFile)" Condition="'$(_StripLike)' == 'apple'"/> <!-- produces the .dylib.dwarf file --> |
| 61 | + <Exec Command="strip -no_code_signature_warning -S $(StripSourceFile)" Condition="'$(_StripLike)' == 'apple'"/> |
| 62 | + <!-- runtime build runs "codesign -f -s - libWhatever.dylib" in release configurations --> |
| 63 | + <Exec Command="codesign -f -s - $(StripSourceFile)" Condition="'$(RuntimeConfiguration)' == 'Release' and '$(_StripLike)' == 'apple'" /> |
| 64 | + |
| 65 | + <Exec Command="$(ObjCopyName) --only-keep-debug $(StripSourceFile) $(StripDestinationFile)" Condition="'$(_StripLike)' == 'gnu'"/> |
| 66 | + <Exec Command="$(ObjCopyName) --strip-debug --strip-unneeded $(StripSourceFile)" Condition="'$(_StripLike)' == 'gnu'"/> |
| 67 | + <Exec Command="$(ObjCopyName) --add-gnu-debuglink=$(StripDestinationFile) $(StripSourceFile)" Condition="'$(_StripLike)' == 'gnu'"/> |
| 68 | + </Target> |
| 69 | + |
| 70 | + <Target Name="InstallRuntimeComponentToFinalDestination" |
| 71 | + AfterTargets="CopyNativeBinary" |
| 72 | + DependsOnTargets="CopyNativeBinary;StripLibraryLikeCoreCLRBuild" Condition="'$(IsRuntimeComponent)' == 'true'"> |
| 73 | + <Error Text="Set at least one @InstallRuntimeComponentDestination item" Condition="@(InstallRuntimeComponentDestination->Count()) == 0" /> |
| 74 | + |
| 75 | + <PropertyGroup> |
| 76 | + <!-- FIXME: this is the same as CoreCLRToolPath - but that doesn't seem like a good name --> |
| 77 | + <FinalRuntimeComponentDestinationBase>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', '$(RuntimeFlavor.ToLower())', '$(TargetOS).$(TargetArchitecture).$(RuntimeConfiguration)'))</FinalRuntimeComponentDestinationBase> |
| 78 | + </PropertyGroup> |
| 79 | + |
| 80 | + <ItemGroup> |
| 81 | + <_NormalizedInstallRuntimeComponentDest Include="$([MSBuild]::NormalizeDirectory('$(FinalRuntimeComponentDestinationBase)', '%(InstallRuntimeComponentDestination.Identity)'))" /> |
| 82 | + </ItemGroup> |
| 83 | + |
| 84 | + <ItemGroup Condition="'$(TargetsWindows)' != 'true'"> |
| 85 | + <CopyFinalFiles Include="$(StripSourceFile)" /> |
| 86 | + <CopyFinalFiles Include="$(StripDestinationFile)" /> |
| 87 | + </ItemGroup> |
| 88 | + |
| 89 | + <ItemGroup Condition="'$(TargetsWindows)' == 'true'"> |
| 90 | + <CopyFinalFiles Include="$(PublishDir)$(TargetName)$(NativeBinaryExt)" /> |
| 91 | + <CopyFinalFilesPDB Include="$(PublishDir)$(TargetName).pdb" /> |
| 92 | + </ItemGroup> |
| 93 | + |
| 94 | + <Message Importance="Normal" Text="Installing @(CopyFinalFiles) into %(_NormalizedInstallRuntimeComponentDest.Identity)"/> |
| 95 | + <Message Importance="Normal" Text="Installing @(CopyFinalFilesPDB) into %(_NormalizedInstallRuntimeComponentDest.Identity)PDB\" Condition="'$(TargetsWindows)' == 'true'"/> |
| 96 | + |
| 97 | + <Copy SourceFiles="@(CopyFinalFiles)" |
| 98 | + DestinationFolder="%(_NormalizedInstallRuntimeComponentDest.Identity)" |
| 99 | + SkipUnchangedFiles="true"/> |
| 100 | + <Copy SourceFiles="@(CopyFinalFilesPDB)" |
| 101 | + DestinationFolder="%(_NormalizedInstallRuntimeComponentDest.Identity)PDB\" |
| 102 | + SkipUnchangedFiles="true" |
| 103 | + Condition="'$(TargetsWindows)' == 'true'"/> |
| 104 | + </Target> |
| 105 | + |
| 106 | + |
| 107 | +</Project> |
0 commit comments