-
Notifications
You must be signed in to change notification settings - Fork 553
Add test for Binding Projects Incremental Build #8706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ | |
using System.Linq; | ||
using System.Xml; | ||
using System.Xml.Linq; | ||
using System.Xml.XPath; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
using Microsoft.Android.Build.Tasks; | ||
|
||
namespace Xamarin.Android.Tasks | ||
|
@@ -67,6 +69,10 @@ public class BindingsGenerator : AndroidDotnetToolTask | |
|
||
public bool UseJavaLegacyResolver { get; set; } | ||
|
||
public string GeneratedFileListFile { get; set; } | ||
[Output] | ||
public ITaskItem [] GeneratedFiles { get; set; } = Array.Empty<ITaskItem> (); | ||
|
||
private List<Tuple<string, string>> transform_files = new List<Tuple<string,string>> (); | ||
|
||
public override bool RunTask () | ||
|
@@ -133,7 +139,20 @@ public override bool RunTask () | |
if (Log.HasLoggedErrors) | ||
return false; | ||
|
||
return base.RunTask (); | ||
var result = base.RunTask (); | ||
List<ITaskItem> files = new List<ITaskItem> (); | ||
if (result && GeneratedFileListFile != null && File.Exists (GeneratedFileListFile)) { | ||
var doc = XDocument.Load (GeneratedFileListFile); | ||
var compileItems = doc.XPathSelectElements ("//Project/ItemGroup/Compile"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised that this works, given that the
Wouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It worked in my tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why it worked in the tests; if I apply this patch: diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs
index a3ee0e211..7b58ed3f4 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs
@@ -142,11 +142,13 @@ namespace Xamarin.Android.Tasks
var result = base.RunTask ();
List<ITaskItem> files = new List<ITaskItem> ();
if (result && GeneratedFileListFile != null && File.Exists (GeneratedFileListFile)) {
+ Log.LogDebugMessage ($"# jonp: SHOULD process {GeneratedFileListFile}");
var doc = XDocument.Load (GeneratedFileListFile);
var compileItems = doc.XPathSelectElements ("//Project/ItemGroup/Compile");
foreach (var item in compileItems) {
var file = item.Attribute ("Include");
if (file != null && File.Exists (file.Value)) {
+ Log.LogDebugMessage ($"# jonp: found //Compile/@Include value: {file.Value}");
files.Add (new TaskItem (file.Value));
}
} then build this branch locally, and do the equivalent of: % dotnet new androidlib
% cat > Example.java <<EOF
package e;
public class Example {
public static void e() {
}
}
EOF
% dotnet build -v:diag > b.txt Then I see:
but I don't see The contents of <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4;ANDROID_5;ANDROID_6;ANDROID_7;ANDROID_8;ANDROID_9;ANDROID_10;ANDROID_11;ANDROID_12;ANDROID_13;ANDROID_14;ANDROID_15;ANDROID_16;ANDROID_17;ANDROID_18;ANDROID_19;ANDROID_20;ANDROID_21;ANDROID_22;ANDROID_23;ANDROID_24;ANDROID_25;ANDROID_26;ANDROID_27;ANDROID_28;ANDROID_29;ANDROID_30;ANDROID_31;ANDROID_32;ANDROID_33;ANDROID_34</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)E.Example.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. …so I use this stackoverflow answer to add use of an void AddGeneratedFiles ()
{
List<ITaskItem> files = new List<ITaskItem> ();
Log.LogDebugMessage ($"# jonp: SHOULD process {GeneratedFileListFile}");
var doc = XDocument.Load (GeneratedFileListFile);
var nsmgr = new XmlNamespaceManager(new NameTable());
nsmgr.AddNamespace ("msb", "http://schemas.microsoft.com/developer/msbuild/2003");
var compileItems = doc.XPathSelectElements ("//msb:Project/msb:ItemGroup/msb:Compile", nsmgr);
foreach (var item in compileItems) {
var file = item.Attribute ("Include");
if (file != null && File.Exists (file.Value)) {
Log.LogDebugMessage ($"# jonp: found //Compile/@Include value: {file.Value}");
files.Add (new TaskItem (file.Value));
}
}
GeneratedFiles = files.ToArray ();
} and realize, to my horror, that it still doesn't work, because of the This in turn means that, as-is, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. …which is a long-winded way of explaining that I think this doesn't work, and is effectively dead (unexecuted) code. I'm trying to remove it; let's see if anything breaks. |
||
foreach (var item in compileItems) { | ||
var file = item.Attribute ("Include"); | ||
if (file != null && File.Exists (file.Value)) { | ||
files.Add (new TaskItem (file.Value)); | ||
} | ||
} | ||
} | ||
GeneratedFiles = files.ToArray (); | ||
return result; | ||
} | ||
|
||
void WriteLine (StreamWriter sw, string line) | ||
|
Uh oh!
There was an error while loading. Please reload this page.