Пример #1
0
        public void Load(DProject proj, DProjectConfiguration config)
        {
            project = proj;
            configuration = config;

            cbUseDefaultCompiler.Active = proj.UseDefaultCompilerVendor;
            OnUseDefaultCompilerChanged();
            Gtk.TreeIter iter;
            if (cmbCompiler.Model.GetIterFirst (out iter)) {
                do {
                    if (proj.UsedCompilerVendor == (DCompilerVendor)cmbCompiler.Model.GetValue(iter, 1)) {
                        cmbCompiler.SetActiveIter(iter);
                        break;
                    }
                } while (cmbCompiler.Model.IterNext (ref iter));
            }

            extraCompilerTextView.Buffer.Text = config.ExtraCompilerArguments;
            extraLinkerTextView.Buffer.Text = config.ExtraLinkerArguments;

            libStore.Clear();
            foreach (string lib in proj.ExtraLibraries)
                libStore.AppendValues (lib);

            includePathStore.Clear();
            foreach(var p in project.LocalIncludeCache.DirectoryPaths)
                includePathStore.AppendValues(p);
        }
Пример #2
0
        public static string TraceLogFile(DProject project)
        {
            if (project == null)
            {
                return(null);
            }

            var config = project.GetConfiguration(Ide.IdeApp.Workspace.ActiveConfiguration) as DProjectConfiguration;

            if (config == null ||
                config.CompileTarget != DCompileTarget.Executable ||
                !project.Compiler.HasProfilerSupport)
            {
                return(null);
            }


            string file = Path.Combine(config.OutputDirectory, "trace.log");

            if (!File.Exists(file))
            {
                return(null);
            }
            return(file);
        }
Пример #3
0
		public ProjectIncludesWidget (DProject prj, DProjectConfiguration cfg)
		{
			this.Build ();

			Project = prj;
			CurrentConfig = cfg;
		}
Пример #4
0
        /// <summary>
        /// Compiles a D project.
        /// </summary>
        public BuildResult Build(DProject Project, ConfigurationSelector BuildConfigurationSelector)
        {
            this.Project = Project;
            BuildConfig  = Project.GetConfiguration(BuildConfigurationSelector) as DProjectConfiguration;
            commonMacros = new PrjPathMacroProvider {
                slnPath = Project.ParentSolution != null?EnsureCorrectPathSeparators(Project.ParentSolution.BaseDirectory) : ""
            };
            BuiltObjects.Clear();

            if (Compiler == null)
            {
                var targetBuildResult = new BuildResult();

                targetBuildResult.AddError("Project compiler \"" + Project.UsedCompilerVendor + "\" not found");
                targetBuildResult.FailedBuildCount++;

                return(targetBuildResult);
            }

            if (!Directory.Exists(AbsoluteObjectDirectory))
            {
                Directory.CreateDirectory(AbsoluteObjectDirectory);
            }

            if (CanDoOneStepBuild)
            {
                return(DoOneStepBuild());
            }
            else
            {
                return(DoStepByStepBuild());
            }
        }
Пример #5
0
        public static string GetCommandArgs(string baseCommandArgs, string filePath, DProject project, DProjectConfiguration conf)
        {
            var compiler = project.Compiler;

            ProjectBuilder.PrjPathMacroProvider prjPath = new ProjectBuilder.PrjPathMacroProvider {
                slnPath = project.ParentSolution != null?ProjectBuilder.EnsureCorrectPathSeparators(project.ParentSolution.BaseDirectory) : ""
            };

            List <string> includes = new List <string>(project.IncludePaths);

            includes.Add(project.BaseDirectory.FullPath);

            string[] src           = { filePath };
            var      compilerMacro = new UnittestMacros
            {
                ObjectsStringPattern  = compiler.ArgumentPatterns.ObjectFileLinkPattern,
                IncludesStringPattern = compiler.ArgumentPatterns.IncludePathPattern,

                SourceFiles = src,
                Includes    = ProjectBuilder.FillInMacros(includes, prjPath),
                Libraries   = ProjectBuilder.GetLibraries(conf, compiler),

                HasMain       = HasMainMethod(D_Parser.Misc.GlobalParseCache.GetModule(filePath)),
                compilerFlags = conf.ExtraCompilerArguments,
                linkerFlags   = conf.ExtraLinkerArguments
            };

            return(ProjectBuilder.FillInMacros(baseCommandArgs, compilerMacro, prjPath));
        }
Пример #6
0
        public static IEnumerable <IAbstractSyntaxTree> EnumAvailableModules(DProject Project = null)
        {
            var ret = new List <IAbstractSyntaxTree>();

            if (Project != null)
            {
                // Add the project's parsed modules to the reachable-packages list
                ret.AddRange(Project.ParsedModules);

                // Add all parsed project include modules that belong to the project's configuration
                foreach (var astColl in Project.LocalIncludeCache)
                {
                    ret.AddRange(astColl);
                }

                // Add all parsed global modules that belong to the project's compiler configuration
                foreach (var astColl in Project.Compiler.GlobalParseCache)
                {
                    ret.AddRange(astColl);
                }
            }
            else
            {
                foreach (var astColl in DCompiler.Instance.GetDefaultCompiler().GlobalParseCache)
                {
                    ret.AddRange(astColl);
                }
            }

            return(ret);
        }
Пример #7
0
        public static void Run(string filePath, DProject project, DProjectConfiguration conf)
        {
            if (manager == null)
            {
                manager = new ProgressMonitorManager();
                monitor = manager.GetOutputProgressMonitor("Run Unittest", Stock.RunProgramIcon, true, true);
            }

            Pad pad = manager.GetPadForMonitor(monitor);

            if (pad != null)
            {
                pad.BringToFront();
            }

            monitor.BeginTask("start unittest...", 1);

            new System.Threading.Thread(delegate(){
                string[] cmdParts = GetCmdParts(project);
                string args       = GetCommandArgs(cmdParts.Length >= 2 ?cmdParts[1] : "", filePath, project, conf);
                string errorOutput;
                string stdOutput;
                string execDir = GetExecDir(project, conf);

                ProjectBuilder.ExecuteCommand(cmdParts[0], args, execDir, monitor, out stdOutput, out errorOutput);

                monitor.Log.WriteLine("unittest done.");
                monitor.EndTask();
            }).Start();
        }
Пример #8
0
        static string GetCommandArgs(string baseCommandArgs, string filePath, DProject project, DProjectConfiguration conf)
        {
            var compiler = project.Compiler;

            ProjectBuilder.PrjPathMacroProvider prjPath = new ProjectBuilder.PrjPathMacroProvider {
                slnPath = project.ParentSolution != null?ProjectBuilder.EnsureCorrectPathSeparators(project.ParentSolution.BaseDirectory) : ""
            };

            List <string> includes = new List <string>(project.IncludePaths);

            includes.Add(project.BaseDirectory.FullPath);

            string[] src = { filePath };
            OneStepBuildArgumentMacroProvider compilerMacro = new OneStepBuildArgumentMacroProvider
            {
                ObjectsStringPattern  = compiler.ArgumentPatterns.ObjectFileLinkPattern,
                IncludesStringPattern = compiler.ArgumentPatterns.IncludePathPattern,

                SourceFiles = src,
                Includes    = ProjectBuilder.FillInMacros(includes, prjPath),
                Libraries   = ProjectBuilder.GetLibraries(conf, compiler),
            };

            return(ProjectBuilder.FillInMacros(baseCommandArgs, compilerMacro, prjPath));
        }
Пример #9
0
        public void Load(DProject proj, DProjectConfiguration config)
        {
            project       = proj;
            configuration = config;

            cbUseDefaultCompiler.Active = proj.UseDefaultCompilerVendor;
            OnUseDefaultCompilerChanged();
            Gtk.TreeIter iter;
            if (cmbCompiler.Model.GetIterFirst(out iter))
            {
                do
                {
                    if (proj.UsedCompilerVendor == (DCompilerVendor)cmbCompiler.Model.GetValue(iter, 1))
                    {
                        cmbCompiler.SetActiveIter(iter);
                        break;
                    }
                } while (cmbCompiler.Model.IterNext(ref iter));
            }

            extraCompilerTextView.Buffer.Text = config.ExtraCompilerArguments;
            extraLinkerTextView.Buffer.Text   = config.ExtraLinkerArguments;

            libStore.Clear();
            foreach (string lib in proj.ExtraLibraries)
            {
                libStore.AppendValues(lib);
            }

            includePathStore.Clear();
            foreach (var p in project.LocalIncludeCache.DirectoryPaths)
            {
                includePathStore.AppendValues(p);
            }
        }
Пример #10
0
 public void AnalyseTraceFile(DProject project)
 {
     TraceParser.Clear();
     if (ProfilerModeHandler.IsProfilerMode)
     {
         TraceParser.Parse(project);
     }
 }
Пример #11
0
        public ProjectDependenciesWidget(DProject prj, DProjectConfiguration cfg)
        {
            this.Build ();
            Show();

            Project = prj;
            CurrentConfig = cfg;
        }
Пример #12
0
        //删除项目信息
        public void DeleteProject()
        {
            NameValueCollection Params = HttpContext.Request.Form;//参数
            string result = DProject.Delete(new Guid(Params["code"])) != null ? "{HasError:false,msg:'项目删除成功!'}" : "{HasError:true,msg:'项目删除失败,请稍候再试!'}";

            Response.Write(result);
            Response.End();
        }
Пример #13
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         DProject ObjDProject = new DProject();
         ObjEProject.UserID = Utility.UserID;
         ObjDProject.UpdateArticleSettings(ObjEProject);
         if (ObjEProject.dtArticleSettings != null && ObjEProject.dtArticleSettings.Rows.Count > 0)
         {
             foreach (DataRow dr in ObjEProject.dtArticleSettings.Rows)
             {
                 if (Convert.ToString(dr["SettingName"]) == "Listpreis")
                 {
                     ObjEProject.lPVisible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "Multi1")
                 {
                     ObjEProject.M1Visible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "Multi2")
                 {
                     ObjEProject.M2Visible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "Multi3")
                 {
                     ObjEProject.M3Visible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "Multi4")
                 {
                     ObjEProject.M4Visible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "Dim")
                 {
                     ObjEProject.DimVisible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "Minutes")
                 {
                     ObjEProject.MinVisible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "Fabrikat")
                 {
                     ObjEProject.FabVisible = Convert.ToBoolean(dr["IsVisible"]);
                 }
                 else if (Convert.ToString(dr["SettingName"]) == "ME")
                 {
                     ObjEProject.MeVisible = Convert.ToBoolean(dr["IsVisible"]);
                 }
             }
         }
         this.Close();
     }
     catch (Exception ex)
     {
         Utility.ShowError(ex);
     }
 }
Пример #14
0
        public void run(DProject project)
        {
            if (project.UrlTemplate.empty())
            {
                return;
            }
            var tasks = project.UrlTemplate.generate();

            tasks.each(x => project.task(x));
        }
Пример #15
0
        static string GetExecDir(DProject project, DProjectConfiguration conf)
        {
            string execDir = conf.OutputDirectory.FullPath;

            if (!Directory.Exists(execDir))
            {
                execDir = project.BaseDirectory.FullPath;
            }
            return(execDir);
        }
Пример #16
0
        public static void GenerateMakefile(DProject prj, DProjectConfiguration cfg, ref string file)
        {
            if (string.IsNullOrEmpty(file))
            {
                file = prj.BaseDirectory.Combine("makefile");
            }

            var code = GenerateMakeCode(prj, cfg);

            File.WriteAllText(file, code);
        }
Пример #17
0
        public static void RunExternal(string filePath, DProject project, DProjectConfiguration conf)
        {
            if (console == null)
            {
                console = ExternalConsoleFactory.Instance.CreateConsole(false);
            }

            string args = GetCommandArgs(UnittestSettings.UnittestCommand, filePath, project, conf);
            //string execDir = GetExecDir(project, conf);

            //Runtime.ProcessService.StartConsoleProcess(cmdParts[0],args,execDir,console,null);
        }
Пример #18
0
        public static void RunExternal(string filePath, DProject project, DProjectConfiguration conf)
        {
            if (console == null)
            {
                console = ExternalConsoleFactory.Instance.CreateConsole(false);
            }

            string[] cmdParts = GetCmdParts(project);
            string   args     = GetCommandArgs(cmdParts.Length >= 2 ?cmdParts[1] : "", filePath, project, conf);
            string   execDir  = GetExecDir(project, conf);

            Runtime.ProcessService.StartConsoleProcess(cmdParts[0], args, execDir, console, null);
        }
Пример #19
0
        /// <summary>
        /// Compiles a D project.
        /// </summary>
        public BuildResult Build(DProject Project, ConfigurationSelector BuildConfigurationSelector)
        {
            this.Project = Project;
            BuildConfig  = Project.GetConfiguration(BuildConfigurationSelector) as DProjectConfiguration;

            if (Ide.IdeApp.Workbench == null)
            {
                _currentConfig = BuildConfig.Selector;
            }

            if (BuildConfig.Project != Project)
            {
                throw new InvalidOperationException("Wrong project configuration");
            }
            commonMacros = new PrjPathMacroProvider {
                slnPath = Project.ParentSolution != null?EnsureCorrectPathSeparators(Project.ParentSolution.BaseDirectory) : ""
            };
            BuiltObjects.Clear();

            if (Compiler == null)
            {
                var targetBuildResult = new BuildResult();

                targetBuildResult.AddError("Project compiler \"" + Project.UsedCompilerVendor + "\" not found");
                targetBuildResult.FailedBuildCount++;

                _currentConfig = null;
                return(targetBuildResult);
            }

            var absDir = AbsoluteObjectDirectory(BuildConfig);

            if (!Directory.Exists(absDir))
            {
                Directory.CreateDirectory(absDir);
            }

            BuildResult result;

            if (CanDoOneStepBuild)
            {
                result = DoOneStepBuild();
            }
            else
            {
                result = DoStepByStepBuild();
            }

            _currentConfig = null;
            return(result);
        }
Пример #20
0
 /// <summary>
 /// Code to delete a project
 /// </summary>
 /// <param name="ProjectID"></param>
 public void DeleteProject(int ProjectID)
 {
     try
     {
         if (ObjDAL == null)
         {
             ObjDAL = new DProject();
         }
         ObjDAL.DeleteProject(ProjectID);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #21
0
 /// <summary>
 /// Code to save the Cover sheets and template path
 /// </summary>
 /// <param name="strPath"></param>
 /// <param name="TemplatePath"></param>
 public void SavePath(string strPath, string TemplatePath)
 {
     try
     {
         if (ObjDAL == null)
         {
             ObjDAL = new DProject();
         }
         ObjDAL.SavePath(strPath, TemplatePath);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #22
0
        //获取项目信息
        public void GetPageProject()
        {
            NameValueCollection Params = HttpContext.Request.Form;//参数
            string page    = Params["page"];
            string rows    = Params["rows"];
            string query   = Params["query"];
            int    intPage = int.Parse((page == null || page == "0") ? "1" : page);
            //每页显示条数
            int pageSize = int.Parse((rows == null || rows == "0") ? "10" : rows);
            //每页的开始记录  第一页为1  第二页为number +1
            int start = (intPage - 1) * pageSize;

            Response.Write(DProject.GetPageProject(start, pageSize, query, User.Identity.Name));
            Response.End();
        }
Пример #23
0
        public static ParseCacheList CreateCacheList(DProject Project = null)
        {
            if (Project != null)
            {
                var pcl = ParseCacheList.Create(Project.LocalFileCache, Project.LocalIncludeCache, Project.Compiler.ParseCache);

                // Automatically include dep projects' caches
                foreach (var dep in Project.DependingProjects)
                    if (dep != null)
                        pcl.Add(dep.LocalFileCache);

                return pcl;
            }
            else
                return ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache);
        }
Пример #24
0
 /// <summary>
 /// Code to Copy a project
 /// </summary>
 /// <param name="ObjEProject"></param>
 /// <returns></returns>
 public EProject CopyProject(EProject ObjEProject)
 {
     try
     {
         if (ObjDAL == null)
         {
             ObjDAL = new DProject();
         }
         ObjEProject = ObjDAL.CopyProject(ObjEProject);
     }
     catch (Exception ex)
     {
         throw;
     }
     return(ObjEProject);
 }
Пример #25
0
        public void Parse(DProject project)
        {
            string file = TraceLogFile(project);

            if (file == null)
            {
                profilerPadWidget.AddTracedFunction(0, 0, 0, 0, new DVariable {
                    Name = "trace.log not found.."
                });
                return;
            }

            lastProfiledProject = project;
            profilerPadWidget.ClearTracedFunctions();

            var ctxt = ResolutionContext.Create(Resolver.DResolverWrapper.CreateCacheList(lastProfiledProject), null, null);

            StreamReader reader = File.OpenText(file);
            string       line;

            while ((line = reader.ReadLine()) != null)
            {
                var m = traceFuncRegex.Match(line);

                if (m.Success)
                {
                    var symName = m.Groups[5].Value;

                    if (symName.StartsWith("="))
                    {
                        continue;
                    }

                    bool mightBeLegalUnresolvableSymbol;
                    var  dn = ExamTraceSymbol(symName, ctxt, out mightBeLegalUnresolvableSymbol);

                    if (dn != null || mightBeLegalUnresolvableSymbol)
                    {
                        profilerPadWidget.AddTracedFunction(long.Parse(m.Groups[1].Value), long.Parse(m.Groups[2].Value),
                                                            long.Parse(m.Groups[3].Value), long.Parse(m.Groups[4].Value), dn ?? new DVariable {
                            Name = symName
                        });
                    }
                }
            }
        }
Пример #26
0
        public static string BuildOneStepBuildString(DProject prj, IEnumerable <string> builtObjects, ConfigurationSelector sel)
        {
            var cfg    = prj.GetConfiguration(sel) as DProjectConfiguration;
            var target = prj.GetOutputFileName(sel);

            var rawArgumentString = new StringBuilder();
            var s = GenAdditionalAttributes(prj.Compiler, cfg);

            if (!string.IsNullOrWhiteSpace(s))
            {
                rawArgumentString.Append(s.Trim()).Append(' ');
            }
            rawArgumentString.Append(BuildArguments(cfg).OneStepBuildArguments.Trim());
            if (!string.IsNullOrEmpty(cfg.ExtraCompilerArguments))
            {
                rawArgumentString.Append(' ').Append(cfg.ExtraCompilerArguments.Trim());
            }
            if (!string.IsNullOrEmpty(cfg.ExtraLinkerArguments))
            {
                rawArgumentString.Append(' ').Append(PrefixedExtraLinkerFlags(cfg));
            }

            var commonMacros = new PrjPathMacroProvider {
                slnPath = prj.ParentSolution != null?EnsureCorrectPathSeparators(prj.ParentSolution.BaseDirectory) : ""
            };

            var res = FillInMacros(rawArgumentString.ToString(),
                                   new OneStepBuildArgumentMacroProvider
            {
                ObjectsStringPattern  = prj.Compiler.ArgumentPatterns.ObjectFileLinkPattern,
                IncludesStringPattern = prj.Compiler.ArgumentPatterns.IncludePathPattern,

                SourceFiles = builtObjects,
                Includes    = FillInMacros(prj.IncludePaths, commonMacros),
                Libraries   = GetLibraries(cfg, prj.Compiler),

                RelativeTargetDirectory = cfg.OutputDirectory.ToRelative(prj.BaseDirectory),
                ObjectsDirectory        = ObjectDirectory(cfg),
                TargetFile = target,
            }, commonMacros);

            return(res);
        }
Пример #27
0
        public static ParseCacheList EnumAvailableModules(DProject Project = null)
        {
            if (Project != null)
            {
                var pcl = ParseCacheList.Create(Project.LocalFileCache, Project.LocalIncludeCache, Project.Compiler.ParseCache);

                // Automatically include dep projects' caches
                foreach (var dep in Project.DependingProjects)
                {
                    pcl.Add(dep.LocalFileCache);
                }

                return(pcl);
            }
            else
            {
                return(ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache));
            }
        }
Пример #28
0
        /// <summary>
        /// Compiles a D project.
        /// </summary>
        public BuildResult Build(DProject Project, ConfigurationSelector BuildConfigurationSelector)
        {
            this.Project = Project;
            BuildConfig  = Project.GetConfiguration(BuildConfigurationSelector) as DProjectConfiguration;

            BuiltObjects.Clear();

            if (Compiler == null)
            {
                var targetBuildResult = new BuildResult();

                targetBuildResult.AddError("Project compiler \"" + Project.UsedCompilerVendor + "\" not found");
                targetBuildResult.FailedBuildCount++;

                return(targetBuildResult);
            }

            if (Path.IsPathRooted(BuildConfig.ObjectDirectory))
            {
                AbsoluteObjectDirectory = BuildConfig.ObjectDirectory;
            }
            else
            {
                AbsoluteObjectDirectory = Path.Combine(Project.BaseDirectory, EnsureCorrectPathSeparators(BuildConfig.ObjectDirectory));
            }

            if (!Directory.Exists(AbsoluteObjectDirectory))
            {
                Directory.CreateDirectory(AbsoluteObjectDirectory);
            }

            if (CanDoOneStepBuild)
            {
                return(DoOneStepBuild());
            }
            else
            {
                return(DoStepByStepBuild());
            }
        }
Пример #29
0
        //保存项目信息
        public void SaveProject()
        {
            NameValueCollection Params  = HttpContext.Request.Form;//参数
            Project             project = new Project();

            project.Author  = User.Identity.Name;
            project.Name    = Params["name"];
            project.Bewrite = Params["bewrite"];
            string result = string.Empty;

            if (Params["code"] != null)
            {
                project.Code = new Guid(Params["code"]);
                result       = DProject.Update(project) != null ? "{HasError:false,msg:'项目编辑成功!'}" : "{HasError:true,msg:'项目编辑失败,请稍候再试!'}";
            }
            else
            {
                project.Code = Guid.NewGuid();
                result       = DProject.Add(project) != null ? "{HasError:false,msg:'项目创建成功!'}" : "{HasError:true,msg:'项目创建失败,请稍候再试!'}";
            }
            Response.Write(result);
            Response.End();
        }
Пример #30
0
 public static BuildResult CompileProject(IProgressMonitor ProgressMonitor, DProject Project, ConfigurationSelector BuildConfigurationSelector)
 {
     return new ProjectBuilder (ProgressMonitor).Build (Project, BuildConfigurationSelector);
 }
Пример #31
0
 static string[] GetCmdParts(DProject project)
 {
     return(UnittestSettings.UnittestCommand.Split(new string[] { " " }, 2, StringSplitOptions.RemoveEmptyEntries));
 }
Пример #32
0
        /// <summary>
        /// Compiles a D project.
        /// </summary>
        public BuildResult Build(DProject Project, ConfigurationSelector BuildConfigurationSelector)
        {
            this.Project = Project;
            BuildConfig = Project.GetConfiguration (BuildConfigurationSelector) as DProjectConfiguration;
            commonMacros = new PrjPathMacroProvider {
                slnPath = Project.ParentSolution.BaseDirectory
            };
            BuiltObjects.Clear ();

            if (Compiler == null) {
                var targetBuildResult = new BuildResult ();

                targetBuildResult.AddError ("Project compiler \"" + Project.UsedCompilerVendor + "\" not found");
                targetBuildResult.FailedBuildCount++;

                return targetBuildResult;
            }

            if (Path.IsPathRooted (BuildConfig.ObjectDirectory))
                AbsoluteObjectDirectory = BuildConfig.ObjectDirectory;
            else
                AbsoluteObjectDirectory = Path.Combine (Project.BaseDirectory, EnsureCorrectPathSeparators (BuildConfig.ObjectDirectory));

            if (!Directory.Exists (AbsoluteObjectDirectory))
                Directory.CreateDirectory (AbsoluteObjectDirectory);

            if (CanDoOneStepBuild)
                return DoOneStepBuild ();
            else
                return DoStepByStepBuild ();
        }
Пример #33
0
        public void Parse(DProject project)
        {
            string file = TraceLogFile(project);
            if(file == null)
            {
                profilerPadWidget.AddTracedFunction(0,0,0,0,new DVariable{Name = "trace.log not found.."});
                return;
            }

            lastProfiledProject = project;
            profilerPadWidget.ClearTracedFunctions();

            var ctxt = ResolutionContext.Create(lastProfiledProject == null ?
                                                ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache) :
                                                lastProfiledProject.ParseCache, null, null);

            StreamReader reader = File.OpenText(file);
            string line;
            while ((line = reader.ReadLine()) != null) {
                var m = traceFuncRegex.Match(line);

                if (m.Success)
                {
                    var symName = m.Groups[5].Value;

                    if(symName.StartsWith("="))
                        continue;

                    bool mightBeLegalUnresolvableSymbol;
                    var dn = ExamTraceSymbol(symName, ctxt, out mightBeLegalUnresolvableSymbol);

                    if(dn != null || mightBeLegalUnresolvableSymbol)
                        profilerPadWidget.AddTracedFunction(long.Parse(m.Groups[1].Value), long.Parse(m.Groups[2].Value),
                                                            long.Parse(m.Groups[3].Value), long.Parse(m.Groups[4].Value), dn ?? new DVariable{Name = symName});
                }
            }
        }
Пример #34
0
        public static string TraceLogFile(DProject project)
        {
            if(project == null)
                return null;

            var config = project.GetConfiguration(Ide.IdeApp.Workspace.ActiveConfiguration) as DProjectConfiguration;

            if (config == null ||
                config.CompileTarget != DCompileTarget.Executable ||
                project.Compiler.HasProfilerSupport == false)
            {
                return null;
            }

            string file = Path.Combine(config.OutputDirectory, "trace.log");
            if(File.Exists(file) == false)
                return null;
            return file;
        }
Пример #35
0
        /// <summary>
        /// Compiles a D project.
        /// </summary>
        public static BuildResult Compile(
            DProject Project,
            ProjectFileCollection FilesToCompile,
            DProjectConfiguration BuildConfig,
            IProgressMonitor monitor)
        {
            var relObjDir = "objs";
            var objDir = Path.Combine(Project.BaseDirectory, relObjDir);

            if(!Directory.Exists(objDir))
                Directory.CreateDirectory(objDir);

            // List of created object files
            var BuiltObjects = new List<string>();
            var compilerResults = new CompilerResults(new TempFileCollection());
            var buildResult = new BuildResult(compilerResults, "");
            bool succesfullyBuilt = true;
            bool modificationsDone = false;

            var Compiler = Project.Compiler;
            var Commands = Compiler.GetTargetConfiguration(Project.CompileTarget);
            var Arguments= Commands.GetArguments(BuildConfig.DebugMode);

            /// The target file to which all objects will be linked to
            var LinkTarget = BuildConfig.OutputDirectory.Combine(BuildConfig.CompiledOutputName);

            monitor.BeginTask("Build Project", FilesToCompile.Count + 1);

            var SourceIncludePaths=new List<string>(Compiler.GlobalParseCache.DirectoryPaths);
                SourceIncludePaths.AddRange(Project.LocalIncludeCache.DirectoryPaths);

            #region Compile sources to objects
            foreach (var f in FilesToCompile)
            {
                if (monitor.IsCancelRequested)
                    return buildResult;

                // If not compilable, skip it
                if (f.BuildAction != BuildAction.Compile || !File.Exists(f.FilePath))
                    continue;

                // a.Check if source file was modified and if object file still exists
                if (Project.LastModificationTimes.ContainsKey(f) &&
                    Project.LastModificationTimes[f] == File.GetLastWriteTime(f.FilePath) &&
                    File.Exists(f.LastGenOutput))
                {
                    // File wasn't edited since last build
                    // but add the built object to the objs array
                    BuiltObjects.Add(f.LastGenOutput);
                    monitor.Step(1);
                    continue;
                }
                else
                    modificationsDone=true;

                #region Resource file
                if(f.Name.EndsWith(".rc",StringComparison.OrdinalIgnoreCase))
                {
                    var res = Path.Combine(objDir, Path.GetFileNameWithoutExtension(f.FilePath))+ ".res";

                    if(File.Exists(res))
                        File.Delete(res);

                    // Build argument string
                    var resCmpArgs = FillInMacros(Win32ResourceCompiler.Instance.Arguments,
                        new Win32ResourceCompiler.ArgProvider{
                            RcFile=f.FilePath.ToString(),
                            ResFile=res
                        });

                    // Execute compiler
                    string output;
                    int _exitCode = ExecuteCommand(Win32ResourceCompiler.Instance.Executable,
                        resCmpArgs,
                        Project.BaseDirectory,
                        monitor,
                        out output);

                    // Error analysis
                    if(!string.IsNullOrEmpty(output))
                        compilerResults.Errors.Add(new CompilerError{ FileName=f.FilePath, ErrorText=output});
                    CheckReturnCode(_exitCode, compilerResults);

                    monitor.Step(1);

                    if (_exitCode != 0)
                    {
                        buildResult.FailedBuildCount++;
                        succesfullyBuilt = false;
                        break;
                    }
                    else
                    {
                        f.LastGenOutput = res;
                        buildResult.BuildCount++;
                        Project.LastModificationTimes[f] = File.GetLastWriteTime(f.FilePath);

                        // Especially when compiling large projects, do only add the relative part of the r file due to command shortness
                        if (res.StartsWith(Project.BaseDirectory))
                            BuiltObjects.Add(res.Substring(Project.BaseDirectory.ToString().Length).TrimStart(Path.DirectorySeparatorChar));
                        else
                            BuiltObjects.Add(res);
                    }

                    continue;
                }
                #endregion

                // Create object file path
                var obj = Path.Combine(objDir, Path.GetFileNameWithoutExtension(f.FilePath)) + ObjectExtension;

                if (File.Exists(obj))
                    File.Delete(obj);

                // Prevent duplicates e.g. when having the samely-named source files in different sub-packages
                int i=2;
                while(File.Exists(obj))
                {
                    // Simply add a number between the obj name and its extension
                    obj= Path.Combine(objDir, Path.GetFileNameWithoutExtension(f.FilePath))+i + ObjectExtension;
                    i++;
                }

                // Create argument string for source file compilation.
                var dmdArgs = FillInMacros(Arguments.CompilerArguments + " " + BuildConfig.ExtraCompilerArguments,  new DCompilerMacroProvider
                {
                    IncludePathConcatPattern=Commands.IncludePathPattern,
                    SourceFile = f.FilePath,
                    ObjectFile = obj,
                    Includes=SourceIncludePaths,
                });

                // b.Execute compiler
                string dmdOutput;
                int exitCode = ExecuteCommand(Commands.Compiler, dmdArgs, Project.BaseDirectory, monitor, out dmdOutput);

                ParseCompilerOutput(dmdOutput, compilerResults);
                CheckReturnCode(exitCode, compilerResults);

                monitor.Step(1);

                if (exitCode != 0)
                {
                    buildResult.FailedBuildCount++;
                    succesfullyBuilt = false;
                    break;
                }
                else
                {
                    f.LastGenOutput = obj;
                    buildResult.BuildCount++;
                    Project.LastModificationTimes[f] = File.GetLastWriteTime(f.FilePath);

                    // Especially when compiling large projects, do only add the relative part of the obj file due to command shortness
                    if (obj.StartsWith(Project.BaseDirectory))
                        BuiltObjects.Add(obj.Substring(Project.BaseDirectory.ToString().Length).TrimStart(Path.DirectorySeparatorChar));
                    else
                        BuiltObjects.Add(obj);
                }
            }
            #endregion

            #region Link files
            if (succesfullyBuilt)
            {
                // a.
                if ((!modificationsDone) && lastLinkerActionSuccessfull)
                {
                    // Only return if build target is still existing
                    if (File.Exists(LinkTarget))
                    {
                        monitor.Step(1);
                        return new BuildResult(compilerResults, "");
                    }
                }

                // b.Build linker argument string

                // Build argument preparation
                /*
                var libPaths=new List<string>(Compiler.DefaultLibPaths);
                libPaths.AddRange(Project.LibraryPaths);
                */
                var libs=new List<string>(Compiler.DefaultLibraries);
                libs.AddRange(Project.ExtraLibraries);

                var linkArgs = FillInMacros(Arguments.LinkerArguments + " "+BuildConfig.ExtraLinkerArguments,
                    new DLinkerMacroProvider {
                        ObjectsStringPattern=Commands.ObjectFileLinkPattern,
                        Objects=BuiltObjects.ToArray(),
                        TargetFile=LinkTarget,
                        RelativeTargetDirectory=BuildConfig.OutputDirectory.ToRelative(Project.BaseDirectory),

                        //LibraryPaths=libPaths,
                        Libraries=libs
                });
                var linkerOutput = "";
                int exitCode = ExecuteCommand(Commands.Linker,linkArgs,Project.BaseDirectory,monitor,out linkerOutput);

                compilerResults.NativeCompilerReturnValue = exitCode;

                CheckReturnCode(exitCode, compilerResults);

                lastLinkerActionSuccessfull = (exitCode == 0);
                if (lastLinkerActionSuccessfull)
                {
                    monitor.ReportSuccess("Build successful!");
                    monitor.Step(1);
                }
            }
            #endregion

            return new BuildResult(compilerResults,"");
        }
Пример #36
0
 public void AnalyseTraceFile(DProject project)
 {
     TraceParser.Clear();
     if(ProfilerModeHandler.IsProfilerMode)
         TraceParser.Parse(project);
 }
Пример #37
0
 public static BuildResult CompileProject(IProgressMonitor ProgressMonitor, DProject Project, ConfigurationSelector BuildConfigurationSelector)
 {
     return(new ProjectBuilder(ProgressMonitor).Build(Project, BuildConfigurationSelector));
 }
Пример #38
0
        public static void GenerateMakefile(DProject prj, DProjectConfiguration cfg, ref string file)
        {
            if (string.IsNullOrEmpty(file))
                file = prj.BaseDirectory.Combine("makefile");

            var code = GenerateMakeCode(prj, cfg);

            File.WriteAllText(file, code);
        }
Пример #39
0
        public void Load(DProject proj, DProjectConfiguration config)
        {
            project = proj;
            configuration = config;

            cbUseDefaultCompiler.Active = proj.UseDefaultCompilerVendor;
            cbPreferOneStepCompilation.Active = proj.PreferOneStepBuild;

            OnUseDefaultCompilerChanged ();
            Gtk.TreeIter iter;
            if (cmbCompiler.Model.GetIterFirst (out iter))
                do {
                    if (proj.UsedCompilerVendor == cmbCompiler.Model.GetValue (iter, 0) as string) {
                        cmbCompiler.SetActiveIter (iter);
                        break;
                    }
                } while (cmbCompiler.Model.IterNext (ref iter));

            extraCompilerTextView.Buffer.Text = config.ExtraCompilerArguments;
            extraLinkerTextView.Buffer.Text = config.ExtraLinkerArguments;

            text_BinDirectory.Text = config.OutputDirectory;
            text_TargetFile.Text = config.Output;
            text_ObjectsDirectory.Text = config.ObjectDirectory;

            if (model_compileTarget.GetIterFirst (out iter))
                do {
                    if (config.CompileTarget == (DCompileTarget)model_compileTarget.GetValue (iter, 1)) {
                        combo_ProjectType.SetActiveIter (iter);
                        break;
                    }
                } while (model_compileTarget.IterNext (ref iter));

            text_Libraries.Buffer.Text = string.Join ("\n", config.ExtraLibraries);
            text_Includes.Buffer.Text = string.Join ("\n", proj.LocalIncludeCache.ParsedDirectories);

            // Init project dep list
            int i=0;
            foreach(var prj in proj.ParentSolution.GetAllProjects())
            {
                if (prj == proj)
                    continue;

                var cb = new Gtk.CheckButton(prj.Name){
                    CanFocus=true,
                    DrawIndicator=true,
                    UseUnderline=false,
                    Active = proj.ProjectDependencies.Contains(prj.ItemId)
                };

                cb.Data.Add("prj", prj);

                vbox_ProjectDeps.Add(cb);

                var bc=(Box.BoxChild)vbox_ProjectDeps[cb];
                bc.Expand=false;
                bc.Fill=false;
                bc.Position=i++;
            }
            vbox_ProjectDeps.ShowAll();
        }
Пример #40
0
        public bool Run(DProject project,INode targetMember, string newName=null)
        {
            if(!CanRename(targetMember) || Ide.IdeApp.Workbench.ActiveDocument ==null)
                return false;

            n = targetMember;

            // Request new name
            if (newName == null)
                newName = MessageService.GetTextResponse("Enter a new name", "Symbol rename", n.Name);

            if (newName == null || newName==n.Name)
                return false;

            // Validate new name
            if (string.IsNullOrWhiteSpace(newName))
            {
                MessageService.ShowError("Symbol name must not be empty!");
                return false;
            }

            foreach (var c in newName)
                if (!D_Parser.Completion.CtrlSpaceCompletionProvider.IsIdentifierChar(c))
                {
                    MessageService.ShowError("Character '" + c + "' in " + newName + " not allowed as identifier character!");
                    return false;
                }

            // Setup locals
            var parseCache = project != null ?
                project.ParseCache :
                ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache);

            var modules = project == null ?
                (IEnumerable<IAbstractSyntaxTree>) new[] { (Ide.IdeApp.Workbench.ActiveDocument.ParsedDocument as MonoDevelop.D.Parser.ParsedDModule).DDom } :
                project.LocalFileCache;

            foundReferences = new Dictionary<string, List<CodeLocation>>();

            var ctxt = new ResolverContextStack(parseCache, new ResolverContext());

            // Enumerate references
            foreach (var mod in modules)
            {
                if (mod == null)
                    continue;

                var references = D_Parser.Refactoring.ReferencesFinder.Scan(mod, n, ctxt).ToList();

                if ((n.NodeRoot as IAbstractSyntaxTree).FileName == mod.FileName)
                    references.Insert(0, new IdentifierDeclaration(n.Name) { Location = n.NameLocation });

                if (references.Count < 1)
                    continue;

                references.Sort(new ReferenceFinding.IdLocationComparer(true));

                if (!foundReferences.ContainsKey(mod.FileName))
                    foundReferences.Add(mod.FileName, new List<CodeLocation>());

                var moduleRefList = foundReferences[mod.FileName];
                foreach (var reference in references)
                {
                    moduleRefList.Add(reference.Location);
                }
            }

            if (foundReferences.Count < 1)
                return false;

            // Replace occurences
            foreach (var kv1 in foundReferences)
            {
                var doc = TextFileProvider.Instance.GetEditableTextFile(new FilePath(kv1.Key));

                if (doc != null)
                {
                    foreach (var kv2 in kv1.Value)
                    {
                        int offset = doc.GetPositionFromLineColumn(kv2.Line, kv2.Column);

                        doc.DeleteText(offset, n.Name.Length);
                        doc.InsertText(offset, newName);
                    }

                    // If project file not open for editing, reparse it
                    if (project != null && !IdeApp.Workbench.Documents.Any((Ide.Gui.Document d) => {
                        if (d.IsFile && d.FileName == kv1.Key)
                            return true;
                        return false;
                    }))
                        project.ReparseModule(kv1.Key);
                }
            }

            // Assign new name to the node
            n.Name = newName;

            /*
            // Prepare current editor (setup textlinks and anchors)
            var doc = Ide.IdeApp.Workbench.ActiveDocument;

            if (doc == null || !doc.IsFile || !foundReferences.ContainsKey(doc.FileName))
                return false;

            var editor = doc.Editor;
            var localReferences = foundReferences[doc.FileName];

            List<TextLink> links = new List<TextLink>();
            TextLink link = new TextLink("name");
            int baseOffset = Int32.MaxValue;

            foreach (var r in localReferences)
            {
                baseOffset = Math.Min(baseOffset, editor.Document.LocationToOffset(r.Line, r.Column));
            }
            foreach (var r in localReferences)
            {
                var segment = new Segment(editor.Document.LocationToOffset(r.Line, r.Column) - baseOffset, n.Name.Length);
                if (segment.Offset <= editor.Caret.Offset - baseOffset && editor.Caret.Offset - baseOffset <= segment.EndOffset)
                {
                    link.Links.Insert(0, segment);
                }
                else
                {
                    link.AddLink(segment);
                }
            }

            links.Add(link);
            if (editor.CurrentMode is TextLinkEditMode)
                ((TextLinkEditMode)editor.CurrentMode).ExitTextLinkMode();
            var tle = new TextLinkEditMode(editor.Parent, baseOffset, links);
            tle.SetCaretPosition = false;
            tle.SelectPrimaryLink = true;

            // Show rename helper popup
            if (tle.ShouldStartTextLinkMode)
            {
                var helpWindow = new ModeHelpWindow();
                helpWindow.TransientFor = IdeApp.Workbench.RootWindow;
                helpWindow.TitleText = "<b>Renaming " + (n as AbstractNode).ToString(false) + "</b>";
                helpWindow.Items.Add(new KeyValuePair<string, string>(GettextCatalog.GetString("<b>Key</b>"), GettextCatalog.GetString("<b>Behavior</b>")));
                helpWindow.Items.Add(new KeyValuePair<string, string>(GettextCatalog.GetString("<b>Return</b>"), GettextCatalog.GetString("<b>Accept</b> this refactoring.")));
                helpWindow.Items.Add(new KeyValuePair<string, string>(GettextCatalog.GetString("<b>Esc</b>"), GettextCatalog.GetString("<b>Cancel</b> this refactoring.")));
                tle.HelpWindow = helpWindow;
                tle.Cancel += delegate
                {
                    if (tle.HasChangedText)
                        editor.Document.Undo();
                };
                helpWindow.Destroyed += (object o, EventArgs e) =>
                {
                    if (tle.HasChangedText)
                    {

                    }
                };
                tle.OldMode = editor.CurrentMode;
                tle.StartMode();
                editor.CurrentMode = tle;
            }
            else
                return false;
            */

            return true;
        }
Пример #41
0
        public void Load(DProject proj, DProjectConfiguration config)
        {
            project       = proj;
            configuration = config;

            cbUseDefaultCompiler.Active       = proj.UseDefaultCompilerVendor;
            cbIsUnittestConfig.Active         = config.UnittestMode;
            cbPreferOneStepCompilation.Active = proj.PreferOneStepBuild;

            OnUseDefaultCompilerChanged();
            Gtk.TreeIter iter;
            if (cmbCompiler.Model.GetIterFirst(out iter))
            {
                do
                {
                    if (proj.UsedCompilerVendor == cmbCompiler.Model.GetValue(iter, 0) as string)
                    {
                        cmbCompiler.SetActiveIter(iter);
                        break;
                    }
                } while (cmbCompiler.Model.IterNext(ref iter));
            }

            extraCompilerTextView.Buffer.Text = config.ExtraCompilerArguments;
            extraLinkerTextView.Buffer.Text   = config.ExtraLinkerArguments;

            check_LinkThirdPartyLibs.Active = configuration.LinkinThirdPartyLibraries;

            text_BinDirectory.Text     = proj.GetRelativeChildPath(config.OutputDirectory);
            text_TargetFile.Text       = config.Output;
            text_ObjectsDirectory.Text = config.ObjectDirectory;
            text_DDocDir.Text          = config.DDocDirectory;

            if (config.CustomDebugIdentifiers == null)
            {
                text_debugConstants.Text = "";
            }
            else
            {
                text_debugConstants.Text = string.Join(";", config.CustomDebugIdentifiers);
            }
            if (config.CustomVersionIdentifiers == null)
            {
                text_versionConstants.Text = "";
            }
            else
            {
                text_versionConstants.Text = string.Join(";", config.CustomVersionIdentifiers);
            }
            spin_debugLevel.Value = (double)config.DebugLevel;

            // Disable debug-specific fields on non-debug configurations
            text_debugConstants.Sensitive = spin_debugLevel.Sensitive = config.DebugMode;

            if (model_compileTarget.GetIterFirst(out iter))
            {
                do
                {
                    if (config.CompileTarget == (DCompileTarget)model_compileTarget.GetValue(iter, 1))
                    {
                        combo_ProjectType.SetActiveIter(iter);
                        break;
                    }
                } while (model_compileTarget.IterNext(ref iter));
            }

            text_Libraries.Buffer.Text = string.Join("\n", config.ExtraLibraries);

            model_Platforms.Clear();
            var blackListed = new List <string>();

            foreach (var cfg in proj.Configurations)
            {
                if (cfg.Name == config.Name && cfg.Platform != config.Platform)
                {
                    blackListed.Add(cfg.Platform.ToLower());
                }
            }

            var platform_lower = config.Platform.ToLower();

            foreach (var platform in proj.SupportedPlatforms)
            {
                // Skip already taken platforms
                if (blackListed.Contains(platform.ToLower()))
                {
                    continue;
                }

                var it = model_Platforms.Append();
                if (platform_lower == platform.ToLower())
                {
                    combo_Platform.SetActiveIter(it);
                }
                model_Platforms.SetValue(it, 0, platform);
            }
        }
Пример #42
0
        public void Load(DProject proj, DProjectConfiguration config)
        {
            project       = proj;
            configuration = config;

            cbUseDefaultCompiler.Active       = proj.UseDefaultCompilerVendor;
            cbPreferOneStepCompilation.Active = proj.PreferOneStepBuild;

            OnUseDefaultCompilerChanged();
            Gtk.TreeIter iter;
            if (cmbCompiler.Model.GetIterFirst(out iter))
            {
                do
                {
                    if (proj.UsedCompilerVendor == cmbCompiler.Model.GetValue(iter, 0) as string)
                    {
                        cmbCompiler.SetActiveIter(iter);
                        break;
                    }
                } while (cmbCompiler.Model.IterNext(ref iter));
            }

            extraCompilerTextView.Buffer.Text = config.ExtraCompilerArguments;
            extraLinkerTextView.Buffer.Text   = config.ExtraLinkerArguments;

            text_BinDirectory.Text     = config.OutputDirectory;
            text_TargetFile.Text       = config.Output;
            text_ObjectsDirectory.Text = config.ObjectDirectory;
            text_DDocDir.Text          = config.DDocDirectory;

            if (config.CustomDebugIdentifiers == null)
            {
                text_debugConstants.Text = "";
            }
            else
            {
                text_debugConstants.Text = string.Join(";", config.CustomDebugIdentifiers);
            }
            if (config.CustomVersionIdentifiers == null)
            {
                text_versionConstants.Text = "";
            }
            else
            {
                text_versionConstants.Text = string.Join(";", config.CustomVersionIdentifiers);
            }
            spin_debugLevel.Value = (double)config.DebugLevel;

            // Disable debug-specific fields on non-debug configurations
            text_debugConstants.Sensitive = spin_debugLevel.Sensitive = config.DebugMode;

            if (model_compileTarget.GetIterFirst(out iter))
            {
                do
                {
                    if (config.CompileTarget == (DCompileTarget)model_compileTarget.GetValue(iter, 1))
                    {
                        combo_ProjectType.SetActiveIter(iter);
                        break;
                    }
                } while (model_compileTarget.IterNext(ref iter));
            }

            text_Libraries.Buffer.Text = string.Join("\n", config.ExtraLibraries);
        }
Пример #43
0
        public static string GenerateMakeCode(DProject Project, DProjectConfiguration cfg)
        {
            var compiler = Project.Compiler;

            var s = new StringBuilder();

            // Constants
            var buildCommands = compiler.GetOrCreateTargetConfiguration(cfg.CompileTarget);
            var Arguments     = buildCommands.GetArguments(cfg.DebugMode);

            s.AppendLine("compiler=" + compiler.SourceCompilerCommand);
            s.AppendLine("linker=" + buildCommands.Linker);
            s.AppendLine();
            s.AppendLine("target=" + cfg.OutputDirectory.Combine(cfg.CompiledOutputName).ToRelative(Project.BaseDirectory));

            var srcObjPairs = new Dictionary <string, string>();
            var objs        = new List <string>();

            foreach (var pf in Project.Files)
            {
                if (pf.BuildAction != BuildAction.Compile)
                {
                    continue;
                }

                var obj = ProjectBuilder.GetRelativeObjectFileName(ProjectBuilder.EnsureCorrectPathSeparators(cfg.ObjectDirectory), pf, DCompilerService.ObjectExtension);

                objs.Add(obj);
                srcObjPairs[pf.FilePath.ToRelative(Project.BaseDirectory)] = obj;
            }

            s.AppendLine("objects = " + string.Join(" ", objs));
            s.AppendLine();
            s.AppendLine();
            s.AppendLine("all: $(target)");

            // Linker
            s.AppendLine();
            s.AppendLine("$(target): $(objects)");

            var linkArgs = ProjectBuilder.FillInMacros(
                ProjectBuilder.GenAdditionalAttributes(compiler, cfg) +
                Arguments.LinkerArguments + " " + cfg.ExtraLinkerArguments,
                new DLinkerMacroProvider
            {
                ObjectsStringPattern = "{0}",
                Objects    = new[] { "$(objects)" },
                TargetFile = "$@",
                RelativeTargetDirectory = cfg.OutputDirectory.ToRelative(Project.BaseDirectory),
                Libraries = ProjectBuilder.GetLibraries(cfg, compiler)
            });

            s.AppendLine("\t@echo Linking...");
            s.AppendLine("\t$(linker) " + linkArgs.Trim());


            // Compiler
            s.AppendLine();

            var compilerCommand = "\t$(compiler) " + ProjectBuilder.FillInMacros(
                Arguments.CompilerArguments + " " + cfg.ExtraCompilerArguments,
                new DCompilerMacroProvider {
                IncludePathConcatPattern = compiler.ArgumentPatterns.IncludePathPattern,
                Includes   = Project.IncludePaths,
                ObjectFile = "$@", SourceFile = "$?"
            })
                                  // Replace "$?" by $? because the $? macro appends one ' ' (space)
                                  // to the name which obstructs the source file names
                                  .Replace("\"$?\"", "$?");

            foreach (var kv in srcObjPairs)
            {
                s.AppendLine(kv.Value + " : " + kv.Key);
                s.AppendLine(compilerCommand);
                s.AppendLine();
            }

            // Clean up
            s.AppendLine("clean:");
            s.AppendLine("\t" + (OS.IsWindows?"del /Q":"$(RM)") + " \"$(target)\" $(objects)");


            return(s.ToString());
        }
Пример #44
0
        public void Load(DProject proj, DProjectConfiguration config)
        {
            project = proj;
            configuration = config;

            cbUseDefaultCompiler.Active = proj.UseDefaultCompilerVendor;
            cbPreferOneStepCompilation.Active = proj.PreferOneStepBuild;

            OnUseDefaultCompilerChanged ();
            Gtk.TreeIter iter;
            if (cmbCompiler.Model.GetIterFirst (out iter))
                do {
                    if (proj.UsedCompilerVendor == cmbCompiler.Model.GetValue (iter, 0) as string) {
                        cmbCompiler.SetActiveIter (iter);
                        break;
                    }
                } while (cmbCompiler.Model.IterNext (ref iter));

            extraCompilerTextView.Buffer.Text = config.ExtraCompilerArguments;
            extraLinkerTextView.Buffer.Text = config.ExtraLinkerArguments;

            text_BinDirectory.Text = config.OutputDirectory;
            text_TargetFile.Text = config.Output;
            text_ObjectsDirectory.Text = config.ObjectDirectory;
            text_DDocDir.Text = config.DDocDirectory;

            if(config.CustomDebugIdentifiers==null)
                text_debugConstants.Text = "";
            else
                text_debugConstants.Text = string.Join(";",config.CustomDebugIdentifiers);
            if(config.CustomVersionIdentifiers == null)
                text_versionConstants.Text = "";
            else
                text_versionConstants.Text = string.Join(";", config.CustomVersionIdentifiers);
            spin_debugLevel.Value = (double)config.DebugLevel;

            // Disable debug-specific fields on non-debug configurations
            text_debugConstants.Sensitive = spin_debugLevel.Sensitive = config.DebugMode;

            if (model_compileTarget.GetIterFirst (out iter))
                do {
                    if (config.CompileTarget == (DCompileTarget)model_compileTarget.GetValue (iter, 1)) {
                        combo_ProjectType.SetActiveIter (iter);
                        break;
                    }
                } while (model_compileTarget.IterNext (ref iter));

            text_Libraries.Buffer.Text = string.Join ("\n", config.ExtraLibraries);
            text_Includes.Buffer.Text = string.Join ("\n", proj.LocalIncludeCache.ParsedDirectories);

            // Remove old children list
            var depsChildren = ((ArrayList)vbox_ProjectDeps.AllChildren);
            for (int k = depsChildren.Count - 1; k >= 0; k--)
                vbox_ProjectDeps.Remove((Widget)depsChildren[k]);

            // Init new project dep list
            int i = 0;
            foreach(var prj in proj.ParentSolution.GetAllProjects())
            {
                if (prj == proj)
                    continue;

                var cb = new Gtk.CheckButton(prj.Name){
                    CanFocus=true,
                    DrawIndicator=true,
                    UseUnderline=false,
                    Active = proj.ProjectDependencies.Contains(prj.ItemId)
                };

                cb.Data.Add("prj", prj);

                vbox_ProjectDeps.Add(cb);

                var bc=(Box.BoxChild)vbox_ProjectDeps[cb];
                bc.Expand=false;
                bc.Fill=false;
                bc.Position=i++;
            }
            vbox_ProjectDeps.ShowAll();
        }
Пример #45
0
        public static string GenerateMakeCode(DProject Project, DProjectConfiguration cfg)
        {
            var compiler = Project.Compiler;

            var s = new StringBuilder();

            // Constants
            var buildCommands = compiler.GetOrCreateTargetConfiguration(cfg.CompileTarget);
            var Arguments = buildCommands.GetArguments(cfg.DebugMode);

            s.AppendLine("compiler=" + compiler.SourceCompilerCommand);
            s.AppendLine("linker=" + buildCommands.Linker);
            s.AppendLine();
            s.AppendLine("target="+ cfg.OutputDirectory.Combine(cfg.CompiledOutputName).ToRelative(Project.BaseDirectory));

            var srcObjPairs = new Dictionary<string, string>();
            var objs= new List<string>();

            foreach (var pf in Project.Files)
            {
                if (pf.BuildAction != BuildAction.Compile)
                    continue;

                var obj = ProjectBuilder.GetRelativeObjectFileName(cfg.ObjectDirectory, pf, DCompilerService.ObjectExtension);

                objs.Add(obj);
                srcObjPairs[pf.FilePath.ToRelative(Project.BaseDirectory)] = obj;
            }

            s.AppendLine("objects = "+ string.Join(" ",objs));
            s.AppendLine();
            s.AppendLine();
            s.AppendLine("all: $(target)");

            // Linker
            s.AppendLine();
            s.AppendLine("$(target): $(objects)");

            var linkArgs = ProjectBuilder.FillInMacros (
                ProjectBuilder.GenAdditionalAttributes(compiler, cfg) +
                Arguments.LinkerArguments + " " + cfg.ExtraLinkerArguments,
                new DLinkerMacroProvider
                {
                    ObjectsStringPattern = "{0}",
                    Objects = new[]{"$(objects)"},
                    TargetFile = "$@",
                    RelativeTargetDirectory = cfg.OutputDirectory.ToRelative (Project.BaseDirectory),
                    Libraries = ProjectBuilder.GetLibraries(cfg, compiler)
                });

            s.AppendLine("\t@echo Linking...");
            s.AppendLine("\t$(linker) "+ linkArgs.Trim());

            // Compiler
            s.AppendLine();

            var compilerCommand = "\t$(compiler) "+ ProjectBuilder.FillInMacros(
                Arguments.CompilerArguments + " " + cfg.ExtraCompilerArguments,
                new DCompilerMacroProvider{
                    IncludePathConcatPattern = compiler.ArgumentPatterns.IncludePathPattern,
                    Includes = Project.IncludePaths,
                    ObjectFile = "$@", SourceFile = "$?"
                })
                // Replace "$?" by $? because the $? macro appends one ' ' (space)
                // to the name which obstructs the source file names
                .Replace("\"$?\"","$?");

            foreach(var kv in srcObjPairs)
            {
                s.AppendLine(kv.Value + " : "+ kv.Key);
                s.AppendLine(compilerCommand);
                s.AppendLine();
            }

            // Clean up
            s.AppendLine("clean:");
            s.AppendLine("\t"+(OS.IsWindows?"del /Q":"$(RM)")+" \"$(target)\" $(objects)");

            return s.ToString();
        }