-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
85 lines (74 loc) · 5.47 KB
/
Directory.Build.props
File metadata and controls
85 lines (74 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<Project>
<Import Project="src/Cosmos.Build.Common/build/Cosmos.ArchitecturePicker.props" />
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591;CS1998;NU1903;SYSLIB0011;</NoWarn>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>true</AppendRuntimeIdentifierToOutputPath>
<UseArtifactsOutput>true</UseArtifactsOutput>
<!--pack as nuget-->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<!--pack as nuget-->
</PropertyGroup>
<!--
Single source of truth for the version of every Cosmos package.
The authoritative literal lives in `global.json` under
`msbuild-sdks.Cosmos.Sdk` — that's what MSBuild's SDK resolver reads for
`<Sdk Name="Cosmos.Sdk" />` references in every kernel csproj, so keeping
it in global.json lets in-repo kernels build without hardcoded versions.
Resolution order for $(VersionPrefix):
1. Env var / `-p:VersionPrefix=` override (Release CI sets this from the
git tag, e.g. `3.0.44`)
2. `msbuild-sdks.Cosmos.Sdk` in global.json (rewritten in-place by
`./.devcontainer/postCreateCommand.sh` to `<base>.<yyyyMMdd>` for
local dev / PR CI so packages get a unique dev version per day —
ALWAYS pick this up here so sibling csprojs built in a fresh shell
see the same value the setup script generated)
Everything else (Directory.Packages.props, the Cosmos.Sdk shipped Sdk.props,
the cosmos-kernel template, Cosmos.Kernel's generated VersionString and
kmain_version.h, the BuildCache test fixture) derives from $(VersionPrefix).
-->
<PropertyGroup>
<_CosmosGlobalJsonPath>$(MSBuildThisFileDirectory)global.json</_CosmosGlobalJsonPath>
<VersionPrefix Condition="'$(VersionPrefix)' == '' and Exists('$(_CosmosGlobalJsonPath)')">$([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(_CosmosGlobalJsonPath)')), '"Cosmos\.Sdk"\s*:\s*"([^"]+)"').Groups[1].Value)</VersionPrefix>
</PropertyGroup>
<!--
AssemblyVersion / FileVersion must be `major.minor.build.revision` with each
component <= 65535, so we can't stuff a date-based revision (ddMMyyyy) in
there like VersionPrefix allows. Strip any trailing components beyond the
first three and append `.0` to produce a valid 4-part assembly version.
The full stamped $(VersionPrefix) is still used for the NuGet package
version, which has no such restriction.
-->
<PropertyGroup>
<_CosmosAssemblyBaseVersion>$([System.Text.RegularExpressions.Regex]::Match($(VersionPrefix), '^\d+\.\d+\.\d+').Value)</_CosmosAssemblyBaseVersion>
<AssemblyVersion Condition="'$(_CosmosAssemblyBaseVersion)' != ''">$(_CosmosAssemblyBaseVersion).0</AssemblyVersion>
<FileVersion Condition="'$(_CosmosAssemblyBaseVersion)' != ''">$(_CosmosAssemblyBaseVersion).0</FileVersion>
</PropertyGroup>
<!-- Normalize TargetArchitecture early so GCC targets pick the right toolchain -->
<PropertyGroup>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(RuntimeIdentifier)' != ''">$([System.String]::Copy('$(RuntimeIdentifier)').Split('-')[1])</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' and '$(CosmosArch)' != ''">$(CosmosArch)</TargetArchitecture>
</PropertyGroup>
<!-- Prefer Homebrew cross compilers when available to avoid hardcoded /opt/homebrew paths in downstream targets -->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<HomebrewPrefix Condition="'$(HomebrewPrefix)' == '' and Exists('/opt/homebrew/bin/brew')">/opt/homebrew</HomebrewPrefix>
<HomebrewPrefix Condition="'$(HomebrewPrefix)' == '' and Exists('/usr/local/bin/brew')">/usr/local</HomebrewPrefix>
<!-- GCCPath only if not already set by the caller; mirrors ResolveHomebrewGCC but runs earlier as a safety net -->
<GCCPath Condition="'$(GCCPath)' == '' and '$(TargetArchitecture)' == 'x64' and '$(HomebrewPrefix)' != '' and Exists('$(HomebrewPrefix)/opt/x86_64-elf-gcc/bin/x86_64-elf-gcc')">$(HomebrewPrefix)/opt/x86_64-elf-gcc/bin/x86_64-elf-gcc</GCCPath>
<GCCPath Condition="'$(GCCPath)' == '' and '$(TargetArchitecture)' == 'x64' and '$(HomebrewPrefix)' != '' and Exists('$(HomebrewPrefix)/bin/x86_64-elf-gcc')">$(HomebrewPrefix)/bin/x86_64-elf-gcc</GCCPath>
<GCCPath Condition="'$(GCCPath)' == '' and '$(TargetArchitecture)' == 'arm64' and '$(HomebrewPrefix)' != '' and Exists('$(HomebrewPrefix)/opt/aarch64-elf-gcc/bin/aarch64-elf-gcc')">$(HomebrewPrefix)/opt/aarch64-elf-gcc/bin/aarch64-elf-gcc</GCCPath>
<GCCPath Condition="'$(GCCPath)' == '' and '$(TargetArchitecture)' == 'arm64' and '$(HomebrewPrefix)' != '' and Exists('$(HomebrewPrefix)/bin/aarch64-elf-gcc')">$(HomebrewPrefix)/bin/aarch64-elf-gcc</GCCPath>
</PropertyGroup>
<!-- Native ASM files come from the NuGet packages (Cosmos.Kernel.Native.X64/ARM64).
Local-source overrides removed to avoid duplicate-symbol conflicts when both the
local copy and the NuGet copy are picked up by AsmSearchPath. To iterate on native
ASM, rebuild the package via `make setup`. -->
</Project>