Skip to content
Closed
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
1 change: 1 addition & 0 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\xamarin.find')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\xamarin.stat')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\xamarin.cp')" />
<_MSBuildFiles Include="@(AndroidSupportedTargetJitAbi->'$(MicrosoftAndroidSdkOutDir)lib\%(Identity)\maui.link')" />
</ItemGroup>
<!-- end monodroid -->
<Target Name="ConstructInstallerItems"
Expand Down
52 changes: 52 additions & 0 deletions src/Xamarin.Android.Build.Debugging.Tasks/Tasks/FastDeploy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ private class DiagnosticData {
{ "deploy.supports.fastdev", "True" },
{ "deploy.systemapp", "False" },
{ "deploy.duration.ms", "0" },
{ "deploy.fastdeploy.tools.install.ms", "" },
{ "deploy.fastdeploy.remote.mkdir.ms", "" },
{ "deploy.fastdeploy.remote.find.ms", "" },
{ "deploy.fastdeploy.compare.ms", "" },
{ "deploy.fastdeploy.copy.ms", "" },
{ "deploy.fastdeploy.environment.copy.ms", "" },
{ "deploy.fastdeploy.stale.remove.ms", "" },
{ "deploy.fastdeploy.changed.files", "" },
{ "deploy.fastdeploy.skipped.files", "" },
{ "deploy.fastdeploy.stale.files", "" },
{ "pii.deploy.error", "" },
{ "pii.deploy.file", "" },
};
Expand Down Expand Up @@ -325,9 +335,12 @@ public async Task RunInstall ()
if (EmbedAssembliesIntoApk)
return;

var phase = Stopwatch.StartNew ();
if (!await InstallFastDevTools (ToolsFullPath)) {
SetDiagnosticElapsed ("deploy.fastdeploy.tools.install.ms", phase);
return;
}
SetDiagnosticElapsed ("deploy.fastdeploy.tools.install.ms", phase);

if (FastDevFiles?.Any () ?? false) {
await TerminateApp ();
Expand Down Expand Up @@ -665,6 +678,7 @@ protected async Task DeployFastDevFiles (string toolPath, string overridePath)
LZ4Level lz4level = LZ4Level.L03_HC;

LogDiagnostic ("Calculating subdirectories");
var phase = Stopwatch.StartNew ();
HashSet<string> directories = new HashSet<string> ();
directories.Add (overridePath);
foreach (var file in FastDevFiles) {
Expand Down Expand Up @@ -694,13 +708,19 @@ protected async Task DeployFastDevFiles (string toolPath, string overridePath)
args.Add (dir);
}
await Device.RunAs (packageInfo, args);
SetDiagnosticElapsed ("deploy.fastdeploy.remote.mkdir.ms", phase);

phase.Restart ();
string filelist = await Device.RunAs (packageInfo, $"{toolPath}/{FastDevFindTool}", DiagnosticLogging ? "-vd" : "-v", overridePath);
SetDiagnosticElapsed ("deploy.fastdeploy.remote.find.ms", phase);
LogDiagnostic ($"{FastDevFindTool}: {filelist}");
string [] files = Array.Empty<string> ();
if (!(filelist.IndexOf ("error:", StringComparison.OrdinalIgnoreCase) >= 0)) {
files = filelist.Split (new char [] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
}
int changedFiles = 0;
int skippedFiles = 0;
var compareWatch = Stopwatch.StartNew ();
Dictionary<string, (long size, DateTimeOffset mtime)> fileData = new Dictionary<string, (long, DateTimeOffset)> ();
foreach (var file in files) { // file size mtime
if (file.IndexOf ("\t") == -1) {
Expand Down Expand Up @@ -730,13 +750,15 @@ protected async Task DeployFastDevFiles (string toolPath, string overridePath)
foreach (var file in FastDevFiles) {
if (!File.Exists (file.ItemSpec)) {
LogDebugMessage ($"File '{file.ItemSpec}' does not exists. Skipping.");
skippedFiles++;
continue;
}
StartTiming ();
if (Path.GetExtension (file.ItemSpec) == ".so") {
string abi = AndroidRidAbiHelper.GetNativeLibraryAbi (file);
if (abi != PrimaryCpuAbi) {
LogDebugMessageWithTiming ($"NotifySync SkipCopyFile {file.ItemSpec} abi not suitable for this device.");
skippedFiles++;
continue;
}
}
Expand All @@ -758,12 +780,18 @@ protected async Task DeployFastDevFiles (string toolPath, string overridePath)
if (!modified) {
LogDebugMessageWithTiming ($"NotifySync SkipCopyFile {file.ItemSpec}=>{targetPath} file is up to date.");
fileData.Remove (targetPath);
skippedFiles++;
continue;
}
changedFiles++;
compareWatch.Stop ();
phase.Restart ();
if (!await DeployFileWithFastDevTool (file, toolPath, overridePath, lz4level, modifiedDateTime)) {
diagnosticData.SetProperty ("deploy.result", "Failed");
return;
}
AddDiagnosticElapsed ("deploy.fastdeploy.copy.ms", phase);
compareWatch.Start ();
LogDebugMessageWithTiming ($"NotifySync CopyFile {file.ItemSpec}.");
LogDiagnostic ($"Local Modified Time '{modifiedDateTime.ToUnixTimeMilliseconds ()}' is newer than '{remoteDateTime.ToUnixTimeMilliseconds ()}'.");
fileData.Remove (targetPath);
Expand All @@ -774,15 +802,26 @@ protected async Task DeployFastDevFiles (string toolPath, string overridePath)
if (fileData.ContainsKey (targetPath)) {
remoteDateTime = fileData [targetPath].mtime;
}
compareWatch.Stop ();
phase.Restart ();
await DeployEnvironmentFiles (EnvironmentFiles, toolPath, overridePath, targetPath, remoteDateTime);
AddDiagnosticElapsed ("deploy.fastdeploy.environment.copy.ms", phase);
compareWatch.Start ();
fileData.Remove (targetPath);
}
compareWatch.Stop ();
SetDiagnosticElapsed ("deploy.fastdeploy.compare.ms", compareWatch);
diagnosticData.SetProperty ("deploy.fastdeploy.changed.files", changedFiles);
diagnosticData.SetProperty ("deploy.fastdeploy.skipped.files", skippedFiles);
diagnosticData.SetProperty ("deploy.fastdeploy.stale.files", fileData.Count);
phase.Restart ();
foreach (var file in fileData.Keys) {
// we need to remove unknown files from the .__override__ path
string targetFile = $"{file.Replace ("./", "")}";
LogDebugMessage ($"Remove redundant file {OverrideFullPath}/{targetFile}");
await Device.RunAs (packageInfo, "rm", "-Rf", $"{OverrideFullPath}/{targetFile}");
}
SetDiagnosticElapsed ("deploy.fastdeploy.stale.remove.ms", phase);
// clean up the temp folder if we are not using the xamarin.sync tool
if (!packageInfo.SupportsFastDev)
await Device.RunShellCommand ("rm", "-Rf", XAToolsTempPath);
Expand Down Expand Up @@ -989,6 +1028,19 @@ bool RaiseRunAsError (string error)

string GetFullPath (string dir) => Path.IsPathRooted (dir) ? dir : Path.GetFullPath (Path.Combine (WorkingDirectory, dir));

void SetDiagnosticElapsed (string key, Stopwatch stopwatch)
{
diagnosticData.SetProperty (key, stopwatch.ElapsedMilliseconds);
}

void AddDiagnosticElapsed (string key, Stopwatch stopwatch)
{
if (!long.TryParse (diagnosticData.Properties [key], out long current)) {
current = 0;
}
diagnosticData.SetProperty (key, current + stopwatch.ElapsedMilliseconds);
}

static string GetErrorCode (string message)
{
foreach (var errorCode in error_codes)
Expand Down
Loading
Loading