Skip to content

Commit

Permalink
Add 'uet android keep-wireless-enabled' command
Browse files Browse the repository at this point in the history
This command should be run on a machine that has Android devices connected via USB. When run, it will switch any devices connected over USB to listen on TCP/IP 5555 so they can be used by the whole build cluster over Wi-Fi. It also forces the public/private key pair for the local user profile to be a well-known key pair, so that USB connections always have the same RSA key for devices (thus avoiding re-authorization prompts).
  • Loading branch information
hach-que committed Jan 1, 2025
1 parent e201fb4 commit 2d10bf9
Show file tree
Hide file tree
Showing 9 changed files with 447 additions and 131 deletions.
14 changes: 14 additions & 0 deletions UET/uet/Commands/Android/AndroidCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace UET.Commands.Android
{
using System.CommandLine;

internal sealed class AndroidCommand
{
public static Command CreateAndroidCommand()
{
var command = new Command("android", "Various utilities for Android development.");
command.AddCommand(AndroidKeepWirelessEnabledCommand.CreateAndroidKeepWirelessEnabledCommand());
return command;
}
}
}
361 changes: 361 additions & 0 deletions UET/uet/Commands/Android/AndroidKeepWirelessEnabledCommand.cs

Large diffs are not rendered by default.

54 changes: 5 additions & 49 deletions UET/uet/Commands/Build/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,55 +392,11 @@ public async Task<int> ExecuteAsync(InvocationContext context)
_logger.LogInformation($"--plugin-version-name: {pluginVersionName}");
_logger.LogInformation($"--plugin-version-number: {pluginVersionNumber}");

BuildEngineSpecification engineSpec;
switch (engine.Type)
{
case EngineSpecType.UEFSPackageTag:
engineSpec = BuildEngineSpecification.ForUEFSPackageTag(engine.UEFSPackageTag!);
break;
case EngineSpecType.SESNetworkShare:
engineSpec = BuildEngineSpecification.ForSESNetworkShare(engine.SESNetworkShare!);
break;
case EngineSpecType.RemoteZfs:
engineSpec = BuildEngineSpecification.ForRemoteZfs(engine.RemoteZfs!);
break;
case EngineSpecType.Version:
engineSpec = BuildEngineSpecification.ForVersionWithPath(engine.Version!, engine.Path!);
break;
case EngineSpecType.Path:
engineSpec = BuildEngineSpecification.ForAbsolutePath(engine.Path!);
break;
case EngineSpecType.GitCommit:
engineSpec = BuildEngineSpecification.ForGitCommitWithZips(
engine.GitUrl!,
engine.GitCommit!,
engine.ZipLayers,
isEngineBuild: false);
break;
case EngineSpecType.SelfEngineByBuildConfig:
var engineDistribution = distribution!.Distribution as BuildConfigEngineDistribution;
var repositoryUrl = engineDistribution!.Source.Repository;
if (!repositoryUrl.Contains("://", StringComparison.Ordinal))
{
var shortSshUrlRegex = new Regex("^(.+@)*([\\w\\d\\.]+):(.*)$");
var shortSshUrlMatch = shortSshUrlRegex.Match(repositoryUrl);
if (shortSshUrlMatch.Success)
{
repositoryUrl = $"ssh://{shortSshUrlMatch.Groups[1].Value}{shortSshUrlMatch.Groups[2].Value}/{shortSshUrlMatch.Groups[3].Value}";
}
}
// @note: This will round trip to ci-build as EngineSpecType.GitCommit
engineSpec = BuildEngineSpecification.ForGitCommitWithZips(
repositoryUrl,
engineDistribution.Source.Ref,
engineDistribution.Source.ConsoleZips,
isEngineBuild: true,
windowsSharedGitCachePath: windowsSharedGitCachePath,
macSharedGitCachePath: macSharedGitCachePath);
break;
default:
throw new NotSupportedException($"The EngineSpecType {engine.Type} is not supported by the 'build' command.");
}
var engineSpec = engine.ToBuildEngineSpecification(
"build",
distribution,
windowsSharedGitCachePath,
macSharedGitCachePath);

// @note: We need the build executor to get the pipeline ID, which is also used as an input to compute the derived storage path that's specific for this build.
var executor = executorName switch
Expand Down
2 changes: 1 addition & 1 deletion UET/uet/Commands/InstallSdks/InstallSdksCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task<int> ExecuteAsync(InvocationContext context)

if (engine.Path == null)
{
_logger.LogError("You must specify a local engine (by version number or by path) in order ot use the 'install-sdks' command.");
_logger.LogError("You must specify a local engine (by version number or by path) in order to use the 'install-sdks' command.");
return 1;
}

Expand Down
37 changes: 5 additions & 32 deletions UET/uet/Commands/Internal/CIBuild/CIBuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,38 +124,11 @@ await _storageManagement.AutoPurgeStorageAsync(
return 1;
}

BuildEngineSpecification engineSpec;
switch (engine.Type)
{
case EngineSpecType.UEFSPackageTag:
engineSpec = BuildEngineSpecification.ForUEFSPackageTag(engine.UEFSPackageTag!);
break;
case EngineSpecType.SESNetworkShare:
engineSpec = BuildEngineSpecification.ForSESNetworkShare(engine.SESNetworkShare!);
break;
case EngineSpecType.RemoteZfs:
engineSpec = BuildEngineSpecification.ForRemoteZfs(engine.RemoteZfs!);
break;
case EngineSpecType.Version:
engineSpec = BuildEngineSpecification.ForVersionWithPath(engine.Version!, engine.Path!);
break;
case EngineSpecType.Path:
engineSpec = BuildEngineSpecification.ForAbsolutePath(engine.Path!);
break;
case EngineSpecType.GitCommit:
engineSpec = BuildEngineSpecification.ForGitCommitWithZips(
engine.GitUrl!,
engine.GitCommit!,
engine.ZipLayers,
isEngineBuild: buildJson.IsEngineBuild,
windowsSharedGitCachePath: engine.WindowsSharedGitCachePath,
macSharedGitCachePath: engine.MacSharedGitCachePath);
break;
case EngineSpecType.SelfEngineByBuildConfig:
throw new InvalidOperationException("EngineSpec.TryParseEngineSpecExact should not be able to return EngineSpecType.SelfEngineByBuildConfig");
default:
throw new NotSupportedException($"The EngineSpecType {engine.Type} is not supported by the 'ci-build' command.");
}
var engineSpec = engine.ToBuildEngineSpecification(
"ci-build",
null,
engine.WindowsSharedGitCachePath,
engine.MacSharedGitCachePath);

IBuildNodeExecutor executor;
switch (executorName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,7 @@ public async Task<int> ExecuteAsync(InvocationContext context)
{
var engine = context.ParseResult.GetValueForOption(_options.Engine)!;

BuildEngineSpecification engineSpec;
switch (engine.Type)
{
case EngineSpecType.UEFSPackageTag:
engineSpec = BuildEngineSpecification.ForUEFSPackageTag(engine.UEFSPackageTag!);
break;
case EngineSpecType.SESNetworkShare:
engineSpec = BuildEngineSpecification.ForSESNetworkShare(engine.SESNetworkShare!);
break;
case EngineSpecType.RemoteZfs:
engineSpec = BuildEngineSpecification.ForRemoteZfs(engine.RemoteZfs!);
break;
case EngineSpecType.Version:
engineSpec = BuildEngineSpecification.ForVersionWithPath(engine.Version!, engine.Path!);
break;
case EngineSpecType.Path:
engineSpec = BuildEngineSpecification.ForAbsolutePath(engine.Path!);
break;
case EngineSpecType.GitCommit:
engineSpec = BuildEngineSpecification.ForGitCommitWithZips(
engine.GitUrl!,
engine.GitCommit!,
engine.ZipLayers,
isEngineBuild: false);
break;
default:
throw new NotSupportedException($"The EngineSpecType {engine.Type} is not supported by the 'cmake-uba-server' command.");
}
var engineSpec = engine.ToBuildEngineSpecification("cmake-uba-server");

await using ((await _engineWorkspaceProvider.GetEngineWorkspace(
engineSpec,
Expand Down
57 changes: 57 additions & 0 deletions UET/uet/Commands/ParameterSpec/EngineSpec.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace UET.Commands.EngineSpec
{
using Redpoint.Registry;
using Redpoint.Uet.BuildPipeline.Executors;
using Redpoint.Uet.Configuration.Engine;
using Redpoint.Uet.Configuration.Project;
using System;
Expand Down Expand Up @@ -540,5 +541,61 @@ public override string ToString()

return OriginalSpec;
}

public BuildEngineSpecification ToBuildEngineSpecification(
string commandName,
DistributionSpec? distributionSpec = null,
string? windowsSharedGitCachePath = null,
string? macSharedGitCachePath = null)
{
switch (Type)
{
case EngineSpecType.UEFSPackageTag:
return BuildEngineSpecification.ForUEFSPackageTag(UEFSPackageTag!);
case EngineSpecType.SESNetworkShare:
return BuildEngineSpecification.ForSESNetworkShare(SESNetworkShare!);
case EngineSpecType.RemoteZfs:
return BuildEngineSpecification.ForRemoteZfs(RemoteZfs!);
case EngineSpecType.Version:
return BuildEngineSpecification.ForVersionWithPath(Version!, Path!);
case EngineSpecType.Path:
return BuildEngineSpecification.ForAbsolutePath(Path!);
case EngineSpecType.GitCommit:
return BuildEngineSpecification.ForGitCommitWithZips(
GitUrl!,
GitCommit!,
ZipLayers,
isEngineBuild: false);
case EngineSpecType.SelfEngineByBuildConfig:
if (distributionSpec != null)
{
var engineDistribution = distributionSpec!.Distribution as BuildConfigEngineDistribution;
var repositoryUrl = engineDistribution!.Source.Repository;
if (!repositoryUrl.Contains("://", StringComparison.Ordinal))
{
var shortSshUrlRegex = new Regex("^(.+@)*([\\w\\d\\.]+):(.*)$");
var shortSshUrlMatch = shortSshUrlRegex.Match(repositoryUrl);
if (shortSshUrlMatch.Success)
{
repositoryUrl = $"ssh://{shortSshUrlMatch.Groups[1].Value}{shortSshUrlMatch.Groups[2].Value}/{shortSshUrlMatch.Groups[3].Value}";
}
}
// @note: This will round trip to ci-build as EngineSpecType.GitCommit
return BuildEngineSpecification.ForGitCommitWithZips(
repositoryUrl,
engineDistribution.Source.Ref,
engineDistribution.Source.ConsoleZips,
isEngineBuild: true,
windowsSharedGitCachePath: windowsSharedGitCachePath,
macSharedGitCachePath: macSharedGitCachePath);
}
else
{
throw new NotSupportedException($"The EngineSpecType {Type} is not supported by the '{commandName}' command.");
}
default:
throw new NotSupportedException($"The EngineSpecType {Type} is not supported by the '{commandName}' command.");
}
}
}
}
22 changes: 1 addition & 21 deletions UET/uet/Commands/Test/TestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,7 @@ public async Task<int> ExecuteAsync(InvocationContext context)
_logger.LogInformation($"--prefix: {prefix}");
_logger.LogInformation($"--name: {name}");

BuildEngineSpecification engineSpec;
switch (engine.Type)
{
case EngineSpecType.UEFSPackageTag:
engineSpec = BuildEngineSpecification.ForUEFSPackageTag(engine.UEFSPackageTag!);
break;
case EngineSpecType.SESNetworkShare:
engineSpec = BuildEngineSpecification.ForSESNetworkShare(engine.SESNetworkShare!);
break;
case EngineSpecType.RemoteZfs:
engineSpec = BuildEngineSpecification.ForRemoteZfs(engine.RemoteZfs!);
break;
case EngineSpecType.Version:
engineSpec = BuildEngineSpecification.ForVersionWithPath(engine.Version!, engine.Path!);
break;
case EngineSpecType.Path:
engineSpec = BuildEngineSpecification.ForAbsolutePath(engine.Path!);
break;
default:
throw new NotSupportedException();
}
var engineSpec = engine.ToBuildEngineSpecification("test");

// @note: We always use the local executor for this test command.
var executor = _localBuildExecutorFactory.CreateExecutor();
Expand Down
2 changes: 2 additions & 0 deletions UET/uet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Diagnostics;
using System.Text.Json.Nodes;
using System.Text.RegularExpressions;
using UET.Commands.Android;
using UET.Commands.AppleCert;
using UET.Commands.Build;
using UET.Commands.CMake;
Expand Down Expand Up @@ -47,6 +48,7 @@
rootCommand.AddCommand(UefsCommand.CreateUefsCommand());
rootCommand.AddCommand(TransferCommand.CreateTransferCommand());
rootCommand.AddCommand(AppleCertCommand.CreateAppleCertCommand());
rootCommand.AddCommand(AndroidCommand.CreateAndroidCommand());
rootCommand.AddCommand(CMakeCommand.CreateCMakeCommand());
rootCommand.AddCommand(InternalCommand.CreateInternalCommand(globalCommands));

Expand Down

0 comments on commit 2d10bf9

Please sign in to comment.