Пример #1
0
        public override IEnumerable <string> GetSourcePaths(ConfigurationSelector sel)
        {
            var dirs = new List <string>();
            List <DubBuildSetting> l;
            string d;
            bool   returnedOneItem = false;

            foreach (var sett in GetBuildSettings(sel))
            {
                if (sett.TryGetValue(DubBuildSettings.SourcePathsProperty, out l))
                {
                    returnedOneItem = true;
                    foreach (var setting in l)
                    {
                        foreach (var directory in setting.Values)
                        {
                            d = ProjectBuilder.EnsureCorrectPathSeparators(directory);
                            if (!Path.IsPathRooted(d))
                            {
                                if (this is DubSubPackage)
                                {
                                    (this as DubSubPackage).useOriginalBasePath = true;
                                }
                                d = Path.GetFullPath(Path.Combine(BaseDirectory.ToString(), d));
                                if (this is DubSubPackage)
                                {
                                    (this as DubSubPackage).useOriginalBasePath = false;
                                }
                            }

                            // Ignore os/arch/version constraints for now

                            if (dirs.Contains(d) || !Directory.Exists(d))
                            {
                                continue;
                            }

                            dirs.Add(d);
                        }
                    }
                }
            }

            if (!returnedOneItem)
            {
                d = BaseDirectory.Combine("source").ToString();
                if (Directory.Exists(d))
                {
                    dirs.Add(d);
                }

                d = BaseDirectory.Combine("src").ToString();
                if (Directory.Exists(d))
                {
                    dirs.Add(d);
                }
            }

            return(dirs);
        }
Пример #2
0
        protected override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            return(Task.Factory.StartNew(async() => {
                ExternalConsole console = context.ExternalConsoleFactory.CreateConsole(false, monitor.CancellationToken);
                string targetName = "";
                foreach (var target in fileFormat.Targets.Values)
                {
                    if (target.Type == CMakeTarget.Types.Binary)
                    {
                        targetName = target.Name;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(targetName))
                {
                    monitor.ReportError("Can't find an executable target.");
                    return;
                }

                FilePath f = BaseDirectory.Combine(outputDirectory);
                NativeExecutionCommand cmd;
                if (File.Exists(f.Combine(targetName)))
                {
                    cmd = new NativeExecutionCommand(f.Combine(targetName));
                }
                else if (File.Exists(f.Combine(string.Format("{0}.{1}", targetName, "exe"))))
                {
                    cmd = new NativeExecutionCommand(f.Combine(string.Format("{0}.{1}", targetName, "exe")));
                }
                else if (File.Exists(f.Combine("./Debug", targetName)))
                {
                    cmd = new NativeExecutionCommand(f.Combine("./Debug", targetName));
                }
                else if (File.Exists(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe"))))
                {
                    cmd = new NativeExecutionCommand(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe")));
                }
                else
                {
                    monitor.ReportError("Can't determine executable path.");
                    return;
                }

                try {
                    var handler = Runtime.ProcessService.GetDefaultExecutionHandler(cmd);
                    var op = handler.Execute(cmd, console);

                    using (var t = monitor.CancellationToken.Register(op.Cancel))
                        await op.Task;

                    monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode);
                } catch (Exception ex) {
                    monitor.ReportError("Can't execute the target.", ex);
                } finally {
                    console.Dispose();
                }
            }));
        }
Пример #3
0
        public override SolutionItemConfiguration CreateConfiguration(string name)
        {
            var conf = new AspNetAppProjectConfiguration(name);

            conf.CopyFrom(base.CreateConfiguration(name));
            conf.OutputDirectory = BaseDirectory.IsNullOrEmpty? "bin" : (string)BaseDirectory.Combine("bin");
            return(conf);
        }
Пример #4
0
		public ProjectFile GetInfoPlist ()
		{
			var name = BaseDirectory.Combine ("Info.plist");
			var pf = Files.GetFile (name);
			if (pf != null)
				return pf;
			var doc = new PlistDocument ();
			doc.Root = new PlistDictionary ();
			doc.WriteToFile (name);
			return AddFile (name);
		}
Пример #5
0
        ProjectFile GetWebConfig()
        {
            var webConf = BaseDirectory.Combine("web.config");

            foreach (var file in Files)
            {
                if (string.Compare(file.FilePath.ToString(), webConf, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(file);
                }
            }
            return(null);
        }
Пример #6
0
        protected override Task <BuildResult> OnClean(ProgressMonitor monitor, ConfigurationSelector configuration,
                                                      OperationContext buildSession)
        {
            return(Task.Factory.StartNew(() => {
                var results = new BuildResult();

                FilePath path = BaseDirectory.Combine(outputDirectory);
                if (Directory.Exists(path))
                {
                    FileService.DeleteDirectory(path);
                }

                return results;
            }));
        }
Пример #7
0
        public IEnumerable <string> GetSourcePaths(List <DubBuildSettings> settings)
        {
            string d;
            List <DubBuildSetting> l;
            bool returnedOneItem = false;

            foreach (var sett in settings)
            {
                if (sett.TryGetValue(DubBuildSettings.SourcePathsProperty, out l))
                {
                    for (int i = l.Count - 1; i >= 0; i--)                     // Ignore architecture/os/compiler restrictions for now
                    {
                        for (int j = l[i].Flags.Length - 1; j >= 0; j--)
                        {
                            d = l[i].Flags[j];
                            if (!Path.IsPathRooted(d))
                            {
                                d = BaseDirectory.Combine(d).ToString();
                            }

                            if (!Directory.Exists(d))
                            {
                                continue;
                            }

                            returnedOneItem = true;
                        }
                    }
                }
            }

            if (returnedOneItem)
            {
                yield break;
            }

            d = BaseDirectory.Combine("source").ToString();
            if (Directory.Exists(d))
            {
                yield return(d);
            }

            d = BaseDirectory.Combine("src").ToString();
            if (Directory.Exists(d))
            {
                yield return(d);
            }
        }
Пример #8
0
        protected override void OnSaved(SolutionItemEventArgs args)
        {
            base.OnSaved(args);

            if (ExtendedConfiguration != null)
            {
                try
                {
                    var json = JsonConvert.SerializeObject(ExtendedConfiguration, Newtonsoft.Json.Formatting.Indented);
                    File.WriteAllText(BaseDirectory.Combine(ConfigJson), json);
                }
                catch
                {
                }
            }
        }
Пример #9
0
        protected override void OnItemsAdded(System.Collections.Generic.IEnumerable <ProjectItem> objs)
        {
            foreach (ProjectItem obj in objs)
            {
                if (obj is NestedContentProject)
                {
                    NestedContentProject contentProject = obj as NestedContentProject;

                    FilePath contentProjectPath = BaseDirectory.Combine(contentProject.Include);
                    if (File.Exists(contentProjectPath))
                    {
                        contentProject.Project = (ContentProject)ContentProject.LoadProject(contentProjectPath, new SimpleProgressMonitor());
                        RegisterInternalChild(contentProject.Project);
                    }
                }
            }
            base.OnItemsAdded(objs);
        }
Пример #10
0
        protected override void OnEndLoad()
        {
            var configJson = BaseDirectory.Combine(ConfigJson);

            if (File.Exists(configJson))
            {
                try
                {
                    var contents = File.ReadAllText(configJson);
                    ExtendedConfiguration = JsonConvert.DeserializeObject <ExtendedProjectConfig>(contents);
                }
                catch
                {
                }
            }

            base.OnEndLoad();
        }
Пример #11
0
        public override FilePath GetOutputFileName(ConfigurationSelector configuration)
        {
            var cfg = GetConfiguration(configuration) as DubProjectConfiguration;

            string targetPath = null, targetName = null, targetType = null;

            CommonBuildSettings.TryGetTargetFileProperties(this, configuration, ref targetType, ref targetName, ref targetPath);
            if (cfg != null)
            {
                cfg.BuildSettings.TryGetTargetFileProperties(this, configuration, ref targetType, ref targetName, ref targetPath);
            }

            if (string.IsNullOrWhiteSpace(targetPath))
            {
                targetPath = BaseDirectory.ToString();
            }
            else if (!Path.IsPathRooted(targetPath))
            {
                targetPath = BaseDirectory.Combine(targetPath).ToString();
            }

            if (string.IsNullOrWhiteSpace(targetName))
            {
                var packName = packageName.Split(':');
                targetName = packName[packName.Length - 1];
            }

            if (string.IsNullOrWhiteSpace(targetType) ||
                (targetType = targetType.ToLowerInvariant()) == "executable" ||
                targetType == "autodetect")
            {
                if (OS.IsWindows)
                {
                    targetName += ".exe";
                }
            }
            else
            {
                //TODO
            }


            return(Path.Combine(targetPath, targetName));
        }
Пример #12
0
        FilePath GetProjectJsonFileName()
        {
            ProjectFile projectJsonFile = Items.OfType <ProjectFile> ()
                                          .FirstOrDefault(projectFile => IsProjectJsonFile(projectFile.FilePath));

            if (projectJsonFile != null)
            {
                return(projectJsonFile.FilePath);
            }

            FilePath projectJsonFileName = BaseDirectory.Combine("project.json");

            if (File.Exists(projectJsonFileName))
            {
                return(projectJsonFileName);
            }

            return(null);
        }
Пример #13
0
        public override string GetDefaultBuildAction(string fileName)
        {
            var baseAction = base.GetDefaultBuildAction(fileName);

            if (baseAction == BuildAction.Compile)
            {
                return(baseAction);
            }

            var parentDir = ((FilePath)fileName).ToRelative(BaseDirectory).ParentDirectory;

            if (!parentDir.IsNullOrEmpty)
            {
                var parentOfParentDir = parentDir.ParentDirectory;
                if (!parentOfParentDir.IsNullOrEmpty)
                {
                    foreach (var prefix in MonoDroidResourcePrefixes)
                    {
                        if (prefix == parentOfParentDir)
                        {
                            return(MonoDroidBuildAction.AndroidResource);
                        }
                    }
                }
            }

            if (!String.IsNullOrEmpty(MonoDroidAssetsPrefix))
            {
                var assetsDir = BaseDirectory.Combine(MonoDroidAssetsPrefix);
                if (((FilePath)fileName).IsChildPathOf(assetsDir) && !fileName.Contains("AboutAssets.txt"))
                {
                    return(MonoDroidBuildAction.AndroidAsset);
                }
            }

            return(baseAction);
        }
Пример #14
0
 internal string GetPreferencesFileName()
 {
     return(BaseDirectory.Combine(".vs", Name, "xs", "UserPrefs.xml"));
 }
Пример #15
0
        bool IsWebConfig(FilePath file)
        {
            var webConf = BaseDirectory.Combine("web.config");

            return(string.Compare(file, webConf, StringComparison.OrdinalIgnoreCase) == 0);
        }
Пример #16
0
 public FilePath GetPreferencesDirectory()
 {
     return(BaseDirectory.Combine(".vs", Name, "xs"));
 }
Пример #17
0
 public void ChangeFileName(string fileName)
 {
     FileName      = new FilePath(fileName.ToNativePath());
     BaseDirectory = FileName.ParentDirectory;
     BaseIntermediateOutputPath = BaseDirectory.Combine("obj");
 }
Пример #18
0
        public void CreateWebRootDirectory()
        {
            FilePath webRootDirectory = BaseDirectory.Combine("wwwroot");

            CreateDirectory(webRootDirectory);
        }
Пример #19
0
 string GetDefaultManifestFileName()
 {
     return(BaseDirectory.Combine("Properties", "AndroidManifest.xml"));
 }
Пример #20
0
        BuildResult ParseGenerationResult(Stream result, ProgressMonitor monitor)
        {
            var results = new BuildResult();

            result.Position = 0;
            var    sr = new StreamReader(result);
            var    sb = new StringBuilder();
            string line;
            string fileName   = "";
            int    lineNumber = 0;
            bool   isWarning  = false;

            while ((line = sr.ReadLine()) != null)
            {
                //e.g.	CMake Warning in/at CMakeLists.txt:10 (COMMAND):
                //or:	CMake Warning:
                if (line.StartsWith("CMake Warning", StringComparison.OrdinalIgnoreCase))
                {
                    //reset everything and add last error or warning.
                    if (sb.Length > 0)
                    {
                        if (isWarning)
                        {
                            results.AddWarning(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                        else
                        {
                            results.AddError(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                    }

                    sb.Clear();
                    fileName   = "";
                    lineNumber = 0;
                    isWarning  = true;

                    // in/at CMakeLists.txt:10 (COMMAND):
                    if (line.Contains(" in "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " in ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else if (line.Contains(" at "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " at ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else
                    {
                        string [] warning = line.Split(':');
                        if (!string.IsNullOrEmpty(warning.ElementAtOrDefault(1)))
                        {
                            sb.Append(warning [1]);
                        }
                    }
                }
                else if (line.StartsWith("CMake Error", StringComparison.OrdinalIgnoreCase))
                {
                    //reset everything and add last error or warning.
                    if (sb.Length > 0)
                    {
                        if (isWarning)
                        {
                            results.AddWarning(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                        else
                        {
                            results.AddError(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                    }

                    sb.Clear();
                    fileName   = "";
                    lineNumber = 0;
                    isWarning  = false;

                    // in/at CMakeLists.txt:10 (COMMAND):
                    if (line.Contains(" in "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " in ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else if (line.Contains(" at "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " at ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else
                    {
                        string [] error = line.Split(':');
                        if (!string.IsNullOrEmpty(error.ElementAtOrDefault(1)))
                        {
                            sb.Append(error [1]);
                        }
                    }
                }
                else
                {
                    sb.Append(line);
                }
            }

            return(results);
        }