Exemple #1
0
        public bool MatchesDevice(SpecializedDevice device)
        {
            if (SkipUnconditionally)
            {
                return(false);
            }

            if (device == null)
            {
                return(true);
            }

            if (Devices != null)
            {
                if (!Devices.Contains(device.Device.ID))
                {
                    return(false);
                }
            }

            if (Cores != null)
            {
                if (!Cores.Contains(device.Core.ID))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #2
0
 public static string ExpandVariables(string str, SpecializedDevice optionalDevice, string packageName = null)
 {
     if (optionalDevice == null)
     {
         return(ExpandCommonVariables(str));
     }
     else
     {
         return(optionalDevice.ExpandVariables(str, packageName));
     }
 }
Exemple #3
0
        public IEnumerable <FileReference> LocateAllFiles(SpecializedDevice device, string rootDir)
        {
            var expandedPath = SpecializedDevice.ExpandVariables(SourcePath, device).Replace('\\', '/');

            foreach (var mask in Masks)
            {
                var expandedMask = SpecializedDevice.ExpandVariables(mask, device);
                if (mask.Contains("|") || expandedPath.Contains("|"))
                {
                    continue;
                }

                string[] foundFileNames;

                try
                {
                    if (mask.Contains("*"))
                    {
                        foundFileNames = Directory.GetFiles(Path.Combine(rootDir, expandedPath), mask).Select(f => Path.GetFileName(f)).ToArray();
                    }
                    else
                    {
                        foundFileNames = new string[] { mask }
                    };
                }
                catch
                {
                    foundFileNames = new string[0];
                }

                foreach (var fn in foundFileNames)
                {
                    string fullPath;
                    try
                    {
                        fullPath = Path.Combine(rootDir, expandedPath + "/" + fn);
                        if (!File.Exists(fullPath))
                        {
                            continue;
                        }
                    }
                    catch
                    {
                        continue;
                    }

                    yield return(new FileReference($"{expandedPath}/{fn}", Type));
                }
            }
        }
Exemple #4
0
        public VendorSample BuildVendorSample(string rootDir, string boardName, SpecializedDevice device, string package, HashSet <string> allComponentIDs, HashSet <string> implicitFrameworks)
        {
            Dictionary <string, string> properties = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(ExplicitFPUSetting))
            {
                properties["com.sysprogs.bspoptions.arm.floatmode"] = ExplicitFPUSetting.Contains("hard") ? "-mfloat-abi=hard" : "-mfloat-abi=soft";
            }

            string sampleName = ID;

            if (!string.IsNullOrEmpty(RelativePath))
            {
                string[] relativePathComponents = RelativePath.Split('/');
                if (relativePathComponents.Length > 3 && relativePathComponents[0] == "boards")
                {
                    string expectedPrefix = relativePathComponents[1] + "_" + relativePathComponents[2] + "_";
                    if (sampleName.StartsWith(expectedPrefix))
                    {
                        sampleName = sampleName.Substring(expectedPrefix.Length);
                    }
                }
            }


            VendorSample sample = new VendorSample
            {
                DeviceID         = device.MakeMCUID(package),
                UserFriendlyName = sampleName,
                InternalUniqueID = ID,
                Description      = Description,
                BoardName        = boardName,
                Configuration    = new VendorSampleConfiguration
                {
                    Frameworks       = Dependencies.Where(d => allComponentIDs.Contains(d)).Select(d => ParsedComponent.FrameworkIDPrefix + d).Concat(implicitFrameworks).Distinct().ToArray(),
                    MCUConfiguration = new PropertyDictionary2(properties)
                },

                VirtualPath        = Category,
                PreprocessorMacros = Defines,

                NoImplicitCopy = true
            };

            List <string>    sources = new List <string>(), headers = new List <string>();
            HashSet <string> includeDirectories = new HashSet <string>();

            string[] matchingPathComponents = null;

            foreach (var lst in SourceLists)
            {
                foreach (var file in lst.LocateAllFiles(device, rootDir))
                {
                    var bspPath = file.GetBSPPath();
                    UpdateMatchingPathComponents(bspPath, ref matchingPathComponents);

                    file.UpdateIncludeDirectoryList(includeDirectories);

                    switch (file.Type)
                    {
                    case SourceType.Library:
                    case SourceType.Source:
                        sources.Add(bspPath);
                        break;

                    case SourceType.Header:
                        headers.Add(bspPath);
                        break;

                    case SourceType.LinkerScript:
                        sample.LinkerScript = bspPath;
                        break;
                    }
                }
            }

            sample.CLanguageStandard = MapLanguageStandard(LanguageStandard);
            sample.LDFLAGS           = string.Join(" ", AdvancedLinkerOptions.Where(f => f.StartsWith("--defsym")).Select(f => "-Wl," + f).ToArray());
            if (sample.LDFLAGS == "")
            {
                sample.LDFLAGS = null;
            }

            if (matchingPathComponents != null)
            {
                sample.Path = string.Join("/", matchingPathComponents);
            }

            sample.SourceFiles        = sources.ToArray();
            sample.HeaderFiles        = headers.ToArray();
            sample.IncludeDirectories = includeDirectories.ToArray();

            return(sample);
        }