Skip to content

Commit 9987069

Browse files
authored
[create-android-api] Centralize API*.xml file generation (dotnet#7054)
Context: 5432886 *One* issue with running `dotnet build Xamarin.Android.sln` without `-m:1` (5432886) is that it attempts to run our Android API extraction process multiple times simultaneously. This results in file locking issues: C:\code\xamarin-android\src\Mono.Android\Mono.Android.targets(409,5): "C:\code\xamarin-android\src\Mono.Android\..\..\bin\Debug\lib\xamarin.android\xbuild\Xamarin\Android\class-parse.exe C:\…\android-toolchain\sdk\platforms\android-26\android.jar -platform=26 -parameter-names="C:\code\xamarin-android\src\Mono.Android\..\..\src\Mono.Android\Profiles\api-26.params.txt" -o="C:\code\xamarin-android\src\Mono.Android\..\..\bin\BuildDebug\api\api-26.xml.class-parse"" failed with code: -532462766 Error output: Unhandled Exception: System.IO.IOException: The process cannot access the file 'C:\code\xamarin-android\bin\BuildDebug\api\api-26.xml.class-parse' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding) at Xamarin.Android.Tools.App.Main(String[] args) in C:\code\xamarin-android\external\Java.Interop\tools\class-parse\Program.cs:line 68 [C:\code\xamarin-android\src\Mono.Android\Mono.Android.csproj] This seems to be a result of running the process as an `AfterTargets="Build"` target in `api-xml-adjuster.csproj`. By moving it to a `NoTargets` project, we can eliminate MSBuild trying to run it multiple times. Move the `class-parse` execution to a new `create-android-api.csproj` project. Also, move the `api-merge` step into `create-android-api.csproj`, from `Mono.Android.targets`. Currently the `pai-merge` process runs twice, once for `monoandroid10` and once for `net7.0`. However, the output is not dependent on `TargetFramework`. Instead of generating: - `src\Mono.Android\obj\Debug\monoandroid10\android-32\mcw\api.xml` - `src\Mono.Android\obj\Debug\net7.0\android-32\mcw\api.xml` we will now generate: - `bin\Build$(Configuration)\api\api-32.xml` Calling `api-merge` only once saves ~25s from build time. Note that `generator` writes intermediate files (eg: `api.xml.fixed`) to the directory containing `api.xml`, so `Mono.Android.targets` will copy the `api-X.xml` file to its eg: `obj\Debug\net7.0\android-32\mcw` directory to work from. Without this, both `monoadroid10` and `net7.0` would write to the common location, causing possible file sharing conflicts. Additionally, let VS2022 rewrite `Xamarin.Android.sln` to its preferred format in order to add the new project.
1 parent bd5d396 commit 9987069

File tree

7 files changed

+213
-142
lines changed

7 files changed

+213
-142
lines changed

Xamarin.Android.sln

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30907.101
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32530.156
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build-Tools", "Build-Tools", "{E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}"
77
EndProject
@@ -132,7 +132,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "jnienv-gen", "external\Java
132132
EndProject
133133
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "check-boot-times", "build-tools\check-boot-times\check-boot-times.csproj", "{D28957BF-5E66-4D60-B528-22820C60AC82}"
134134
EndProject
135-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "java-interop", "external\Java.Interop\src\java-interop\java-interop.csproj", "{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}"
135+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "java-interop", "external\Java.Interop\src\java-interop\java-interop.csproj", "{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}"
136136
EndProject
137137
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Generator", "external\Java.Interop\src\Java.Interop.Tools.Generator\Java.Interop.Tools.Generator.csproj", "{2CE4CD4B-B7B7-4EAE-A9BE-2699824D6096}"
138138
EndProject
@@ -152,19 +152,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.JavaType
152152
EndProject
153153
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "relnote-gen", "tools\relnote-gen\relnote-gen.csproj", "{D8E14B43-E929-4C18-9FA6-2C3DC47EFC17}"
154154
EndProject
155-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Runtime.Environment", "external\Java.Interop\src\Java.Runtime.Environment\Java.Runtime.Environment.csproj", "{C0E44558-FEE3-4DD3-986A-3F46DD1BF41B}"
155+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Runtime.Environment", "external\Java.Interop\src\Java.Runtime.Environment\Java.Runtime.Environment.csproj", "{C0E44558-FEE3-4DD3-986A-3F46DD1BF41B}"
156+
EndProject
157+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "create-android-api", "build-tools\create-android-api\create-android-api.csproj", "{BA4D889D-066B-4C2C-A973-09E319CBC396}"
156158
EndProject
157159
Global
158-
GlobalSection(SharedMSBuildProjectFiles) = preSolution
159-
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{3f1f2f50-af1a-4a5a-bedb-193372f068d7}*SharedItemsImports = 5
160-
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{66cf299a-ce95-4131-bcd8-db66e30c4bf7}*SharedItemsImports = 5
161-
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{74598f5c-b8cc-4ce6-8ee2-ab9ca1400076}*SharedItemsImports = 13
162-
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{d1295a8f-4f42-461d-a046-564476c10002}*SharedItemsImports = 5
163-
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{d18fcf91-8876-48a0-a693-2dc1e7d3d80a}*SharedItemsImports = 5
164-
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{e0890301-f75f-40e7-b008-54c28b3ba542}*SharedItemsImports = 5
165-
external\Java.Interop\src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings.projitems*{e0890301-f75f-40e7-b008-54c28b3ba542}*SharedItemsImports = 5
166-
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{fe789f04-5e95-42c5-aef1-e33f8df06b3f}*SharedItemsImports = 13
167-
EndGlobalSection
168160
GlobalSection(SolutionConfigurationPlatforms) = preSolution
169161
Debug|AnyCPU = Debug|AnyCPU
170162
Release|AnyCPU = Release|AnyCPU
@@ -382,6 +374,10 @@ Global
382374
{D28957BF-5E66-4D60-B528-22820C60AC82}.Debug|AnyCPU.Build.0 = Debug|Any CPU
383375
{D28957BF-5E66-4D60-B528-22820C60AC82}.Release|AnyCPU.ActiveCfg = Release|Any CPU
384376
{D28957BF-5E66-4D60-B528-22820C60AC82}.Release|AnyCPU.Build.0 = Release|Any CPU
377+
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
378+
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Debug|AnyCPU.Build.0 = Debug|Any CPU
379+
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Release|AnyCPU.ActiveCfg = Release|Any CPU
380+
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Release|AnyCPU.Build.0 = Release|Any CPU
385381
{2CE4CD4B-B7B7-4EAE-A9BE-2699824D6096}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
386382
{2CE4CD4B-B7B7-4EAE-A9BE-2699824D6096}.Debug|AnyCPU.Build.0 = Debug|Any CPU
387383
{2CE4CD4B-B7B7-4EAE-A9BE-2699824D6096}.Release|AnyCPU.ActiveCfg = Release|Any CPU
@@ -406,10 +402,6 @@ Global
406402
{1A273ED2-AE84-48E9-9C23-E978C2D0CB34}.Debug|AnyCPU.Build.0 = Debug|anycpu
407403
{1A273ED2-AE84-48E9-9C23-E978C2D0CB34}.Release|AnyCPU.ActiveCfg = Release|anycpu
408404
{1A273ED2-AE84-48E9-9C23-E978C2D0CB34}.Release|AnyCPU.Build.0 = Release|anycpu
409-
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
410-
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Debug|AnyCPU.Build.0 = Debug|Any CPU
411-
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Release|AnyCPU.ActiveCfg = Release|Any CPU
412-
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B}.Release|AnyCPU.Build.0 = Release|Any CPU
413405
{DA50FC92-7FE7-48B5-BDB6-CDA57B37BB51}.Debug|AnyCPU.ActiveCfg = Debug|anycpu
414406
{DA50FC92-7FE7-48B5-BDB6-CDA57B37BB51}.Debug|AnyCPU.Build.0 = Debug|anycpu
415407
{DA50FC92-7FE7-48B5-BDB6-CDA57B37BB51}.Release|AnyCPU.ActiveCfg = Release|anycpu
@@ -426,6 +418,10 @@ Global
426418
{C0E44558-FEE3-4DD3-986A-3F46DD1BF41B}.Debug|AnyCPU.Build.0 = Debug|Any CPU
427419
{C0E44558-FEE3-4DD3-986A-3F46DD1BF41B}.Release|AnyCPU.ActiveCfg = Release|Any CPU
428420
{C0E44558-FEE3-4DD3-986A-3F46DD1BF41B}.Release|AnyCPU.Build.0 = Release|Any CPU
421+
{BA4D889D-066B-4C2C-A973-09E319CBC396}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
422+
{BA4D889D-066B-4C2C-A973-09E319CBC396}.Debug|AnyCPU.Build.0 = Debug|Any CPU
423+
{BA4D889D-066B-4C2C-A973-09E319CBC396}.Release|AnyCPU.ActiveCfg = Release|Any CPU
424+
{BA4D889D-066B-4C2C-A973-09E319CBC396}.Release|AnyCPU.Build.0 = Release|Any CPU
429425
EndGlobalSection
430426
GlobalSection(SolutionProperties) = preSolution
431427
HideSolutionNode = FALSE
@@ -485,21 +481,32 @@ Global
485481
{DE40756E-57F6-4AF2-B155-55E3A88CCED8} = {05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}
486482
{6410DA0F-5E14-4FC0-9AEE-F4C542C96C7A} = {05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}
487483
{D28957BF-5E66-4D60-B528-22820C60AC82} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
484+
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
488485
{2CE4CD4B-B7B7-4EAE-A9BE-2699824D6096} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
489486
{86A8DEFE-7ABB-4097-9389-C249581E243D} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
490487
{9A9EF774-6EA6-414F-9D2F-DCD66C56B92A} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
491488
{37FCD325-1077-4603-98E7-4509CAD648D6} = {864062D3-A415-4A6F-9324-5820237BA058}
492489
{88B746FF-8D6E-464D-9D66-FF2ECCF148E0} = {864062D3-A415-4A6F-9324-5820237BA058}
493490
{1A273ED2-AE84-48E9-9C23-E978C2D0CB34} = {864062D3-A415-4A6F-9324-5820237BA058}
494491
{DA50FC92-7FE7-48B5-BDB6-CDA57B37BB51} = {864062D3-A415-4A6F-9324-5820237BA058}
495-
{1FED3F23-1175-42AA-BE87-EF1E8DB52F8B} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
496492
{4EFCED6E-9A6B-453A-94E4-CE4B736EC684} = {864062D3-A415-4A6F-9324-5820237BA058}
497493
{D8E14B43-E929-4C18-9FA6-2C3DC47EFC17} = {864062D3-A415-4A6F-9324-5820237BA058}
498494
{C0E44558-FEE3-4DD3-986A-3F46DD1BF41B} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
495+
{BA4D889D-066B-4C2C-A973-09E319CBC396} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
499496
EndGlobalSection
500497
GlobalSection(ExtensibilityGlobals) = postSolution
501498
SolutionGuid = {53A1F287-EFB2-4D97-A4BB-4A5E145613F6}
502499
EndGlobalSection
500+
GlobalSection(SharedMSBuildProjectFiles) = preSolution
501+
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{3f1f2f50-af1a-4a5a-bedb-193372f068d7}*SharedItemsImports = 5
502+
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{66cf299a-ce95-4131-bcd8-db66e30c4bf7}*SharedItemsImports = 5
503+
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{74598f5c-b8cc-4ce6-8ee2-ab9ca1400076}*SharedItemsImports = 13
504+
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{d1295a8f-4f42-461d-a046-564476c10002}*SharedItemsImports = 5
505+
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{d18fcf91-8876-48a0-a693-2dc1e7d3d80a}*SharedItemsImports = 5
506+
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{e0890301-f75f-40e7-b008-54c28b3ba542}*SharedItemsImports = 5
507+
external\Java.Interop\src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings.projitems*{e0890301-f75f-40e7-b008-54c28b3ba542}*SharedItemsImports = 5
508+
external\Java.Interop\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{fe789f04-5e95-42c5-aef1-e33f8df06b3f}*SharedItemsImports = 13
509+
EndGlobalSection
503510
GlobalSection(MonoDevelopProperties) = preSolution
504511
Policies = $0
505512
$0.DotNetNamingPolicy = $1

build-tools/api-merge/merge-configuration.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@
2424
<File Path="api-Tiramisu.xml.in" Level="33" />
2525
</Inputs>
2626
<Outputs>
27-
<File Path="android-19\mcw\api.xml" LastLevel="19" />
28-
<File Path="android-20\mcw\api.xml" LastLevel="20" />
29-
<File Path="android-21\mcw\api.xml" LastLevel="21" />
30-
<File Path="android-22\mcw\api.xml" LastLevel="22" />
31-
<File Path="android-23\mcw\api.xml" LastLevel="23" />
32-
<File Path="android-24\mcw\api.xml" LastLevel="24" />
33-
<File Path="android-25\mcw\api.xml" LastLevel="25" />
34-
<File Path="android-26\mcw\api.xml" LastLevel="26" />
35-
<File Path="android-27\mcw\api.xml" LastLevel="27" />
36-
<File Path="android-28\mcw\api.xml" LastLevel="28" />
37-
<File Path="android-29\mcw\api.xml" LastLevel="29" />
38-
<File Path="android-30\mcw\api.xml" LastLevel="30" />
39-
<File Path="android-31\mcw\api.xml" LastLevel="31" />
40-
<File Path="android-32\mcw\api.xml" LastLevel="32" />
41-
<File Path="android-Tiramisu\mcw\api.xml" LastLevel="33" />
27+
<File Path="api-19.xml" LastLevel="19" />
28+
<File Path="api-20.xml" LastLevel="20" />
29+
<File Path="api-21.xml" LastLevel="21" />
30+
<File Path="api-22.xml" LastLevel="22" />
31+
<File Path="api-23.xml" LastLevel="23" />
32+
<File Path="api-24.xml" LastLevel="24" />
33+
<File Path="api-25.xml" LastLevel="25" />
34+
<File Path="api-26.xml" LastLevel="26" />
35+
<File Path="api-27.xml" LastLevel="27" />
36+
<File Path="api-28.xml" LastLevel="28" />
37+
<File Path="api-29.xml" LastLevel="29" />
38+
<File Path="api-30.xml" LastLevel="30" />
39+
<File Path="api-31.xml" LastLevel="31" />
40+
<File Path="api-32.xml" LastLevel="32" />
41+
<File Path="api-Tiramisu.xml" LastLevel="33" />
4242
</Outputs>
4343
</Configuration>

build-tools/api-xml-adjuster/api-xml-adjuster.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@
1616
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
1717
</ProjectReference>
1818
</ItemGroup>
19-
<Import Project="api-xml-adjuster.targets" />
2019

2120
</Project>

build-tools/api-xml-adjuster/api-xml-adjuster.targets

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)