public static SwiftTargetCompilerInfo Create(SwiftCompilerLocation compilerLocation, string target) { if (compilerLocation == null) { throw new ArgumentNullException(nameof(compilerLocation)); } string pathToCompilerLib = compilerLocation.SwiftCompilerLib; string sdkPath = ""; if (target != null) { string parent = ReliablePath.GetParentDirectory(pathToCompilerLib); sdkPath = SdkForTarget(target); pathToCompilerLib = Path.Combine(parent, sdkPath); } if (!Directory.Exists(pathToCompilerLib)) { throw ErrorHelper.CreateError(ReflectorError.kCantHappenBase + 18, $"Unable to find path to compiler library directory '{pathToCompilerLib}'."); } string swiftc = Path.Combine(compilerLocation.SwiftCompilerBin, "swiftc"); string swift = Path.Combine(compilerLocation.SwiftCompilerBin, "swift"); return(new SwiftTargetCompilerInfo(target, compilerLocation.SwiftCompilerBin, pathToCompilerLib, swiftc, swift, sdkPath)); }
void AppendLibraryAndFrameworks(StringBuilder sb, IEnumerable <string> candidateDirectories, string [] modNames, bool addReference) { List <string> candidates = candidateDirectories.ToList(); List <string> fwkDirectories = new List <string> (); List <string> libs = new List <string> (); List <string> fwks = new List <string> (); foreach (string moduleName in modNames) { string swiftModule = moduleName + ".swiftmodule"; bool addedFwk = false; for (int i = 0; i < candidates.Count(); i++) { // if it's a framework, there will be a one-to-one mapping of module names -> framework directories // remove the path from the candidate and move it to fwkDirectories // and add the name to fwks if (SwiftModuleFinder.IsAppleFramework(candidates [i], swiftModule)) { fwks.Add(moduleName); fwkDirectories.Add(candidates [i]); candidates.RemoveAt(i); addedFwk = true; break; } } // if we didn't add a framework, it's probably a library if (!addedFwk) { libs.Add(moduleName); } addedFwk = false; } foreach (string libdir in candidates) { sb.Append("-L ").Append(QuoteIfNeeded(libdir)).Append(' '); } foreach (string fwkdir in fwkDirectories) { string parentdir = ReliablePath.GetParentDirectory(fwkdir); sb.Append("-F ").Append(QuoteIfNeeded(parentdir)).Append(' '); } sb.Append("-L ").Append(QuoteIfNeeded(CompilerInfo.LibDirectory)).Append(' '); if (addReference) { foreach (string lib in libs) { sb.Append("-l").Append(lib).Append(' '); } foreach (string fwk in fwks) { sb.Append("-framework ").Append(fwk).Append(' '); } } }
private static string GetOutputPath(string pattern, DateTime time, BuildTarget target, string buildPath) { var fullPath = pattern; fullPath = fullPath.Replace(DateKey, time.ToString("yyyy-MM-dd")); fullPath = fullPath.Replace(TimeKey, time.ToString("HH-mm-ss")); fullPath = fullPath.Replace(BuildTargetKey, target.ToString()); fullPath = fullPath.Replace(BuildDirKey, ReliablePath.GetDirectoryName(buildPath)); fullPath = ReplaceKeySafe(fullPath, SvnRevisionKey, VersionControlUtils.GetSVNRevision, "svn revision"); fullPath = ReplaceKeySafe(fullPath, GitShortHashKey, VersionControlUtils.GetGitShortCommitHash, "git commit short hash"); fullPath = ReplaceKeySafe(fullPath, GitHashKey, VersionControlUtils.GetGitCommitHash, "git commit hash"); var expandedResult = Environment.ExpandEnvironmentVariables(fullPath); return(expandedResult); }
public static string RichifyFileName(string path) { try { var directory = ReliablePath.GetDirectoryName(path); if (!string.IsNullOrEmpty(directory)) { directory += '/'; } return(directory + "<b>" + ReliablePath.GetFileName(path) + "</b>"); } catch (System.Exception ex) { Debug.LogError(string.Format("Error {0} for path {1}", ex, path)); return(path); } }
private string CreateText(bool rich, bool fullPath) { var path = info.path; if (path.StartsWith("Assets/")) { path = path.Substring("Assets/".Length); } if (!fullPath) { path = ReliablePath.GetFileName(path); } if (rich) { return(Skin.RichifyFileName(path)); } else { return(path); } }
private void PostProcessBuild(BuildTarget target, string path, Func <Dictionary <string, long>, Dictionary <string, long> > assetsGetter) { toolOverheadTimer.Start(); try { EditorUtility.DisplayProgressBar("Better Build Info", "Analyzing build...", 1.0f); List <AssetInfo> infos = new List <AssetInfo>(); Dictionary <string, long> scenesSizesFromLog = new Dictionary <string, long>(); { Dictionary <string, long> assetsFromLog = assetsGetter(scenesSizesFromLog); infos = GetAssetsAndSizes(assetsUsedByScenes, assetsFromLog); } BuildInfoProcessorUtils.DiscoverDependenciesAndMissingAtlases(infos, assetsUsedByScenes, detailsCollector); if (detailsCollector != null) { BuildInfoProcessorUtils.FinishCollectingDetails(infos, detailsCollector); } BuildArtifactsInfo artifactsInfo = null; try { artifactsInfo = BuildArtifactsInfo.Create(target, path); } catch (Exception ex) { Log.Warning("Unable to obtain build artifacts info: {0}", ex); } BuildInfoProcessorUtils.RefreshScenesInfo(scenesSizesFromLog, infos, artifactsInfo, processedScenes, scenesDetails, detailsCollector); if (artifactsInfo != null) { BuildInfoProcessorUtils.RefreshModulesInfo(infos, artifactsInfo); } // sort infos based on paths (easier diffs) infos.Sort(BuildInfoProcessorUtils.PathComparer); if (artifactsInfo != null) { BuildInfoProcessorUtils.RefreshOtherArtifacts(infos, artifactsInfo); } if (detailsCollector != null) { EditorUtility.DisplayProgressBar("Better Build Info", "Analyzing build... (compressed sizes)", 1.0f); BuildInfoProcessorUtils.FinishCalculatingCompressedSizes(infos, detailsCollector); BuildInfoProcessorUtils.CalculateScriptReferences(infos, detailsCollector); } var settings = BuildInfoProcessorUtils.GetPlayerSettings(typeof(PlayerSettings)) .Concat(BuildInfoProcessorUtils.GetPlayerSettings(typeof(EditorUserBuildSettings))); #if UNITY_ANDROID settings = settings.Concat(BuildInfoProcessorUtils.GetPlayerSettings(typeof(PlayerSettings.Android))); #elif UNITY_IOS settings = settings.Concat(BuildInfoProcessorUtils.GetPlayerSettings(typeof(PlayerSettings.iOS))); #endif var buildInfo = new BuildInfo() { dateUTC = DateTime.UtcNow.Ticks, buildTarget = target.ToString(), projectPath = Environment.CurrentDirectory.Replace('\\', '/'), outputPath = path, unityVersion = Application.unityVersion, buildTime = buildTimer.ElapsedMilliseconds / 1000.0f, overheadTime = toolOverheadTimer.ElapsedMilliseconds / 1000.0f, assets = infos, scenes = processedScenes.Distinct().ToList(), buildSettings = settings.GroupBy(x => x.name).OrderBy(x => x.Key).Select(x => x.FirstOrDefault()).ToList(), environmentVariables = System.Environment.GetEnvironmentVariables().Cast <DictionaryEntry>().Select(x => new BuildSetting() { name = x.Key.ToString(), value = x.Value.ToString() }).OrderBy(x => x.name).ToList(), }; if (artifactsInfo != null) { buildInfo.totalSize = artifactsInfo.totalSize.uncompressed; buildInfo.compressedSize = artifactsInfo.totalSize.compressed; buildInfo.streamingAssetsSize = artifactsInfo.streamingAssetsSize; buildInfo.runtimeSize = artifactsInfo.runtimeSize.uncompressed; buildInfo.compressedRuntimeSize = artifactsInfo.runtimeSize.compressed; } ; var serializer = new System.Xml.Serialization.XmlSerializer(typeof(BuildInfo)); var outputPath = string.Empty; try { outputPath = BuildInfoSettings.Instance.GetOutputPath(DateTime.Now, target, path); var dirName = ReliablePath.GetDirectoryName(outputPath); if (!string.IsNullOrEmpty(dirName) && !Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } using (var writer = File.CreateText(outputPath)) { serializer.Serialize(writer, buildInfo); } Log.Info("Generated report at: {0}", outputPath); if (BuildInfoSettings.Instance.autoOpenReportAfterBuild) { BuildInfoSettings.ReportToOpen = outputPath; } } catch (System.Exception ex) { var tempPath = ReliablePath.GetTempPath() + "BBI_" + Guid.NewGuid().ToString() + ".bbi"; Log.Error("Error saving report at {0}, saving it temporarily at {1}. Copy it manually to a target location. Error details: {2}", outputPath, tempPath, ex); using (var writer = new StreamWriter(tempPath)) { serializer.Serialize(writer, buildInfo); } } } catch (System.Exception ex) { Log.Error("Unexpected error: {0}", ex); } finally { if (!BuildInfoSettings.Instance.autoOpenReportAfterBuild) { BuildInfoSettings.ReportToOpen = null; } EditorUtility.ClearProgressBar(); } }
private static string GetResourcePath(string name) { return(ReliablePath.Combine(BuildInfoPaths.SkinDirectory, name).Replace('\\', '/')); }
private void ProjectWindowItemCallback(string guid, Rect selectionRect) { if (!m_skin.loaded) { return; } if (m_assetsDirectoriesInfo.IsEmpty) { return; } var path = AssetDatabase.GUIDToAssetPath(guid); if (string.IsNullOrEmpty(path)) { return; } int usedCount, assetsCount, editorAssetsCount; FileSize size; if (Directory.Exists(path)) { path = path.TrimEnd('/', '\\'); if (m_assetsDirectoriesInfo.GetDirectoryInfo(path, out assetsCount, out usedCount, out editorAssetsCount, out size)) { Color backgroundColor; GUIContent content; if (assetsCount == 0) { if (editorAssetsCount == 0) { backgroundColor = m_skin.overlayUnusedColor; content = m_skin.overlayEmptyContent; } else { backgroundColor = m_skin.overlaySpecialColor; content = m_skin.overlayHasSpecialContent; } } else { backgroundColor = Color.Lerp(m_skin.overlayUnusedColor, m_skin.overlayUsedColor, (float)usedCount / assetsCount); content = new GUIContent(string.Format("{0}/{1} | {2}", usedCount, assetsCount, size)); } using (GUIHelpers.BackgroundColor(backgroundColor)) { GUIHelpers.StaticLabel(selectionRect, content, m_skin.projectOverlayMask, false); } } else if (AssetsDirectoriesInfo.IsInSpecialEditorDirectory(path)) { using (GUIHelpers.BackgroundColor(m_skin.overlaySpecialColor)) { GUIHelpers.StaticLabel(selectionRect, m_skin.overlaySpecialContent, m_skin.projectOverlayMask, false); } } } else if (m_assetsByPath != null) { AssetEntry asset; if (m_assetsByPath.TryGetValue(path, out asset)) { using (GUIHelpers.BackgroundColor(m_skin.overlayUsedColor)) { GUIHelpers.StaticLabel(selectionRect, asset.sizeContent, m_skin.projectOverlayMask, false); } } else { var directory = ReliablePath.GetDirectoryName(path); if (m_assetsDirectoriesInfo.GetDirectoryInfo(directory, out assetsCount, out usedCount, out editorAssetsCount, out size)) { using (GUIHelpers.BackgroundColor(m_skin.overlayUnusedColor)) { GUIHelpers.StaticLabel(selectionRect, m_skin.overlayUnusedContent, m_skin.projectOverlayMask, false); } } else if (AssetsDirectoriesInfo.IsInSpecialEditorDirectory(path)) { using (GUIHelpers.BackgroundColor(m_skin.overlaySpecialColor)) { GUIHelpers.StaticLabel(selectionRect, m_skin.overlaySpecialContent, m_skin.projectOverlayMask, false); } } } } }
private Texture2D CreatePreview(bool thumbnail = true) { Texture2D result = null; if (!string.IsNullOrEmpty(info.spritePackerTag)) { if (thumbnail) { if (asset != null) { result = AssetPreview.GetMiniThumbnail(asset); } } if (!result) { result = AssetPreview.GetMiniTypeThumbnail(typeof(Texture2D)); } } else { string extension = ReliablePath.GetExtension(info.path).ToLower(); switch (extension) { case ".ai": case ".apng": case ".png": case ".bmp": case ".cdr": case ".dib": case ".eps": case ".exif": case ".gif": case ".ico": case ".icon": case ".j": case ".j2c": case ".j2k": case ".jas": case ".jiff": case ".jng": case ".jp2": case ".jpc": case ".jpe": case ".jpeg": case ".jpf": case ".jpg": case ".jpw": case ".jpx": case ".jtf": case ".mac": case ".omf": case ".qif": case ".qti": case ".qtif": case ".tex": case ".tfw": case ".tga": case ".tif": case ".tiff": case ".wmf": case ".psd": case ".exr": case ".shadervariants": case ".asset": if (thumbnail) { if (asset != null) { result = AssetPreview.GetMiniThumbnail(asset); } } break; case ".cubemap": result = AssetPreview.GetMiniTypeThumbnail(typeof(Cubemap)); break; case ".xml": case ".txt": case ".bytes": result = AssetPreview.GetMiniTypeThumbnail(typeof(TextAsset)); break; } if (result == null) { result = UnityEditorInternal.InternalEditorUtility.GetIconForFile(extension); } } return(result); }