Example #1
0
        public static void Save(BoardSupportPackage bsp, String BSPRoot)
        {
            XmlTools.SaveObject(bsp, Path.Combine(BSPRoot, "BSP.XML"));

            string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion);

            TarPacker.PackDirectoryToTGZ(BSPRoot, Path.Combine(BSPRoot, archiveName), fn => Path.GetExtension(fn).ToLower() != ".vgdbxbsp");

            BSPSummary lst = new BSPSummary
            {
                BSPName              = bsp.PackageDescription,
                BSPID                = bsp.PackageID,
                BSPVersion           = bsp.PackageVersion,
                MinimumEngineVersion = bsp.MinimumEngineVersion,
                FileName             = archiveName,
            };

            foreach (var mcu in bsp.SupportedMCUs)
            {
                lst.MCUs.Add(new BSPSummary.MCU {
                    Name = mcu.ID, FLASHSize = mcu.FLASHSize, RAMSize = mcu.RAMSize, UserFriendlyName = mcu.UserFriendlyName
                });
            }

            XmlTools.SaveObject(lst, Path.Combine(BSPRoot, Path.ChangeExtension(archiveName, ".xml")));
        }
Example #2
0
        //-----------------------------------------------
        static void Main(string[] args)
        {
            const string bspDir = @"..\..\..\..\generators\nrf5x\output";
            string       tempDir;

            if (args.Length < 2)
            {
                throw new Exception("Usage: NordicVendorSampleParser <SDKDir> <TestDir>");
            }

            SDKdir  = args[0];
            tempDir = args[1];

            toolchainDir = File.ReadAllLines(SDKdir + @"\components\toolchain\gcc\Makefile.windows")[0].Split('=')[1].Trim(' ');

            ApplyKnownPatches();
            string sampleListFile = Path.Combine(outputDir, "samples.xml");
            var    sampleDir      = BuildOrLoadSampleDirectory(SDKdir, outputDir, sampleListFile, toolchainDir);

            if (sampleDir.Samples.FirstOrDefault(s => s.AllDependencies != null) == null)
            {
                //Perform Pass 1 testing - test the raw VendorSamples in-place
                StandaloneBSPValidator.Program.TestVendorSamples(sampleDir, bspDir, tempDir);
                XmlTools.SaveObject(sampleDir, sampleListFile);
            }

            foreach (var s in sampleDir.Samples)
            {
                s.BSPReferencesAreCopyable = true;
            }

            //Insert the samples into the generated BSP
            var relocator = new NordicSampleRelocator();

            relocator.InsertVendorSamplesIntoBSP(sampleDir, bspDir);

            var bsp = XmlTools.LoadObject <BoardSupportPackage>(Path.Combine(bspDir, "bsp.xml"));

            bsp.VendorSampleDirectoryPath = "VendorSamples";
            bsp.VendorSampleCatalogName   = "Nordic SDK Samples";
            XmlTools.SaveObject(bsp, Path.Combine(bspDir, "bsp.xml"));

            string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion);
            string statFile    = Path.ChangeExtension(archiveName, ".xml");

            TarPacker.PackDirectoryToTGZ(bspDir, Path.Combine(bspDir, archiveName), fn => Path.GetExtension(fn).ToLower() != ".vgdbxbsp" && Path.GetFileName(fn) != statFile);

            var expandedSamples = XmlTools.LoadObject <VendorSampleDirectory>(Path.Combine(bspDir, "VendorSamples", "VendorSamples.xml"));

            expandedSamples.Path = Path.GetFullPath(Path.Combine(bspDir, "VendorSamples"));
            var result = StandaloneBSPValidator.Program.TestVendorSamples(expandedSamples, bspDir, tempDir);

            if (result.Failed > 0)
            {
                throw new Exception("Some of the vendor samples failed to build. Check the build log.");
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                throw new Exception("Usage: stm32.exe <SW package directory> <temporary directory>");
            }
            string       SDKdir    = args[0];
            string       outputDir = @"..\..\Output";
            const string bspDir    = @"..\..\..\..\generators\stm32\output";
            string       tempDir   = args[1];

            string sampleListFile = Path.Combine(outputDir, "samples.xml");

            var sampleDir = BuildOrLoadSampleDirectory(SDKdir, outputDir, sampleListFile);

            if (sampleDir.Samples.FirstOrDefault(s => s.AllDependencies != null) == null)
            {
                //Perform Pass 1 testing - test the raw VendorSamples in-place
                StandaloneBSPValidator.Program.TestVendorSamples(sampleDir, bspDir, tempDir);
                XmlTools.SaveObject(sampleDir, sampleListFile);
            }

            //Insert the samples into the generated BSP
            var relocator = new STM32SampleRelocator();

            relocator.InsertVendorSamplesIntoBSP(sampleDir, bspDir, new STM32PathMapper(sampleDir));

            var bsp = XmlTools.LoadObject <BoardSupportPackage>(Path.Combine(bspDir, "bsp.xml"));

            bsp.VendorSampleDirectoryPath = "VendorSamples";
            bsp.VendorSampleCatalogName   = "STM32 CubeMX Samples";
            XmlTools.SaveObject(bsp, Path.Combine(bspDir, "bsp.xml"));

            string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion);
            string statFile    = Path.ChangeExtension(archiveName, ".xml");

            TarPacker.PackDirectoryToTGZ(bspDir, Path.Combine(bspDir, archiveName), fn => Path.GetExtension(fn).ToLower() != ".vgdbxbsp" && Path.GetFileName(fn) != statFile);

            // Finally verify that everything builds
            var expandedSamples = XmlTools.LoadObject <VendorSampleDirectory>(Path.Combine(bspDir, "VendorSamples", "VendorSamples.xml"));

            expandedSamples.Path = Path.GetFullPath(Path.Combine(bspDir, "VendorSamples"));
            StandaloneBSPValidator.Program.TestVendorSamples(expandedSamples, bspDir, tempDir, 1);
        }
Example #4
0
        public void ProduceBSPArchive(BoardSupportPackage bsp)
        {
            //bsp.PackageVersion = string.Format("{0:d4}{1:d2}{2:d2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            //bsp.PackageVersion += "-beta";
            XmlTools.SaveObject(bsp, Path.Combine(mbedRoot, "BSP.XML"));

            string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion);

            Console.WriteLine("Creating BSP archive...");

            TarPacker.PackDirectoryToTGZ(mbedRoot, Path.Combine(Path.GetDirectoryName(mbedRoot), archiveName), fn =>
            {
                string relPath = fn.Substring(mbedRoot.Length + 1);
                if (relPath.StartsWith(".git"))
                {
                    return(false);
                }
                if (relPath.ToLower() == "ParsedTargets.xml".ToLower())
                {
                    return(false);
                }
                return(true);
            }, subdir => !subdir.StartsWith(".git", StringComparison.CurrentCultureIgnoreCase));

            var lst = new BSPGenerationTools.BSPSummary
            {
                BSPName              = bsp.PackageDescription,
                BSPID                = bsp.PackageID,
                BSPVersion           = bsp.PackageVersion,
                MinimumEngineVersion = bsp.MinimumEngineVersion,
                FileName             = archiveName,
            };

            foreach (var mcu in bsp.SupportedMCUs)
            {
                lst.MCUs.Add(new BSPGenerationTools.BSPSummary.MCU {
                    Name = mcu.ID, FLASHSize = mcu.FLASHSize, RAMSize = mcu.RAMSize
                });
            }

            XmlTools.SaveObject(lst, Path.Combine(Path.GetDirectoryName(mbedRoot), Path.ChangeExtension(archiveName, ".xml")));
        }
Example #5
0
        public void Run(string[] args)
        {
            string  SDKdir             = null;
            string  specificSampleName = null;
            RunMode mode = RunMode.Invalid;

            foreach (var arg in args)
            {
                string singlePrefix = "/single:";
                if (arg.StartsWith(singlePrefix, StringComparison.InvariantCultureIgnoreCase))
                {
                    mode = RunMode.SingleSample;
                    specificSampleName = arg.Substring(singlePrefix.Length);
                }
                else if (arg.StartsWith("/"))
                {
                    mode = Enum.GetValues(typeof(RunMode)).OfType <RunMode>().First(v => v.ToString().ToLower() == arg.Substring(1).ToLower());
                }
                else
                {
                    SDKdir = arg;
                }
            }

            if (SDKdir == null || mode == RunMode.Invalid)
            {
                Console.WriteLine($"Usage: {Path.GetFileName(Assembly.GetEntryAssembly().Location)} <mode> <SW package directory>");
                Console.WriteLine($"Modes:");
                Console.WriteLine($"       /incremental   - Only retest/rebuild previously failed samples.");
                Console.WriteLine($"                       This doesn't update the BSP archive.");
                Console.WriteLine($"       /release       - Reuse cached definitions, retest all samples. Update BSP.");
                Console.WriteLine($"       /cleanRelease  - Reparse/retest all samples. Update BSP.");
                Console.WriteLine($"       /updateErrors  - Re-categorize errors based on KnownProblems.xml");
                Console.WriteLine($"       /single:<name> - Run all phases of just one sample.");
                Console.WriteLine($"Press any key to continue...");
                Console.ReadKey();
                Environment.ExitCode = 1;
                return;
            }

            if (mode == RunMode.Incremental)
            {
                Console.WriteLine("*********************** WARNING ************************");
                Console.WriteLine("* Vendor sample parser is running in incremental mode. *");
                Console.WriteLine("* Only retested samples will be saved to BSP!          *");
                Console.WriteLine("* Re-run in /release mode to build a releasable BSP.   *");
                Console.WriteLine("********************************************************");
            }

            if (mode == RunMode.UpdateErrors)
            {
                foreach (var rec in _Report.Records)
                {
                }

                XmlTools.SaveObject(_Report, ReportFile);

                return;
            }

            string archiveName     = string.Format("{0}-{1}.vgdbxbsp", BSP.BSP.PackageID.Split('.').Last(), BSP.BSP.PackageVersion);
            string archiveFilePath = Path.Combine(BSPDirectory, archiveName);

            if (File.Exists(archiveFilePath))
            {
                File.Delete(archiveFilePath);
            }

            string sampleListFile = Path.Combine(CacheDirectory, "Samples.xml");

            var sampleDir = BuildOrLoadSampleDirectoryAndUpdateReportForFailedSamples(sampleListFile, SDKdir, mode, specificSampleName);
            Dictionary <VendorSampleID, string> encounteredIDs = new Dictionary <VendorSampleID, string>();

            foreach (var vs in sampleDir.Samples)
            {
                var id = new VendorSampleID(vs);
                if (encounteredIDs.TryGetValue(id, out var dir))
                {
                    throw new Exception("Duplicate sample for " + id);
                }
                encounteredIDs[new VendorSampleID(vs)] = vs.Path;

                var rec = _Report.ProvideEntryForSample(new VendorSampleID(vs));
                if (rec.LastSucceededPass < VendorSamplePass.InitialParse)
                {
                    rec.LastSucceededPass = VendorSamplePass.InitialParse;
                }
            }

            //We cache unadjusted sample definitions to allow tweaking the adjusting code without the need to reparse everything.
            Console.WriteLine("Adjusting sample properties...");
            foreach (var vs in sampleDir.Samples)
            {
                AdjustVendorSampleProperties(vs);
                if (vs.Path == null)
                {
                    throw new Exception("Missing sample path for " + vs.UserFriendlyName);
                }
            }

            VendorSample[] pass1Queue, insertionQueue;

            switch (mode)
            {
            case RunMode.Incremental:
                pass1Queue = insertionQueue = sampleDir.Samples.Where(s => _Report.ShouldBuildIncrementally(new VendorSampleID(s), VendorSamplePass.InPlaceBuild)).ToArray();
                break;

            case RunMode.Release:
                insertionQueue = sampleDir.Samples;
                if (sampleDir.Samples.FirstOrDefault(s => s.AllDependencies != null) == null)
                {
                    pass1Queue = sampleDir.Samples;
                }
                else
                {
                    pass1Queue = new VendorSample[0];
                }
                break;

            case RunMode.CleanRelease:
                pass1Queue = insertionQueue = sampleDir.Samples;
                break;

            case RunMode.SingleSample:
                pass1Queue = insertionQueue = sampleDir.Samples.Where(s => new VendorSampleID(s).ToString() == specificSampleName).ToArray();
                if (pass1Queue.Length == 0)
                {
                    throw new Exception("No samples match " + specificSampleName);
                }
                break;

            default:
                throw new Exception("Invalid run mode");
            }

            if (pass1Queue.Length > 0)
            {
                //Test the raw VendorSamples in-place and store AllDependencies
                TestVendorSamplesAndUpdateReportAndDependencies(pass1Queue, null, VendorSamplePass.InPlaceBuild, vs => _Report.HasSampleFailed(new VendorSampleID(vs)), validationFlags: BSPValidationFlags.ResolveNameCollisions);

                foreach (var vs in pass1Queue)
                {
                    if (vs.Path == null)
                    {
                        throw new Exception("Missing sample path for " + vs.UserFriendlyName);
                    }
                }

                sampleDir.ToolchainDirectory = ToolchainDirectory;
                sampleDir.BSPDirectory       = Path.GetFullPath(BSPDirectory);
                XmlTools.SaveObject(sampleDir, sampleListFile);
            }

            //Insert the samples into the generated BSP
            var relocator   = CreateRelocator(sampleDir);
            var copiedFiles = relocator.InsertVendorSamplesIntoBSP(sampleDir, insertionQueue, BSPDirectory);

            var bsp = XmlTools.LoadObject <BoardSupportPackage>(Path.Combine(BSPDirectory, LoadedBSP.PackageFileName));

            bsp.VendorSampleDirectoryPath = VendorSampleDirectoryName;
            bsp.VendorSampleCatalogName   = VendorSampleCatalogName;
            XmlTools.SaveObject(bsp, Path.Combine(BSPDirectory, LoadedBSP.PackageFileName));

            if (mode != RunMode.Incremental && mode != RunMode.SingleSample)
            {
                Console.WriteLine("Creating new BSP archive...");
                string statFile = Path.ChangeExtension(archiveName, ".xml");
                TarPacker.PackDirectoryToTGZ(BSPDirectory, archiveFilePath, fn => Path.GetExtension(fn).ToLower() != ".vgdbxbsp" && Path.GetFileName(fn) != statFile);
            }

            var vendorSampleListInBSP = Path.Combine(BSPDirectory, VendorSampleDirectoryName, "VendorSamples.xml");
            // Finally verify that everything builds
            var expandedSamples = XmlTools.LoadObject <VendorSampleDirectory>(vendorSampleListInBSP);

            expandedSamples.Path = Path.GetFullPath(Path.Combine(BSPDirectory, VendorSampleDirectoryName));

            var finalStats = TestVendorSamplesAndUpdateReportAndDependencies(expandedSamples.Samples, expandedSamples.Path, VendorSamplePass.RelocatedBuild);

            XmlTools.SaveObject(_Report, ReportFile);

            if (mode == RunMode.Incremental || mode == RunMode.SingleSample)
            {
                Console.WriteLine($"Deleting incomplete {vendorSampleListInBSP}...\n***Re-run in /release mode to produce a valid BSP.");
                File.Delete(vendorSampleListInBSP);   //Incremental mode only places the samples that are currently built.
            }

            if (finalStats.Failed == 0)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"All {finalStats.Total} tests passed during final pass.");
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"{finalStats.Failed} out of {finalStats.Total} tests failed during final pass.");
            }

            Console.ResetColor();
            Console.WriteLine("=============================================");
            Console.WriteLine($"Overall statistics for v{BSP.BSP.PackageVersion}:");
            List <KeyValuePair <string, string> > fields = new List <KeyValuePair <string, string> >();

            fields.Add(new KeyValuePair <string, string>("Total samples discovered:", sampleDir.Samples.Length.ToString()));

            int unparsableSamples   = _Report.Records.Count(r => r.LastSucceededPass == VendorSamplePass.None);
            int failedAtFirstBuild  = _Report.Records.Count(r => r.LastSucceededPass == VendorSamplePass.InitialParse && r.BuildFailedExplicitly);
            int failedAtSecondBuild = _Report.Records.Count(r => r.LastSucceededPass == VendorSamplePass.InPlaceBuild && r.BuildFailedExplicitly);

            fields.Add(new KeyValuePair <string, string>("Failed during initial parse attempt:", $"{unparsableSamples}/{sampleDir.Samples.Length} ({unparsableSamples * 100.0 / sampleDir.Samples.Length:f1}%)"));
            fields.Add(new KeyValuePair <string, string>("Failed during in-place build:", $"{failedAtFirstBuild}/{sampleDir.Samples.Length} ({failedAtFirstBuild * 100.0 / sampleDir.Samples.Length:f1}%)"));
            fields.Add(new KeyValuePair <string, string>("Failed during relocated build:", $"{failedAtSecondBuild}/{sampleDir.Samples.Length} ({failedAtSecondBuild * 100.0 / sampleDir.Samples.Length:f1}%)"));
            if (mode != RunMode.Incremental)
            {
                fields.Add(new KeyValuePair <string, string>("Inserted into BSP:", expandedSamples.Samples.Length.ToString()));
            }
            OutputKeyValueList(fields);

            if (finalStats.Failed > 0 && mode != RunMode.Incremental)
            {
                throw new Exception("Some of the vendor samples have failed the final test. Fix this before releasing the BSP.");
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Example #6
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            if (args.Length < 2)
            {
                throw new Exception("Usage: TestFrameworkGenerator <Rules subdir> <Source directory>");
            }
            var dummyBSPBuilder = new DummyBSPBuilder(new BSPDirectories(args[1], @"..\..\Output\" + args[0], @"..\..\rules\" + args[0]));

            if (Directory.Exists(dummyBSPBuilder.Directories.OutputDir))
            {
                Directory.Delete(dummyBSPBuilder.Directories.OutputDir, true);
            }
            Directory.CreateDirectory(dummyBSPBuilder.Directories.OutputDir);


            var fwObj = XmlTools.LoadObject <TestFrameworkDefinition>(Path.Combine(dummyBSPBuilder.Directories.RulesDir, "TestFramework.xml"));

            dummyBSPBuilder.FrameworkID = fwObj.ID;
            var           rules        = XmlTools.LoadObject <TestFrameworkRules>(Path.Combine(dummyBSPBuilder.Directories.RulesDir, "rules.xml"));
            List <string> projectFiles = new List <string>();
            ToolFlags     flags        = new ToolFlags();

            if (fwObj.Common == null)
            {
                fwObj.Common = new TestFrameworkDefinition.TestPlatformBuild();
            }


            foreach (var job in rules.CopyJobs)
            {
                flags = flags.Merge(job.CopyAndBuildFlags(dummyBSPBuilder, projectFiles, null, ref fwObj.Common.ConfigurableProperties, null));
            }

            Dictionary <string, FileCondition> matchedConditions = new Dictionary <string, FileCondition>(StringComparer.InvariantCultureIgnoreCase);

            foreach (var cond in dummyBSPBuilder.MatchedFileConditions)
            {
                matchedConditions[cond.FilePath] = cond;
            }

            var           platformIndepenentFiles = projectFiles.Where(f => !matchedConditions.ContainsKey(f)).ToList();
            List <string> embeddedFiles           = new List <string>();
            List <string> linuxFiles = new List <string>();

            foreach (var f in projectFiles)
            {
                FileCondition cond;
                if (matchedConditions.TryGetValue(f, out cond))
                {
                    var eq = (cond.ConditionToInclude as Condition.Equals);
                    if (eq?.Expression == "$$platform$$")
                    {
                        dummyBSPBuilder.MatchedFileConditions.Remove(cond);
                        switch (eq.ExpectedValue)
                        {
                        case "embedded":
                            embeddedFiles.Add(f);
                            break;

                        case "linux":
                            linuxFiles.Add(f);
                            break;

                        default:
                            throw new Exception("Invalid platform condition");
                        }
                    }
                    else if (!platformIndepenentFiles.Contains(f))
                    {
                        platformIndepenentFiles.Add(f);
                    }
                }
            }

            fwObj.Common.AdditionalSourceFiles = platformIndepenentFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).Select(f => dummyBSPBuilder.MakeRelativePath(f)).ToArray();
            fwObj.Common.AdditionalHeaderFiles = platformIndepenentFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).Select(f => dummyBSPBuilder.MakeRelativePath(f)).ToArray();

            fwObj.Common.AdditionalIncludeDirs        = flags.IncludeDirectories?.Select(f => dummyBSPBuilder.MakeRelativePath(f))?.ToArray();
            fwObj.Common.AdditionalPreprocessorMacros = flags.PreprocessorMacros?.Select(f => dummyBSPBuilder.MakeRelativePath(f))?.ToArray();

            if (fwObj.Embedded != null)
            {
                fwObj.Embedded.AdditionalSourceFiles = embeddedFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).Select(f => dummyBSPBuilder.MakeRelativePath(f)).ToArray();
                fwObj.Embedded.AdditionalHeaderFiles = embeddedFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).Select(f => dummyBSPBuilder.MakeRelativePath(f)).ToArray();
                fwObj.Embedded.AdditionalIncludeDirs = fwObj.Embedded.AdditionalIncludeDirs?.Select(f => dummyBSPBuilder.MakeRelativePath(f))?.ToArray();
            }

            if (fwObj.Linux != null)
            {
                fwObj.Linux.AdditionalSourceFiles = linuxFiles.Where(f => !MCUFamilyBuilder.IsHeaderFile(f)).Select(f => dummyBSPBuilder.MakeRelativePath(f)).ToArray();
                fwObj.Linux.AdditionalHeaderFiles = linuxFiles.Where(f => MCUFamilyBuilder.IsHeaderFile(f)).Select(f => dummyBSPBuilder.MakeRelativePath(f)).ToArray();
                fwObj.Linux.AdditionalIncludeDirs = fwObj.Linux.AdditionalIncludeDirs?.Select(f => dummyBSPBuilder.MakeRelativePath(f))?.ToArray();
            }

            foreach (var cond in dummyBSPBuilder.MatchedFileConditions)
            {
                cond.FilePath = dummyBSPBuilder.MakeRelativePath(cond.FilePath);    //Substitute $$SYS:BSP_ROOT$$ with $$SYS:TESTFW_BASE$$/...
            }
            fwObj.FileConditions = dummyBSPBuilder.MatchedFileConditions.ToArray();

            CopyAndAdjustSamples(dummyBSPBuilder, fwObj.Embedded.Samples);
            CopyAndAdjustSamples(dummyBSPBuilder, fwObj.Common.Samples);

            XmlTools.SaveObject(fwObj, Path.Combine(dummyBSPBuilder.Directories.OutputDir, "TestFramework.xml"));

            string outDir      = dummyBSPBuilder.Directories.OutputDir;
            string archiveName = $"{fwObj.ID.Split('.').Last()}-{fwObj.Version}.vgdbxtfp";

            Console.WriteLine("Building archive...");
            string archiveFile = Path.Combine(dummyBSPBuilder.Directories.OutputDir, archiveName);

            TarPacker.PackDirectoryToTGZ(outDir, archiveFile, fn => Path.GetExtension(fn).ToLower() != ".vgdbxtfp");
        }
Example #7
0
        /*
         * PropertyList ConfigurableProperties= new PropertyList
         * {
         * PropertyGroups = new List<PropertyGroup>
         * {
         * new PropertyGroup
         * {
         *  Properties = new List<PropertyEntry>
         *  {
         *      new PropertyEntry.Enumerated
         *      {
         *          Name = "Execute from",
         *          UniqueID = PrimaryMemoryOptionName,
         *          SuggestionList = new PropertyEntry.Enumerated.Suggestion[]
         *          {
         *              new PropertyEntry.Enumerated.Suggestion{InternalValue = "flash", UserFriendlyName = "FLASH"},
         *              new PropertyEntry.Enumerated.Suggestion{InternalValue = "sram", UserFriendlyName = "SRAM"},
         *          }
         *      }
         *  }
         * }
         * }
         */

        //------------------------------------------------
        static void Main(string[] args)
        {
            string tempDir;

            SDKdir  = args[0];
            tempDir = args[1];
            string       bspDir   = SDKdir + @"\esp32-bsp"; //@"..\..\..\..\generators\Esp32\output";
            const string bspRules = @"..\..\..\..\generators\Esp32\Rules";

            if (args.Length > 2)
            {
                if (args[2] == "KConfig")
                { //Generate sdkconfig from KConfig
                    CLParserKConfig.ParserAllFilesKConfig(bspDir);
                    //CLParserKConfig.SdkconfigChangeMacros(@"C:\SysGCC\esp32\esp32-bsp\sysprogs\samples\01_Hello_world\sdkconfig.h");
                    CLParserKConfig.GenerateSdkconfigFile();
                    return;
                }
            }

            if (args.Length < 2)
            {
                throw new Exception("Usage: Esp32VendorSampleParser <Toolchain ESP32 Dir> <TestDir>");
            }


            string sampleListFile = Path.Combine(outputDir, "samples.xml");
            var    sampleDir      = BuildOrLoadSampleDirectory(SDKdir, outputDir, sampleListFile);

            if (sampleDir.Samples.FirstOrDefault(s => s.AllDependencies != null) == null)
            {
                //Perform Pass 1 testing - test the raw VendorSamples in-place
                StandaloneBSPValidator.Program.TestVendorSamples(sampleDir, bspDir, tempDir, 1, true);
                foreach (var smp in sampleDir.Samples)
                {
                    if (smp.AllDependencies == null)
                    {
                        Console.WriteLine(smp.UserFriendlyName + "no dependes");
                    }
                    else
                    {
                        for (int cntdep = 0; cntdep < smp.AllDependencies.Count(); cntdep++)
                        {
                            if (smp.AllDependencies[cntdep].StartsWith("/"))
                            {
                                smp.AllDependencies[cntdep] = smp.AllDependencies[cntdep].Replace("/usr/lib/", SDKdir + "/lib/");// @"c:/SysGCC/esp32/");
                            }
                            if (smp.AllDependencies[cntdep].StartsWith("/"))
                            {
                                smp.AllDependencies[cntdep] = SDKdir + smp.AllDependencies[cntdep];
                            }
                        }
                    }
                }
                sampleDir.ToolchainDirectory = sampleDir.ToolchainDirectory.Replace('/', '\\');
                XmlTools.SaveObject(sampleDir, sampleListFile);
            }

            //Insert the samples into the generated BSP

            var relocator = new Esp32SampleRelocator();

            relocator.InsertVendorSamplesEsp32IntoBSP(sampleDir, bspDir);

            var bsp = XmlTools.LoadObject <BoardSupportPackage>(Path.Combine(bspDir, "bsp.xml"));

            bsp.VendorSampleDirectoryPath = "VendorSamples";
            bsp.VendorSampleCatalogName   = "ESP32 SDK Samples";
            XmlTools.SaveObject(bsp, Path.Combine(bspDir, "bsp.xml"));

            string archiveName = string.Format("{0}-{1}.vgdbxbsp", bsp.PackageID.Split('.').Last(), bsp.PackageVersion);
            string statFile    = Path.ChangeExtension(archiveName, ".xml");

            TarPacker.PackDirectoryToTGZ(bspDir, Path.Combine(bspDir, archiveName), fn => Path.GetExtension(fn).ToLower() != ".vgdbxbsp" && Path.GetFileName(fn) != statFile);

            var expandedSamples = XmlTools.LoadObject <VendorSampleDirectory>(Path.Combine(bspDir, "VendorSamples", "VendorSamples.xml"));

            expandedSamples.Path = Path.GetFullPath(Path.Combine(bspDir, "VendorSamples"));
            var result = StandaloneBSPValidator.Program.TestVendorSamples(expandedSamples, bspDir, tempDir, 1, true);

            if (result.Failed > 0)
            {
                throw new Exception("Some of the vendor samples failed to build. Check the build log.");
            }
        }