예제 #1
0
        public LibManager(SetupData setup)
        {
            sharedRepositoryPath = Path.Combine(Helpers.getSketchbookFolder(), "libraries");
            sharedRepository     = new RepositoryLocal("Shared Libraries", sharedRepositoryPath);



            repositories = new List <IRepository>();
            repositories.Add(new RepositoryIndexJson("Arduino Repository", Path.Combine(Helpers.arduinoAppPath, "library_index.json")));
            repositories.Add(new RepositoryLocal("Installed Teensyduino Libraries", setup.libBase));

            repositories.Add(sharedRepository);
        }
예제 #2
0
        public void update()
        {
            repositories.Clear();

            IRepository rvm;

            rvm = new RepositoryLocal("Teensyduino Libraries", setup.tdLibBase);
            if (rvm.libraries != null)
            {
                repositories.Add(rvm);
            }

            rvm = new RepositoryLocal("Installed, shared Libraries", setup.sharedLibrariesFolder, shared: true);
            if (rvm.libraries != null)
            {
                repositories.Add(rvm);
            }

            rvm = new RepositoryIndexJson("Arduino Repository", setup.libIndex_json);
            if (rvm.libraries != null)
            {
                repositories.Add(rvm);
            }
        }
예제 #3
0
        private void openExistingFolder(string vsTeensyJsonPath)
        {
            try
            {  // read vsTeensy.json
                var fileContent = JsonConvert.DeserializeObject <ProjectTransferData>(File.ReadAllText(vsTeensyJsonPath));

                if (fileContent == null || fileContent.version != "1" || fileContent.configurations.Count == 0)
                {
                    openNewFolder();
                }
                else
                {
                    buildSystem  = fileContent.buildSystem;
                    target       = fileContent.target;
                    debugSupport = fileContent.debugSupport;

                    foreach (var cfg in fileContent.configurations)
                    {
                        var configuration = (Configuration)cfg;
                        configuration.setup = this.setup;       /// hack, look for better solution


                        // add shared libraries ---------------------
                        if (cfg.sharedLibraries != null)
                        {
                            var sharedLibraries = libManager.sharedRepository?.libraries.Select(version => version.FirstOrDefault()); //flatten out list by selecting first version. Shared libraries  can only have one version

                            foreach (var cfgSharedLib in cfg.sharedLibraries)
                            {
                                var library = sharedLibraries?.FirstOrDefault(lib => lib.sourceFolderName == cfgSharedLib); // find the corresponding lib
                                if (library != null)
                                {
                                    configuration.sharedLibs.Add(ProjectLibrary.cloneFromLib(library));
                                }
                            }
                        }

                        // add libraries installed in ./lib ---------------------
                        var repo      = new RepositoryLocal("tmp", libBase); // Hack, directly store repo instead of lib list???
                        var localLibs = repo.libraries?.Select(version => version.FirstOrDefault());

                        if (localLibs != null)
                        {
                            foreach (var lib in localLibs)
                            {
                                var pl = ProjectLibrary.cloneFromLib(lib);
                                pl.targetUri = lib.sourceUri;
                                configuration.localLibs.Add(pl);
                            }
                        }

                        // initialize boards list and options
                        configuration.parseBoardsTxt(/*configuration.setupType == SetupTypes.quick ? setup.arduinoBoardsTxt : null*/ null);
                        configuration.selectedBoard = configuration.boards?.FirstOrDefault(b => b.name == cfg.board.name);
                        if (configuration.selectedBoard != null)
                        {
                            foreach (var option in cfg.board.options)
                            {
                                var optionSet = configuration.selectedBoard.optionSets.FirstOrDefault(x => x.name == option.Key);
                                if (optionSet != null)
                                {
                                    optionSet.selectedOption = optionSet.options.FirstOrDefault(x => x.name == option.Value);
                                }
                            }
                        }

                        _configurations.Add(configuration);
                    }
                    _selectedConfiguration = _configurations.FirstOrDefault();
                }
            }
            catch //(Exception ex)
            {
                //log.Warn($"config file {vsTeensyJson} does not exist");
                var sc = Configuration.getDefault(setup);
                _selectedConfiguration = sc;
                _configurations.Add(sc);

                return;
            }
        }