Example #1
1
		/// <summary>
		/// Starts to run a build inside the SharpDevelop GUI.
		/// Only one build can run inside the GUI at one time.
		/// </summary>
		/// <param name="project">The project/solution to build.</param>
		/// <param name="options">The build options.</param>
		public static void BuildInGui(IBuildable project, BuildOptions options)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			if (options == null)
				throw new ArgumentNullException("options");
			WorkbenchSingleton.AssertMainThread();
			if (guiBuildCancellation != null) {
				BuildResults results = new BuildResults();
				WorkbenchSingleton.StatusBar.SetMessage(Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
				BuildError error = new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
				results.Add(error);
				TaskService.Add(new Task(error));
				results.Result = BuildResultCode.MSBuildAlreadyRunning;
				if (options.Callback != null) {
					options.Callback(results);
				}
			} else {
				guiBuildCancellation = new CancellationTokenSource();
				IProgressMonitor progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token);
				guiBuildTrackedFeature = AnalyticsMonitorService.TrackFeature("ICSharpCode.SharpDevelop.Project.BuildEngine.Build");
				WorkbenchSingleton.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}..."));
				ProjectService.RaiseEventBuildStarted(new BuildEventArgs(project, options));
				StartBuild(project, options,
				           new MessageViewSink(TaskService.BuildMessageViewCategory, progressMonitor, WorkbenchSingleton.StatusBar));
			}
		}
    public bool CanBuild(Coordinate position, IBuildable buildable)
    {
        if (TryGetBuildCoordinates(position, buildable.BuildSizeLow, buildable.BuildSizeHigh, bufferBuildCoordinates) == false)
        {
            return(false);
        }

        this.GetSpacedNeighborCoordinates(position, buildable.BuildSizeLow, buildable.BuildSizeHigh, this.bufferNeighborCoordinates);
        for (int i = 0; i < this.bufferNeighborCoordinates.Count; i++)
        {
            Coordinate coor = this.bufferNeighborCoordinates[i];

            if (Grid[coor.x, coor.y].Occupied && !buildable.IsOverlay)
            {
                return(false);
            }
        }

        for (int i = 0; i < bufferBuildCoordinates.Count; i++)
        {
            Coordinate coor = bufferBuildCoordinates[i];
            if (this.IsOnGrid(coor.x, coor.y))
            {
                if (this.Grid[coor.x, coor.y].Occupied && !buildable.IsOverlay)
                {
                    return(false);
                }
            }
        }

        return(true);
    }
Example #3
0
 public void AddBuildingTemplate(IBuildable template)
 {
     if (BuildingTemplates.FirstOrDefault(t => t.SystemName == template.SystemName) == null)
     {
         BuildingTemplates.Add(template.Clone());
     }
 }
Example #4
0
        /// <summary>
        /// Starts to run a build.
        /// </summary>
        /// <param name="project">The project/solution to build</param>
        /// <param name="options">The build options that should be used</param>
        /// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output.
        /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
        /// will ensure that output from two projects building in parallel isn't interleaved.</param>
        /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
        /// when the build completes.</param>
        public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink)
        {
            if (project == null)
            {
                throw new ArgumentNullException("solution");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            Solution solution = project.ParentSolution;

            if (solution == null)
            {
                throw new ArgumentException("project.ParentSolution must not be null", "project");
            }

            if (string.IsNullOrEmpty(options.SolutionConfiguration))
            {
                options.SolutionConfiguration = solution.Preferences.ActiveConfiguration;
            }
            if (string.IsNullOrEmpty(options.SolutionPlatform))
            {
                options.SolutionPlatform = solution.Preferences.ActivePlatform;
            }

            BuildEngine engine = new BuildEngine(options, project);

            engine.buildStart = DateTime.Now;
            engine.combinedBuildFeedbackSink = realtimeBuildFeedbackSink;
            engine.progressMonitor           = realtimeBuildFeedbackSink.ProgressMonitor;
            try {
                engine.rootNode = engine.CreateBuildGraph(project);
            } catch (CyclicDependencyException ex) {
                if (ex.Project1 != null && ex.Project2 != null)
                {
                    engine.results.Add(new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name));
                }
                else
                {
                    engine.results.Add(new BuildError(null, "Cyclic dependency"));
                }
                engine.results.Result = BuildResultCode.BuildFileError;
                engine.ReportDone();
                return;
            }

            engine.workersToStart = options.ParallelProjectCount;
            if (engine.workersToStart < 1)
            {
                engine.workersToStart = 1;
            }

            engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled);

            engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}");
            engine.StartBuildProjects();
            engine.UpdateProgressTaskName();
        }
 public BodyPartBuilder AddHeadProduct <TResult>(AssetManagerLoader loader, IBuildable <TResult> builder)
     where TResult : WearableProduct
 {
     AddStep("HEAD_PRODUCT",
             (handler) => { _appendFieldProductWearable(handler.Target, "headItems", builder.Build(loader)); });
     return(this);
 }
 public static bool Place(IBuildable buildable, Vector2d newPos)
 {
     SetTarget(buildable);
     StartPlace();
     UpdatePlace(newPos);
     return(EndPlace());
 }
 public static IEnumerable <IBuildable> GetOccupyingBuildings(IBuildable buildable)
 {
     foreach (var obj in BuildGridAPI.MainBuildGrid.GetOccupyingBuildables(buildable))
     {
         yield return(obj);
     }
 }
Example #8
0
 public CostumeBuilder BodyPartFemale <TResult>(AssetManagerLoader loader,
                                                IBuildable <BodyPartsContainer> container)
     where TResult : BodyPartsContainer
 {
     AddStep("BODY_PART_FEMALE", handler => { handler.Target.bodyPartsFemale = container.Build(loader); });
     return(this);
 }
Example #9
0
 /// <summary>
 /// Starts to run a build inside the SharpDevelop GUI.
 /// Only one build can run inside the GUI at one time.
 /// </summary>
 /// <param name="project">The project/solution to build.</param>
 /// <param name="options">The build options.</param>
 public static void BuildInGui(IBuildable project, BuildOptions options)
 {
     if (project == null)
     {
         throw new ArgumentNullException("project");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     WorkbenchSingleton.AssertMainThread();
     if (guiBuildProgressMonitor != null)
     {
         BuildResults results = new BuildResults();
         results.Add(new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")));
         results.Result = BuildResultCode.MSBuildAlreadyRunning;
         if (options.Callback != null)
         {
             options.Callback(results);
         }
     }
     else
     {
         guiBuildProgressMonitor = new CancellableProgressMonitor(StatusBarService.CreateProgressMonitor());
         Gui.WorkbenchSingleton.Workbench.GetPad(typeof(Gui.CompilerMessageView)).BringPadToFront();
         GuiBuildStarted.RaiseEvent(null, new BuildEventArgs(project, options));
         StartBuild(project, options,
                    new MessageViewSink(TaskService.BuildMessageViewCategory),
                    guiBuildProgressMonitor);
     }
 }
Example #10
0
        void InitializeProjectOptions(BuildNode node)
        {
            IBuildable project = node.project;

            // Create options for building the project
            node.options = project.CreateProjectBuildOptions(options, project == rootProject);
        }
Example #11
0
 /// <summary>
 /// Starts to run a build inside the SharpDevelop GUI.
 /// Only one build can run inside the GUI at one time.
 /// </summary>
 /// <param name="project">The project/solution to build.</param>
 /// <param name="options">The build options.</param>
 public static void BuildInGui(IBuildable project, BuildOptions options)
 {
     if (project == null)
     {
         throw new ArgumentNullException("project");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     WorkbenchSingleton.AssertMainThread();
     if (guiBuildCancellation != null)
     {
         BuildResults results = new BuildResults();
         WorkbenchSingleton.StatusBar.SetMessage(Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
         BuildError error = new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
         results.Add(error);
         TaskService.Add(new Task(error));
         results.Result = BuildResultCode.MSBuildAlreadyRunning;
         if (options.Callback != null)
         {
             options.Callback(results);
         }
     }
     else
     {
         guiBuildCancellation = new CancellationTokenSource();
         IProgressMonitor progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token);
         guiBuildTrackedFeature = AnalyticsMonitorService.TrackFeature("ICSharpCode.SharpDevelop.Project.BuildEngine.Build");
         WorkbenchSingleton.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}..."));
         ProjectService.RaiseEventBuildStarted(new BuildEventArgs(project, options));
         StartBuild(project, options,
                    new MessageViewSink(TaskService.BuildMessageViewCategory, progressMonitor, WorkbenchSingleton.StatusBar));
     }
 }
Example #12
0
 public JobDeconstruct(SystemDeconstruct orders, IBuilding building)
     : base(orders, building, $"Deconstruct {building.def.name}.")
 {
     BB.AssertNotNull(building);
     buildable = (IBuildable)building.prototype;
     BB.Assert(buildable != null);
 }
Example #13
0
        public void ReadXml(XmlReader reader)
        {
            int i = 0;

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    Type       type    = Type.GetType(this.GetType().Namespace + "." + reader.Name);
                    IBuildable element = (IBuildable)Activator.CreateInstance(type);
                    element.ReadXml(reader);

                    if (i == 0)
                    {
                        first = element;
                    }
                    else
                    {
                        second = element;
                    }
                    i++;
                }
                else if (reader.NodeType == XmlNodeType.EndElement & reader.Name == this.GetType().Name)
                {
                    return;
                }
            }
        }
 public void CompileFiles(IBuildable buildable)
 {
     ClearOutputWindow();
     foreach (TypeScriptProject project in buildable.GetTypeScriptProjects()) {
         CompileFiles(project);
     }
 }
Example #15
0
 public void Done(IBuildable buildable, BuildOptions options, BuildResults results)
 {
     WorkbenchSingleton.SafeThreadAsyncCall(
         delegate {
         guiBuildProgressMonitor = null;
         GuiBuildFinished.RaiseEvent(null, new BuildEventArgs(buildable, options, results));
     });
 }
Example #16
0
 public void Build(IBuildable target)
 {
     if (!CanBuild(target))
     {
         throw new InvalidOperationException("建設不可能な地形にbuildしました");
     }
     Building = target;
 }
Example #17
0
        public string ParseAndOutput(string mathML)
        {
            IBuildable    b  = Parser.Parse(XElement.Parse(mathML));
            StringBuilder sb = new StringBuilder();

            b.Visit(sb, new BuildContext(Singleton.Instance.Options));
            return(sb.ToString());
        }
 public BodyPartBuilder AddAccessoryProduct <TResult>(AssetManagerLoader loader,
                                                      IBuildable <TResult> builder)
     where TResult : WearableProduct
 {
     AddStep("ACCESSORY_PRODUCT",
             (handler) => { _appendFieldProductWearable(handler.Target, "accessories", builder.Build(loader)); });
     return(this);
 }
Example #19
0
        public static string ParseAndOutput(string mathML, BuildContextOptions options)
        {
            IBuildable    b  = Parser.Parse(XElement.Parse(mathML));
            StringBuilder sb = new StringBuilder();

            b.Visit(sb, new BuildContext(options));
            return(sb.ToString());
        }
 static IProject GetProjectFromBuildable(IBuildable b)
 {
     while (b is Wrapper)
     {
         b = ((Wrapper)b).wrapped;
     }
     return(b as IProject);
 }
Example #21
0
		/// <summary>
		/// Adds a project to the list of built projects.
		/// This method is thread-safe.
		/// </summary>
		public void AddBuiltProject(IBuildable buildable)
		{
			if (buildable == null)
				throw new ArgumentNullException("buildable");
			lock (builtProjects) {
				readOnlyBuiltProjects = null;
				builtProjects.Add(buildable);
			}
		}
			public IBuildable GetWrapper(IBuildable wrapped)
			{
				IBuildable b;
				lock (dict) {
					if (!dict.TryGetValue(wrapped, out b))
						b = dict[wrapped] = new Wrapper(wrapped, this);
				}
				return b;
			}
Example #23
0
        public static ProjectBuildOptions CreateProjectBuildOptions(this IBuildable buildable, BuildOptions options, bool isRootBuildable)
        {
            IBuildable2 buildable2 = buildable as IBuildable2;

            if (buildable2 != null)
            {
                return(buildable2.CreateProjectBuildOptions(options, isRootBuildable));
            }
            // start of default implementation
            var configMatchings = buildable.ParentSolution.GetActiveConfigurationsAndPlatformsForProjects(options.SolutionConfiguration, options.SolutionPlatform);
            ProjectBuildOptions projectOptions = new ProjectBuildOptions(isRootBuildable ? options.ProjectTarget : options.TargetForDependencies);
            // Find the project configuration, and build an XML string containing all configurations from the solution
            StringWriter solutionConfigurationXml = new StringWriter();

            using (XmlTextWriter solutionConfigurationWriter = new XmlTextWriter(solutionConfigurationXml)) {
                solutionConfigurationWriter.WriteStartElement("SolutionConfiguration", "");
                foreach (var matching in configMatchings)
                {
                    if (matching.Project == buildable)
                    {
                        projectOptions.Configuration = matching.Configuration;
                        projectOptions.Platform      = matching.Platform;
                    }

                    solutionConfigurationWriter.WriteStartElement("ProjectConfiguration");
                    solutionConfigurationWriter.WriteAttributeString("Project", matching.Project.IdGuid);
                    solutionConfigurationWriter.WriteValue(matching.Configuration + "|" + MSBuildInternals.FixPlatformNameForProject(matching.Platform));
                    solutionConfigurationWriter.WriteEndElement();
                }
                solutionConfigurationWriter.WriteEndElement();
            }

            // fall back to solution config if we don't find any entries for the project
            if (string.IsNullOrEmpty(projectOptions.Configuration))
            {
                projectOptions.Configuration = options.SolutionConfiguration;
            }
            if (string.IsNullOrEmpty(projectOptions.Platform))
            {
                projectOptions.Platform = options.SolutionPlatform;
            }

            // copy properties to project options
            options.GlobalAdditionalProperties.ForEach(projectOptions.Properties.Add);
            if (isRootBuildable)
            {
                foreach (var pair in options.ProjectAdditionalProperties)
                {
                    projectOptions.Properties[pair.Key] = pair.Value;
                }
            }
            // Set property for solution configuration. This allows MSBuild to know the correct configuration for project references,
            // which is necessary to resolve the referenced project's OutputPath.
            projectOptions.Properties["CurrentSolutionConfigurationContents"] = solutionConfigurationXml.ToString();
            return(projectOptions);
        }
    public void AssignBuilding(IBuildable newBuilding)
    {
        assignedBuilding = newBuilding;
        GetComponent<Image>().sprite = assignedBuilding.GetIcon();
        if (!newBuilding.IsBuilt())
        {
            bool canBuild = false;

            List<InventoryItem> usedLocalItems = new List<InventoryItem>();

            //if (currentSelectedMember.CheckEnoughFatigue(totalBuildFatigueCost))
            {
                //Prep used item list and required item count dict
                Dictionary<CraftRecipe.CraftableItems, int> availableIngredients
                    = new Dictionary<CraftRecipe.CraftableItems, int>(assignedBuilding.GetMaterials());
                //Run a check through local inventory and member personal inventory, to see if
                foreach (CraftRecipe.CraftableItems ingredientKey in assignedBuilding.GetMaterials().Keys)
                {
                    foreach (InventoryItem localItem in MapManager.main.GetTown().GetStashedItems())//InventoryScreenHandler.mainISHandler.selectedMember.currentRegion.GetStashedItems())
                    {
                        if (localItem.GetType() == CraftRecipe.GetItemInstance(ingredientKey).GetType())
                        {
                            availableIngredients[ingredientKey] = availableIngredients[ingredientKey] - 1;
                            usedLocalItems.Add(localItem);
                            if (availableIngredients[ingredientKey] == 0) break;
                        }
                    }
                }
                bool enoughIngredients = true;
                foreach (int remainingRequiredCount in availableIngredients.Values)
                {
                    if (remainingRequiredCount > 0)
                    {
                        enoughIngredients = false;
                        break;
                    }
                }
                canBuild = (enoughIngredients && TownManager.main.money >= assignedBuilding.GetBuildCost());
            }
            //Refresh button
            if (canBuild)
            {
                GetComponent<Button>().interactable = true;
                //Add button effect
                GetComponent<Button>().onClick.RemoveAllListeners();
                GetComponent<Button>().onClick.AddListener(
                () => ButtonClicked(usedLocalItems));
            }
            else GetComponent<Button>().interactable = false;
        }
        else
        {
            GetComponent<Button>().onClick.RemoveAllListeners();
            GetComponent<Button>().interactable = true;
        }
    }
Example #25
0
    /// <summary>
    /// Initializes a new instance of the <see cref="BuildableJobs"/> class.
    /// </summary>
    /// <param name="buildable">The current buildable.</param>
    public BuildableJobs(IBuildable buildEntity)
    {
        buildable  = buildEntity;
        activeJobs = new List <Job>();
        pausedJobs = new List <Job>();

        WorkSpotOffset   = Vector2.zero;
        InputSpotOffset  = Vector2.zero;
        OutputSpotOffset = Vector2.zero;
    }
Example #26
0
    /// <summary>
    /// Initializes a new instance of the <see cref="BuildableJobs"/> class by copying some of the values from another instance.
    /// </summary>
    /// <param name="buildEntity">The current buildable.</param>
    /// <param name="jobs">The buildable jobs to copy from.</param>
    public BuildableJobs(IBuildable buildEntity, BuildableJobs jobs)
    {
        buildable  = buildEntity;
        activeJobs = new List <Job>();
        pausedJobs = new List <Job>();

        WorkSpotOffset   = jobs.WorkSpotOffset;
        InputSpotOffset  = jobs.InputSpotOffset;
        OutputSpotOffset = jobs.OutputSpotOffset;
    }
Example #27
0
 public FrontBackTrainBuilder <TResult> BackVehicle <TVehicle>(IBuildable <TVehicle> vehicleBuilder)
     where TVehicle : Vehicle
 {
     AddStep("BACK_VEHICLE", (container) =>
     {
         TVehicle vehicle = vehicleBuilder.Build(container.Loader);
         container.Target.rearVehicleGO = vehicle;
     });
     return(this);
 }
 public void CompileFiles(IBuildable buildable)
 {
     ClearOutputWindow();
     foreach (TypeScriptProject project in buildable.GetTypeScriptProjects())
     {
         if (project.CompileOnBuild)
         {
             CompileFiles(project);
         }
     }
 }
Example #29
0
    public void Select(GameObject inst)
    {
        if (inst == null)
        {
            return;
        }

        selectedObj = inst;
        obj         = inst.GetComponent <IBuildable>();
        obj.OnSelected();
    }
Example #30
0
 /// <summary>
 /// Adds a project to the list of built projects.
 /// This method is thread-safe.
 /// </summary>
 public void AddBuiltProject(IBuildable buildable)
 {
     if (buildable == null)
     {
         throw new ArgumentNullException("buildable");
     }
     lock (builtProjects) {
         readOnlyBuiltProjects = null;
         builtProjects.Add(buildable);
     }
 }
Example #31
0
    public void Build()
    {
        if (selectedObj == null || !isBuildable)
        {
            return;
        }

        selectedObj = null;
        obj.OnBuild();
        obj = null;
    }
Example #32
0
 public TSelf FrontVehicle <TVehicle>(IBuildable <TVehicle> vehicleBuilder, AssetManagerLoader loader)
     where TVehicle : Vehicle
 {
     AddStep("FRONT_VEHICLE",
             (container) =>
     {
         TVehicle vehicle = vehicleBuilder.Build(loader);
         container.Target.frontVehicleGO = vehicle;
     });
     return(this as TSelf);
 }
 public static void StartMove(IBuildable buildable)
 {
     SetTarget(buildable);
     StartPlace();
     TargetOriginalValid    = Target.IsValidOnGrid;
     TargetOriginalPosition = Target.GridPosition;
     if (TargetOriginalValid)
     {
         BuildGridAPI.Unbuild(TargetOriginalPosition, Target);
     }
     IsMovingBuilding = true;
 }
Example #34
0
        public override void Enter()
        {
            builderData = GetComponent <IBuildData>();
            building    = unit.Target.transform.GetComponent <IBuildable>();

            Utils.LookTarget(unit, unit.Target);

            if (tool != null)
            {
                tool.SetActive(true);
            }
        }
        static IEnumerable<IProject> GetProjects(IBuildable buildable)
        {
            var project = buildable as IProject;
            if (project != null) {
                return new IProject[] { project };
            }

            var solution = buildable as Solution;
            if (solution != null) {
                return solution.Projects;
            }

            return new IProject[0];
        }
		public IBuildable WrapBuildable(IBuildable buildable, BuildDetection setting)
		{
			switch (setting) {
				case BuildDetection.DoNotBuild:
					return new DummyBuildable(buildable);
				case BuildDetection.BuildModifiedAndDependent:
				case BuildDetection.BuildOnlyModified:
					lock (unmodifiedProjects) {
						foreach (var pair in unmodifiedProjects) {
							LoggingService.Debug(pair.Key.Name + ": " + pair.Value);
						}
					}
					return new WrapperFactory(this, setting).GetWrapper(buildable);
				case BuildDetection.RegularBuild:
					return buildable;
				default:
					throw new NotSupportedException();
			}
		}
Example #37
0
		/// <summary>
		/// Starts to run a build.
		/// </summary>
		/// <param name="project">The project/solution to build</param>
		/// <param name="options">The build options that should be used</param>
		/// <param name="buildFeedbackSink">The build feedback sink that receives the build output.
		/// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
		/// will ensure that output from two projects building in parallel isn't interleaved.</param>
		/// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
		/// when the build completes.</param>
		public static Task<BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			if (options == null)
				throw new ArgumentNullException("options");
			
			BuildEngine engine = new BuildEngine(options, project);
			engine.buildStart = DateTime.Now;
			engine.combinedBuildFeedbackSink = buildFeedbackSink;
			engine.progressMonitor = progressMonitor;
			try {
				engine.rootNode = engine.CreateBuildGraph(project);
			} catch (CyclicDependencyException ex) {
				BuildError error;
				if (ex.Project1 != null && ex.Project2 != null)
					error = new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name);
				else
					error = new BuildError(null, "Cyclic dependency");
				engine.results.Add(error);
				if (engine.combinedBuildFeedbackSink != null) {
					engine.combinedBuildFeedbackSink.ReportError(error);
					engine.combinedBuildFeedbackSink.ReportMessage(error.ToRichText());
				}
				
				engine.results.Result = BuildResultCode.BuildFileError;
				engine.ReportDone();
				return engine.tcs.Task;
			}
			
			engine.workersToStart = options.ParallelProjectCount;
			if (engine.workersToStart < 1)
				engine.workersToStart = 1;
			
			engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled);
			
			engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}");
			engine.StartBuildProjects();
			engine.UpdateProgressTaskName();
			return engine.tcs.Task;
		}
Example #38
0
		/// <summary>
		/// Starts to run a build inside the SharpDevelop GUI.
		/// Only one build can run inside the GUI at one time.
		/// </summary>
		/// <param name="project">The project/solution to build.</param>
		/// <param name="options">The build options.</param>
		public static void BuildInGui(IBuildable project, BuildOptions options)
		{
			if (project == null)
				throw new ArgumentNullException("project");
			if (options == null)
				throw new ArgumentNullException("options");
			WorkbenchSingleton.AssertMainThread();
			if (guiBuildProgressMonitor != null) {
				BuildResults results = new BuildResults();
				results.Add(new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")));
				results.Result = BuildResultCode.MSBuildAlreadyRunning;
				if (options.Callback != null) {
					options.Callback(results);
				}
			} else {
				guiBuildProgressMonitor = new CancellableProgressMonitor(StatusBarService.CreateProgressMonitor());
				Gui.WorkbenchSingleton.Workbench.GetPad(typeof(Gui.CompilerMessageView)).BringPadToFront();
				GuiBuildStarted.RaiseEvent(null, new BuildEventArgs(project, options));
				StartBuild(project, options,
				           new MessageViewSink(TaskService.BuildMessageViewCategory),
				           guiBuildProgressMonitor);
			}
		}
		void CreateBeforeBuildCustomToolProjectItems(IBuildable buildable)
		{
			beforeBuildCustomToolProjectItems = new BeforeBuildCustomToolProjectItems(buildable);
		}
Example #40
0
		private BuildEngine(BuildOptions options, IBuildable rootProject)
		{
			this.options = options;
			this.rootProject = rootProject;
		}
Example #41
0
			public BuildNode(BuildEngine engine, IBuildable project)
			{
				this.engine = engine;
				this.project = project;
			}
Example #42
0
		/// <summary>
		/// Starts to run a build.
		/// </summary>
		/// <param name="project">The project/solution to build</param>
		/// <param name="options">The build options that should be used</param>
		/// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output.
		/// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
		/// will ensure that output from two projects building in parallel isn't interleaved.</param>
		/// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
		/// when the build completes.</param>
		public static void StartBuild(IBuildable project, BuildOptions options, IBuildFeedbackSink realtimeBuildFeedbackSink)
		{
			if (project == null)
				throw new ArgumentNullException("solution");
			if (options == null)
				throw new ArgumentNullException("options");
			
			Solution solution = project.ParentSolution;
			if (solution == null)
				throw new ArgumentException("project.ParentSolution must not be null", "project");
			
			if (string.IsNullOrEmpty(options.SolutionConfiguration))
				options.SolutionConfiguration = solution.Preferences.ActiveConfiguration;
			if (string.IsNullOrEmpty(options.SolutionPlatform))
				options.SolutionPlatform = solution.Preferences.ActivePlatform;
			
			BuildEngine engine = new BuildEngine(options, project);
			engine.buildStart = DateTime.Now;
			engine.combinedBuildFeedbackSink = realtimeBuildFeedbackSink;
			engine.progressMonitor = realtimeBuildFeedbackSink.ProgressMonitor;
			try {
				engine.rootNode = engine.CreateBuildGraph(project);
			} catch (CyclicDependencyException ex) {
				if (ex.Project1 != null && ex.Project2 != null)
					engine.results.Add(new BuildError(null, "Cyclic dependency between " + ex.Project1.Name + " and " + ex.Project2.Name));
				else
					engine.results.Add(new BuildError(null, "Cyclic dependency"));
				engine.results.Result = BuildResultCode.BuildFileError;
				engine.ReportDone();
				return;
			}
			
			engine.workersToStart = options.ParallelProjectCount;
			if (engine.workersToStart < 1)
				engine.workersToStart = 1;
			
			engine.cancellationRegistration = engine.progressMonitor.CancellationToken.Register(engine.BuildCancelled);
			
			engine.ReportMessageLine("${res:MainWindow.CompilerMessages.BuildStarted}");
			engine.StartBuildProjects();
			engine.UpdateProgressTaskName();
		}
Example #43
0
		public BuildProjectBeforeExecute(IBuildable project) : base(project)
		{
		}
			public Wrapper(IBuildable wrapped, WrapperFactory factory)
			{
				this.wrapped = wrapped;
				this.factory = factory;
			}
			public DummyBuildable(IBuildable wrappedBuildable)
			{
				this.wrappedBuildable = wrappedBuildable;
			}
Example #46
0
 public void QueueBuild(IBuildable build)
 {
     throw new NotImplementedException();
 }
Example #47
0
		public BuildEventArgs(IBuildable buildable, BuildOptions options)
			: this(buildable, options, null)
		{
		}
Example #48
0
		public BuildProject(IBuildable targetProject)
		{
			this.targetProject = targetProject;
		}
Example #49
0
        private void ProcessBuild(IBuildable build)
        {
            //http://www.odewit.net/ArticleContent.aspx?id=MsBuildApi4&format=html

            var assemblyExecutionPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            var logFilePath = assemblyExecutionPath.Remove(assemblyExecutionPath.LastIndexOf("\\") + 1) + "build.log";
            var sln = Path.GetFullPath(build.SolutionDirectory.FullName);
            var OutputHeaderRow = new List<string>();
            var OutputItemRow = new List<string>();

            try
            {
                var logger = new FileLogger();
                var pc = new ProjectCollection();
                var GlobalProperty = new Dictionary<string, string>();

                logger.Parameters = @"logfile=" + logFilePath;
                GlobalProperty.Add("Configuration", "Release");
                GlobalProperty.Add("Platform", "Any CPU");

                var buildRequest = new BuildRequestData(sln, GlobalProperty, null, new string[] { "Build" }, null);
                var bp = new BuildParameters(pc);

                bp.Loggers = new List<Microsoft.Build.Framework.ILogger> { logger }.AsEnumerable();

                //build solution

                var buildResult = BuildManager.DefaultBuildManager.Build(bp, buildRequest);

                pc.UnregisterAllLoggers();

                //read lines from log file having project build output details

                string[] solutionBuildOutputs = File.ReadAllLines(logFilePath);

                //write the result of solution build to html report

                OutputHeaderRow.Add("Artifact;Build Result");

                //split the contents of logger file to retrieve project build details

                string[] splitter = { "__________________________________________________" };

                string loggerOutput = File.ReadAllText(logFilePath);

                string[] projectResults = loggerOutput.Split(splitter, StringSplitOptions.None);

                foreach (string projectBuildDetails in projectResults)

                {

                    if (projectBuildDetails.Contains("(default targets):"))

                    {

                        if (projectBuildDetails.Contains("Done building project \""))

                        {

                            //write the result of failed projects build to html report

                            string[] lines = projectBuildDetails.Split("\n".ToCharArray());

                            string buildFailedProjectName = lines.Where(x => x.Contains("Done building project \"")).FirstOrDefault();

                            buildFailedProjectName = buildFailedProjectName.Replace("Done building project ", string.Empty).Trim();

                            buildFailedProjectName = buildFailedProjectName.Replace("\"", string.Empty);

                            buildFailedProjectName = buildFailedProjectName.Replace(" -- FAILED.", string.Empty);

                            OutputItemRow.Add(buildFailedProjectName + ";FAILED");

                        }

                        else

                        {

                            //write the result of successfully built projects to html report

                            string[] lines = projectBuildDetails.Split("\n".ToCharArray());

                            string buildSuccededProjectName = lines.Where(x => x.Contains(" (default targets):")).FirstOrDefault().Replace("\" (default targets):", "");

                            string finalProjectName = buildSuccededProjectName.Substring(buildSuccededProjectName.LastIndexOf("\\") + 1);

                            OutputItemRow.Add(finalProjectName + ";SUCCEEDED");

                        }

                    }

                }

            }

            catch (Exception ex)

            {

                throw ex;

            }

            finally

            {

                //delete log file

                File.Delete(logFilePath);

            }
        }
Example #50
0
 public void QueueBuild(IBuildable build)
 {
     _queuedBuilds.Enqueue(build);
 }
			public Wrapper(IBuildable wrapped, WrapperFactory factory)
			{
				this.wrapped = wrapped;
				this.factory = factory;
				this.service = factory.Service;
			}
Example #52
0
		BuildNode CreateBuildGraph(IBuildable project)
		{
			BuildNode node;
			if (nodeDict.TryGetValue(project, out node)) {
				return node;
			}
			node = new BuildNode(this, project);
			nodeDict[project] = node;
			InitializeProjectOptions(node);
			InitializeDependencies(node);
			
			node.nodeComplete = true;
			return node;
		}
Example #53
0
			public CyclicDependencyException(IBuildable project1, IBuildable project2)
			{
				this.Project1 = project1;
				this.Project2 = project2;
			}
Example #54
0
		public RebuildProject(IBuildable targetProject) : base(targetProject) {}
			public IBuildable GetWrapper(IBuildable wrapped)
			{
				IBuildable b;
				lock (dict) {
					if (!dict.TryGetValue(wrapped, out b))
						b = dict[wrapped] = new Wrapper(wrapped, this);
				}
				return b;
			}
Example #56
0
			public void Done(IBuildable buildable, BuildOptions options, BuildResults results)
			{
				WorkbenchSingleton.SafeThreadAsyncCall(
					delegate {
						guiBuildCancellation = null;
						if (guiBuildTrackedFeature != null) {
							guiBuildTrackedFeature.EndTracking();
							guiBuildTrackedFeature = null;
						}
						string message;
						if (results.Result == BuildResultCode.Cancelled) {
							message = "${res:MainWindow.CompilerMessages.BuildCancelled}";
						} else {
							if (results.Result == BuildResultCode.Success)
								message = "${res:MainWindow.CompilerMessages.BuildFinished}";
							else
								message = "${res:MainWindow.CompilerMessages.BuildFailed}";
							
							if (results.ErrorCount > 0)
								message += " " + results.ErrorCount + " error(s)";
							if (results.WarningCount > 0)
								message += " " + results.WarningCount + " warning(s)";
						}
						statusBarService.SetMessage(message);
						ProjectService.RaiseEventBuildFinished(new BuildEventArgs(buildable, options, results));
					});
			}
		static IProject GetProjectFromBuildable(IBuildable b)
		{
			while (b is Wrapper)
				b = ((Wrapper)b).wrapped;
			return b as IProject;
		}
		public BeforeBuildCustomToolProjectItems(IBuildable buildable)
		{
			this.buildable = buildable;
		}
Example #59
0
		public BuildEventArgs(IBuildable buildable, BuildOptions options, BuildResults results)
		{
			if (buildable == null)
				throw new ArgumentNullException("buildable");
			if (options == null)
				throw new ArgumentNullException("options");
			this.Buildable = buildable;
			this.Options = options;
			this.Results = results;
		}
Example #60
0
			public void Done(IBuildable buildable, BuildOptions options, BuildResults results)
			{
				WorkbenchSingleton.SafeThreadAsyncCall(
					delegate {
						guiBuildProgressMonitor = null;
						GuiBuildFinished.RaiseEvent(null, new BuildEventArgs(buildable, options, results));
					});
			}