Skip to content
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

Revert "[Xamarin.Android.Build.Tasks] Fix Facade assembly deployment" #357

Merged
merged 1 commit into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions src/Xamarin.Android.Build.Tasks/Tasks/ResolveAssemblies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public class ResolveAssemblies : Task
[Required]
public string ReferenceAssembliesDirectory { get; set; }

public ITaskItem[] DesignTimeFacadeDirectories { get; set; }

public string I18nAssemblies { get; set; }
public string LinkMode { get; set; }

Expand Down Expand Up @@ -58,12 +56,11 @@ bool Execute (DirectoryAssemblyResolver resolver)
Log.LogDebugMessage (" I18nAssemblies: {0}", I18nAssemblies);
Log.LogDebugMessage (" LinkMode: {0}", LinkMode);
Log.LogDebugTaskItems (" Assemblies:", Assemblies);
Log.LogDebugTaskItems (" DesignTimeFacadeDirectories:", DesignTimeFacadeDirectories);

foreach (var dir in ReferenceAssembliesDirectory.Split (new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
resolver.SearchDirectories.Add (dir);

var assemblies = new HashSet<ITaskItem> (new ITaskItemEqualityComparer ());
var assemblies = new HashSet<string> ();

var topAssemblyReferences = new List<AssemblyDefinition> ();

Expand All @@ -79,7 +76,7 @@ bool Execute (DirectoryAssemblyResolver resolver)
if (assemblyDef == null)
throw new InvalidOperationException ("Failed to load assembly " + assembly.ItemSpec);
topAssemblyReferences.Add (assemblyDef);
assemblies.Add (new TaskItem (Path.GetFullPath (assemblyDef.MainModule.FullyQualifiedName)));
assemblies.Add (Path.GetFullPath (assemblyDef.MainModule.FullyQualifiedName));
}
} catch (Exception ex) {
Log.LogError ("Exception while loading assemblies: {0}", ex);
Expand All @@ -96,8 +93,8 @@ bool Execute (DirectoryAssemblyResolver resolver)
// Add I18N assemblies if needed
AddI18nAssemblies (resolver, assemblies);

ResolvedAssemblies = assemblies.ToArray ();
ResolvedSymbols = assemblies.Select (a => new TaskItem (a + ".mdb")).Where (a => File.Exists (a.ItemSpec)).ToArray ();
ResolvedAssemblies = assemblies.Select (a => new TaskItem (a)).ToArray ();
ResolvedSymbols = assemblies.Select (a => a + ".mdb").Where (a => File.Exists (a)).Select (a => new TaskItem (a)).ToArray ();
ResolvedFrameworkAssemblies = ResolvedAssemblies.Where (p => MonoAndroidHelper.IsFrameworkAssembly (p.ItemSpec, true)).ToArray ();
ResolvedUserAssemblies = ResolvedAssemblies.Where (p => !MonoAndroidHelper.IsFrameworkAssembly (p.ItemSpec, true)).ToArray ();
ResolvedDoNotPackageAttributes = do_not_package_atts.ToArray ();
Expand All @@ -113,14 +110,13 @@ bool Execute (DirectoryAssemblyResolver resolver)
readonly List<string> do_not_package_atts = new List<string> ();
int indent = 2;

void AddAssemblyReferences (DirectoryAssemblyResolver resolver, ICollection<ITaskItem> assemblies, AssemblyDefinition assembly, bool topLevel)
void AddAssemblyReferences (DirectoryAssemblyResolver resolver, ICollection<string> assemblies, AssemblyDefinition assembly, bool topLevel)
{
var fqname = assembly.MainModule.FullyQualifiedName;
var fullPath = Path.GetFullPath (fqname);
var item = new TaskItem (fullPath);

// Don't repeat assemblies we've already done
if (!topLevel && assemblies.Contains (item))
if (!topLevel && assemblies.Contains (fullPath))
return;

foreach (var att in assembly.CustomAttributes.Where (a => a.AttributeType.FullName == "Java.Interop.DoNotPackageAttribute")) {
Expand All @@ -133,11 +129,8 @@ void AddAssemblyReferences (DirectoryAssemblyResolver resolver, ICollection<ITas
Log.LogMessage (MessageImportance.Low, "{0}Adding assembly reference for {1}, recursively...", new string (' ', indent), assembly.Name);
indent += 2;
// Add this assembly
if (!topLevel && assemblies.All (a => new AssemblyNameDefinition (a.ItemSpec, null).Name != assembly.Name.Name)) {
var path = Path.GetDirectoryName (fullPath);
item.SetMetadata ("ResolvedFrom", DesignTimeFacadeDirectories.Any (x => Path.GetDirectoryName (x.ItemSpec).StartsWith (Path.GetDirectoryName (path))) ? "ImplicitlyExpandDesignTimeFacades" : "");
assemblies.Add (item);
}
if (!topLevel && assemblies.All (a => new AssemblyNameDefinition (a, null).Name != assembly.Name.Name))
assemblies.Add (fullPath);

// Recurse into each referenced assembly
foreach (AssemblyNameReference reference in assembly.MainModule.AssemblyReferences) {
Expand All @@ -159,7 +152,7 @@ static LinkModes ParseLinkMode (string linkmode)
return mode;
}

void AddI18nAssemblies (DirectoryAssemblyResolver resolver, ICollection<ITaskItem> assemblies)
void AddI18nAssemblies (DirectoryAssemblyResolver resolver, ICollection<string> assemblies)
{
var i18n = Linker.ParseI18nAssemblies (I18nAssemblies);
var link = ParseLinkMode (LinkMode);
Expand All @@ -186,10 +179,10 @@ void AddI18nAssemblies (DirectoryAssemblyResolver resolver, ICollection<ITaskIte
assemblies.Add (ResolveI18nAssembly (resolver, "I18N.West"));
}

ITaskItem ResolveI18nAssembly (DirectoryAssemblyResolver resolver, string name)
string ResolveI18nAssembly (DirectoryAssemblyResolver resolver, string name)
{
var assembly = resolver.Resolve (AssemblyNameReference.Parse (name));
return new TaskItem (Path.GetFullPath (assembly.MainModule.FullyQualifiedName));
return Path.GetFullPath (assembly.MainModule.FullyQualifiedName);
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@
<Compile Include="Utilities\Files.cs">
<Link>Utilities\Files.cs</Link>
</Compile>
<Compile Include="Utilities\ITaskItemEqualityComparer.cs">
<Link>Utilities\ITaskItemEqualityComparer.cs</Link>
</Compile>
<Compile Include="$(LinkerSourceFullPath)\tuner\Mono.Tuner\ApplyPreserveAttributeBase.cs">
<Link>Linker\Mono.Tuner\ApplyPreserveAttributeBase.cs</Link>
</Compile>
Expand Down
25 changes: 4 additions & 21 deletions src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,6 @@ because xbuild doesn't support framework reference assemblies.
_GetAdditionalResourcesFromAssemblies;
_CreateAdditionalResourceCache;
_GenerateAndroidResourceDir;
_ValidateAndroidPackageProperties;
</_UpdateAndroidResgenDependsOnTargets>
</PropertyGroup>

Expand Down Expand Up @@ -1394,7 +1393,6 @@ because xbuild doesn't support framework reference assemblies.
Assemblies="$(OutDir)$(TargetFileName);@(FilteredAssemblies)"
I18nAssemblies="$(MandroidI18n)"
LinkMode="$(AndroidLinkMode)"
DesignTimeFacadeDirectories="@(DesignTimeFacadeDirectories)"
ReferenceAssembliesDirectory="$(TargetFrameworkDirectory)">
<Output TaskParameter="ResolvedAssemblies" ItemName="ResolvedAssemblies" />
<Output TaskParameter="ResolvedUserAssemblies" ItemName="ResolvedUserAssemblies" />
Expand Down Expand Up @@ -1600,7 +1598,6 @@ because xbuild doesn't support framework reference assemblies.
<Target Name="_PrepareAssemblies" DependsOnTargets="$(_PrepareAssembliesDependsOnTargets)">
<!-- Update our assembly lists to the copies for linking. We also need to verify
they still exist cause linking will delete them if they aren't used -->

<GetFilesThatExist
Condition="'$(AndroidLinkMode)' != 'None'"
Files="@(ResolvedAssemblies->'$(MonoAndroidIntermediateAssetsDir)%(Filename)%(Extension)')">
Expand All @@ -1627,42 +1624,36 @@ because xbuild doesn't support framework reference assemblies.

<CreateItem
Include="@(ResolvedAssemblies->'$(MonoAndroidIntermediateAssemblyDir)%(Filename)%(Extension)')"
PreserveExistingMetadata="True"
Condition="'$(AndroidLinkMode)' == 'None'">
<Output TaskParameter="Include" ItemName="_ResolvedAssemblies" />
</CreateItem>

<CreateItem
Include="@(ResolvedSymbols->'$(MonoAndroidIntermediateAssemblyDir)%(Filename)%(Extension)')"
PreserveExistingMetadata="True"
Condition="'$(AndroidLinkMode)' == 'None'">
<Output TaskParameter="Include" ItemName="_ResolvedSymbols" />
</CreateItem>

<CreateItem
Include="@(ResolvedUserAssemblies->'$(MonoAndroidIntermediateAssemblyDir)%(Filename)%(Extension)')"
PreserveExistingMetadata="True"
Condition="'$(AndroidLinkMode)' == 'None'">
<Output TaskParameter="Include" ItemName="_ResolvedUserAssemblies" />
</CreateItem>

<CreateItem
Include="@(ResolvedFrameworkAssemblies)"
PreserveExistingMetadata="True"
Condition="'$(AndroidLinkMode)' == 'None'">
<Output TaskParameter="Include" ItemName="_ResolvedFrameworkAssemblies" />
</CreateItem>

<CreateItem
Include="@(_ResolvedFrameworkAssemblies)"
PreserveExistingMetadata="True"
Condition="'$(AndroidLinkMode)' == 'None' OR '$(AndroidUseSharedRuntime)' == 'true'">
<Output TaskParameter="Include" ItemName="_ShrunkFrameworkAssemblies" />
</CreateItem>

<CreateItem
Include="@(_ResolvedFrameworkAssemblies->'$(MonoAndroidIntermediateAssetsDir)shrunk\%(Filename)%(Extension)')"
PreserveExistingMetadata="True"
Condition="'$(AndroidLinkMode)' != 'None' AND '$(AndroidUseSharedRuntime)' != 'true'">
<Output TaskParameter="Include" ItemName="_ShrunkFrameworkAssemblies" />
</CreateItem>
Expand Down Expand Up @@ -1728,7 +1719,6 @@ because xbuild doesn't support framework reference assemblies.
_CheckDuplicateJavaLibraries;
_GetAdditionalResourcesFromAssemblies;
_CreateAdditionalResourceCache;
_DefineBuildTargetAbis;
</_CreateBaseApkDependsOnTargets>
<_CreateBaseApkInputs>
$(MSBuildAllProjects)
Expand Down Expand Up @@ -2145,12 +2135,6 @@ because xbuild doesn't support framework reference assemblies.
<Touch Files="$(_AndroidApkPerAbiFlagFile)" Condition="'$(AndroidCreatePackagePerAbi)' == 'true'" AlwaysCreate="True" />
</Target>

<Target Name="FilterDesignTimeFacades">
<ItemGroup>
<_FilteredShrunkFrameworkAssemblies Include="@(_ShrunkFrameworkAssemblies)" Condition="'%(_ShrunkFrameworkAssemblies.ResolvedFrom)' != 'ImplicitlyExpandDesignTimeFacades'" />
</ItemGroup>
</Target>

<PropertyGroup>
<_PrepareBuildApkDependsOnTargets>
_SetLatestTargetFrameworkVersion;
Expand All @@ -2167,7 +2151,6 @@ because xbuild doesn't support framework reference assemblies.
_ResolveSatellitePaths;
_CheckApkPerAbiFlag
;_LintChecks
;FilterDesignTimeFacades
</_PrepareBuildApkDependsOnTargets>
</PropertyGroup>

Expand Down Expand Up @@ -2203,7 +2186,7 @@ because xbuild doesn't support framework reference assemblies.
SupportedAbis="$(_BuildTargetAbis)"
AndroidSequencePointsMode="$(_SequencePointsMode)"
AotAdditionalArguments="$(AndroidAotAdditionalArguments)"
ResolvedAssemblies="@(_ResolvedUserAssemblies);@(_FilteredShrunkFrameworkAssemblies)"
ResolvedAssemblies="@(_ResolvedUserAssemblies);@(_ShrunkFrameworkAssemblies)"
AotOutputDirectory="$(_AndroidAotBinDirectory)"
IntermediateAssemblyDir="$(MonoAndroidIntermediateAssemblyDir)"
LinkMode="$(AndroidLinkMode)"
Expand All @@ -2217,14 +2200,14 @@ because xbuild doesn't support framework reference assemblies.
Condition=" '$(AndroidAotMode)' == 'Hybrid' And '$(AotAssemblies)' == 'True' "
AndroidAotMode="$(AndroidAotMode)"
ToolPath="$(_MonoAndroidToolsDirectory)"
ResolvedAssemblies="@(_FilteredShrunkFrameworkAssemblies)">
ResolvedAssemblies="@(_ResolvedAssemblies)">
</CilStrip>

<!-- Bundle the assemblies into native libraries in the apk -->
<MakeBundleNativeCodeExternal
Condition="'$(BundleAssemblies)' == 'True'"
AndroidNdkDirectory="$(_AndroidNdkDirectory)"
Assemblies="@(_ResolvedUserAssemblies);@(_AndroidResolvedSatellitePaths);@(_FilteredShrunkFrameworkAssemblies)"
Assemblies="@(_ResolvedUserAssemblies);@(_AndroidResolvedSatellitePaths);@(_ShrunkFrameworkAssemblies)"
IncludePath="$(MonoAndroidIncludeDirectory)"
SupportedAbis="$(_BuildTargetAbis)"
TempOutputPath="$(IntermediateOutputPath)"
Expand All @@ -2242,7 +2225,7 @@ because xbuild doesn't support framework reference assemblies.
EmbedAssemblies="$(EmbedAssembliesIntoApk)"
Environments="@(AndroidEnvironment);@(LibraryEnvironments)"
ResolvedUserAssemblies="@(_ResolvedUserAssemblies);@(_AndroidResolvedSatellitePaths)"
ResolvedFrameworkAssemblies="@(_FilteredShrunkFrameworkAssemblies)"
ResolvedFrameworkAssemblies="@(_ShrunkFrameworkAssemblies)"
NativeLibraries="@(AndroidNativeLibrary)"
AdditionalNativeLibraryReferences="@(_AdditionalNativeLibraryReferences)"
EmbeddedNativeLibraryAssemblies="$(OutDir)$(TargetFileName);@(ReferencePath);@(ReferenceDependencyPaths)"
Expand Down