Skip to content

Commit

Permalink
Make DotNetBuildFromSource work in more cases. (dotnet#81480)
Browse files Browse the repository at this point in the history
* Make DotNetBuildFromSource work in more cases.

DotNetBuildFromSource is mostly used when this repository is built as part of source-build.

With these changes the flag works in more cases, making it easier to reproduce the
source-build behavior when building the runtime repository directly.

* Microsoft.NETCore.Platforms.Tests: use  for .NET Framwork.

* Remove redundant PortableBuild property.

* eng/SourceBuild.props: remove DotNetBuildFromSource defaults.

* PR feedback.

* Use a proper default RuntimeOS and OutputRid when DotNetBuildFromSource is true.

* SourceBuild.props: move KeepNativeSymbols to repo, remove BuildDepPackage.

* SourceBuild.props: add comment describing what properties go where.
  • Loading branch information
tmds authored Feb 10, 2023
1 parent bbb107b commit 671196d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
15 changes: 11 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<MonoAOTCompilerTasksAssemblyPath>$([MSBuild]::NormalizePath('$(MonoAOTCompilerDir)', 'MonoAOTCompiler.dll'))</MonoAOTCompilerTasksAssemblyPath>
<MonoTargetsTasksAssemblyPath>$([MSBuild]::NormalizePath('$(MonoTargetsTasksDir)', 'MonoTargetsTasks.dll'))</MonoTargetsTasksAssemblyPath>
<TestExclusionListTasksAssemblyPath>$([MSBuild]::NormalizePath('$(TestExclusionListTasksDir)', 'TestExclusionListTasks.dll'))</TestExclusionListTasksAssemblyPath>
<CoreCLRToolPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'coreclr', '$(TargetOS).$(TargetArchitecture).$(Configuration)'))</CoreCLRToolPath>
<CoreCLRToolPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'coreclr', '$(TargetOS).$(TargetArchitecture).$(RuntimeConfiguration)'))</CoreCLRToolPath>
<ILAsmToolPath Condition="'$(DotNetBuildFromSource)' == 'true' or '$(BuildArchitecture)' == 's390x' or '$(BuildArchitecture)' == 'ppc64le'">$(CoreCLRToolPath)</ILAsmToolPath>

<WasmtimeDir>$([MSBuild]::NormalizeDirectory($(ArtifactsObjDir), 'wasmtime'))</WasmtimeDir>
Expand All @@ -154,11 +154,14 @@

<PropertyGroup Label="CalculateOS">
<!-- Default to portable build if not explicitly set -->
<PortableBuild Condition="'$(PortableBuild)' == '' and '$(DotNetBuildFromSource)' == 'true'">false</PortableBuild>
<PortableBuild Condition="'$(PortableBuild)' == ''">true</PortableBuild>

<_hostRid Condition="'$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</_hostRid>
<_hostRid Condition="'$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</_hostRid>

<_parseDistroRid>$(__DistroRid)</_parseDistroRid>
<_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</_parseDistroRid>
<_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</_parseDistroRid>
<_parseDistroRid Condition="'$(_parseDistroRid)' == ''">$(_hostRid)</_parseDistroRid>
<_distroRidIndex>$(_parseDistroRid.LastIndexOf('-'))</_distroRidIndex>

<_runtimeOS>$(RuntimeOS)</_runtimeOS>
Expand Down Expand Up @@ -187,6 +190,7 @@

<_runtimeOS Condition="$(_runtimeOS.StartsWith('tizen'))">linux</_runtimeOS>
<_runtimeOS Condition="'$(PortableBuild)' == 'true'">$(_portableOS)</_runtimeOS>
<_runtimeOS Condition="'$(RuntimeOS)' == '' and '$(DotNetBuildFromSource)' == 'true'">$(_portableOS)</_runtimeOS>

<_packageLibc Condition="$(_runtimeOS.Contains('musl'))">-musl</_packageLibc>
<_packageOS Condition="'$(CrossBuild)' == 'true'">$(_hostOS)$(_packageLibc)</_packageOS>
Expand Down Expand Up @@ -219,6 +223,7 @@

<PackageRID>$(_packageOS)-$(TargetArchitecture)</PackageRID>

<OutputRid Condition="'$(OutputRid)' == '' and '$(DotNetBuildFromSource)' == 'true'">$(_hostRid)</OutputRid>
<OutputRid Condition="'$(OutputRid)' == ''">$(PackageRID)</OutputRid>
<OutputRid Condition="'$(PortableBuild)' == 'true'">$(_portableOS)-$(TargetArchitecture)</OutputRid>
<TargetsLinuxBionic Condition="$(OutputRid.StartsWith('linux-bionic'))">true</TargetsLinuxBionic>
Expand Down Expand Up @@ -261,6 +266,8 @@

<!--Feature switches -->
<PropertyGroup>
<NoPgoOptimize Condition="'$(NoPgoOptimize)' == '' and '$(DotNetBuildFromSource)' == 'true'">true</NoPgoOptimize>
<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == '' and '$(DotNetBuildFromSource)' == 'true'">false</EnableNgenOptimization>
<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == '' and ('$(Configuration)' == 'Release' or '$(Configuration)' == 'Checked')">true</EnableNgenOptimization>
<!-- Enable NuGet static graph evaluation to optimize incremental restore -->
<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
Expand Down Expand Up @@ -327,7 +334,7 @@
<!-- Always pass portable to override arcade sdk which uses embedded for local builds -->
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<!-- Default to discarding symbols if not explicitly set -->
<KeepNativeSymbols Condition="'$(KeepNativeSymbols)' == '' and '$(DotNetBuildFromSource)' == 'true'">true</KeepNativeSymbols>
<KeepNativeSymbols Condition="'$(KeepNativeSymbols)' == ''">false</KeepNativeSymbols>
<!-- Used for launchSettings.json and runtime config files. -->
<AppDesignerFolder>Properties</AppDesignerFolder>
Expand Down
14 changes: 3 additions & 11 deletions eng/SourceBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<PropertyGroup>
<BaseInnerSourceBuildCommand>./build.sh</BaseInnerSourceBuildCommand>

<SourceBuildPortable>true</SourceBuildPortable>
<SourceBuildPortable Condition="'$(SourceBuildNonPortable)' == 'true'">false</SourceBuildPortable>

<!-- TargetRid names what gets built. -->
<TargetRid Condition="'$(TargetRid)' == '' and '$(SourceBuildNonPortable)' == 'true'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</TargetRid>
<TargetRid Condition="'$(TargetRid)' == ''">$(__DistroRid)</TargetRid>
Expand All @@ -32,25 +29,20 @@
<Target Name="GetRuntimeSourceBuildCommandConfiguration"
BeforeTargets="GetSourceBuildCommandConfiguration">
<PropertyGroup>
<!-- Properties that control the source-build configuration should be added to the repository and guarded with the DotNetBuildFromSource Condition.
This allows to build the repository using './build.sh <args> /p:DotNetBuildFromSource=true'.
Properties that control flags from source-build, and the expected output for source-build should be added to this file. -->
<InnerBuildArgs>$(InnerBuildArgs) --arch $(TargetArch)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --configuration $(Configuration)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --allconfigurations</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --verbosity $(LogVerbosity)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --nodereuse false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --warnAsError false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --outputrid $(TargetRid)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --portablebuild $(SourceBuildPortable)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:NoPgoOptimize=true</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:KeepNativeSymbols=true</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:RuntimeOS=$(RuntimeOS)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(OfficialBuildId)' != ''">$(InnerBuildArgs) /p:OfficialBuildId=$(OfficialBuildId)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(ContinuousIntegrationBuild)' != ''">$(InnerBuildArgs) /p:ContinuousIntegrationBuild=$(ContinuousIntegrationBuild)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:BuildDebPackage=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:EnableNgenOptimization=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:EnablePackageValidation=false</InnerBuildArgs>
<!-- Re-enable for source-build when 8.0 Preview 1 shipped. See https://github.com/dotnet/installer/pull/14991 for more information. -->
<InnerBuildArgs>$(InnerBuildArgs) /p:ApiCompatValidateAssemblies=false</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true'">$(InnerBuildArgs) /p:PrimaryRuntimeFlavor=Mono /p:RuntimeFlavor=Mono</InnerBuildArgs>
</PropertyGroup>
</Target>
Expand Down
4 changes: 3 additions & 1 deletion eng/packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<PropertyGroup>
<!-- Package Validation isn't helpful when authoring shared framework packages. -->
<EnablePackageValidation Condition="'$(EnablePackageValidation)' == '' and '$(UsingMicrosoftDotNetSharedFrameworkSdk)' != 'true'">true</EnablePackageValidation>
<EnablePackageValidation Condition="'$(EnablePackageValidation)' == '' and
'$(UsingMicrosoftDotNetSharedFrameworkSdk)' != 'true' and
'$(DotNetBuildFromSource)' != 'true'">true</EnablePackageValidation>
<!-- Don't perform baseline validation if we don't have a stable prebuilt version.
Don't attempt to restore prebuilts during source-build. -->
<DisablePackageBaselineValidation Condition="'$(IsShipping)' == 'false' or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,10 @@ private static bool GetProtocolSupportFromWindowsRegistry(SslProtocols protocol,
#pragma warning disable CS0618 // Ssl2 and Ssl3 are obsolete
SslProtocols.Ssl3 => "SSL 3.0",
#pragma warning restore CS0618
#pragma warning disable SYSLIB0039 // TLS versions 1.0 and 1.1 have known vulnerabilities
SslProtocols.Tls => "TLS 1.0",
SslProtocols.Tls11 => "TLS 1.1",
#pragma warning restore SYSLIB0039
SslProtocols.Tls12 => "TLS 1.2",
#if !NETFRAMEWORK
SslProtocols.Tls13 => "TLS 1.3",
Expand Down Expand Up @@ -493,6 +495,7 @@ private static bool AndroidGetSslProtocolSupport(SslProtocols protocol)
return (protocol & s_androidSupportedSslProtocols.Value) == protocol;
}

#pragma warning disable SYSLIB0039 // TLS versions 1.0 and 1.1 have known vulnerabilities
private static bool GetTls10Support()
{
// on macOS and Android TLS 1.0 is supported.
Expand Down Expand Up @@ -531,6 +534,7 @@ private static bool GetTls11Support()

return OpenSslGetTlsSupport(SslProtocols.Tls11);
}
#pragma warning restore SYSLIB0039

private static bool GetTls12Support()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private void CreateUser()
[return: MarshalAs(UnmanagedType.Bool)]
private static partial bool LogonUser(string userName, string domain, string password, int logonType, int logonProvider, out SafeAccessTokenHandle safeAccessTokenHandle);

[LibraryImport("netapi32.dll", SetLastError = true)]
internal static partial uint NetUserAdd([MarshalAs(UnmanagedType.LPWStr)] string servername, uint level, ref USER_INFO_1 buf, out uint parm_err);
[DllImport("netapi32.dll", SetLastError = true)]
internal static extern uint NetUserAdd([MarshalAs(UnmanagedType.LPWStr)] string servername, uint level, ref USER_INFO_1 buf, out uint parm_err);

[LibraryImport("netapi32.dll")]
internal static partial uint NetUserDel([MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string username);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);net472</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkToolCurrent)</TargetFrameworks>
<IgnoreForCI Condition="'$(TargetOS)' == 'browser'">true</IgnoreForCI>
</PropertyGroup>

Expand Down
1 change: 0 additions & 1 deletion src/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<RuntimeFlavor Condition="'$(RuntimeFlavor)' == ''">coreclr</RuntimeFlavor>

<RestoreDefaultOptimizationDataPackage Condition="'$(RestoreDefaultOptimizationDataPackage)' == ''">false</RestoreDefaultOptimizationDataPackage>
<PortableBuild Condition="'$(PortableBuild)' == ''">true</PortableBuild>

<UsePartialNGENOptimization Condition="'$(UsePartialNGENOptimization)' == ''">false</UsePartialNGENOptimization>

Expand Down

0 comments on commit 671196d

Please sign in to comment.