You've already forked Commercialization.topon
release: 1.4.15
This commit is contained in:
@@ -11,17 +11,19 @@ namespace Topon_Adapter.Editor
|
||||
{
|
||||
public bool enableDebuggerUI = false;
|
||||
public bool forceVerbtoUtilVersion = true;
|
||||
public string verbtoUtilDependency = ToponBuildSettingsStore.DefaultVerbtoUtilDependency;
|
||||
public bool stripResolvedDebuggerArtifacts = true;
|
||||
}
|
||||
|
||||
internal static class ToponBuildSettingsStore
|
||||
{
|
||||
public const string DefaultVerbtoUtilDependency = "com.verbto.tools:util:1.1.3";
|
||||
|
||||
private const string ActiveBuildSessionKey = "Commercialization.Topon.ActiveBuildSettings";
|
||||
private const string SettingsFileSuffix = "_topon_build_settings.json";
|
||||
private const string BuildConfigsFolder = "BuildConfigs";
|
||||
private const string DebuggerPackageMarker = "com.anythink.sdk:debugger-ui";
|
||||
private const string VerbtoPackageMarker = "com.verbto.tools:util";
|
||||
private const string DebuggerRepositoryMarker = "jfrog.anythinktech.com/artifactory/debugger";
|
||||
|
||||
[Serializable]
|
||||
private sealed class ActiveBuildSettings
|
||||
@@ -35,6 +37,16 @@ namespace Topon_Adapter.Editor
|
||||
return new ToponBuildSettings();
|
||||
}
|
||||
|
||||
public static string GetVerbtoUtilDependency(ToponBuildSettings settings)
|
||||
{
|
||||
if (settings == null || string.IsNullOrWhiteSpace(settings.verbtoUtilDependency))
|
||||
{
|
||||
return DefaultVerbtoUtilDependency;
|
||||
}
|
||||
|
||||
return settings.verbtoUtilDependency.Trim();
|
||||
}
|
||||
|
||||
public static ToponBuildSettings LoadForProfileName(string profileName, string repositoryRoot)
|
||||
{
|
||||
var settings = CreateDefault();
|
||||
@@ -47,6 +59,7 @@ namespace Topon_Adapter.Editor
|
||||
try
|
||||
{
|
||||
JsonUtility.FromJsonOverwrite(File.ReadAllText(path), settings);
|
||||
Normalize(settings);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -62,6 +75,10 @@ namespace Topon_Adapter.Editor
|
||||
{
|
||||
settings = CreateDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
Normalize(settings);
|
||||
}
|
||||
|
||||
var path = GetSettingsPath(profileName, repositoryRoot);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
@@ -111,6 +128,7 @@ namespace Topon_Adapter.Editor
|
||||
{
|
||||
return CreateDefault();
|
||||
}
|
||||
Normalize(activeSettings.settings);
|
||||
|
||||
var activatedAt = new DateTime(activeSettings.utcTicks, DateTimeKind.Utc);
|
||||
if (DateTime.UtcNow - activatedAt > TimeSpan.FromHours(6))
|
||||
@@ -143,9 +161,35 @@ namespace Topon_Adapter.Editor
|
||||
}
|
||||
|
||||
var content = File.ReadAllText(path);
|
||||
if (content.Contains(DebuggerPackageMarker) ||
|
||||
content.Contains(VerbtoPackageMarker) ||
|
||||
content.Contains(DebuggerRepositoryMarker))
|
||||
if (content.Contains(DebuggerPackageMarker))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool HasUnforcedVerbtoUtilOutput(string repositoryRoot, string expectedDependency)
|
||||
{
|
||||
expectedDependency = NormalizeDependency(expectedDependency);
|
||||
foreach (var path in GetResolverOutputPaths(repositoryRoot))
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var content = File.ReadAllText(path);
|
||||
if (content.Contains(VerbtoPackageMarker) && !content.Contains(expectedDependency))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var path in FindResolvedVerbtoUtilArtifacts(repositoryRoot))
|
||||
{
|
||||
if (!IsExpectedVerbtoUtilArtifactFileName(Path.GetFileName(path), expectedDependency))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -180,6 +224,32 @@ namespace Topon_Adapter.Editor
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IReadOnlyList<string> FindResolvedVerbtoUtilArtifacts(string repositoryRoot)
|
||||
{
|
||||
var result = new List<string>();
|
||||
var root = ResolveRepositoryRoot(repositoryRoot);
|
||||
if (string.IsNullOrEmpty(root))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var androidPluginPath = Path.Combine(root, "Assets", "Plugins", "Android");
|
||||
if (!Directory.Exists(androidPluginPath))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var path in Directory.GetFiles(androidPluginPath, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
if (IsVerbtoUtilArtifactFileName(Path.GetFileName(path)))
|
||||
{
|
||||
result.Add(path);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static bool IsDebuggerArtifactFileName(string fileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
@@ -187,8 +257,33 @@ namespace Topon_Adapter.Editor
|
||||
return false;
|
||||
}
|
||||
|
||||
return fileName.StartsWith("com.anythink.sdk.debugger-ui-", StringComparison.OrdinalIgnoreCase) ||
|
||||
fileName.StartsWith("com.verbto.tools.util-", StringComparison.OrdinalIgnoreCase);
|
||||
return fileName.StartsWith("com.anythink.sdk.debugger-ui-", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
internal static bool IsVerbtoUtilArtifactFileName(string fileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return fileName.StartsWith("com.verbto.tools.util-", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
internal static bool IsExpectedVerbtoUtilArtifactFileName(string fileName, string expectedDependency)
|
||||
{
|
||||
if (!IsVerbtoUtilArtifactFileName(fileName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var version = GetVersionFromDependency(expectedDependency);
|
||||
if (string.IsNullOrEmpty(version))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return fileName.StartsWith($"com.verbto.tools.util-{version}", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static ToponBuildSettings Clone(ToponBuildSettings settings)
|
||||
@@ -202,10 +297,38 @@ namespace Topon_Adapter.Editor
|
||||
{
|
||||
enableDebuggerUI = settings.enableDebuggerUI,
|
||||
forceVerbtoUtilVersion = settings.forceVerbtoUtilVersion,
|
||||
verbtoUtilDependency = GetVerbtoUtilDependency(settings),
|
||||
stripResolvedDebuggerArtifacts = settings.stripResolvedDebuggerArtifacts
|
||||
};
|
||||
}
|
||||
|
||||
private static void Normalize(ToponBuildSettings settings)
|
||||
{
|
||||
if (settings == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
settings.verbtoUtilDependency = NormalizeDependency(settings.verbtoUtilDependency);
|
||||
}
|
||||
|
||||
private static string NormalizeDependency(string dependency)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dependency))
|
||||
{
|
||||
return DefaultVerbtoUtilDependency;
|
||||
}
|
||||
|
||||
return dependency.Trim();
|
||||
}
|
||||
|
||||
private static string GetVersionFromDependency(string dependency)
|
||||
{
|
||||
dependency = NormalizeDependency(dependency);
|
||||
var parts = dependency.Split(':');
|
||||
return parts.Length >= 3 ? parts[parts.Length - 1] : string.Empty;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetResolverOutputPaths(string repositoryRoot)
|
||||
{
|
||||
var root = ResolveRepositoryRoot(repositoryRoot);
|
||||
|
||||
Reference in New Issue
Block a user