Example #1
0
        public static bool IsDropAllowed(string file, PrjExplorerNode dropNode)
        {
            if (string.IsNullOrEmpty(file))
            {
                return(false);
            }

            if (file.EndsWith(Solution.SolutionExtension))
            {
                return(true);
            }

            if (dropNode == null)
            {
                return(false);
            }

            bool isPrj = false;

            AbstractLanguageBinding.SearchBinding(file, out isPrj);

            if (isPrj && dropNode is SolutionNode && !(dropNode as SolutionNode).Solution.ContainsProject(file))
            {
                return(true);
            }
            else if (isPrj)             // Ignore already existing projects
            {
                return(false);
            }

            if (dropNode is SolutionNode)
            {
                return(false);
            }

            /*
             * After checking for solution or project extension, check if 'file' is file or directory
             */
            bool IsDir   = Directory.Exists(file);
            var  fileDir = Path.GetDirectoryName(file);

            var dropFile = dropNode.AbsolutePath;
            var dropDir  = dropFile;

            if (!(dropNode is DirectoryNode))
            {
                dropDir = Path.GetDirectoryName(dropFile);
            }

            if (IsDir && file != dropDir && !dropDir.Contains(file))
            {
                return(true);
            }
            else if (fileDir != dropDir)           // Ensure the file gets moved either to an other directory or project
            {
                return(true);
            }

            return(false);
        }
Example #2
0
            static bool InternalBuild(Project Project, bool Incrementally)
            {
                // Important: Reset error list's unbound build result
                LastSingleBuildResult = null;

                // Select appropriate language binding
                bool isPrj = false;
                var  lang  = AbstractLanguageBinding.SearchBinding(Project.FileName, out isPrj);

                // If binding is able to build..
                if (lang != null && isPrj && lang.CanBuild && lang.BuildSupport.CanBuildProject(Project))
                {
                    // If not building the project incrementally, cleanup project outputs first
                    if (!Incrementally)
                    {
                        CleanUpOutput(Project);
                    }

                    // Set debug support
                    if (lang.CanUseDebugging)
                    {
                        DebugManagement.CurrentDebugSupport = lang.DebugSupport;
                    }
                    else
                    {
                        DebugManagement.CurrentDebugSupport = null;
                    }

                    // Increment build number if the user enabled it
                    if (Project.AutoIncrementBuildNumber)
                    {
                        if (Project.LastBuildResult != null && Project.LastBuildResult.Successful)
                        {
                            Project.Version.IncrementBuild();
                        }
                        else                         //TODO: How to handle revision number?
                        {
                            Project.Version.Revision++;
                        }
                    }

                    // Build project
                    lang.BuildSupport.BuildProject(Project);

                    // Copy additional output files to target dir
                    if (Project.LastBuildResult.Successful)
                    {
                        Project.CopyCopyableOutputFiles();
                    }

                    if (Project.LastBuildResult.NoBuildNeeded)
                    {
                        ErrorLogger.Log("No project files were changed -- No compilation required", ErrorType.Information, ErrorOrigin.Build);
                    }

                    return(Project.LastBuildResult.Successful);
                }
                return(false);
            }
Example #3
0
            public static BuildResult BuildSingle()
            {
                AbstractEditorDocument ed = ed = Instance.CurrentEditor;

                if (ed == null)
                {
                    return(null);
                }

                // Save module
                ed.Save();

                // Select appropriate language binding
                string file      = ed.AbsoluteFilePath;
                bool   IsProject = false;
                var    lang      = AbstractLanguageBinding.SearchBinding(file, out IsProject);

                // Check if binding supports building
                if (lang == null || IsProject || !lang.CanBuild || !lang.BuildSupport.CanBuildFile(file))
                {
                    return(null);
                }

                // Set debug support
                if (lang.CanUseDebugging)
                {
                    DebugManagement.CurrentDebugSupport = lang.DebugSupport;
                }
                else
                {
                    DebugManagement.CurrentDebugSupport = null;
                }

                // Enable build menu
                IsBuilding = true;

                IDEManager.Instance.MainWindow.RefreshMenu();

                // Clear build output
                Instance.MainWindow.ClearLog();

                // Execute build
                var br = LastSingleBuildResult = lang.BuildSupport.BuildStandAlone(file);

                if (br.Successful && br.NoBuildNeeded)
                {
                    ErrorLogger.Log("File wasn't changed -- No compilation required", ErrorType.Information, ErrorOrigin.Build);
                }


                // Update error list, Disable build menu
                ErrorManagement.RefreshErrorList();
                IsBuilding = false;
                IDEManager.Instance.MainWindow.RefreshMenu();

                return(br);
            }
Example #4
0
        /// <summary>
        /// Note: We will be only allowed to COPY files, not move them
        /// </summary>
        /// <param name="file"></param>
        /// <param name="dropNode"></param>
        public void DoPaste(string file, DnDData dropNode)
        {
            // Solution
            if (file.EndsWith(Solution.SolutionExtension))
            {
                IDEManager.Instance.OpenFile(file);
                return;
            }

            // Project
            bool isPrj = false;

            AbstractLanguageBinding.SearchBinding(file, out isPrj);

            if (isPrj && dropNode.IsSln)
            {
                IDEManager.ProjectManagement.AddExistingProjectToSolution(dropNode.Solution, file);
            }
            else if (isPrj)             // Ignore already existing projects
            {
                return;
            }

            bool IsDir    = Directory.Exists(file);
            var  dropFile = dropNode.Path;

            // 'Pre-expand' our drop node - when the tree gets updated
            if (!dropNode.IsPrj)
            {
                _ExpandedNodes.Add(dropNode.Node.FullPath);
            }

            var dropDir = "";

            if (dropNode.IsDir)
            {
                dropDir = (dropNode.Node as DirectoryNode).RelativePath;
            }
            else if (dropNode.IsFile)
            {
                dropDir = Path.GetDirectoryName((dropNode.Node as FileNode).RelativeFilePath);
            }

            if (IsDir)
            {
                IDEManager.FileManagement.AddExistingDirectoryToProject(file, dropNode.Project, dropDir);
            }
            else
            {
                IDEManager.FileManagement.AddExistingSourceToProject(dropNode.Project, dropDir, file);
            }
        }
Example #5
0
        public override void BuildProject(Project prj)
        {
            var dprj = prj as DProject;

            if (dprj == null)
            {
                return;
            }

            DMDVersion = dprj.DMDVersion;

            dprj.LastBuildResult = new BuildResult()
            {
                SourceFile = dprj.FileName, TargetFile = dprj.OutputFile
            };

            // Build outputs/target paths
            string objectDirectory = dprj.BaseDirectory + "\\obj";

            Util.CreateDirectoryRecursively(objectDirectory);

            #region Compile d sources to object files
            var  objs = new List <string>();
            bool AllObjectsUnchanged = true;

            AbstractLanguageBinding lang = null;
            foreach (var f in dprj.CompilableFiles)
            {
                if (ShallStop)
                {
                    return;
                }
                bool _u = false;
                if (lang == null || !lang.CanHandleFile(f.FileName))
                {
                    lang = AbstractLanguageBinding.SearchBinding(f.FileName, out _u);
                }

                if (lang == null || _u || !lang.CanBuild || !lang.BuildSupport.CanBuildFile(f.FileName))
                {
                    continue;
                }

                lang.BuildSupport.BuildModule(f, objectDirectory, prj.BaseDirectory, !dprj.IsRelease, false);

                if (!f.LastBuildResult.Successful)
                {
                    return;
                }

                if (!f.LastBuildResult.NoBuildNeeded)
                {
                    AllObjectsUnchanged = false;
                }

                // To save command line space, make the targetfile relative to our objectDirectory
                objs.Add(dprj.ToRelativeFileName(f.LastBuildResult.TargetFile));
            }

            if (objs.Count < 1)
            {
                prj.LastBuildResult.Successful    = true;
                prj.LastBuildResult.NoBuildNeeded = true;
                ErrorLogger.Log("Project " + dprj.Name + " empty", ErrorType.Error, ErrorOrigin.Build);
                return;
            }
            #endregion

            // If no source has been changed, skip linkage
            if (AllObjectsUnchanged && File.Exists(dprj.OutputFile))
            {
                dprj.LastBuildResult.NoBuildNeeded = true;
                dprj.LastBuildResult.Successful    = true;
                return;
            }

            // Add default & project specific import libraries
            objs.AddRange(CurrentDMDConfig.DefaultLinkedLibraries);
            objs.AddRange(dprj.LinkedLibraries);

            // Link files to console-based application by default
            var linkerExe  = CurrentDMDConfig.ExeLinker;
            var args       = CurrentDMDConfig.BuildArguments(!dprj.IsRelease);
            var linkerArgs = args.ExeLinker;

            switch (dprj.OutputType)
            {
            case OutputTypes.CommandWindowLessExecutable:
                linkerExe  = CurrentDMDConfig.Win32ExeLinker;
                linkerArgs = args.Win32ExeLinker;
                break;

            case OutputTypes.DynamicLibary:
                linkerExe  = CurrentDMDConfig.DllLinker;
                linkerArgs = args.DllLinker;
                break;

            case OutputTypes.StaticLibrary:
                linkerExe  = CurrentDMDConfig.LibLinker;
                linkerArgs = args.LibLinker;
                break;
            }

            if (ShallStop)
            {
                return;
            }
            dprj.LastBuildResult = LinkFiles(CurrentDMDConfig, linkerExe, linkerArgs, dprj.BaseDirectory, dprj.OutputFile, !dprj.IsRelease, objs.ToArray());
        }