Skip to content

Commit 5e9346d

Browse files
[xaprepare] Move CMake file generation into a dedicated MSBuild project (#11760)
Continues the incremental dismantling of `xaprepare` (see #11568, #11580, #11608, #11613, #11631, #11657, #11658, #11731, #11732, #11733, #11737, #11740). Two more generator methods come out, and the work they did moves into a small dedicated MSBuild project. ## What changes Two xaprepare generators in `build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs` are deleted: * `Get_Cmake_XA_Build_Configuration` — produced `bin/Build$(Configuration)/xa_build_configuration.cmake`, included by `src/native/CMakeLists.txt`. * `Get_Cmake_Presets` (and its `GetCmakePresetsCommon` helper) — produced `src/native/CMakePresets.json`, consumed by the `cmake` preset invocations in `src/native/native.targets`. Both are now generated by a new project: * **`src/native/cmake-config/cmake-config.csproj`** (`Microsoft.Build.NoTargets`) hosts `_GenerateCMakeFiles`, which uses the existing `ReplaceFileContents` MSBuild task to substitute the placeholders in `build-tools/scripts/xa_build_configuration.cmake.in` and `src/native/CMakePresets.json.in`. * `native-mono.csproj`, `native-clr.csproj`, and `native-nativeaot.csproj` each `<ProjectReference>` this project. ### Why a dedicated project (not just a target in `native.targets`) The three native csproj share two output files (`bin/Build$(Configuration)/xa_build_configuration.cmake` and `src/native/CMakePresets.json`). Hosting the generator in `native.targets` would either: * Race on the shared outputs under parallel msbuild (`/m`), or * Require a `'$(MSBuildProjectName)' == 'native-mono'` gate -- which breaks isolated `dotnet build native-clr.csproj` on a clean tree (the gitignored output files would never get generated). A dedicated project with three incoming `<ProjectReference>`s solves both: single producer, and project-reference ordering guarantees the outputs exist before any consumer's `cmake` preset call -- including for isolated single-csproj builds. ### Incremental correctness `_GenerateCMakeFiles` declares fully-anchored `Inputs`: * `build-tools/scripts/xa_build_configuration.cmake.in` * `src/native/CMakePresets.json.in` * `Configuration.props` (`AndroidNdkDirectory`, `NinjaPath`, `MicrosoftAndroidSdkOutDir`, `XAPackagesDir`, `AndroidMinimumDotNetApiLevel`) * `Directory.Build.props` (`TestOutputDirectory`) * `eng/Versions.props` (`MicrosoftNETCoreAppRefPackageVersion`) so editing any of those re-runs the target; a no-change rebuild skips it. (Note: `$(MSBuildAllProjects)` is intentionally **not** used -- it does not include imported `.props` files for SDK-style projects since MSBuild 16.0; verified empirically.) ### Cascading deletions in xaprepare * `Configurables.NativeSourcesDir` (was used only by `Get_Cmake_Presets`). * All eight `Configurables.Paths.NetcoreAppRuntimeAndroid*` / `CoreClrAppRuntimeAndroid*` properties (+ backing fields + the `GetNetcoreAppRuntimePath` / `GetCoreClrAppRuntimePath` helpers) -- the new MSBuild target reads `$(XAPackagesDir)` / `$(MicrosoftNETCoreAppRefPackageVersion)` directly. * The `Get_Cmake_*` entries in `Step_GenerateFiles.GetFilesToGenerate`. `BuildAndroidPlatforms.NdkMinimumAPI` / `NdkMinimumAPILegacy32` are kept -- still used by `Get_XABuildConfig_cs` (a separate generator for a future PR). ### What stays The `.in` template files are unchanged and still tracked in git -- the new MSBuild target reads them. The other generators in `Step_GenerateFiles.cs` (`Get_SourceLink_Json`, `Get_Configuration_OperatingSystem_props`, `Get_XABuildConfig_cs`, `AddOSSpecificSteps`) are out of scope and untouched. ## Verification On Windows: * `build.cmd Prepare -c Debug` * `dotnet-local.cmd build src\native\native-mono.csproj -c Debug` -> 0 errors, generates both files * `dotnet-local.cmd build src\native\native-clr.csproj -c Debug` -> 0 errors (incl. clean-tree isolated build) * `dotnet-local.cmd build src\native\native-nativeaot.csproj -c Debug` -> 0 errors * `dotnet-local.cmd build build-tools\xaprepare\xaprepare\xaprepare.csproj -c Debug` -> 0 errors Incremental behaviour verified by walking through MSBuild diagnostic output: * No-change rebuild: `Skipping target "_GenerateCMakeFiles" because all output files are up-to-date`. * `touch eng/Versions.props` + rebuild: `Building target "_GenerateCMakeFiles" completely`, outputs re-written. The generated `CMakePresets.json` and `xa_build_configuration.cmake` were diffed against the xaprepare baselines captured before the deletion; only the path separator normalisation (forward slashes throughout) differs, which both CMake and JSON accept on every platform. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4decac8 commit 5e9346d

7 files changed

Lines changed: 108 additions & 98 deletions

File tree

Xamarin.Android.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "native-clr", "src\native\na
4949
EndProject
5050
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "native-nativeaot", "src\native\native-nativeaot.csproj", "{645E1718-C8C4-4C23-8A49-5A37E4ECF7ED}"
5151
EndProject
52+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cmake-config", "src\native\cmake-config\cmake-config.csproj", "{5AA3C091-400C-40E4-A073-E093541A5B98}"
53+
EndProject
5254
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}"
5355
EndProject
5456
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.ProjectTools", "src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Xamarin.ProjectTools.csproj", "{2DD1EE75-6D8D-4653-A800-0A24367F7F38}"
@@ -397,6 +399,18 @@ Global
397399
{645E1718-C8C4-4C23-8A49-5A37E4ECF7ED}.Release|x64.Build.0 = Release|Any CPU
398400
{645E1718-C8C4-4C23-8A49-5A37E4ECF7ED}.Release|x86.ActiveCfg = Release|Any CPU
399401
{645E1718-C8C4-4C23-8A49-5A37E4ECF7ED}.Release|x86.Build.0 = Release|Any CPU
402+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
403+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Debug|Any CPU.Build.0 = Debug|Any CPU
404+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Debug|x64.ActiveCfg = Debug|Any CPU
405+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Debug|x64.Build.0 = Debug|Any CPU
406+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Debug|x86.ActiveCfg = Debug|Any CPU
407+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Debug|x86.Build.0 = Debug|Any CPU
408+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Release|Any CPU.ActiveCfg = Release|Any CPU
409+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Release|Any CPU.Build.0 = Release|Any CPU
410+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Release|x64.ActiveCfg = Release|Any CPU
411+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Release|x64.Build.0 = Release|Any CPU
412+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Release|x86.ActiveCfg = Release|Any CPU
413+
{5AA3C091-400C-40E4-A073-E093541A5B98}.Release|x86.Build.0 = Release|Any CPU
400414
{2DD1EE75-6D8D-4653-A800-0A24367F7F38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
401415
{2DD1EE75-6D8D-4653-A800-0A24367F7F38}.Debug|Any CPU.Build.0 = Debug|Any CPU
402416
{2DD1EE75-6D8D-4653-A800-0A24367F7F38}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -1044,6 +1058,7 @@ Global
10441058
{53EE4C57-1C03-405A-8243-8DA539546C88} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
10451059
{9B42A5BB-74CB-46E2-BCE0-AF763A792551} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
10461060
{645E1718-C8C4-4C23-8A49-5A37E4ECF7ED} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
1061+
{5AA3C091-400C-40E4-A073-E093541A5B98} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
10471062
{2DD1EE75-6D8D-4653-A800-0A24367F7F38} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}
10481063
{53E4ABF0-1085-45F9-B964-DCAE4B819998} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}
10491064
{F9CD012E-67AC-4A4E-B2A7-252387F91256} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}

build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public static partial class Paths
140140
public static readonly string BinDirRoot = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "bin");
141141
public static readonly string ExternalDir = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "external");
142142
public static readonly string ExternalXamarinAndroidToolsSln = Path.Combine (ExternalDir, "xamarin-android-tools", "Xamarin.Android.Tools.sln");
143-
public static readonly string NativeSourcesDir = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "src", "native");
144143

145144
// Dynamic locations used throughout the code
146145
public static string ExternalJavaInteropDir => GetCachedPath (ref externalJavaInteropDir, () => ctx.Properties.GetRequiredValue (KnownProperties.JavaInteropFullPath));
@@ -150,18 +149,6 @@ public static partial class Paths
150149
public static string MonoAndroidFrameworksSubDir = Path.Combine ("xbuild-frameworks", "MonoAndroid");
151150
public static string MonoAndroidFrameworksRootDir => GetCachedPath (ref monoAndroidFrameworksRootDir, () => Path.Combine (XAInstallPrefix, MonoAndroidFrameworksSubDir));
152151

153-
// .NET 6+
154-
public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm"));
155-
public static string NetcoreAppRuntimeAndroidARM64 => GetCachedPath (ref netcoreAppRuntimeAndroidARM64, () => GetNetcoreAppRuntimePath (ctx, "arm64"));
156-
public static string NetcoreAppRuntimeAndroidX86 => GetCachedPath (ref netcoreAppRuntimeAndroidX86, () => GetNetcoreAppRuntimePath (ctx, "x86"));
157-
public static string NetcoreAppRuntimeAndroidX86_64 => GetCachedPath (ref netcoreAppRuntimeAndroidX86_64, () => GetNetcoreAppRuntimePath (ctx, "x64"));
158-
159-
// CoreCLR
160-
public static string CoreClrAppRuntimeAndroidARM => GetCachedPath (ref coreclrAppRuntimeAndroidARM, () => GetCoreClrAppRuntimePath (ctx, "arm"));
161-
public static string CoreClrAppRuntimeAndroidARM64 => GetCachedPath (ref coreclrAppRuntimeAndroidARM64, () => GetCoreClrAppRuntimePath (ctx, "arm64"));
162-
public static string CoreClrAppRuntimeAndroidX86 => GetCachedPath (ref coreclrAppRuntimeAndroidX86, () => GetCoreClrAppRuntimePath (ctx, "x86"));
163-
public static string CoreClrAppRuntimeAndroidX86_64 => GetCachedPath (ref coreclrAppRuntimeAndroidX86_64, () => GetCoreClrAppRuntimePath (ctx, "x64"));
164-
165152
public static string DotNetPreviewPath => ctx.Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath);
166153

167154
public static string DotNetPreviewTool => Path.Combine (DotNetPreviewPath, "dotnet");
@@ -174,28 +161,6 @@ public static partial class Paths
174161
public static string XAInstallPrefix => ctx.Properties.GetRequiredValue (KnownProperties.XAInstallPrefix);
175162
public static string XAPackagesDir => ctx.Properties.GetRequiredValue (KnownProperties.XAPackagesDir);
176163

177-
static string GetNetcoreAppRuntimePath (Context ctx, string androidTarget)
178-
{
179-
return Path.Combine (
180-
XAPackagesDir,
181-
$"microsoft.netcore.app.runtime.mono.android-{androidTarget}",
182-
ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETCoreAppRefPackageVersion),
183-
"runtimes",
184-
$"android-{androidTarget}"
185-
);
186-
}
187-
188-
static string GetCoreClrAppRuntimePath (Context ctx, string androidTarget)
189-
{
190-
return Path.Combine (
191-
XAPackagesDir,
192-
$"microsoft.netcore.app.runtime.android-{androidTarget}",
193-
ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETCoreAppRefPackageVersion),
194-
"runtimes",
195-
$"android-{androidTarget}"
196-
);
197-
}
198-
199164
static string GetCachedPath (ref string? variable, Func<string> creator)
200165
{
201166
if (!String.IsNullOrEmpty (variable))
@@ -210,14 +175,6 @@ static string GetCachedPath (ref string? variable, Func<string> creator)
210175
static string? binDir;
211176
static string? monoAndroidFrameworksRootDir;
212177
static string? externalJavaInteropDir;
213-
static string? netcoreAppRuntimeAndroidARM;
214-
static string? netcoreAppRuntimeAndroidARM64;
215-
static string? netcoreAppRuntimeAndroidX86;
216-
static string? netcoreAppRuntimeAndroidX86_64;
217-
static string? coreclrAppRuntimeAndroidARM;
218-
static string? coreclrAppRuntimeAndroidARM64;
219-
static string? coreclrAppRuntimeAndroidX86;
220-
static string? coreclrAppRuntimeAndroidX86_64;
221178
}
222179
}
223180
}

build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,11 @@ protected override async Task<bool> Execute (Context context)
5555
if (onlyRequired) {
5656
return new List<GeneratedFile> {
5757
Get_SourceLink_Json (context),
58-
Get_Cmake_XA_Build_Configuration (context),
59-
Get_Cmake_Presets (context),
6058
};
6159
} else {
6260
return new List <GeneratedFile> {
6361
Get_SourceLink_Json (context),
6462
Get_Configuration_OperatingSystem_props (context),
65-
Get_Cmake_XA_Build_Configuration (context),
66-
Get_Cmake_Presets (context),
6763
Get_XABuildConfig_cs (context),
6864
};
6965
}
@@ -81,57 +77,6 @@ protected override async Task<bool> Execute (Context context)
8177

8278
partial void AddOSSpecificSteps (Context context, List<GeneratedFile> steps);
8379

84-
GeneratedFile Get_Cmake_XA_Build_Configuration (Context context)
85-
{
86-
const string OutputFileName = "xa_build_configuration.cmake";
87-
88-
var replacements = new Dictionary<string, string> (StringComparer.Ordinal) {
89-
{ "@NETCORE_APP_RUNTIME_ANDROID_ARM@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidARM) },
90-
{ "@NETCORE_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidARM64) },
91-
{ "@NETCORE_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86) },
92-
{ "@NETCORE_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86_64) },
93-
94-
{ "@CORECLR_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidARM64) },
95-
{ "@CORECLR_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidX86_64) },
96-
};
97-
98-
return new GeneratedPlaceholdersFile (
99-
replacements,
100-
Path.Combine (Configurables.Paths.BuildToolsScriptsDir, $"{OutputFileName}.in"),
101-
Path.Combine (Configurables.Paths.BuildBinDir, OutputFileName)
102-
);
103-
}
104-
105-
GeneratedFile GetCmakePresetsCommon (Context context, string sourcesDir)
106-
{
107-
const string OutputFileName = "CMakePresets.json";
108-
109-
Properties props = context.Properties;
110-
var replacements = new Dictionary <string, string> (StringComparer.Ordinal) {
111-
{ "@AndroidNdkDirectory@", Utilities.EscapePathSeparators (props.GetRequiredValue (KnownProperties.AndroidNdkDirectory)) },
112-
{ "@NinjaPath@", Utilities.EscapePathSeparators (props.GetRequiredValue (KnownProperties.NinjaPath)) },
113-
{ "@MicrosoftAndroidSdkOutDir@", Utilities.EscapePathSeparators (props.GetRequiredValue (KnownProperties.MicrosoftAndroidSdkOutDir)) },
114-
{ "@OutputPath@", Utilities.EscapePathSeparators (Path.Combine (props.GetRequiredValue (KnownProperties.MicrosoftAndroidSdkOutDir), "lib")) },
115-
{ "@NDK_ARMEABI_V7_API_NET@", BuildAndroidPlatforms.NdkMinimumAPILegacy32 },
116-
{ "@NDK_ARM64_V8A_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI },
117-
{ "@NDK_X86_API_NET@", BuildAndroidPlatforms.NdkMinimumAPILegacy32 },
118-
{ "@NDK_X86_64_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI },
119-
{ "@XA_BUILD_CONFIGURATION@", context.Configuration },
120-
{ "@XA_TEST_OUTPUT_DIR@", Utilities.EscapePathSeparators (props.GetRequiredValue (KnownProperties.TestOutputDirectory)) },
121-
};
122-
123-
return new GeneratedPlaceholdersFile (
124-
replacements,
125-
Path.Combine (sourcesDir, $"{OutputFileName}.in"),
126-
Path.Combine (sourcesDir, OutputFileName)
127-
);
128-
}
129-
130-
GeneratedFile Get_Cmake_Presets (Context context)
131-
{
132-
return GetCmakePresetsCommon (context, Configurables.Paths.NativeSourcesDir);
133-
}
134-
13580
GeneratedFile Get_Configuration_OperatingSystem_props (Context context)
13681
{
13782
const string OutputFileName = "Configuration.OperatingSystem.props";
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Generates the CMake-input files previously produced by xaprepare's
4+
Get_Cmake_XA_Build_Configuration and Get_Cmake_Presets generators:
5+
6+
* bin/Build$(Configuration)/xa_build_configuration.cmake
7+
(included by src/native/CMakeLists.txt)
8+
* src/native/CMakePresets.json
9+
(read by the cmake preset invocations in src/native/native.targets)
10+
11+
This is its own project so that native-mono.csproj, native-clr.csproj,
12+
and native-nativeaot.csproj can each ProjectReference it. That gives us:
13+
14+
* A single producer for the shared output files (no parallel-write race).
15+
* MSBuild project-reference ordering so every consumer's `cmake` preset
16+
call sees the generated files (works for isolated builds of any one
17+
native-*.csproj, not just full-tree builds).
18+
19+
Paths are emitted with forward slashes, which CMake and JSON both accept
20+
on all OSes and which avoids backslash-escaping concerns.
21+
-->
22+
<Project Sdk="Microsoft.Build.NoTargets">
23+
<PropertyGroup>
24+
<TargetFramework>netstandard2.0</TargetFramework>
25+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
26+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
27+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
28+
</PropertyGroup>
29+
30+
<Import Project="$(MSBuildThisFileDirectory)..\..\..\Configuration.props" />
31+
32+
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" TaskFactory="TaskHostFactory" Runtime="NET" />
33+
34+
<PropertyGroup>
35+
<_RepoRoot>$(MSBuildThisFileDirectory)..\..\..\</_RepoRoot>
36+
<_XaBuildConfigurationCMakeIn>$(_RepoRoot)build-tools\scripts\xa_build_configuration.cmake.in</_XaBuildConfigurationCMakeIn>
37+
<_XaBuildConfigurationCMakeOut>$(_RepoRoot)bin\Build$(Configuration)\xa_build_configuration.cmake</_XaBuildConfigurationCMakeOut>
38+
<_CMakePresetsIn>$(MSBuildThisFileDirectory)..\CMakePresets.json.in</_CMakePresetsIn>
39+
<_CMakePresetsOut>$(MSBuildThisFileDirectory)..\CMakePresets.json</_CMakePresetsOut>
40+
</PropertyGroup>
41+
42+
<Target Name="_GenerateCMakeFiles"
43+
BeforeTargets="Build"
44+
Inputs="$(_XaBuildConfigurationCMakeIn);$(_CMakePresetsIn);$(_RepoRoot)Configuration.props;$(_RepoRoot)Directory.Build.props;$(_RepoRoot)eng\Versions.props"
45+
Outputs="$(_XaBuildConfigurationCMakeOut);$(_CMakePresetsOut)">
46+
<PropertyGroup>
47+
<_XAPackagesDirSlashes>$([System.String]::Copy('$(XAPackagesDir)').Replace('\','/').TrimEnd('/'))</_XAPackagesDirSlashes>
48+
<_NetCoreRuntimePrefix>$(_XAPackagesDirSlashes)/microsoft.netcore.app.runtime.mono.android-</_NetCoreRuntimePrefix>
49+
<_NetCoreRuntimeSuffix>/$(MicrosoftNETCoreAppRefPackageVersion)/runtimes/android-</_NetCoreRuntimeSuffix>
50+
<_CoreClrRuntimePrefix>$(_XAPackagesDirSlashes)/microsoft.netcore.app.runtime.android-</_CoreClrRuntimePrefix>
51+
<_CoreClrRuntimeSuffix>/$(MicrosoftNETCoreAppRefPackageVersion)/runtimes/android-</_CoreClrRuntimeSuffix>
52+
53+
<_AndroidNdkDirectorySlashes>$([System.String]::Copy('$(AndroidNdkDirectory)').Replace('\','/'))</_AndroidNdkDirectorySlashes>
54+
<_NinjaPathSlashes>$([System.String]::Copy('$(NinjaPath)').Replace('\','/'))</_NinjaPathSlashes>
55+
<_MicrosoftAndroidSdkOutDirSlashes>$([System.String]::Copy('$(MicrosoftAndroidSdkOutDir)').Replace('\','/'))</_MicrosoftAndroidSdkOutDirSlashes>
56+
<_TestOutputDirectorySlashes>$([System.String]::Copy('$(TestOutputDirectory)').Replace('\','/'))</_TestOutputDirectorySlashes>
57+
</PropertyGroup>
58+
59+
<ItemGroup>
60+
<_XaBuildConfigurationReplacement Include="@NETCORE_APP_RUNTIME_ANDROID_ARM@=$(_NetCoreRuntimePrefix)arm$(_NetCoreRuntimeSuffix)arm" />
61+
<_XaBuildConfigurationReplacement Include="@NETCORE_APP_RUNTIME_ANDROID_ARM64@=$(_NetCoreRuntimePrefix)arm64$(_NetCoreRuntimeSuffix)arm64" />
62+
<_XaBuildConfigurationReplacement Include="@NETCORE_APP_RUNTIME_ANDROID_X86@=$(_NetCoreRuntimePrefix)x86$(_NetCoreRuntimeSuffix)x86" />
63+
<_XaBuildConfigurationReplacement Include="@NETCORE_APP_RUNTIME_ANDROID_X86_64@=$(_NetCoreRuntimePrefix)x64$(_NetCoreRuntimeSuffix)x64" />
64+
<_XaBuildConfigurationReplacement Include="@CORECLR_APP_RUNTIME_ANDROID_ARM64@=$(_CoreClrRuntimePrefix)arm64$(_CoreClrRuntimeSuffix)arm64" />
65+
<_XaBuildConfigurationReplacement Include="@CORECLR_APP_RUNTIME_ANDROID_X86_64@=$(_CoreClrRuntimePrefix)x64$(_CoreClrRuntimeSuffix)x64" />
66+
67+
<_CMakePresetsReplacement Include="@AndroidNdkDirectory@=$(_AndroidNdkDirectorySlashes)" />
68+
<_CMakePresetsReplacement Include="@NinjaPath@=$(_NinjaPathSlashes)" />
69+
<_CMakePresetsReplacement Include="@MicrosoftAndroidSdkOutDir@=$(_MicrosoftAndroidSdkOutDirSlashes)" />
70+
<_CMakePresetsReplacement Include="@NDK_ARMEABI_V7_API_NET@=$(AndroidMinimumDotNetApiLevel)" />
71+
<_CMakePresetsReplacement Include="@NDK_ARM64_V8A_API_NET@=$(AndroidMinimumDotNetApiLevel)" />
72+
<_CMakePresetsReplacement Include="@NDK_X86_API_NET@=$(AndroidMinimumDotNetApiLevel)" />
73+
<_CMakePresetsReplacement Include="@NDK_X86_64_API_NET@=$(AndroidMinimumDotNetApiLevel)" />
74+
<_CMakePresetsReplacement Include="@XA_BUILD_CONFIGURATION@=$(Configuration)" />
75+
<_CMakePresetsReplacement Include="@XA_TEST_OUTPUT_DIR@=$(_TestOutputDirectorySlashes)" />
76+
</ItemGroup>
77+
78+
<MakeDir Directories="$(_RepoRoot)bin\Build$(Configuration)" />
79+
80+
<ReplaceFileContents
81+
SourceFile="$(_XaBuildConfigurationCMakeIn)"
82+
DestinationFile="$(_XaBuildConfigurationCMakeOut)"
83+
Replacements="@(_XaBuildConfigurationReplacement)" />
84+
85+
<ReplaceFileContents
86+
SourceFile="$(_CMakePresetsIn)"
87+
DestinationFile="$(_CMakePresetsOut)"
88+
Replacements="@(_CMakePresetsReplacement)" />
89+
</Target>
90+
</Project>

src/native/native-clr.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<Import Project="native.targets" />
2323

2424
<ItemGroup>
25+
<ProjectReference Include="cmake-config\cmake-config.csproj" ReferenceOutputAssembly="False" />
2526
<ProjectReference Include="..\java-runtime\java-runtime.csproj" ReferenceOutputAssembly="False" />
2627
</ItemGroup>
2728
</Project>

src/native/native-mono.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Import Project="native.targets" />
1919

2020
<ItemGroup>
21+
<ProjectReference Include="cmake-config\cmake-config.csproj" ReferenceOutputAssembly="False" />
2122
<ProjectReference Include="..\java-runtime\java-runtime.csproj" ReferenceOutputAssembly="False" />
2223
</ItemGroup>
2324
</Project>

src/native/native-nativeaot.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<Import Project="native.targets" />
2222

2323
<ItemGroup>
24+
<ProjectReference Include="cmake-config\cmake-config.csproj" ReferenceOutputAssembly="False" />
2425
<ProjectReference Include="..\java-runtime\java-runtime.csproj" ReferenceOutputAssembly="False" />
2526
</ItemGroup>
2627
</Project>

0 commit comments

Comments
 (0)