Exemple #1
0
        private static IncludePath GetIncludePath(string include, out bool isPrefix)
        {
            isPrefix = false;
            var result = new IncludePath {
                Path = include
            };
            var match       = Match.Empty;
            var matchPrefix = IncludePrefixRegex.Match(include);

            if (matchPrefix.Success)
            {
                match    = matchPrefix;
                isPrefix = true;
            }
            else
            {
                var matchSuffix = IncludeSuffixRegex.Match(include);
                if (matchSuffix.Success)
                {
                    match = matchSuffix;
                }
            }

            if (match.Success && match.Groups.Count >= 2)
            {
                result.Addition = match.Groups[1].Value;
                result.Path     = result.Path.Replace(result.Addition, "");
                result.Addition = result.Addition.Substring(1, result.Addition.Length - 2);
            }
            return(result);
        }
Exemple #2
0
        private void lstIncludes_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            ListBox     lb   = (ListBox)sender;
            IncludePath obj  = (IncludePath)lb.Items[e.Index];
            string      text = obj.Path;

            e.DrawBackground();

            Graphics g = e.Graphics;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                g.FillRectangle(SystemBrushes.Highlight, e.Bounds);
            }
            else
            {
                g.FillRectangle(new SolidBrush(e.BackColor), e.Bounds);
            }
            g.DrawString(text, e.Font, new SolidBrush(e.ForeColor), new PointF(e.Bounds.X, e.Bounds.Y));

            e.DrawFocusRectangle();
        }
Exemple #3
0
        public override bool Compile(string file)
        {
            var file_name = file.Split('.')[0];

            // Compile
            string cl_args = "";

            Options.ForEach((str) => cl_args     += $" {str}");
            IncludePath.ForEach((str) => cl_args += $" /I\"{str}\"");
            cl_args += $" /c {file} /Fo{file_name}.obj";
            var cl = MakeProcess(ToolchainPath[0] + "\\cl.exe", cl_args);

            ReadCompileResult(cl);
            if (ExitCode != 0)
            {
                return(false);
            }

            // Link
            string link_args = " " + Options[0];

            LibraryPath.ForEach((str) => link_args += $" /LIBPATH:\"{str}\"");
            link_args += $" /out:{file_name}.exe {file_name}.obj";
            var link = MakeProcess(ToolchainPath[0] + "\\link.exe", link_args);

            ReadCompileResult(link);
            if (ExitCode != 0)
            {
                return(false);
            }

            return(true);
        }
Exemple #4
0
		private static IncludePath GetIncludePath(string include)
		{
			var result = new IncludePath { Path = include };
			var match = includePrefixRegex.Match(include);
			if (match.Success && match.Groups.Count >= 2)
			{
				result.Prefix = match.Groups[1].Value;
				result.Path = result.Path.Replace(result.Prefix, "");
				result.Prefix = result.Prefix.Substring(1, result.Prefix.Length - 2);
			}
			return result;
		}
Exemple #5
0
 public void IncludeDelete()
 {
     if (lstIncludes.SelectedItem != null)
     {
         if (MessageBox.Show("Do you really want to remove this path from the backups?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             IncludePath sel = (IncludePath)lstIncludes.SelectedItem;
             MainDbContext.DB.IncludePaths.Remove(sel);
             MainDbContext.DB.SaveChanges();
             RefreshFromDB();
         }
     }
 }
Exemple #6
0
        private static IncludePath GetIncludePath(string include)
        {
            var result = new IncludePath {
                Path = include
            };
            var match = includePrefixRegex.Match(include);

            if (match.Success && match.Groups.Count >= 2)
            {
                result.Prefix = match.Groups[1].Value;
                result.Path   = result.Path.Replace(result.Prefix, "");
                result.Prefix = result.Prefix.Substring(1, result.Prefix.Length - 2);
            }
            return(result);
        }
Exemple #7
0
        public void Initialize(Entity root)
        {
            ProjectEntity  project  = ProjectEntity.Decorate(root);
            TemplateEntity template = TemplateEntity.Decorate(root);

            Target[]   availableTargets = sdkRepository.GetAllTargets().ToArray();
            ICodeModel codeModel        = root.Value <ICodeModel>();

            SetProjectName();
            SetProjectNamespace();
            SetProjectType();
            SetProjectTargets();
            SetProjectEntities();
            SetProjectIncludes();

            void SetProjectName()
            {
                ProjectName = null;
                if (fileSystem.FileExists(System.IO.Path.Combine(root.Path, Constants.ProjectFileName)))
                {
                    ProjectName = root.Name;
                }
            }

            void SetProjectNamespace()
            {
                ProjectNamespace = CodeEntity.Decorate(project).Namespace;
            }

            void SetProjectType()
            {
                ProjectType = project.Type;
            }

            void SetProjectTargets()
            {
                TargetsResult targetsResult = targetParser.Targets(project, false);

                ProjectTargets = targetsResult.ValidTargets
                                 .Select(t => new ProjectTarget(t, availableTargets.Any(at => t.Name == at.Name && at.LongVersion == t.LongVersion)));

                Exceptions = targetsResult.Errors;
            }

            void SetProjectEntities()
            {
                IEnumerable <CodeEntity> entities = template.EntityHierarchy.Select(e =>
                {
                    CodeEntity codeEntity = CodeEntity.Decorate(e);
                    return(codeEntity);
                }
                                                                                    );

                ProjectCodeEntities = entities.Select(e =>
                {
                    TemplateEntity te = TemplateEntity.Decorate(e);
                    return(e, te.RelatedEntites.Where(en => !en.Type.Contains("project")));
                })
                                      .Where(e => !e.Item1.Type.Contains("project")).ToDictionary(p => p.Item1, p => p.Item2);
            }

            void SetProjectIncludes()
            {
                IncludePaths = new List <IncludePath>();
                IEnumerable <SdkInformation> relevantSdks = ProjectTargets.Select(t => availableTargets.FirstOrDefault(at => t.Target.Name == at.Name && at.LongVersion == t.Target.LongVersion))
                                                            .Where(t => t != null)
                                                            .Select(sdkRepository.GetSdk)
                                                            .Where(sdk => sdk != null)
                                                            .Distinct();
                var targetsWithIncludePaths = relevantSdks.Select(sdk => (sdk.Targets, sdk.IncludePaths.Concat(sdk.CompilerInformation.IncludePaths).Distinct()));

                foreach (var item in targetsWithIncludePaths)
                {
                    foreach (Target target in item.Targets)
                    {
                        foreach (string includePath in item.Item2)
                        {
                            IncludePath existingIncludePath = IncludePaths.Where(i => i.PathValue.Equals(includePath, StringComparison.InvariantCulture)).FirstOrDefault();

                            if (existingIncludePath == null)
                            {
                                existingIncludePath = new IncludePath(includePath, true, new List <Target>());
                                IncludePaths.Add(existingIncludePath);
                            }
                            existingIncludePath.Targets = existingIncludePath.Targets.Concat(new[] { target });
                        }
                    }
                }

                foreach (IncludePath codeModelIncludeDirectory in codeModel.IncludeDirectories)
                {
                    IncludePath existingIncludePath = IncludePaths.Where(p => p.PathValue.Equals(codeModelIncludeDirectory.PathValue, StringComparison.InvariantCulture)).FirstOrDefault();

                    if (existingIncludePath == null)
                    {
                        IncludePaths.Add(codeModelIncludeDirectory);
                    }
                    else
                    {
                        foreach (Target target in codeModelIncludeDirectory.Targets)
                        {
                            if (!existingIncludePath.Targets.Contains(target))
                            {
                                existingIncludePath.Targets = existingIncludePath.Targets.Concat(new[] { target });
                            }
                        }
                    }
                }
            }
        }