|
| 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> |
0 commit comments