protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new CopyJob(); var handle = job.Schedule(this, inputDeps); return(handle); }
/// <summary> /// Queues new or rebuild of the specified group. /// </summary> /// <param name="group">The group to rebuild.</param> private void QueueRebuild(StaticBatchingGroupKey group) { // Read instances List <StaticMeshInstance> instances; if (!this.meshInstances.TryGetValue(group, out instances)) { return; } // Prepare data arrays for job int vCounter = 0, iCounter = 0; // Vertex and index counter StaticBatchingRebuildJobData jobData = new StaticBatchingRebuildJobData() { groupKey = group }; jobData.PreAllocate(); foreach (var instance in instances) { var cache = GetVisCache(instance.mesh); jobData.meshInstances.Add(instance); jobData.vertexOffsets.Add(vCounter); jobData.indexOffsets.Add(iCounter); vCounter += cache.vertices.Length; iCounter += cache.indices.Length; } // Allocate job data memory jobData.Allocate(vCounter, iCounter); // Dispatch jobs var dep = new TransformJob() { dataId = this.runningJobDataCounter }.Schedule(jobData.meshInstances.Count, 4); dep = new CopyJob() { dataId = this.runningJobDataCounter }.Schedule(dep); jobData.jobHandle = dep; jobData.jobId = this.runningJobDataCounter++; this.runningJobs.Add(jobData.jobId, jobData); JobHandle.ScheduleBatchedJobs(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var handle = inputDeps; var transforms = _transformGroup.GetTransformAccessArray(); var translations = new NativeArray <Translation>(transforms.length, Allocator.TempJob); var rotations = new NativeArray <Rotation>(transforms.length, Allocator.TempJob); handle = new StashJob { Translations = translations, Rotations = rotations, }.Schedule(transforms, handle); handle = new CopyJob { Translations = translations, Rotations = rotations, }.Schedule(this, handle); return(handle); }
public async Task handleEventGridBlobCreated(string eventGridBlobCreatedAsJson) { //Handle PutBlob/PutBlockList BlobEventGridData blobEvent = JsonConvert.DeserializeObject <BlobEventGridData>(eventGridBlobCreatedAsJson); if (blobEvent.api == "PutBlockList" || blobEvent.api == "PutBlob") { CloudBlob sourceBlob = new CloudBlob(new Uri(blobEvent.url)); BlobStorage sourceBlobStorage = new BlobStorage(masterStorageAccount, sourceBlob.Container.Name); Uri sourceBlobUri = sourceBlobStorage.GetReadBlobSasUri(sourceBlob.Name, 24); TableStorage <ReplicationStorageAccount> accountTableStorage = new TableStorage <ReplicationStorageAccount>(masterStorageAccount, "accounts"); var accounts = await accountTableStorage.GetAllAsync(); Parallel.ForEach(accounts, async(targetAccountEntity) => { CloudStorageAccount targetAccount = CloudStorageAccount.Parse(targetAccountEntity.connectionString); CloudBlobClient targetBlobClient = targetAccount.CreateCloudBlobClient(); CloudBlobContainer targetContainer = targetBlobClient.GetContainerReference(sourceBlob.Container.Name); await targetContainer.CreateIfNotExistsAsync(); CloudBlockBlob targetBlob = targetContainer.GetBlockBlobReference(sourceBlob.Name); await targetBlob.StartCopyAsync(sourceBlobUri); await targetBlob.FetchAttributesAsync(); CopyState state = targetBlob.CopyState; TableStorage <CopyJob> copyJobtableStorage = new TableStorage <CopyJob>(masterStorageAccount, "jobs"); CopyJob job = new CopyJob(state, targetContainer.Name, targetBlob.Name, targetBlob.Uri.ToString(), targetAccountEntity.RowKey); await copyJobtableStorage.InsertOrReplaceAsync(job); //log.Info($"Copyiing {blobUri} to {targetAccountEntity.accountName} in region {targetAccountEntity.region}"); }); } //Handle copy complete if (blobEvent.api == "CopyBlob") { } }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Usage: EFM32.exe <SLab SW package directory>"); } var bspBuilder = new SLabBSPBuilder(new BSPDirectories(args[0], @"..\..\Output", @"..\..\rules")); List <MCUFamilyBuilder> allFamilies = new List <MCUFamilyBuilder>(); var ignoredFamilyNames = File.ReadAllLines(Path.Combine(bspBuilder.Directories.RulesDir, "rulesfamaly.txt")); string DirDevices = Path.Combine(bspBuilder.Directories.InputDir, @"platform\Device\SiliconLabs"); string[] allFamilySubdirectories = Directory.GetDirectories(DirDevices); Console.WriteLine("Enumerating devices..."); foreach (var dir in allFamilySubdirectories) { string familyName = Path.GetFileNameWithoutExtension(dir); if (ignoredFamilyNames.FirstOrDefault(n => dir.Contains(n)) != null) { continue; } var devices = GetMCUsForFamily(dir); Console.WriteLine($" {familyName}: {devices.Count} devices"); ValidateMCUNames(devices); if (devices.Where(d => d.RAMSize == 0 || d.FlashSize == 0).Count() > 0) { throw new Exception($"Some devices are RAM Size ({devices.Where(d => d.RAMSize == 0).Count()}) = 0 or FLASH Size({devices.Where(d => d.FlashSize == 0).Count()}) = 0 "); } if (devices.Count == 0) { throw new Exception("No devices for " + familyName); } string StartupFile = Directory.GetFiles(Path.Combine(DirDevices, familyName, @"Source\GCC"), "startup_*.c")[0].Replace(bspBuilder.Directories.InputDir, @"$$BSPGEN:INPUT_DIR$$"); var copyJob = new CopyJob() { FilesToCopy = "-*startup_*;*.h;*.c", TargetFolder = "Devices", ProjectInclusionMask = "*.c", AutoIncludeMask = "*.h", SourceFolder = DirDevices + "\\" + familyName }; var fam = new MCUFamilyBuilder(bspBuilder, new FamilyDefinition() { Name = familyName, FamilySubdirectory = familyName, PrimaryHeaderDir = "$$BSPGEN:INPUT_DIR$$", StartupFileDir = StartupFile, CoreFramework = new Framework() { CopyJobs = new[] { copyJob } }, Subfamilies = new MCUClassifier[] { }.ToArray() }); fam.MCUs.AddRange(devices); allFamilies.Add(fam); } List <MCUFamily> familyDefinitions = new List <MCUFamily>(); List <MCU> mcuDefinitions = new List <MCU>(); List <EmbeddedFramework> frameworks = new List <EmbeddedFramework>(); List <MCUFamilyBuilder.CopiedSample> exampleDirs = new List <MCUFamilyBuilder.CopiedSample>(); bool noPeripheralRegisters = args.Contains("/noperiph"); List <KeyValuePair <string, string> > macroToHeaderMap = new List <KeyValuePair <string, string> >(); var commonPseudofamily = new MCUFamilyBuilder(bspBuilder, XmlTools.LoadObject <FamilyDefinition>(bspBuilder.Directories.RulesDir + @"\CommonFiles.xml")); foreach (var fw in commonPseudofamily.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } var flags = new ToolFlags(); List <string> projectFiles = new List <string>(); commonPseudofamily.CopyFamilyFiles(ref flags, projectFiles); foreach (var sample in commonPseudofamily.CopySamples()) { exampleDirs.Add(sample); } Console.WriteLine("Processing families..."); int cnt = 0; foreach (var fam in allFamilies) { Console.WriteLine($" {fam.Definition.Name} ({++cnt}/{allFamilies.Count})..."); var rejectedMCUs = fam.RemoveUnsupportedMCUs(true); if (rejectedMCUs.Length != 0) { Console.WriteLine("Unsupported {0} MCUs:", fam.Definition.Name); foreach (var mcu in rejectedMCUs) { Console.WriteLine("\t{0}", mcu.Name); } } fam.AttachStartupFiles(ParseStartupFiles(fam.Definition.StartupFileDir, fam)); var famObj = fam.GenerateFamilyObject(true); famObj.AdditionalSourceFiles = LoadedBSP.Combine(famObj.AdditionalSourceFiles, projectFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalHeaderFiles = LoadedBSP.Combine(famObj.AdditionalHeaderFiles, projectFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).ToArray()); famObj.AdditionalSystemVars = LoadedBSP.Combine(famObj.AdditionalSystemVars, commonPseudofamily.Definition.AdditionalSystemVars); famObj.CompilationFlags = famObj.CompilationFlags.Merge(flags); famObj.CompilationFlags.PreprocessorMacros = LoadedBSP.Combine(famObj.CompilationFlags.PreprocessorMacros, new string[] { "$$com.sysprogs.bspoptions.primary_memory$$_layout" }); familyDefinitions.Add(famObj); fam.GenerateLinkerScripts(false); if (!noPeripheralRegisters) { fam.AttachPeripheralRegisters(ParsePeripheralRegisters(bspBuilder.Directories.OutputDir + "\\" + fam.Definition.FamilySubdirectory + "\\Devices", fam)); } foreach (var mcu in fam.MCUs) { mcuDefinitions.Add(mcu.GenerateDefinition(fam, bspBuilder, !noPeripheralRegisters)); } foreach (var fw in fam.GenerateFrameworkDefinitions()) { frameworks.Add(fw); } foreach (var sample in fam.CopySamples()) { exampleDirs.Add(sample); } } BoardSupportPackage bsp = new BoardSupportPackage { PackageID = "com.sysprogs.arm.silabs.efm32", PackageDescription = "Silabs EFM32 Devices", GNUTargetID = "arm-eabi", GeneratedMakFileName = "efm32.mak", MCUFamilies = familyDefinitions.ToArray(), SupportedMCUs = mcuDefinitions.ToArray(), Frameworks = frameworks.ToArray(), Examples = exampleDirs.Where(s => !s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), TestExamples = exampleDirs.Where(s => s.IsTestProjectSample).Select(s => s.RelativePath).ToArray(), FileConditions = bspBuilder.MatchedFileConditions.ToArray(), PackageVersion = "5.8.3" }; Console.WriteLine("Saving BSP..."); bspBuilder.Save(bsp, true); }
private void SynthesizeAndAppendCopyJobFromCMakeFiles(Framework framework) { var fwPath = string.Format("{0}\\lib\\ksdk_{1}_lib\\armgcc", Directories.InputDir, framework.ID.Substring(framework.ID.LastIndexOf(".") + 1)); var cmakeFiles = Directory.GetFiles(fwPath, "CMakeLists.txt", SearchOption.AllDirectories); var filesToFamilies = new Dictionary <string, HashSet <string> >(); var families = new List <string>(); var copyPaths = new HashSet <string>(); var allFiles = new HashSet <string>(); foreach (var cmakeFile in cmakeFiles) { var splitPath = cmakeFile.Split(Path.DirectorySeparatorChar); var family = splitPath[splitPath.Length - 2]; families.Add(family); var contents = File.ReadAllText(cmakeFile); var includeDirs = Regex.Matches(contents, @"INCLUDE_DIRECTORIES\(\${ProjDirPath}\/..\/..\/..\/..\/([\w\/]+)\)").Cast <Match>().Select(m => m.Groups[1].Value).ToList(); var sourceFiles = Regex.Matches(contents, @"\${ProjDirPath}\/..\/..\/..\/..\/([\w\/.]+)").Cast <Match>().Select(m => m.Groups[1].Value).ToList(); var allFamilyFiles = sourceFiles.Concat(includeDirs).Where( f => { var t = f.ToLower(); return(!t.Contains(DEVICES_FOLDER) && !t.Contains(CMSIS_FOLDER) && !t.Contains("iar") && !t.Contains("realview") && !t.Contains("mdk") && !t.Contains("rtos/freertos/config")); }).ToArray(); allFiles.UnionWith(allFamilyFiles); foreach (var file in allFamilyFiles) { var filePath = file; if (file.EndsWith(".h") || file.EndsWith(".c") || file.EndsWith(".txt")) { filePath = file.Substring(0, file.LastIndexOf('/')); } if (file == "rtos") { continue; } filePath = filePath.Replace("/", "\\"); filePath += "\\"; copyPaths.Add(filePath + "*.c"); copyPaths.Add(filePath + "*.h"); } foreach (var file in allFamilyFiles.Select(f => f.Replace("/", "\\\\"))) { if (!filesToFamilies.ContainsKey(file)) { filesToFamilies.Add(file, new HashSet <string>()); } filesToFamilies[file].Add(family); } } var dirs = allFiles.Where(f => !f.EndsWith(".h") && !f.EndsWith(".c")).Select(f => "$$SYS:BSP_ROOT$$/" + f).ToArray(); var allIncludeDirs = new HashSet <string>(); for (int i = 0; i < dirs.Length; i++) { var familyFound = false; foreach (var fam in families) { if (dirs[i].Contains(fam)) { familyFound = true; allIncludeDirs.Add(dirs[i].Replace(fam, "$$SYS:FAMILY_ID$$")); break; } } if (!familyFound) { allIncludeDirs.Add(dirs[i]); } } allIncludeDirs.Remove("$$SYS:BSP_ROOT$$/rtos/FreeRTOS/config/$$SYS:FAMILY_ID$$/gcc"); //FreeRTOS config files are copied to each project individually var frameworkMCUs = new List <string>(); foreach (var familyName in families) { frameworkMCUs.AddRange(_familyToMCUs[familyName]); } framework.Filter = string.Join("|", frameworkMCUs); var fileConditions = new Dictionary <string, string>(); foreach (var fileFamilies in filesToFamilies) { var fcKey = fileFamilies.Key; string absPath = Path.Combine(Directories.InputDir, fcKey); if (!File.Exists(absPath) && !Directory.Exists(absPath)) { if (fcKey == @"rtos\\mqx\\config\\mcu\\MK66F18" || fcKey == @"rtos\\mqx\\config\\mcu\\MKV10Z1287" || fcKey == @"rtos\\uCOSII\\src\\uCOS" || fcKey == @"rtos\\uCOSIII\\src\\uCOS" || fcKey == @"rtos\\uCOSIII\\src\\uC") { continue; } throw new Exception("Non-existing path mentioned in Kinetis CMake files. Please investigate."); } if (fileFamilies.Value.Count == 1) { fileConditions.Add(fcKey, fileFamilies.Value.First()); } else if (fileFamilies.Value.Count < families.Count) { fileConditions.Add(fcKey, string.Join(" | ", fileFamilies.Value)); } } var newJob = new CopyJob { SourceFolder = Directories.InputDir, TargetFolder = "", FilesToCopy = "-platform\\devices\\startup.*;" + string.Join(";", copyPaths), SimpleFileConditions = fileConditions.Select(kv => string.Format("{0}: $$SYS:FAMILY_ID$$ =~ {1}", kv.Key.Replace(".", "\\."), kv.Value)).ToArray(), AdditionalIncludeDirs = string.Join(";", allIncludeDirs.ToArray()), ProjectInclusionMask = string.Join(";", allFiles.Where(f => f.EndsWith(".h", StringComparison.CurrentCultureIgnoreCase) || f.EndsWith(".c", StringComparison.CurrentCultureIgnoreCase))), AlreadyCopied = true, AutoIncludeMask = "-*", }; framework.CopyJobs = framework.CopyJobs.Concat(new CopyJob[] { newJob }).ToArray(); }
void Start(Collection <MetaRecord> metarecords, IEnumerable <ArchiveTask> archiveParameters) { _log.ProcedureCall("Start"); foreach (ArchiveTask archiveParameter in archiveParameters) { var job = new CompressionJob(archiveParameter, _task.EnableEncryption, _log); if (NotificationEventHandler != null) { job.NotificationEventHandler += NotificationEventHandler; } _compressionManager.AddJob(job); } _compressionManager.WaitUntilAllJobsAreDone(); if (_aborting) { _log.ProcedureCall("Start::archiving aborted"); return; } var imageCreationJob = new ImageCreationJob(_log, _imageFile, metarecords); if (NotificationEventHandler != null) { imageCreationJob.NotificationEventHandler += NotificationEventHandler; } _imageCreationManager.AddJob(imageCreationJob); _imageCreationManager.WaitUntilAllJobsAreDone(); if (_aborting) { _log.ProcedureCall("Start::Image creation aborted"); return; } foreach (StorageBase storage in _task.Storages) { var job = new CopyJob(storage, _imageFile.FileName, _task.EnableEncryption, _log); if (NotificationEventHandler != null) { job.NotificationEventHandler += NotificationEventHandler; } _copyManager.AddJob(job); } _copyManager.WaitUntilAllJobsAreDone(); if (_aborting) { _log.ProcedureCall("Start::copying storage aborted"); return; } RunProgramsChainAfterBackup(); if (_aborting) { _log.ProcedureCall("Start::run programs chain after backup aborted"); return; } // removing if (_task.SecureDeletingOfFiles) { OverWriteFileWithZeros(_imageFile.FileName); } else { File.Delete(_imageFile.FileName); } }
private void GenerateConditionsForSubdirs(FamilyDefinition family, Framework fw, CopyJob job) { HashSet <string> explicitlyMentionedDirectories = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); HashSet <string> excludedSubdirectories = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); foreach (var cond in job.SmartFileConditions ?? new string[0]) { var def = SmartPropertyDefinition.Parse(cond, null); foreach (var item in def.Items) { int idx = item.Key.IndexOf('\\'); if (idx != -1) { explicitlyMentionedDirectories.Add(item.Key.Substring(0, idx)); } } } Regex rgExcludedSubdir = new Regex(@"-([^\\]+)\\\*$"); foreach (var cond in (job.FilesToCopy + ";" + job.ProjectInclusionMask).Split(';')) { var m = rgExcludedSubdir.Match(cond); if (m.Success) { excludedSubdirectories.Add(m.Groups[1].Value); } } List <string> generatedSmartFileConditions = new List <string>(); foreach (var dir in Directory.GetDirectories(_Builder.ExpandVariables(job.SourceFolder))) { string name = Path.GetFileName(dir); if (explicitlyMentionedDirectories.Contains(name)) { continue; } if (excludedSubdirectories.Contains(name)) { continue; } generatedSmartFileConditions.Add($"-{name}|{name}\\\\.*"); if (!_FrameworkConditions.TryGetValue(fw.ID, out var conditions)) { _FrameworkConditions[fw.ID] = conditions = new GeneratedFrameworkConditions { TargetPath = $"$$SYS:BSP_ROOT$$/{family.FamilySubdirectory}/{job.TargetFolder}".Replace('\\', '/') } } ; conditions.ConditionalSubdirectories.Add(name); } job.SmartFileConditions = (job.SmartFileConditions ?? new string[0]).Concat(generatedSmartFileConditions).OrderBy(c => c.ToLower().TrimStart('-')).ToArray(); } void GenerateBLEFrameworks(FamilyDefinition family) { List <Framework> bleFrameworks = new List <Framework>(); string famBase = family.Name.Substring(0, 5).ToLower(); HashSet <string> discoveredSubdirs = new HashSet <string>(); string baseDir = Path.Combine(family.PrimaryHeaderDir, @"..\..\..\components\ble"); foreach (var subdir in Directory.GetDirectories(baseDir)) { discoveredSubdirs.Add(Path.GetFileName(subdir)); } foreach (var subdir in Directory.GetDirectories(Path.Combine(baseDir, "ble_services"))) { discoveredSubdirs.Add(Path.Combine("ble_services", Path.GetFileName(subdir))); } foreach (var name in new[] { "ble_services", "common", "peer_manager", "nrf_ble_gatt" }) { discoveredSubdirs.Remove(name); } foreach (var dir in discoveredSubdirs) { string desc = FetchDescriptionFromDirectory(Path.Combine(baseDir, dir)) ?? throw new Exception("Failed to load description of " + dir); if (desc.StartsWith("BLE")) { desc = desc.Substring(3).Trim(); } string virtualFolderName = "BLE " + desc; desc = "Bluetooth LE - " + desc; string id = Path.GetFileName(dir); if (id.StartsWith("experimental_")) { id = id.Substring(13); } if (!id.StartsWith("ble_") && !id.StartsWith("nrf_ble")) { id = "ble_" + id; } /*if (dir.StartsWith("ble_services\\", StringComparison.CurrentCultureIgnoreCase)) * { * int idx = id.IndexOf("ble_"); * if (idx == -1) * id = "ble_svc_" + id; * else * id = id.Insert(idx + 4, "svc_"); * }*/ bleFrameworks.Add(new Framework { Name = string.Format("{0} ({1})", desc, Path.GetFileName(dir)), ID = "com.sysprogs.arm.nordic." + famBase + "." + id, ClassID = "com.sysprogs.arm.nordic.nrfx." + id, ProjectFolderName = virtualFolderName, DefaultEnabled = false, CopyJobs = new CopyJob[] { new CopyJob { SourceFolder = Path.Combine(baseDir, dir), TargetFolder = @"components\ble\" + dir, FilesToCopy = "-*_nrf51.c;*.c;*.h", } } }); } family.AdditionalFrameworks = family.AdditionalFrameworks.Concat(bleFrameworks).OrderBy(fw => fw.Name).ToArray(); }
private void GenerateConditionsForPrebuiltLibraries(FamilyDefinition family, Framework fw, CopyJob job) { var srcDir = Path.GetFullPath(_Builder.ExpandVariables(job.SourceFolder)); var allLibraries = Directory.GetFiles(srcDir, "*.a", SearchOption.AllDirectories) .Select(l => l.Substring(srcDir.Length).TrimStart('\\')).ToArray(); var conditions = new[] { new PrebuiltLibraryCondition("hard-float", "com.sysprogs.bspoptions.arm.floatmode", "-mfloat-abi=hard", "soft-float"), new PrebuiltLibraryCondition("no-interrupts", "com.sysprogs.bspoptions.nrf5x.interrupts", "no"), new PrebuiltLibraryCondition("short-wchar", "com.sysprogs.bspoptions.nrf5x.wchar", "-fshort-wchar"), }; Dictionary <string, PrebuiltLibraryCondition> conditionsByFolder = new Dictionary <string, PrebuiltLibraryCondition>(); foreach (var cond in conditions) { conditionsByFolder[cond.Folder] = cond; if (cond.InverseFolder != null) { conditionsByFolder[cond.InverseFolder] = cond; } } foreach (var grp in allLibraries.GroupBy(l => l.Substring(0, l.IndexOf('\\')), StringComparer.InvariantCultureIgnoreCase)) { HashSet <PrebuiltLibraryCondition> allConditionsInGroup = new HashSet <PrebuiltLibraryCondition>(); List <ConstructedLibraryCondition> libs = new List <ConstructedLibraryCondition>(); foreach (var lib in grp) { List <string> components = lib.Split('\\').ToList(); int libComponent = components.IndexOf("lib"); if (libComponent < 0) { throw new Exception($"Cannot build a list of conditional folders. {lib} does not contain 'lib' in the path."); } components.RemoveRange(0, libComponent + 1); string cortexPrefix = "cortex-"; if (!components[0].StartsWith(cortexPrefix)) { throw new Exception($"Relative path to {lib} does not start with 'cortex-'"); } string cortexCore = components[0].Substring(cortexPrefix.Length); components.RemoveAt(0); components.RemoveAt(components.Count - 1); foreach (var cmp in components) { if (!conditionsByFolder.TryGetValue(cmp, out var cond)) { throw new Exception($"Don't know how to map '{cmp}' to a prebuilt library condition"); } allConditionsInGroup.Add(cond); } libs.Add(new ConstructedLibraryCondition { Library = $"$$SYS:BSP_ROOT$$/{family.FamilySubdirectory}/{job.TargetFolder}/" + lib.Replace('\\', '/'), PathComponents = components.ToArray(), Core = cortexCore }); } foreach (var lib in libs) { List <Condition> finalConditions = new List <Condition>(); finalConditions.Add(new Condition.Equals { Expression = "$$com.sysprogs.bspoptions.nrf5x.cortex$$", ExpectedValue = lib.Core }); foreach (var usedCond in allConditionsInGroup) { var eqCond = new Condition.Equals { Expression = $"$${usedCond.Variable}$$", ExpectedValue = usedCond.Value }; if (lib.PathComponents.Contains(usedCond.Folder)) { finalConditions.Add(eqCond); } else { finalConditions.Add(new Condition.Not { Argument = eqCond }); } } FileCondition cond = new FileCondition { FilePath = lib.Library, ConditionToInclude = new Condition.And { Arguments = finalConditions.ToArray() } }; _Builder.AddFileCondition(cond); } } }
//Different STM32 device subfamilies support different subsets of USB device classes, so we have to dynamically remove the unsupported ones. public override void PatchSmartFileConditions(ref string[] smartFileConditions, string expandedSourceFolder, string subdir, CopyJob copyJob) { if (copyJob.SourceFolder.EndsWith("STM32_USB_Device_Library")) { for (int i = 0; i < smartFileConditions.Length; i++) { var condList = smartFileConditions[i].Split('\n').Select(s => s.Trim()).ToList(); for (int j = 0; j < condList.Count; j++) { int idx = condList[j].IndexOf("=>"); if (idx < 0) { continue; } string mask = condList[j].Substring(0, idx); idx = mask.LastIndexOf('\\'); if (idx == -1) { continue; } string condSubdir = mask.Substring(0, idx); if (!condSubdir.StartsWith("Class\\", StringComparison.InvariantCultureIgnoreCase)) { continue; } if (!Directory.Exists(Path.Combine(expandedSourceFolder, condSubdir))) { condList.RemoveAt(j--); } } smartFileConditions[i] = string.Join("\r\n", condList); } } }