/// <summary> /// Calls selection dialog and calculates hash for the selected build. /// </summary> /// <param name="selectedBuildPath">Selected build path or null if selection was cancelled.</param> /// <returns>Calculated hash or null in case of error / user cancellation.</returns> public static string CalculateExternalBuildHash(out string selectedBuildPath) { var buildPath = EditorUtility.OpenFilePanel("Select Standalone Windows build exe or Android build apk / aab", "", "exe,apk,aab"); selectedBuildPath = buildPath; if (string.IsNullOrEmpty(buildPath)) { return(null); } var extension = Path.GetExtension(selectedBuildPath); if (extension == null) { return(null); } extension = extension.ToLower(CultureInfo.InvariantCulture); string result = null; var sha1 = new SHA1Managed(); try { var il2Cpp = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) == ScriptingImplementation.IL2CPP; if (extension == ".apk" || extension == ".aab") { result = GetApkHash(buildPath, CodeHashGenerator.GetFileFiltersAndroid(il2Cpp), sha1); } else { var buildFolder = Path.GetDirectoryName(selectedBuildPath); result = StandaloneWindowsWorker.GetBuildHash(buildFolder, CodeHashGenerator.GetFileFiltersStandaloneWindows(il2Cpp), sha1); } } catch (Exception e) { Debug.LogError(ACTkConstants.LogPrefix + "Error while trying to hash build: " + e); } finally { sha1.Clear(); EditorUtility.ClearProgressBar(); } return(result); }
// --------------------------------------------------------------- // Standalone Windows build post-processing // --------------------------------------------------------------- private List <BuildHashes> GetStandaloneWindowsBuildHashes(BuildReport report, FileFilter[] fileFilters, SHA1Wrapper sha1) { var result = new List <BuildHashes>(); var folder = Path.GetDirectoryName(report.summary.outputPath); if (folder == null) { Debug.LogError(EditorTools.ConstructError("Could not found build folder for this file: " + report.summary.outputPath)); return(result); } var buildHashes = StandaloneWindowsWorker.GetBuildHashes(folder, fileFilters, sha1); if (buildHashes == null) { return(result); } result.Add(buildHashes); return(result); }
// -------------------------------------------------------------- // Standalone Windows build post-processing // -------------------------------------------------------------- private Dictionary <string, string> GetStandaloneWindowsBuildHashes(BuildReport report, FileFilter[] fileFilters, SHA1Managed sha1) { var result = new Dictionary <string, string>(); var folder = Path.GetDirectoryName(report.summary.outputPath); if (folder == null) { Debug.LogError(ACTkConstants.LogPrefix + "Could not found build folder for this file: "); return(result); } var codeHash = StandaloneWindowsWorker.GetBuildHash(folder, fileFilters, sha1); if (codeHash == null) { return(result); } var buildPath = report.files[0].path; result.Add(buildPath, codeHash); return(result); }