A dub package.
상속: AbstractDProject
예제 #1
0
        public static DubProject ReadPackageInformation(FilePath packageJsonPath, JsonReader r, IProgressMonitor monitor)
        {
            var defaultPackage = new DubProject();

            defaultPackage.FileName      = packageJsonPath;
            defaultPackage.BaseDirectory = packageJsonPath.ParentDirectory;

            defaultPackage.BeginLoad();

            defaultPackage.AddProjectAndSolutionConfiguration(new DubProjectConfiguration {
                Name = GettextCatalog.GetString("Default"), Id = DubProjectConfiguration.DefaultConfigId
            });

            while (r.Read())
            {
                if (r.TokenType == JsonToken.PropertyName)
                {
                    var propName = r.Value as string;
                    defaultPackage.TryPopulateProperty(propName, r, monitor);
                }
                else if (r.TokenType == JsonToken.EndObject)
                {
                    break;
                }
            }

            defaultPackage.Items.Add(new ProjectFile(packageJsonPath, BuildAction.None));

            defaultPackage.EndLoad();
            return(defaultPackage);
        }
예제 #2
0
 public void BuildCommonArgAppendix(StringBuilder sr, DubProject prj, ConfigurationSelector sel)
 {
     if (prj.Configurations.Count > 1)
     {
         sr.Append(" --config=").Append(sel.GetConfiguration(prj).Id);
     }
 }
예제 #3
0
		public static BuildResult BuildProject(DubProject prj, IProgressMonitor mon, ConfigurationSelector sel)
		{
			var br = new BuildResult();

			// Skip building sourceLibraries
			string targetType = null;
			var cfg = prj.GetConfiguration (sel) as DubProjectConfiguration;
			if (cfg != null){
				cfg.BuildSettings.TryGetTargetTypeProperty (prj, sel, ref targetType);
				if(string.IsNullOrWhiteSpace(targetType))
					prj.CommonBuildSettings.TryGetTargetTypeProperty (prj, sel, ref targetType);

				if (targetType != null && targetType.ToLower ().Contains("sourcelibrary")) {
					br.BuildCount = 1;
					return br;
				}
			}

			var args = new StringBuilder("build");

			BuildCommonArgAppendix(args, prj, sel);

			string output;
			string errDump;

			int status = ProjectBuilder.ExecuteCommand(DubSettings.Instance.DubCommand, args.ToString(), prj.BaseDirectory, 
				mon, out errDump, out output);
			br.CompilerOutput = output;

			ErrorExtracting.HandleReturnCode (mon, br, status);
			ErrorExtracting.HandleCompilerOutput(prj, br, output);
			ErrorExtracting.HandleCompilerOutput(prj, br, errDump);

			return br;
		}
예제 #4
0
        public void TryGetTargetFileProperties(DubProject prj, ConfigurationSelector configuration, ref string targetType, ref string targetName, ref string targetPath)
        {
            List <DubBuildSetting> l;

            if (TryGetValue(DubBuildSettings.TargetNameProperty, out l))
            {
                foreach (var sett in l)
                {
                    if (prj.BuildSettingMatchesConfiguration(sett, configuration))
                    {
                        targetName = sett.Values [0];
                    }
                }
            }

            if (TryGetValue(DubBuildSettings.TargetPathProperty, out l))
            {
                foreach (var sett in l)
                {
                    if (prj.BuildSettingMatchesConfiguration(sett, configuration))
                    {
                        targetPath = sett.Values [0];
                    }
                }
            }

            TryGetTargetTypeProperty(prj, configuration, ref targetType);
        }
예제 #5
0
        internal static void ExecuteProject(DubProject prj, IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            bool isDebug = context.ExecutionHandler.GetType().Name.StartsWith("Debug");

            var      conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
            IConsole console;

            if (conf.ExternalConsole)
            {
                console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
            }
            else
            {
                console = context.ConsoleFactory.CreateConsole(true);
            }

            var operationMonitor = new AggregatedOperationMonitor(monitor);

            var sr = new StringBuilder();

            if (!isDebug)
            {
                sr.Append("run");
                BuildCommonArgAppendix(sr, prj, configuration);
            }

            try
            {
                var cmd = isDebug ? prj.CreateExecutionCommand(configuration) : new NativeExecutionCommand(DubSettings.Instance.DubCommand, sr.ToString(), prj.BaseDirectory.ToString());
                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("Cannot execute \"" + cmd.Command + " " + cmd.Arguments + "\". The selected execution mode is not supported for Dub projects.", null);
                    return;
                }

                var op = context.ExecutionHandler.Execute(cmd, console);

                operationMonitor.AddOperation(op);
                op.WaitForCompleted();

                if (op.ExitCode != 0)
                {
                    monitor.ReportError(cmd.Command + " exited with code: " + op.ExitCode.ToString(), null);
                }
                else
                {
                    monitor.Log.WriteLine(cmd.Command + " exited with code: {0}", op.ExitCode);
                }
            }
            catch (Exception ex)
            {
                monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
            }
            finally
            {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
예제 #6
0
파일: DubBuilder.cs 프로젝트: Geod24/Mono-D
        public static void BuildCommonArgAppendix(StringBuilder sr,DubProject prj, ConfigurationSelector sel)
        {
            sr.Append (" \"").Append(prj.packageName).Append("\"");

            if(!string.IsNullOrWhiteSpace(DubSettings.Instance.CommonArgs))
                sr.Append(' ').Append (DubSettings.Instance.CommonArgs);

            if (prj.Configurations.Count > 1 && sel.GetConfiguration(prj).Name.ToLower() != "default")
                sr.Append(" \"--config=").Append(sel.GetConfiguration(prj).Name).Append("\"");
        }
예제 #7
0
        public static DubSubPackage ReadAndAdd(DubProject superProject, JsonReader r, IProgressMonitor monitor)
        {
            if (r.TokenType != JsonToken.StartObject)
            {
                throw new JsonReaderException("Illegal token on subpackage definition beginning");
            }

            var sub = new DubSubPackage();

            sub.FileName = superProject.FileName;

            sub.OriginalBasePath = superProject is DubSubPackage ? (superProject as DubSubPackage).OriginalBasePath :
                                   superProject.BaseDirectory;
            sub.VirtualBasePath = sub.OriginalBasePath;

            sub.BeginLoad();

            sub.AddProjectAndSolutionConfiguration(new DubProjectConfiguration {
                Name = GettextCatalog.GetString("Default"), Id = DubProjectConfiguration.DefaultConfigId
            });

            superProject.packagesToAdd.Add(sub);

            while (r.Read())
            {
                if (r.TokenType == JsonToken.PropertyName)
                {
                    sub.TryPopulateProperty(r.Value as string, r, monitor);
                }
                else if (r.TokenType == JsonToken.EndObject)
                {
                    break;
                }
            }

            sub.packageName = superProject.packageName + ":" + (sub.packageName ?? string.Empty);

            var sourcePaths = sub.GetSourcePaths().ToArray();

            if (sourcePaths.Length > 0 && !string.IsNullOrWhiteSpace(sourcePaths[0]))
            {
                sub.VirtualBasePath = new FilePath(sourcePaths [0]);
            }

            PackageJsonParser.LoadDubProjectReferences(sub, monitor);

            // TODO: What to do with new configurations that were declared in this sub package? Add them to all other packages as well?
            sub.EndLoad();

            if (r.TokenType != JsonToken.EndObject)
            {
                throw new JsonReaderException("Illegal token on subpackage definition end");
            }
            return(sub);
        }
예제 #8
0
        public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor)
        {
            object ret;
            var    serializer = new JsonSerializer();

            DubSolution sln;
            var         dp = new DubProject {
                FileName = file, BaseDirectory = file.ParentDirectory
            };

            if (expectedType.Equals(typeof(SolutionEntityItem)))
            {
                ret = dp;
                sln = null;
            }
            else if (expectedType.Equals(typeof(WorkspaceItem)))
            {
                ret = sln = new DubSolution(file);
                sln.RootFolder.AddItem(dp, false);
                sln.StartupItem = dp;
                dp.AddProjectAndSolutionConfiguration(new DubProjectConfiguration {
                    Name = "Default", Id = "Default"
                });
            }
            else
            {
                return(null);
            }

            using (var s = File.OpenText(file))
                using (var rdr = new JsonTextReader(s))
                {
                    while (rdr.Read())
                    {
                        if (rdr.TokenType == JsonToken.PropertyName)
                        {
                            dp.TryPopulateProperty(rdr.Value as string, rdr);
                        }
                        else if (rdr.TokenType == JsonToken.EndObject)
                        {
                            break;
                        }
                    }
                }

            dp.UpdateFilelist();
            if (sln != null)
            {
                sln.LoadUserProperties();
            }

            return(ret);
        }
예제 #9
0
        public static void BuildCommonArgAppendix(StringBuilder sr, DubProject prj, ConfigurationSelector sel)
        {
            sr.Append(" \"").Append(prj.packageName).Append("\"");

            if (!string.IsNullOrWhiteSpace(DubSettings.Instance.CommonArgs))
            {
                sr.Append(' ').Append(DubSettings.Instance.CommonArgs);
            }

            if (prj.Configurations.Count > 1 && sel.GetConfiguration(prj).Name.ToLower() != "default")
            {
                sr.Append(" \"--config=").Append(sel.GetConfiguration(prj).Name).Append("\"");
            }
        }
예제 #10
0
파일: DubBuilder.cs 프로젝트: foerdi/Mono-D
        public static void BuildCommonArgAppendix(StringBuilder sr,DubProject prj, ConfigurationSelector sel)
        {
            sr.Append (" \"").Append(prj.packageName).Append("\"");

            if(!string.IsNullOrWhiteSpace(DubSettings.Instance.CommonArgs))
                sr.Append(' ').Append (DubSettings.Instance.CommonArgs);

            var buildType = Ide.IdeApp.Workspace.ActiveExecutionTarget.Id;
            if (!string.IsNullOrWhiteSpace(buildType))
                sr.Append(" \"--build=").Append(buildType).Append("\"");

            if (prj.Configurations.Count > 1 && sel.GetConfiguration(prj).Name.ToLower() != "default")
                sr.Append(" \"--config=").Append(sel.GetConfiguration(prj).Name).Append("\"");
        }
예제 #11
0
        public static DubSubPackage ReadAndAdd(DubProject superProject,JsonReader r, IProgressMonitor monitor)
        {
            DubSubPackage sub;
            switch (r.TokenType) {
                case JsonToken.StartObject:
                    break;
                case JsonToken.String:

                    sub = PackageJsonParser.ReadPackageInformation (PackageJsonParser.GetDubJsonFilePath (superProject, r.Value as string), monitor, null, superProject) as DubSubPackage;
                    return sub;
                default:
                    throw new JsonReaderException ("Illegal token on subpackage definition beginning");
            }

            sub = new DubSubPackage ();
            sub.FileName = superProject.FileName;

            sub.OriginalBasePath = superProject is DubSubPackage ? (superProject as DubSubPackage).OriginalBasePath :
                superProject.BaseDirectory;
            sub.VirtualBasePath = sub.OriginalBasePath;

            sub.BeginLoad ();

            sub.AddProjectAndSolutionConfiguration(new DubProjectConfiguration { Name = GettextCatalog.GetString("Default"), Id = DubProjectConfiguration.DefaultConfigId });

            superProject.packagesToAdd.Add(sub);

            while (r.Read ()) {
                if (r.TokenType == JsonToken.PropertyName)
                    sub.TryPopulateProperty (r.Value as string, r, monitor);
                else if (r.TokenType == JsonToken.EndObject)
                    break;
            }

            sub.packageName = superProject.packageName + ":" + (sub.packageName ?? string.Empty);

            var sourcePaths = sub.GetSourcePaths ().ToArray();
            if (sourcePaths.Length > 0 && !string.IsNullOrWhiteSpace(sourcePaths[0]))
                sub.VirtualBasePath = new FilePath(sourcePaths [0]);

            PackageJsonParser.LoadDubProjectReferences (sub, monitor);

            // TODO: What to do with new configurations that were declared in this sub package? Add them to all other packages as well?
            sub.EndLoad ();

            if (r.TokenType != JsonToken.EndObject)
                throw new JsonReaderException ("Illegal token on subpackage definition end");
            return sub;
        }
예제 #12
0
        public void TryGetTargetTypeProperty(DubProject prj, ConfigurationSelector cfg, ref string targetType)
        {
            List <DubBuildSetting> l;

            if (TryGetValue(DubBuildSettings.TargetTypeProperty, out l))
            {
                foreach (var sett in l)
                {
                    if (prj.BuildSettingMatchesConfiguration(sett, cfg))
                    {
                        targetType = sett.Values [0];
                    }
                }
            }
        }
예제 #13
0
		public static void ExecuteProject(DubProject prj,IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, string dubVerb = "run")
		{
			bool isDebug = context.ExecutionHandler.GetType ().Name.StartsWith ("Debug");

			var conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
			IConsole console;
			if (conf.ExternalConsole)
				console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
			else
				console = context.ConsoleFactory.CreateConsole(true);
			
			var operationMonitor = new AggregatedOperationMonitor(monitor);

			var sr = new StringBuilder();
			if (!isDebug) {
				sr.Append (dubVerb);
				BuildCommonArgAppendix (sr, prj, configuration);
			}

			try
			{
				var cmd = isDebug ? prj.CreateExecutionCommand(configuration) : new NativeExecutionCommand(DubSettings.Instance.DubCommand, sr.ToString(), prj.BaseDirectory.ToString());
				if (!context.ExecutionHandler.CanExecute(cmd))
				{
					monitor.ReportError("Cannot execute \"" + cmd.Command + " " + cmd.Arguments + "\". The selected execution mode is not supported for Dub projects.", null);
					return;
				}

				var op = context.ExecutionHandler.Execute(cmd, console);

				operationMonitor.AddOperation(op);
				op.WaitForCompleted();

				if(op.ExitCode != 0)
					monitor.ReportError(cmd.Command+" exited with code: "+op.ExitCode.ToString(), null);
				else
					monitor.Log.WriteLine(cmd.Command+" exited with code: {0}", op.ExitCode);
			}
			catch (Exception ex)
			{
				monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
			}
			finally
			{
				operationMonitor.Dispose();
				console.Dispose();
			}
		}
예제 #14
0
        internal static void ExecuteProject(DubProject prj, IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            var      conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
            IConsole console;

            if (conf.ExternalConsole)
            {
                console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
            }
            else
            {
                console = context.ConsoleFactory.CreateConsole(true);
            }

            var operationMonitor = new AggregatedOperationMonitor(monitor);

            var sr = new StringBuilder("run");

            Instance.BuildCommonArgAppendix(sr, prj, configuration);

            try
            {
                var cmd = new NativeExecutionCommand(Instance.DubExecutable, sr.ToString(), prj.BaseDirectory.ToString());
                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("Cannot execute \"" + "\". The selected execution mode is not supported for Dub projects.", null);
                    return;
                }

                var op = context.ExecutionHandler.Execute(cmd, console);

                operationMonitor.AddOperation(op);
                op.WaitForCompleted();

                monitor.Log.WriteLine(Instance.DubExecutable + " exited with code: {0}", op.ExitCode);
            }
            catch (Exception ex)
            {
                monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
            }
            finally
            {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
예제 #15
0
        public static BuildResult BuildProject(DubProject prj, IProgressMonitor mon, ConfigurationSelector sel)
        {
            var br = new BuildResult();

            // Skip building sourceLibraries
            string targetType = null;
            var    cfg        = prj.GetConfiguration(sel) as DubProjectConfiguration;

            if (cfg != null)
            {
                cfg.BuildSettings.TryGetTargetTypeProperty(prj, sel, ref targetType);
                if (string.IsNullOrWhiteSpace(targetType))
                {
                    prj.CommonBuildSettings.TryGetTargetTypeProperty(prj, sel, ref targetType);
                }

                if (targetType != null && targetType.ToLower().Contains("sourcelibrary"))
                {
                    br.BuildCount = 1;
                    return(br);
                }
            }

            var args = new StringBuilder("build");

            BuildCommonArgAppendix(args, prj, sel);

            string output;
            string errDump;

            int status = ProjectBuilder.ExecuteCommand(DubSettings.Instance.DubCommand, args.ToString(), prj.BaseDirectory,
                                                       mon, out errDump, out output);

            br.CompilerOutput = output;

            ErrorExtracting.HandleReturnCode(mon, br, status);
            ErrorExtracting.HandleCompilerOutput(prj, br, output);
            ErrorExtracting.HandleCompilerOutput(prj, br, errDump);

            return(br);
        }
예제 #16
0
        internal static void ExecuteProject(DubProject prj,IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            var conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
            IConsole console;
            if (conf.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
            else
                console = context.ConsoleFactory.CreateConsole(true);

            var operationMonitor = new AggregatedOperationMonitor(monitor);

            var sr = new StringBuilder("run");
            Instance.BuildCommonArgAppendix(sr, prj, configuration);

            try
            {
                var cmd = new NativeExecutionCommand(Instance.DubExecutable, sr.ToString(), prj.BaseDirectory.ToString());
                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("Cannot execute \""  + "\". The selected execution mode is not supported for Dub projects.", null);
                    return;
                }

                var op = context.ExecutionHandler.Execute(cmd, console);

                operationMonitor.AddOperation(op);
                op.WaitForCompleted();

                monitor.Log.WriteLine(Instance.DubExecutable+" exited with code: {0}", op.ExitCode);

            }
            catch (Exception ex)
            {
                monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
            }
            finally
            {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
예제 #17
0
        internal static void LoadDubProjectReferences(DubProject defaultPackage, IProgressMonitor monitor, Solution sln = null)
        {
            var sub = defaultPackage as DubSubPackage;

            foreach (var dep in defaultPackage.DubReferences)
            {
                if (string.IsNullOrWhiteSpace(dep.Path))
                {
                    continue;
                }

                if (sub != null)
                {
                    sub.useOriginalBasePath = true;
                }
                var packageDir = defaultPackage.GetAbsPath(Building.ProjectBuilder.EnsureCorrectPathSeparators(dep.Path));

                if (sub != null)
                {
                    sub.useOriginalBasePath = false;
                }

                string packageJsonToLoad;
                if (File.Exists(packageJsonToLoad = Path.Combine(packageDir, PackageJsonFile)) ||
                    File.Exists(packageJsonToLoad = Path.Combine(packageDir, DubJsonFile)))
                {
                    var prj = ReadFile_(packageJsonToLoad, typeof(Project), monitor) as DubProject;
                    if (prj != null)
                    {
                        if (sln != null)
                        {
                            sln.RootFolder.AddItem(prj, false);
                        }
                        else
                        {
                            defaultPackage.packagesToAdd.Add(prj);
                        }
                    }
                }
            }
        }
예제 #18
0
        public static BuildResult BuildProject(DubProject prj, IProgressMonitor mon, ConfigurationSelector sel)
        {
            var br = new BuildResult();

            var args = new StringBuilder("build");

            Instance.BuildCommonArgAppendix(args, prj, sel);

            string output;
            string errDump;

            int status = ProjectBuilder.ExecuteCommand(Instance.DubExecutable, args.ToString(), prj.BaseDirectory,
                mon, out errDump, out output);
            br.CompilerOutput = output;

            ErrorExtracting.HandleReturnCode(mon, br, status);
            ErrorExtracting.HandleCompilerOutput(prj, br, output);
            ErrorExtracting.HandleCompilerOutput(prj, br, errDump);

            return br;
        }
예제 #19
0
        public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor)
        {
            object ret;
            var serializer = new JsonSerializer();

            DubSolution sln;
            var dp = new DubProject { FileName = file, BaseDirectory = file.ParentDirectory };
            if (expectedType.Equals(typeof(SolutionEntityItem))){
                ret = dp;
                sln = null;
            }
            else if(expectedType.Equals(typeof(WorkspaceItem)))
            {
                ret = sln = new DubSolution(file);
                sln.RootFolder.AddItem(dp, false);
                sln.StartupItem = dp;
                dp.AddProjectAndSolutionConfiguration(new DubProjectConfiguration { Name = "Default", Id = "Default" });
            }
            else
                return null;

            using (var s = File.OpenText(file))
            using(var rdr = new JsonTextReader(s))
            {
                while (rdr.Read())
                {
                    if (rdr.TokenType == JsonToken.PropertyName)
                        dp.TryPopulateProperty(rdr.Value as string, rdr);
                    else if (rdr.TokenType == JsonToken.EndObject)
                        break;
                }
            }

            dp.UpdateFilelist();
            if (sln != null)
                sln.LoadUserProperties();

            return ret;
        }
예제 #20
0
        public static BuildResult BuildProject(DubProject prj, IProgressMonitor mon, ConfigurationSelector sel)
        {
            var br = new BuildResult();

            var args = new StringBuilder("build");

            Instance.BuildCommonArgAppendix(args, prj, sel);

            string output;
            string errDump;

            int status = ProjectBuilder.ExecuteCommand(Instance.DubExecutable, args.ToString(), prj.BaseDirectory,
                                                       mon, out errDump, out output);

            br.CompilerOutput = output;

            ErrorExtracting.HandleReturnCode(mon, br, status);
            ErrorExtracting.HandleCompilerOutput(prj, br, output);
            ErrorExtracting.HandleCompilerOutput(prj, br, errDump);

            return(br);
        }
예제 #21
0
        public static void BuildCommonArgAppendix(StringBuilder sr, DubProject prj, ConfigurationSelector sel)
        {
            sr.Append(" \"").Append(prj.packageName).Append("\"");

            if (!string.IsNullOrWhiteSpace(DubSettings.Instance.CommonArgs))
            {
                sr.Append(' ').Append(DubSettings.Instance.CommonArgs);
            }

            var buildType = Ide.IdeApp.Workspace.ActiveExecutionTarget.Id;

            if (!string.IsNullOrWhiteSpace(buildType))
            {
                sr.Append(" \"--build=").Append(buildType).Append("\"");

                MonoDevelop.D.Profiler.Commands.ProfilerModeHandler.IsProfilerMode = buildType.ToLowerInvariant() == "profile";
            }

            if (prj.Configurations.Count > 1 && sel.GetConfiguration(prj).Name.ToLower() != "default")
            {
                sr.Append(" \"--config=").Append(sel.GetConfiguration(prj).Name).Append("\"");
            }
        }
예제 #22
0
 public void BuildCommonArgAppendix(StringBuilder sr,DubProject prj, ConfigurationSelector sel)
 {
     if (prj.Configurations.Count > 1)
         sr.Append(" --config=").Append(sel.GetConfiguration(prj).Id);
 }
예제 #23
0
		public void BuildProgramArgAppendix(StringBuilder sr, DubProject prj, DubProjectConfiguration cfg)
		{

		}
예제 #24
0
        internal static void LoadDubProjectReferences(DubProject defaultPackage, IProgressMonitor monitor, Solution sln = null)
        {
            var sub = defaultPackage as DubSubPackage;
            foreach (var dep in defaultPackage.DubReferences)
            {
                if (string.IsNullOrWhiteSpace(dep.Path))
                    continue;

                if (sub != null)
                    sub.useOriginalBasePath = true;
                var packageDir = defaultPackage.GetAbsPath(Building.ProjectBuilder.EnsureCorrectPathSeparators(dep.Path));

                if(sub != null)
                    sub.useOriginalBasePath = false;

                string packageJsonToLoad;
                if (File.Exists(packageJsonToLoad = Path.Combine(packageDir, PackageJsonFile)) ||
                    File.Exists(packageJsonToLoad = Path.Combine(packageDir, DubJsonFile)))
                {
                    var prj = ReadFile_(packageJsonToLoad, typeof(Project), monitor) as DubProject;
                    if (prj != null) {
                        if (sln != null)
                            sln.RootFolder.AddItem (prj, false);
                        else
                            defaultPackage.packagesToAdd.Add (prj);
                    }
                }
            }
        }
예제 #25
0
        internal static void LoadDubProjectReferences(DubProject defaultPackage, IProgressMonitor monitor, Solution sln = null)
        {
            foreach (var dep in defaultPackage.DubReferences)
            {
                if (string.IsNullOrWhiteSpace(dep.Path))
                    continue;

                string packageJsonToLoad = GetDubJsonFilePath(defaultPackage, dep.Path);
                if (packageJsonToLoad != null && packageJsonToLoad != defaultPackage.FileName)
                {
                    var prj = ReadFile_(packageJsonToLoad, typeof(Project), monitor) as DubProject;
                    if (prj != null) {
                        if (sln != null)
                            sln.RootFolder.AddItem (prj, false);
                        else
                            defaultPackage.packagesToAdd.Add (prj);
                    }
                }
            }
        }
예제 #26
0
        public static DubProject ReadPackageInformation(FilePath packageJsonPath,IProgressMonitor monitor,JsonReader r = null, DubProject superPackage = null)
        {
            DubProject defaultPackage;
            bool free;
            StreamReader s = null;
            bool cleanupAlreadyLoadedPacks = AlreadyLoadedPackages == null;
            if (cleanupAlreadyLoadedPacks)
                AlreadyLoadedPackages = new Dictionary<string, DubProject> ();

            if (free = (r == null)) {
                if (AlreadyLoadedPackages.TryGetValue (packageJsonPath, out defaultPackage)) {
                    if (cleanupAlreadyLoadedPacks)
                        AlreadyLoadedPackages = null;
                    return defaultPackage;
                }

                s = File.OpenText (packageJsonPath);
                r = new JsonTextReader (s);
            }

            defaultPackage = superPackage != null ? new DubSubPackage() : new DubProject();
            try
            {
                defaultPackage.FileName = packageJsonPath;
                AlreadyLoadedPackages[packageJsonPath] = defaultPackage;
                defaultPackage.BaseDirectory = packageJsonPath.ParentDirectory;

                defaultPackage.BeginLoad ();

                defaultPackage.AddProjectAndSolutionConfiguration(new DubProjectConfiguration { Name = GettextCatalog.GetString("Default"), Id = DubProjectConfiguration.DefaultConfigId });

                if(superPackage != null)
                    superPackage.packagesToAdd.Add(defaultPackage);

                while (r.Read ()) {
                    if (r.TokenType == JsonToken.PropertyName) {
                        var propName = r.Value as string;
                        defaultPackage.TryPopulateProperty (propName, r, monitor);
                    }
                    else if (r.TokenType == JsonToken.EndObject)
                        break;
                }

                if(superPackage != null)
                    defaultPackage.packageName = superPackage.packageName + ":" + (defaultPackage.packageName ?? string.Empty);

                defaultPackage.Items.Add(new ProjectFile(packageJsonPath, BuildAction.None));

                // https://github.com/aBothe/Mono-D/issues/555
                var dubSelectionJsonPath = packageJsonPath.ParentDirectory.Combine(DubSelectionsJsonFile);
                if(File.Exists(dubSelectionJsonPath))
                    defaultPackage.Items.Add(new ProjectFile(dubSelectionJsonPath, BuildAction.None));

                defaultPackage.EndLoad ();
            }
            catch(Exception ex) {
                monitor.ReportError ("Exception while reading dub package "+packageJsonPath,ex);
            }
            finally{
                if (free) {
                    r.Close ();
                    s.Dispose ();
                }

                if (cleanupAlreadyLoadedPacks)
                    AlreadyLoadedPackages = null;
            }
            return defaultPackage;
        }
예제 #27
0
        public static DubProject ReadPackageInformation(FilePath packageJsonPath,JsonReader r, IProgressMonitor monitor)
        {
            var defaultPackage = new DubProject();
            defaultPackage.FileName = packageJsonPath;
            defaultPackage.BaseDirectory = packageJsonPath.ParentDirectory;

            defaultPackage.BeginLoad ();

            defaultPackage.AddProjectAndSolutionConfiguration(new DubProjectConfiguration { Name = GettextCatalog.GetString("Default"), Id = DubProjectConfiguration.DefaultConfigId });

            while (r.Read ()) {
                if (r.TokenType == JsonToken.PropertyName) {
                    var propName = r.Value as string;
                    defaultPackage.TryPopulateProperty (propName, r, monitor);
                }
                else if (r.TokenType == JsonToken.EndObject)
                    break;
            }

            defaultPackage.Items.Add(new ProjectFile(packageJsonPath, BuildAction.None));

            defaultPackage.EndLoad ();
            return defaultPackage;
        }
예제 #28
0
 public DubReferencesCollection(DubProject prj) : base(prj)
 {
 }
예제 #29
0
 public void BuildProgramArgAppendix(StringBuilder sr, DubProject prj, DubProjectConfiguration cfg)
 {
 }