public async Task <DataTablesResult> Get(string buildConfig, int draw, int start, int length, string src = "files") { if (string.IsNullOrEmpty(buildConfig)) { throw new ArgumentException("Invalid arguments!"); } var result = new DataTablesResult { draw = draw }; Logger.WriteLine("Serving file table data for build " + buildConfig); var searching = false; if (string.IsNullOrWhiteSpace(Request.Query["search[value]"])) { Logger.WriteLine("Serving file table data " + start + "," + length + " for build " + buildConfig + " for draw " + draw); } else { searching = true; Logger.WriteLine("Serving file table data " + start + "," + length + " for build " + buildConfig + " for draw " + draw + " with filter " + Request.Query["search[value]"]); } var build = await BuildCache.GetOrCreate(buildConfig); result.recordsTotal = build.root.entriesFDID.Count; result.data = new List <List <object> >(); result.recordsFiltered = result.recordsTotal; var entries = build.root.entriesFDID.OrderBy(x => x.Key).ToList(); if (start + length > entries.Count) { length = entries.Count - start; } foreach (var entry in entries.GetRange(start, length)) { var row = new List <object> { entry.Value[0].fileDataID }; var dbFile = await Database.GetFileByFileDataID(entry.Value[0].fileDataID); if (dbFile.ID == 0) { Logger.WriteLine("WARNING! File " + entry.Value[0].fileDataID + " is not known in database!", ConsoleColor.Red); } // Filename if (!string.IsNullOrEmpty(dbFile.Filename)) { row.Add(dbFile.Filename); } else { row.Add(""); } // Lookup if (!string.IsNullOrEmpty(dbFile.Lookup)) { row.Add(dbFile.Lookup); } else if (entry.Value[0].lookup != 0) { row.Add(entry.Value[0].lookup.ToString("X").ToLower().PadLeft(16, '0')); } else { row.Add("000000000000000"); } // Versions var versionList = new List <FileVersion>(); foreach (var rootFileEntry in entry.Value) { versionList.Add( new FileVersion() { root_cdn = build.buildConfig.root_cdn.ToHexString().ToLower(), contenthash = rootFileEntry.md5.ToHexString().ToLower(), buildconfig = buildConfig, description = rootFileEntry.localeFlags.ToString().Replace("All_WoW", "") + " " + rootFileEntry.contentFlags.ToString(), cdnconfig = await Database.GetCDNConfigByBuildConfig(buildConfig) } ); } row.Add(versionList); // Type if (!string.IsNullOrEmpty(dbFile.Type)) { row.Add(dbFile.Type); } else { row.Add("unk"); } result.data.Add(row); } return(result); }
void OnCleanSBP() { BuildCache.PurgeCache(true); }
public static bool CouldSetupReleaseBuildName(string[] args) { return(BuildCache.SetupReleaseBuildName(args) != BuildCache.INVALID_STRING); }
private bool SaveToCache(Hash128 hash, string outputFolder, string[] manifestFiles) { return(BuildCache.SaveCachedArtifacts(hash, manifestFiles, outputFolder)); }
public void OnCleanSBP() { BuildCache.PurgeCache(promtWarning); }
public override BuildPipelineCodes Convert(BuildDependencyInformation buildInfo, out BuildCommandSet output) { StartProgressBar("Generating Build Commands", buildInfo.assetLoadInfo.Count); Hash128 hash = CalculateInputHash(buildInfo); if (UseCache && BuildCache.TryLoadCachedResults(hash, out output)) { output = new BuildCommandSet(); EndProgressBar(); return(BuildPipelineCodes.SuccessCached); } var commands = new List <WriteCommand>(); foreach (var bundle in buildInfo.bundleToAssets) { var command = new WriteCommand(); var explicitAssets = new List <AssetLoadInfo>(); var assetBundleObjects = new List <SerializationInfo>(); var dependencies = new HashSet <string>(); foreach (var asset in bundle.Value) { var assetInfo = buildInfo.assetLoadInfo[asset]; explicitAssets.Add(assetInfo); if (!UpdateProgressBar(assetInfo.asset)) { output = new BuildCommandSet(); EndProgressBar(); return(BuildPipelineCodes.Canceled); } dependencies.UnionWith(buildInfo.assetToBundles[asset]); foreach (var includedObject in assetInfo.includedObjects) { if (!buildInfo.virtualAssets.Contains(asset) && buildInfo.objectToVirtualAsset.ContainsKey(includedObject)) { continue; } assetBundleObjects.Add(new SerializationInfo { serializationObject = includedObject, serializationIndex = SerializationIndexFromObjectIdentifier(includedObject) }); } foreach (var referencedObject in assetInfo.referencedObjects) { if (referencedObject.filePath == kUnityDefaultResourcePath) { continue; } if (buildInfo.objectToVirtualAsset.ContainsKey(referencedObject)) { continue; } if (buildInfo.assetLoadInfo.ContainsKey(referencedObject.guid)) { continue; } assetBundleObjects.Add(new SerializationInfo { serializationObject = referencedObject, serializationIndex = SerializationIndexFromObjectIdentifier(referencedObject) }); } BuildUsageTagGlobal globalUsage; if (buildInfo.sceneUsageTags.TryGetValue(asset, out globalUsage)) { command.sceneBundle = true; command.globalUsage |= globalUsage; } } dependencies.Remove(bundle.Key); assetBundleObjects.Sort(Compare); command.assetBundleName = bundle.Key; command.explicitAssets = explicitAssets; command.assetBundleDependencies = dependencies.OrderBy(x => x).ToList(); command.assetBundleObjects = assetBundleObjects; commands.Add(command); } output = new BuildCommandSet(); output.commands = commands; if (UseCache && !BuildCache.SaveCachedResults(hash, output)) { BuildLogger.LogWarning("Unable to cache CommandSetProcessor results."); } if (!EndProgressBar()) { return(BuildPipelineCodes.Canceled); } return(BuildPipelineCodes.Success); }
public static async Task GetBuild(DSoptions _options, DSReplayContext _context, object dblock, ILogger _logger) { if (_options.Vs == "ALL") { _options.Vs = String.Empty; } string Hash = _options.GenHash(); if (!_options.Decoding && BuildCache.ContainsKey(Hash)) { _options.buildResult = BuildCache[Hash]; return; } bool doWait = false; lock (Computing) { if (!Computing.Contains(Hash)) { Computing.Add(Hash); } else { doWait = true; } } if (doWait) { while (Computing.Contains(Hash)) { await Task.Delay(500); } if (BuildCache.ContainsKey(Hash)) { _options.buildResult = BuildCache[Hash]; } return; } BuildResult bresult = new BuildResult(); foreach (var ent in _options.Gamemodes.Keys.ToArray()) { _options.Gamemodes[ent] = false; } if (_options.Interest == "Terran" || _options.Interest == "Zerg" || _options.Interest == "Protoss") { _options.Gamemodes["GameModeStandard"] = true; } else { _options.Gamemodes["GameModeCommanders"] = true; _options.Gamemodes["GameModeCommandersHeroic"] = true; } lock (dblock) { bool mengskfilter = _options.MengskPreviewFilter; _options.MengskPreviewFilter = false; var replays = DBReplayFilter.Filter(_options, _context); _options.MengskPreviewFilter = mengskfilter; bresult.TotalGames = replays.Count(); var presult = (String.IsNullOrEmpty(_options.Vs) switch { true => from r in replays from t1 in r.DSPlayer where t1.RACE == _options.Interest where _options.Dataset.Contains(t1.NAME) from u1 in t1.Breakpoints where u1.Breakpoint == _options.Breakpoint select new { r.ID, r.DURATION, r.GAMETIME, t1.WIN, u1.dsUnitsString, u1.Upgrades, u1.Gas }, false => from r in replays from t1 in r.DSPlayer where t1.RACE == _options.Interest && t1.OPPRACE == _options.Vs where _options.Dataset.Contains(t1.NAME) from u1 in t1.Breakpoints where u1.Breakpoint == _options.Breakpoint select new { r.ID, r.DURATION, r.GAMETIME, t1.WIN, u1.dsUnitsString, u1.Upgrades, u1.Gas } });
static void PruneCache(object state) { BuildCache.PruneCache_Background((long)state); }
/// <summary> /// Default implementation of generating Asset Bundles using the Scriptable Build Pipeline. /// </summary> /// <param name="parameters">Set of parameters used for building asset bundles.</param> /// <param name="content">Set of content and explicit asset bundle layout to build.</param> /// <param name="result">Results from building the content and explicit asset bundle layout.</param> /// <param name="taskList">Custom task list for building asset bundles.</param> /// <param name="contextObjects">Additional context objects to make available to the build.</param> /// <returns>Return code with status information about success or failure causes.</returns> public static ReturnCode BuildAssetBundles(IBundleBuildParameters parameters, IBundleBuildContent content, out IBundleBuildResults result, IList <IBuildTask> taskList, params IContextObject[] contextObjects) { // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code if (parameters == null) { result = null; BuildLogger.LogException(new ArgumentNullException("parameters")); return(ReturnCode.Exception); } // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code if (taskList.IsNullOrEmpty()) { result = null; BuildLogger.LogException(new ArgumentException("Argument cannot be null or empty.", "taskList")); return(ReturnCode.Exception); } // Don't run if there are unsaved changes if (Hackery.HasDirtyScenes()) { result = null; return(ReturnCode.UnsavedChanges); } AssetDatabase.SaveAssets(); ReturnCode exitCode; result = new BundleBuildResults(); // using (new SceneStateCleanup()) using (new BuildInterfacesWrapper()) using (var progressTracker = new ProgressTracker()) using (var buildCache = new BuildCache(parameters.CacheServerHost, parameters.CacheServerPort)) { Directory.CreateDirectory(parameters.TempOutputFolder); BuildContext buildContext; try { buildContext = new BuildContext(contextObjects); buildContext.SetContextObject(parameters); buildContext.SetContextObject(content); buildContext.SetContextObject(result); buildContext.SetContextObject(progressTracker); buildContext.SetContextObject(buildCache); buildContext.SetContextObject(new Unity5PackedIdentifiers()); buildContext.SetContextObject(new BuildDependencyData()); buildContext.SetContextObject(new BundleWriteData()); buildContext.SetContextObject(BuildCallbacks); } catch (Exception e) { // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code result = null; BuildLogger.LogException(e); return(ReturnCode.Exception); } exitCode = BuildTasksRunner.Validate(taskList, buildContext); if (exitCode >= ReturnCode.Success) { exitCode = BuildTasksRunnerProfiled.Run(taskList, buildContext); } if (Directory.Exists(parameters.TempOutputFolder)) { Directory.Delete(parameters.TempOutputFolder, true); } } return(exitCode); }
public string Get() { Console.WriteLine("[" + DateTime.Now + "] Serving stats!"); return("Builds loaded: " + BuildCache.Count() + "\nIndexes loaded: " + CASC.indexNames.Count + "\nFiles indexed: " + CASC.indexDictionary.Count + "\nEncoding mappings: " + NGDP.encodingDictionary.Count); }
public override BuildPipelineCodes Convert(AssetInfoMap assetLoadInfo, out AssetInfoMap output) { StartProgressBar("Stripping unused sprite source textures", 3); if (!UpdateProgressBar("Finding sprite source textures")) { output = null; return(BuildPipelineCodes.Canceled); } var spriteRefCount = new Dictionary <ObjectIdentifier, int>(); foreach (var assetInfo in assetLoadInfo) { var path = AssetDatabase.GUIDToAssetPath(assetInfo.Value.asset.ToString()); var importer = AssetImporter.GetAtPath(path) as TextureImporter; if (importer != null && importer.textureType == TextureImporterType.Sprite && !string.IsNullOrEmpty(importer.spritePackingTag)) { spriteRefCount[assetInfo.Value.includedObjects[0]] = 0; } } Hash128 hash = CalculateInputHash(assetLoadInfo, spriteRefCount); if (UseCache && BuildCache.TryLoadCachedResults(hash, out output)) { EndProgressBar(); return(BuildPipelineCodes.SuccessCached); } // Mutating the input, this is the only converter that does this output = assetLoadInfo; if (!UpdateProgressBar("Finding sprite source textures usage")) { EndProgressBar(); return(BuildPipelineCodes.Canceled); } foreach (var assetInfo in output) { if (!string.IsNullOrEmpty(assetInfo.Value.processedScene)) { continue; } foreach (var reference in assetInfo.Value.referencedObjects) { int refCount = 0; if (!spriteRefCount.TryGetValue(reference, out refCount)) { continue; } // Note: Because pass by value spriteRefCount[reference] = ++refCount; } } if (!UpdateProgressBar("Removing unused sprite source textures.")) { EndProgressBar(); return(BuildPipelineCodes.Canceled); } foreach (var source in spriteRefCount) { if (source.Value > 0) { continue; } var assetInfo = output[source.Key.guid]; var includedObjects = assetInfo.includedObjects; includedObjects.RemoveAt(0); } if (UseCache && !BuildCache.SaveCachedResults(hash, output)) { BuildLogger.LogWarning("Unable to cache SpriteSourceProcessor results."); } if (!EndProgressBar()) { return(BuildPipelineCodes.Canceled); } return(BuildPipelineCodes.Success); }
static void Build(Action behaviour) { // Check error if (exportTo == ExportTo.Project && !Directory.Exists(Path.Combine(projectPath, "Assets/StreamingAssets"))) { Debug.LogError("Cannot deploy to project dir as the folder doesn't seem to be an Unity project"); return; } if (exportTo == ExportTo.Game) { bool gameSupported = false; foreach (string supportedGame in Enum.GetNames(typeof(SupportedGame))) { if (File.Exists(Path.Combine(gamePath, supportedGame + ".exe"))) { gameSupported = true; gameName = (SupportedGame)Enum.Parse(typeof(SupportedGame), supportedGame); } } if (!gameSupported) { Debug.LogError("Target game not supported!"); return; } } #if PrivateSDK if (exportTo == ExportTo.Android) { string adbPath = Path.Combine(EditorPrefs.GetString("AndroidSdkRoot"), "platform-tools", "adb.exe"); if (!EditorPrefs.HasKey("AndroidSdkRoot") || !File.Exists(adbPath)) { Debug.LogError("Android SDK is not installed!"); Debug.LogError("Path not found " + adbPath); return; } } #endif // Configure stereo rendering if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { PlayerSettings.stereoRenderingPath = StereoRenderingPath.SinglePass; } if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64) { PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing; } // Configure addressable groups if (AddressableAssetSettingsDefaultObject.Settings != null) { foreach (AddressableAssetGroup group in AddressableAssetSettingsDefaultObject.Settings.groups) { BundledAssetGroupSchema bundledAssetGroupSchema = group.GetSchema <BundledAssetGroupSchema>(); if (bundledAssetGroupSchema != null) { if (group.Default) { bundledAssetGroupSchema.BuildPath.SetVariableByName(AddressableAssetSettingsDefaultObject.Settings, "LocalBuildPath"); bundledAssetGroupSchema.LoadPath.SetVariableByName(AddressableAssetSettingsDefaultObject.Settings, "LocalLoadPath"); } bundledAssetGroupSchema.BundleNaming = BundledAssetGroupSchema.BundleNamingStyle.NoHash; bundledAssetGroupSchema.BundleNaming = BundledAssetGroupSchema.BundleNamingStyle.NoHash; AddressableAssetSettingsDefaultObject.Settings.profileSettings.SetValue(group.Settings.activeProfileId, "LocalBuildPath", "[ThunderRoad.ModBuilder.buildPath]"); AddressableAssetSettingsDefaultObject.Settings.profileSettings.SetValue(group.Settings.activeProfileId, "LocalLoadPath", (toDefault ? "{ThunderRoad.FileManager.aaDefaultPath}/" : "{ThunderRoad.FileManager.aaModPath}/") + exportFolderName); // Set builtin shader to export folder name to avoid duplicates AddressableAssetSettingsDefaultObject.Settings.ShaderBundleNaming = UnityEditor.AddressableAssets.Build.ShaderBundleNaming.Custom; AddressableAssetSettingsDefaultObject.Settings.ShaderBundleCustomNaming = exportFolderName; AddressableAssetSettingsDefaultObject.Settings.BuildRemoteCatalog = true; /* TODO: OBB support (zip file uncompressed and adb push to obb folder) * AddressableAssetSettingsDefaultObject.Settings.profileSettings.SetValue(group.Settings.activeProfileId, "LocalLoadPath", "{ThunderRoad.FileManager.obbPath}/" + exportFolderName + "{ThunderRoad.FileManager.obbPathEnd}"); */ } } } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); // Build if (behaviour == Action.BuildAndExport || behaviour == Action.BuildOnly) { Debug.Log("Build path is: " + buildPath); if (OnBuildEvent != null) { OnBuildEvent.Invoke(EventTime.OnStart); } // Clean build path if (Directory.Exists(buildPath)) { foreach (string filePath in Directory.GetFiles(buildPath, "*.*", SearchOption.AllDirectories)) { File.Delete(filePath); } } BuildCache.PurgeCache(true); AddressableAssetSettings.CleanPlayerContent(); AddressableAssetSettings.CleanPlayerContent(AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder); AddressableAssetSettings.BuildPlayerContent(); Debug.Log("Build done"); if (OnBuildEvent != null) { OnBuildEvent.Invoke(EventTime.OnEnd); } } // Export if (behaviour == Action.BuildAndExport || behaviour == Action.ExportOnly) { if (exportTo == ExportTo.Game || exportTo == ExportTo.Project) { // Get paths string buildFullPath = Path.Combine(Directory.GetCurrentDirectory(), buildPath); string catalogFullPath = Path.Combine(Directory.GetCurrentDirectory(), catalogPath); string destinationAssetsPath = ""; string destinationCatalogPath = ""; if (exportTo == ExportTo.Project) { destinationAssetsPath = Path.Combine(projectPath, buildPath); destinationCatalogPath = Path.Combine(projectPath, catalogPath); } else if (exportTo == ExportTo.Game) { if (toDefault) { destinationAssetsPath = destinationCatalogPath = Path.Combine(gamePath, gameName + "_Data/StreamingAssets/Default", exportFolderName); } else { destinationAssetsPath = destinationCatalogPath = Path.Combine(gamePath, gameName + "_Data/StreamingAssets/Mods", exportFolderName); } } // Create folders if needed if (!File.Exists(destinationAssetsPath)) { Directory.CreateDirectory(destinationAssetsPath); } if (!File.Exists(destinationCatalogPath)) { Directory.CreateDirectory(destinationCatalogPath); } // Clean destination path if (cleanDestination) { foreach (string filePath in Directory.GetFiles(destinationAssetsPath, "*.*", SearchOption.AllDirectories)) { File.Delete(filePath); } if (exportTo == ExportTo.Game) { foreach (string filePath in Directory.GetFiles(destinationCatalogPath, "*.*", SearchOption.AllDirectories)) { File.Delete(filePath); } } } else { foreach (string filePath in Directory.GetFiles(destinationAssetsPath, "catalog_*.json", SearchOption.AllDirectories)) { File.Delete(filePath); } foreach (string filePath in Directory.GetFiles(destinationAssetsPath, "catalog_*.hash", SearchOption.AllDirectories)) { File.Delete(filePath); } if (exportTo == ExportTo.Game) { foreach (string filePath in Directory.GetFiles(destinationCatalogPath, "catalog_*.json", SearchOption.AllDirectories)) { File.Delete(filePath); } foreach (string filePath in Directory.GetFiles(destinationCatalogPath, "catalog_*.hash", SearchOption.AllDirectories)) { File.Delete(filePath); } } } // Copy addressable assets to destination path CopyDirectory(buildFullPath, destinationAssetsPath); Debug.Log("Copied addressable asset folder " + buildFullPath + " to " + destinationAssetsPath); if (exportTo == ExportTo.Game) { // Copy json catalog to destination path CopyDirectory(catalogFullPath, destinationCatalogPath); Debug.Log("Copied catalog folder " + catalogFullPath + " to " + destinationCatalogPath); // Copy plugin dll if any string dllPath = Path.Combine("BuildStaging", "Plugins", exportFolderName) + "/bin/Release/netstandard2.0/" + exportFolderName + ".dll"; if (File.Exists(dllPath)) { File.Copy(dllPath, destinationCatalogPath + "/" + exportFolderName + ".dll", true); Debug.Log("Copied dll " + dllPath + " to " + destinationCatalogPath); } } } if ((exportTo == ExportTo.Game) && runGameAfterBuild) { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = Path.Combine(gamePath, gameName + ".exe"); process.StartInfo.Arguments = runGameArguments; process.Start(); Debug.Log("Start game: " + process.StartInfo.FileName + " " + process.StartInfo.Arguments); } #if PrivateSDK if (exportTo == ExportTo.Android) { string buildFullPath = Path.Combine(Directory.GetCurrentDirectory(), "BuildStaging", "AddressableAssets", "Android"); System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = GetAdbPath(); string destinationPath = "/sdcard/Android/data/com.Warpfrog." + gameName + "/files/mods/" + exportFolderName; process.StartInfo.Arguments = "push " + buildFullPath + "/. " + destinationPath; // for default: obb : /sdcard/Android/obb/" + PlayerSettings.applicationIdentifier + "/main.1.com.Warpfrog.BladeAndSorcery.obb"); process.Start(); process.WaitForExit(); Debug.Log(GetAdbPath() + " " + process.StartInfo.Arguments); if (runGameAfterBuild) { process = new System.Diagnostics.Process(); process.StartInfo.FileName = GetAdbPath(); process.StartInfo.Arguments = "shell am start -n " + PlayerSettings.applicationIdentifier + "/com.unity3d.player.UnityPlayerActivity"; process.Start(); Debug.Log("Start game: " + process.StartInfo.FileName + " " + process.StartInfo.Arguments); } } #endif Debug.Log("Export done"); } // The end System.Media.SystemSounds.Asterisk.Play(); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Build Addressable Assets: Build Addressable Assets.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(4f); EditorGUILayout.HelpBox("Build Addressable Assets does not respect Platform selection in Graph Editor." + "Instead, Addressable Profile will be used for platform targeting.", MessageType.Info); if (!AddressableAssetSettingsDefaultObject.SettingsExists) { return; } var profileNames = Settings.profileSettings.GetAllProfileNames(); profileNames.Insert(0, kCurrentProfile); var profileIndex = string.IsNullOrEmpty(m_profileName) ? 0 : profileNames.IndexOf(m_profileName); var newProfileIndex = EditorGUILayout.Popup("Profile", profileIndex, profileNames.ToArray()); if (newProfileIndex != profileIndex) { using (new RecordUndoScope("Change Profile", node, true)) { m_profileName = profileNames[newProfileIndex]; onValueChanged(); } } if (m_currentDataBuilder == null && !string.IsNullOrEmpty(m_builderGuid)) { m_currentDataBuilder = Settings.DataBuilders.FirstOrDefault(obj => AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)) == m_builderGuid); } var dataBuilders = Settings.DataBuilders.Where(builder => (builder as IDataBuilder).CanBuildData <AddressablesPlayerBuildResult>()).ToList(); var builderIndex = m_currentDataBuilder == null ? -1 : dataBuilders.IndexOf(m_currentDataBuilder); var builderNames = dataBuilders .Select(builder => ((IDataBuilder)builder).Name).ToArray(); var newIndex = EditorGUILayout.Popup("Builder Script", builderIndex, builderNames); if (newIndex != builderIndex) { using (new RecordUndoScope("Change Builder", node, true)) { m_currentDataBuilder = dataBuilders[newIndex]; m_builderGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_currentDataBuilder)); onValueChanged(); } } var newPreferUpdate = EditorGUILayout.ToggleLeft("Update", m_preferUpdate); if (newPreferUpdate != m_preferUpdate) { using (new RecordUndoScope("Update Toggle", node, true)) { m_preferUpdate = newPreferUpdate; onValueChanged(); } } using (new EditorGUI.DisabledScope(!m_preferUpdate)) { GUILayout.Label("Content State File", "BoldLabel"); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.SelectableLabel(m_contentStateFilePath, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); if (GUILayout.Button("Select", GUILayout.Width(50f))) { var newStateData = ContentUpdateScript.GetContentStateDataPath(true); if (newStateData != null && newStateData != m_contentStateFilePath) { using (new RecordUndoScope("Content State Data Path", node, true)) { m_contentStateFilePath = newStateData; onValueChanged(); } } } } } GUILayout.Space(10f); if (GUILayout.Button("Clean Build Cache", GUILayout.Width(250f))) { if (EditorUtility.DisplayDialog("Clean Build Cache", "Do you really want to clean build cache?", "OK", "Cancel")) { AddressableAssetSettings.CleanPlayerContent(null); BuildCache.PurgeCache(false); } } }
public override BuildPipelineCodes Convert(BuildDependencyInfo input, BuildSettings settings, bool aggressive, out BuildDependencyInfo output) { StartProgressBar("Generated shared object bundles", 3); Hash128 hash = CalculateInputHash(input); if (UseCache && BuildCache.TryLoadCachedResults(hash, out output)) { EndProgressBar(); return(BuildPipelineCodes.SuccessCached); } // Mutating the input output = input; if (!UpdateProgressBar("Generate lookup of all objects")) { EndProgressBar(); return(BuildPipelineCodes.Canceled); } // Generate mapping of each object to the bundles it would be used by var objectToBundles = new Dictionary <ObjectIdentifier, HashSet <string> >(); var objectToAssets = new Dictionary <ObjectIdentifier, HashSet <GUID> >(); foreach (var asset in input.assetInfo.Values) { var dependencies = input.assetToBundles[asset.asset]; if (aggressive && !asset.includedObjects.IsNullOrEmpty()) { for (int i = 1; i < asset.includedObjects.Count; ++i) { var objectID = asset.includedObjects[i]; HashSet <string> bundles; objectToBundles.GetOrAdd(objectID, out bundles); bundles.Add(dependencies[0]); HashSet <GUID> assets; objectToAssets.GetOrAdd(objectID, out assets); assets.Add(asset.asset); } } foreach (var referenceID in asset.referencedObjects) { if (!aggressive && input.assetToBundles.ContainsKey(referenceID.guid)) { continue; } if (referenceID.filePath == BuildWriteProcessor.kUnityDefaultResourcePath) { continue; } HashSet <string> bundles; objectToBundles.GetOrAdd(referenceID, out bundles); bundles.Add(dependencies[0]); HashSet <GUID> assets; objectToAssets.GetOrAdd(referenceID, out assets); assets.Add(asset.asset); } } if (!UpdateProgressBar("Finding set of reused objects")) { EndProgressBar(); return(BuildPipelineCodes.Canceled); } // Generate the set of reused objects var hashToObjects = new Dictionary <Hash128, List <ObjectIdentifier> >(); foreach (var objectPair in objectToBundles) { if (objectPair.Value.Count <= 1) { continue; } var bundleHash = HashingMethods.CalculateMD5Hash(objectPair.Value.ToArray()); List <ObjectIdentifier> objectIDs; hashToObjects.GetOrAdd(bundleHash, out objectIDs); objectIDs.Add(objectPair.Key); } if (!UpdateProgressBar("Creating shared object bundles")) { EndProgressBar(); return(BuildPipelineCodes.Canceled); } // Generate Shared Bundles foreach (var hashPair in hashToObjects) { // Generate Dependency Information for virtual asset var assetInfo = new AssetLoadInfo(); assetInfo.asset = new GUID(hashPair.Key.ToString()); assetInfo.address = hashPair.Key.ToString(); assetInfo.includedObjects = hashPair.Value.ToList(); assetInfo.referencedObjects = new List <ObjectIdentifier>(); assetInfo.includedObjects.Sort((x, y) => { if (x < y) { return(-1); } if (x > y) { return(1); } return(0); }); // Add new AssetLoadInfo for virtual asset output.assetInfo.Add(assetInfo.asset, assetInfo); var assetBundles = new List <string>(); assetBundles.Add(assetInfo.address); // Add new bundle as dependency[0] for virtual asset output.assetToBundles.Add(assetInfo.asset, assetBundles); var bundleAssets = new List <GUID>(); bundleAssets.Add(assetInfo.asset); // Add virtual asset to the list of assets for new bundle output.bundleToAssets.Add(assetInfo.address, bundleAssets); // Add virtual asset to lookup output.virtualAssets.Add(assetInfo.asset); foreach (var objectID in assetInfo.includedObjects) { // Add objects in virtual asset to lookup output.objectToVirtualAsset.Add(objectID, assetInfo.asset); var assets = objectToAssets[objectID]; foreach (var asset in assets) { if (!output.assetToBundles.TryGetValue(asset, out assetBundles)) { continue; } if (assetBundles.Contains(assetInfo.address)) { continue; } // Add new bundle as dependency to assets referencing virtual asset objects assetBundles.Add(assetInfo.address); } } } // Generate Shared Bundle Build Dependencies foreach (var virtualAsset in output.virtualAssets) { var assetInfo = output.assetInfo[virtualAsset]; var dependencies = output.assetToBundles[virtualAsset]; var references = BundleBuildInterface.GetPlayerDependenciesForObjects(assetInfo.includedObjects.ToArray(), settings.target, settings.typeDB); foreach (var reference in references) { GUID dependency; List <string> bundles; string depStr = ""; // If the reference is to an object in a virtual asset, no major checks, just add it as a dependency if (output.objectToVirtualAsset.TryGetValue(reference, out dependency)) { if (dependency == virtualAsset) { continue; } depStr = dependency.ToString(); } // Otherwise if this reference is part of an asset assigned to a bundle, then set the bundle as a dependency to the virtual asset else if (output.assetToBundles.TryGetValue(reference.guid, out bundles)) { if (bundles.IsNullOrEmpty()) { continue; } depStr = bundles[0]; } if (dependencies.Contains(depStr)) { continue; } dependencies.Add(depStr); } } if (UseCache && !BuildCache.SaveCachedResults(hash, output)) { BuildLogger.LogWarning("Unable to cache SharedObjectProcessor results."); } if (!EndProgressBar()) { return(BuildPipelineCodes.Canceled); } return(BuildPipelineCodes.Success); }
public async static Task <byte[]> GetFileByFilename(string buildConfig, string cdnConfig, string filename, LocaleFlags locale = LocaleFlags.All_WoW) { var build = await BuildCache.GetOrCreate(buildConfig, cdnConfig); using var hasher = new Jenkins96(); var lookup = hasher.ComputeHash(filename, true); var target = ""; if (build.root.entriesLookup.TryGetValue(lookup, out var entry)) { RootEntry prioritizedEntry; if (locale == LocaleFlags.All_WoW) { prioritizedEntry = entry.FirstOrDefault(subentry => subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && (subentry.localeFlags.HasFlag(LocaleFlags.All_WoW) || subentry.localeFlags.HasFlag(LocaleFlags.enUS)) ); } else { prioritizedEntry = entry.FirstOrDefault(subentry => subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && subentry.localeFlags.HasFlag(locale) ); } var selectedEntry = (prioritizedEntry.fileDataID != 0) ? prioritizedEntry : entry.First(); target = selectedEntry.md5.ToHexString().ToLower(); } if (string.IsNullOrEmpty(target)) { var filedataid = await Database.GetFileDataIDByFilename(filename); if (filedataid != 0) { if (build.root.entriesFDID.TryGetValue(filedataid, out var fdidentry)) { RootEntry prioritizedEntry; if (locale == LocaleFlags.All_WoW) { prioritizedEntry = fdidentry.FirstOrDefault(subentry => subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && (subentry.localeFlags.HasFlag(LocaleFlags.All_WoW) || subentry.localeFlags.HasFlag(LocaleFlags.enUS)) ); } else { prioritizedEntry = fdidentry.FirstOrDefault(subentry => subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && subentry.localeFlags.HasFlag(locale) ); } var selectedEntry = (prioritizedEntry.fileDataID != 0) ? prioritizedEntry : fdidentry.First(); target = selectedEntry.md5.ToHexString().ToLower(); } } } if (string.IsNullOrEmpty(target)) { throw new FileNotFoundException("No file found in root for filename " + filename); } return(await GetFile(buildConfig, cdnConfig, target)); }
/// <summary> /// Default implementation of generating Asset Bundles using the Scriptable Build Pipeline. /// </summary> /// <param name="parameters">Set of parameters used for building asset bundles.</param> /// <param name="content">Set of content and explicit asset bundle layout to build.</param> /// <param name="result">Results from building the content and explicit asset bundle layout.</param> /// <param name="taskList">Custom task list for building asset bundles.</param> /// <param name="contextObjects">Additional context objects to make available to the build.</param> /// <returns>Return code with status information about success or failure causes.</returns> public static ReturnCode BuildAssetBundles(IBundleBuildParameters parameters, IBundleBuildContent content, out IBundleBuildResults result, IList <IBuildTask> taskList, params IContextObject[] contextObjects) { // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code if (parameters == null) { result = null; BuildLogger.LogException(new ArgumentNullException("parameters")); return(ReturnCode.Exception); } // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code if (taskList.IsNullOrEmpty()) { result = null; BuildLogger.LogException(new ArgumentException("Argument cannot be null or empty.", "taskList")); return(ReturnCode.Exception); } // Don't run if there are unsaved changes if (ValidationMethods.HasDirtyScenes()) { result = null; return(ReturnCode.UnsavedChanges); } AssetDatabase.SaveAssets(); ReturnCode exitCode; result = new BundleBuildResults(); BuildCacheUtility.ClearCacheHashes(); using (var interfacesWrapper = new BuildInterfacesWrapper()) #if !CI_TESTRUNNER_PROJECT using (new SceneStateCleanup()) using (var progressTracker = new ProgressTracker()) #else using (var progressTracker = new ProgressLoggingTracker()) #endif using (var buildCache = new BuildCache(parameters.CacheServerHost, parameters.CacheServerPort)) { Directory.CreateDirectory(parameters.TempOutputFolder); BuildContext buildContext; BuildLog buildLog = null; try { buildContext = new BuildContext(contextObjects); buildContext.SetContextObject(parameters); buildContext.SetContextObject(content); buildContext.SetContextObject(result); buildContext.SetContextObject(interfacesWrapper); buildContext.SetContextObject(progressTracker); buildContext.SetContextObject(buildCache); // If IDeterministicIdentifiers was passed in with contextObjects, don't add the default if (!buildContext.ContainsContextObject(typeof(IDeterministicIdentifiers))) { buildContext.SetContextObject(new Unity5PackedIdentifiers()); } buildContext.SetContextObject(new BuildDependencyData()); buildContext.SetContextObject(new BundleWriteData()); buildContext.SetContextObject(BuildCallbacks); IBuildLogger logger; if (!buildContext.TryGetContextObject <IBuildLogger>(out logger)) { logger = buildLog = new BuildLog(); buildContext.SetContextObject(buildLog); } buildCache.SetBuildLogger(logger); } catch (Exception e) { // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code result = null; BuildLogger.LogException(e); return(ReturnCode.Exception); } exitCode = BuildTasksRunner.Validate(taskList, buildContext); if (exitCode >= ReturnCode.Success) #if SBP_PROFILER_ENABLE { exitCode = BuildTasksRunner.RunProfiled(taskList, buildContext); } #else { exitCode = BuildTasksRunner.Run(taskList, buildContext); } #endif if (Directory.Exists(parameters.TempOutputFolder)) { Directory.Delete(parameters.TempOutputFolder, true); } if (buildLog != null) { string buildLogPath = parameters.GetOutputFilePathForIdentifier("buildlogtep.json"); Directory.CreateDirectory(Path.GetDirectoryName(buildLogPath)); File.WriteAllText(parameters.GetOutputFilePathForIdentifier("buildlogtep.json"), buildLog.FormatForTraceEventProfiler()); } } long maximumCacheSize = ScriptableBuildPipeline.maximumCacheSize * 1073741824L; // gigabytes to bytes ThreadPool.QueueUserWorkItem(PruneCache, maximumCacheSize); return(exitCode); }
public BuildsViewModel GenerateViewModel() { // 1. Skriv content till fil. // 2. Kolla om filen är gammal eller ny. // 3. Hämta fil om ny och gör till model, annars skriv ner den på fil var content = _buildsRepository.GetStaticBuilds(); if (content.BuildList == null) { return(this); } else { //var model = new BuildsViewModel(_buildsRepository) //{ // BuildList = content.BuildList //}; this.BuildList = content.BuildList; foreach (var build in this.BuildList) { foreach (var changeSet in build.ChangesetList) { if (changeSet.ItemList.Any()) { foreach (var item in changeSet.ItemList) { if (item.Msg.Contains("#")) { Regex pattern = new Regex(@"\#(.\d+)"); var result = Regex.Matches(item.Msg, pattern.ToString()); StringBuilder sb = new StringBuilder(); foreach (Match m in result) { string add = m.Groups[1].Value; sb.Append(add); } item.GitHashNumber = sb.ToString(); int index = item.Msg.LastIndexOf("("); if (index > 0) { item.Msg = item.Msg.Substring(0, index); } } } } else { var item = new Item { Msg = "No changes, same code as previous build!" }; changeSet.ItemList.Add(item); } } } // START Skriva till och hämta från cache var rootCachePath = @"Cache\builds.txt"; System.IO.Directory.CreateDirectory(System.IO.Path.Combine(_env.ContentRootPath, "Cache")); var cachePath = System.IO.Path.Combine(_env.ContentRootPath, rootCachePath); var cacheModel = new BuildCache(this, DateTime.Now); string serializeContent = JsonConvert.SerializeObject(cacheModel); System.IO.File.WriteAllText(cachePath, serializeContent); var deserializeContent = System.IO.File.ReadAllText(@"C:\Users\Bowa\Desktop\cddamvc\CDDA\Cache\builds.txt", Encoding.UTF8); var fromCacheModel = JsonConvert.DeserializeObject <BuildCache>(deserializeContent); // END return(this); } }
/// <summary> /// Default implementation of generating Asset Bundles using the Scriptable Build Pipeline. /// </summary> /// <param name="parameters">Set of parameters used for building asset bundles.</param> /// <param name="content">Set of content and explicit asset bundle layout to build.</param> /// <param name="result">Results from building the content and explicit asset bundle layout.</param> /// <param name="taskList">Custom task list for building asset bundles.</param> /// <param name="contextObjects">Additional context objects to make available to the build.</param> /// <returns>Return code with status information about success or failure causes.</returns> public static ReturnCode BuildAssetBundles(IBundleBuildParameters parameters, IBundleBuildContent content, out IBundleBuildResults result, IList <IBuildTask> taskList, params IContextObject[] contextObjects) { // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code if (parameters == null) { result = null; BuildLogger.LogException(new ArgumentNullException("parameters")); return(ReturnCode.Exception); } // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code if (taskList.IsNullOrEmpty()) { result = null; BuildLogger.LogException(new ArgumentException("Argument cannot be null or empty.", "taskList")); return(ReturnCode.Exception); } // Don't run if there are unsaved changes if (ValidationMethods.HasDirtyScenes()) { result = null; return(ReturnCode.UnsavedChanges); } AssetDatabase.SaveAssets(); ReturnCode exitCode; result = new BundleBuildResults(); using (new BuildInterfacesWrapper()) #if !CI_TESTRUNNER_PROJECT using (new SceneStateCleanup()) using (var progressTracker = new ProgressTracker()) #else using (var progressTracker = new ProgressLoggingTracker()) #endif using (var buildCache = new BuildCache(parameters.CacheServerHost, parameters.CacheServerPort)) { Directory.CreateDirectory(parameters.TempOutputFolder); BuildContext buildContext; try { buildContext = new BuildContext(contextObjects); buildContext.SetContextObject(parameters); buildContext.SetContextObject(content); buildContext.SetContextObject(result); buildContext.SetContextObject(progressTracker); buildContext.SetContextObject(buildCache); buildContext.SetContextObject(new Unity5PackedIdentifiers()); buildContext.SetContextObject(new BuildDependencyData()); buildContext.SetContextObject(new BundleWriteData()); buildContext.SetContextObject(BuildCallbacks); } catch (Exception e) { // Avoid throwing exceptions in here as we don't want them bubbling up to calling user code result = null; BuildLogger.LogException(e); return(ReturnCode.Exception); } exitCode = BuildTasksRunner.Validate(taskList, buildContext); if (exitCode >= ReturnCode.Success) { exitCode = BuildTasksRunner.Run(taskList, buildContext); } if (Directory.Exists(parameters.TempOutputFolder)) { Directory.Delete(parameters.TempOutputFolder, true); } } int maximumSize = EditorPrefs.GetInt("BuildCache.maximumSize", 200); long maximumCacheSize = maximumSize * 1073741824L; // gigabytes to bytes ThreadPool.QueueUserWorkItem(PruneCache, maximumCacheSize); return(exitCode); }
public void Setup() { m_Seed = 0; BuildCache.PurgeCache(false); // TOOD: If the build cache didn't use global directories, this wouldn't be necessary m_TempDir = GetTemporaryDirectory(); }