-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all of assembly store building code to a separate class
This makes it possible to build assembly stores easily outside `BuildApk`
- Loading branch information
Showing
2 changed files
with
87 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Xamarin.Android.Build.Tasks/Utilities/AssemblyStoreBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
using Microsoft.Android.Build.Tasks; | ||
using Microsoft.Build.Utilities; | ||
using Microsoft.Build.Framework; | ||
using Xamarin.Android.Tools; | ||
|
||
namespace Xamarin.Android.Tasks; | ||
|
||
class AssemblyStoreBuilder | ||
{ | ||
readonly TaskLoggingHelper log; | ||
readonly AssemblyStoreGenerator storeGenerator; | ||
|
||
public AssemblyStoreBuilder (TaskLoggingHelper log) | ||
{ | ||
this.log = log; | ||
storeGenerator = new (log); | ||
} | ||
|
||
public void AddAssembly (string assemblySourcePath, ITaskItem assemblyItem, bool includeDebugSymbols) | ||
{ | ||
var storeAssemblyInfo = new AssemblyStoreAssemblyInfo (assemblySourcePath, assemblyItem); | ||
|
||
// Try to add config if exists. We use assemblyItem, because `sourcePath` might refer to a compressed | ||
// assembly file in a different location. | ||
var config = Path.ChangeExtension (assemblyItem.ItemSpec, "dll.config"); | ||
if (File.Exists (config)) { | ||
storeAssemblyInfo.ConfigFile = new FileInfo (config); | ||
} | ||
|
||
if (includeDebugSymbols) { | ||
string debugSymbolsPath = Path.ChangeExtension (assemblyItem.ItemSpec, "pdb"); | ||
if (File.Exists (debugSymbolsPath)) { | ||
storeAssemblyInfo.SymbolsFile = new FileInfo (debugSymbolsPath); | ||
} | ||
} | ||
|
||
storeGenerator.Add (storeAssemblyInfo); | ||
} | ||
|
||
public Dictionary<AndroidTargetArch, string> Generate (string outputDirectoryPath) => storeGenerator.Generate (outputDirectoryPath); | ||
} |