static IList <ScraperEntry> ScrapeIfConfigured(IEnumerable <string> paths) { var tbs = new List <ScraperEntry>(); using (s_ScanAndScrapeMarker.Auto()) { foreach (var path in paths) { var entry = ScrapeIfConfigured(path); if (entry == null) { continue; } tbs.Add(entry); } using (s_RunScraperMarker.Auto()) { s_Scraper.RunScraper(tbs); } } return(tbs); }
/// <summary> /// Executes the system immediately. /// </summary> /// <remarks>The exact behavior is determined by this system's specific subclass.</remarks> /// <seealso cref="ComponentSystem"/> /// <seealso cref="JobComponentSystem"/> /// <seealso cref="ComponentSystemGroup"/> /// <seealso cref="EntityCommandBufferSystem"/> public void Update() { #if ENABLE_PROFILER using (m_ProfilerMarker.Auto()) #endif { InternalUpdate(); } }
public void ApplyChangeSet(EntityChangeSet changes) { using (s_PatchesMarker.Auto()) { EntityManagerPatcherUtility.ApplyChangeSet( m_EntityManager, m_EntityQuery, m_PrefabQuery, m_LinkedEntityGroupQuery, changes); } }
static ScraperEntry ScrapeIfConfigured(string path) { string asmdefPath; using (s_GetAssemblyDefinitionFilePathMarker.Auto()) { asmdefPath = CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyReference(path); } if (asmdefPath != null && IsConfiguredToScrape(asmdefPath)) { var fullOutputPath = Path.GetFullPath(path); var scrapeFilePath = Path.Combine(Path.GetDirectoryName(asmdefPath), Path.GetFileNameWithoutExtension(path) + ".api"); using (s_TimestampMatchesMarker.Auto()) { if (s_Scraper.TimestampMatches(fullOutputPath) && File.Exists(scrapeFilePath)) { return(null); } } using (s_GetReferenceDirectoriesMarker.Auto()) { // CompilationPipeline.GetAssemblies() is very slow, so instead we use the paths returned by // CompilationPipeline.GetPrecompiledAssemblyPaths and the path of the assembly being scraped. // There are plans to make a version of GetAssemblies that returns just one assembly and should be much faster. // var actualAssembly = assembly ?? CompilationPipeline.GetAssemblies().First(a => a.outputPath == path); // var referenceDirectories = actualAssembly.allReferences.Select(Path.GetDirectoryName).Distinct().ToArray(); var extensionsFolder = Path.Combine(EditorApplication.applicationContentsPath, "UnityExtensions/Unity"); if (s_ReferenceDirectories == null) { s_ReferenceDirectories = CompilationPipeline .GetPrecompiledAssemblyPaths(CompilationPipeline.PrecompiledAssemblySources.All) .Append(path) .Select(Path.GetDirectoryName) .Append(Path.Combine(extensionsFolder, "TestRunner")) .Append(Path.Combine(extensionsFolder, "TestRunner/net35/unity-custom")) .Append(Path.Combine(extensionsFolder, "GUISystem")) .Append(Path.Combine(extensionsFolder, "GUISystem/Editor")) .Append(Path.Combine(extensionsFolder, "UnityVR/Editor")) .Distinct() .Where(Directory.Exists) .ToArray(); } } return(new ScraperEntry(fullOutputPath, scrapeFilePath, s_ReferenceDirectories)); } return(null); }
internal static bool IsConfiguredToScrape(string asmdefPath) { string fullAsmdefPath; using (s_IsChildOfProjectMarker.Auto()) { //The original code used NPath and PackageInfo.FindForAssetPath(projectRelativePath.ToString(SlashMode.Forward)); // It was changed to only use file system APIs for performance fullAsmdefPath = Path.GetFullPath(asmdefPath); var projectRootPath = Path.GetDirectoryName(Application.dataPath); if (!fullAsmdefPath.StartsWith(Path.Combine(projectRootPath, "Assets")) && !fullAsmdefPath.StartsWith(Path.Combine(projectRootPath, "Packages"))) { return(false); } } using (s_EditorConfigParsingMarker.Auto()) { // uncomment to use EditorConfig.Core instead of FastEditorConfigParser // var editorConfig = new EditorConfigParser().Parse(asmdefPath).FirstOrDefault(); // if(editorConfig == null) // return false; // if (!editorConfig.Properties.TryGetValue("scrape_api", out string scrapeApi)) // return false; var scrapeApi = FastEditorConfigParser.ParseForSingleValue(fullAsmdefPath.ToNPath(), "scrape_api"); if (scrapeApi == null) { return(false); } if (!Boolean.TryParse(scrapeApi, out var shouldScrape)) { Debug.LogError($".editorconfig value '{scrapeApi}' is invalid for property scrape_api (valid values: true/false)."); return(false); } return(shouldScrape); } }
internal static void ScanAndScrape(bool log = false) { IEnumerable <string> dlls; using (s_DirectoryGetFiles.Auto()) { dlls = Directory.GetFiles("Library/ScriptAssemblies", "*.dll"); } var scrapedDlls = ScrapeIfConfigured(dlls); if (log) { if (scrapedDlls.Count == 0) { Debug.Log("Updated 0 .api files."); } else { Debug.Log($"Updated {scrapedDlls.Count} .api files:\n{string.Join("\n", scrapedDlls.Select(c => Path.GetFileName(c.AssemblyFullPath) ))}"); } } }
public void RunScraper(IList <ScraperEntry> entries) { if (entries.Count == 0) { return; } var scrapeList = entries.Select(e => (e.AssemblyFullPath, e.OutputPath)); var referencedFolders = entries.First().ReferenceDirectories; using (s_ProcessStart.Auto()) m_Process.Start(scrapeList, referencedFolders, scrapeMode); using (s_UpdateTimestamp.Auto()) { foreach (var entry in entries) { var timestampFilePath = TimestampFilePathFor(entry.AssemblyFullPath); UpdateTimestamp(entry.AssemblyFullPath, timestampFilePath); } } }