Пример #1
0
        public static bool Install(WrenchProject proj, BuildServices bs, bool backwards)
        {
            IResultInstaller iri;
            Result           res;

            if (GetInstallerAndResult(proj, bs, out iri, out res))
            {
                return(true);
            }

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

            try {
                bs.Logger.Log("operation.install", bs.FullName);
                if (backwards)
                {
                    DoBeforeUninstall(proj, bs);
                }
                else
                {
                    DoBeforeInstall(proj, bs);
                }
                return(iri.InstallResult(res, backwards, bs.Context));
            } catch (Exception e) {
                bs.Logger.Error(3012, "Unhandled exception in install routine for " + res.ToString(), e.ToString());
                return(true);
            }
        }
Пример #2
0
		public static bool GetInstaller (WrenchProject proj, BuildServices bs, 
						 out IResultInstaller ret) {
			ret = null;

			// potential recursion!
			Result installer;
			if (bs.GetTag (proj.Graph.GetTagId ("install"), out installer))
				return true;

			if (installer == null)
				return false;

			// use install = false to mean "don't install"

			if (installer is MBBool) {
				if (((MBBool) installer).Value) {
					bs.Logger.Error (2019, "To install this target, set its installer tag to an Installer.", null);
					return true;
				}

				return false;
			}

			ret = installer as IResultInstaller;

			if (ret == null) {
				bs.Logger.Error (2016, "This target's \"install\" tag does not support installation", installer.ToString ());
				return true;
			}

			return false;
		}
Пример #3
0
 public static bool Uncache(WrenchProject proj, BuildServices bs)
 {
     bs.Logger.Log("operation.uncache", bs.FullName);
     DoBeforeUncache(proj, bs);
     bs.UncacheValue();
     return(false);
 }
Пример #4
0
        static void DoBeforeSkip(WrenchProject proj, BuildServices bs)
        {
            if (BeforeSkip == null)
            {
                return;
            }

            BeforeSkip(proj, bs);
        }
Пример #5
0
        static void DoBeforeClean(WrenchProject proj, BuildServices bs)
        {
            if (BeforeClean == null)
            {
                return;
            }

            BeforeClean(proj, bs);
        }
Пример #6
0
        static void DoBeforeUncache(WrenchProject proj, BuildServices bs)
        {
            if (BeforeUncache == null)
            {
                return;
            }

            BeforeUncache(proj, bs);
        }
Пример #7
0
        static void DoBeforeUninstall(WrenchProject proj, BuildServices bs)
        {
            if (BeforeUninstall == null)
            {
                return;
            }

            BeforeUninstall(proj, bs);
        }
Пример #8
0
        static void DoBeforeDistribute(WrenchProject proj, BuildServices bs)
        {
            if (BeforeDistribute == null)
            {
                return;
            }

            BeforeDistribute(proj, bs);
        }
Пример #9
0
		public static BuiltItem BuildValue (WrenchProject proj, BuildServices bs) {
			BuiltItem bi;

			if (bs.TryValueRecovery (out bi))
				return BuiltItem.Null;

			if (bi.IsValid) {
				DoBeforeSkip (proj, bs);
				return bi;
			}

			return BuildValueUnconditional (proj, bs);
		}
Пример #10
0
		public static bool Clean (WrenchProject proj, BuildServices bs) {
			BuiltItem bi = bs.GetRawCachedValue ();

			if (!bi.IsValid)
				return false;

			bs.Logger.Log ("operation.clean", bs.FullName);
			if (bi.Result.Clean (bs.Context))
				// FIXME: rename to After
				DoBeforeClean (proj, bs);

			bs.UncacheValue ();
			return false;
		}
Пример #11
0
            public BuiltItem[] EvaluateTargets(int[] targets)
            {
                BuiltItem[] bis = new BuiltItem[targets.Length];

                for (int i = 0; i < targets.Length; i++)
                {
                    //proj.Log.PushLocation (targets[i]);
                    BuildServices bs = proj.GetTargetServices(targets[i]);
                    //proj.Log.PopLocation ();

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

                    switch (proj.GetTargetState(targets[i]))
                    {
                    case WrenchProject.TargetState.BuiltOk:
                        //Console.WriteLine ("EVAL {0}: from cache", targets[i]);
                        bis[i] = bs.GetRawCachedValue();
                        break;

                    case WrenchProject.TargetState.BuiltError:
                        //Console.WriteLine ("EVAL {0}: errored", targets[i]);
                        return(null);

                    case WrenchProject.TargetState.Building:
                        //Console.WriteLine ("EVAL {0}: recursed", targets[i]);
                        bs.Logger.Error(2048, "Recursion in build; this target depends on " + targets[i] +
                                        " which is currently being built", null);
                        return(null);

                    default:
                        //Console.WriteLine ("EVAL {0}: build it", targets[i]);
                        // State unknown. Load from cache if possible, otherwise build.

                        proj.Log.PushLocation(bs.FullName);
                        bis[i] = WrenchOperations.BuildValue(proj, bs);
                        proj.Log.PopLocation();

                        if (!bis[i].IsValid)
                        {
                            return(null);
                        }
                        break;
                    }
                }

                return(bis);
            }
Пример #12
0
        public static BuiltItem BuildValue(WrenchProject proj, BuildServices bs)
        {
            BuiltItem bi;

            if (bs.TryValueRecovery(out bi))
            {
                return(BuiltItem.Null);
            }

            if (bi.IsValid)
            {
                DoBeforeSkip(proj, bs);
                return(bi);
            }

            return(BuildValueUnconditional(proj, bs));
        }
Пример #13
0
        public static bool Distribute(WrenchProject proj, BuildServices bs)
        {
            Result res = bs.GetValue().Result;

            if (res == null)
            {
                return(true);
            }

            bs.Logger.Log("operation.distribute", bs.FullName);
            if (res.DistClone(bs.Context))
            {
                // rename this event
                DoBeforeDistribute(proj, bs);
            }

            return(false);
        }
Пример #14
0
        public static bool Clean(WrenchProject proj, BuildServices bs)
        {
            BuiltItem bi = bs.GetRawCachedValue();

            if (!bi.IsValid)
            {
                return(false);
            }

            bs.Logger.Log("operation.clean", bs.FullName);
            if (bi.Result.Clean(bs.Context))
            {
                // FIXME: rename to After
                DoBeforeClean(proj, bs);
            }

            bs.UncacheValue();
            return(false);
        }
Пример #15
0
        public static bool GetInstaller(WrenchProject proj, BuildServices bs,
                                        out IResultInstaller ret)
        {
            ret = null;

            // potential recursion!
            Result installer;

            if (bs.GetTag(proj.Graph.GetTagId("install"), out installer))
            {
                return(true);
            }

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

            // use install = false to mean "don't install"

            if (installer is MBBool)
            {
                if (((MBBool)installer).Value)
                {
                    bs.Logger.Error(2019, "To install this target, set its installer tag to an Installer.", null);
                    return(true);
                }

                return(false);
            }

            ret = installer as IResultInstaller;

            if (ret == null)
            {
                bs.Logger.Error(2016, "This target's \"install\" tag does not support installation", installer.ToString());
                return(true);
            }

            return(false);
        }
Пример #16
0
        public static bool GetInstallerAndResult(WrenchProject proj,
                                                 BuildServices bs, out IResultInstaller iri,
                                                 out Result obj)
        {
            obj = null;

            if (GetInstaller(proj, bs, out iri))
            {
                return(true);
            }

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

            obj = bs.GetValue().Result;

            if (obj == null)
            {
                // error already reported
                return(true);
            }

            bs.Logger.PushLocation(bs.FullName);
            obj = CompositeResult.FindCompatible(obj, iri.OtherType);
            bs.Logger.PopLocation();

            if (obj == null)
            {
                bs.Logger.Error(2031, "Trying to install result with incompatible installer",
                                iri.OtherType.ToString());
                return(true);
            }

            return(false);
        }
Пример #17
0
 public static BuiltItem BuildValueUnconditional(WrenchProject proj, BuildServices bs)
 {
     bs.Logger.Log("operation.build", bs.FullName);
     DoBeforeBuild(proj, bs);
     return(bs.BuildValue());
 }
Пример #18
0
	bool BeforeInstallEvent (WrenchProject proj, BuildServices bs) {
		Console.WriteLine (" + {0}", bs.FullName);
		numinstalled++;
		return false;
	}
Пример #19
0
		public static bool Install (WrenchProject proj, BuildServices bs, bool backwards) {
			IResultInstaller iri;
			Result res;

			if (GetInstallerAndResult (proj, bs, out iri, out res))
				return true;

			if (iri == null)
				return false;

			try {
				bs.Logger.Log ("operation.install", bs.FullName);
				if (backwards)
					DoBeforeUninstall (proj, bs);
				else
					DoBeforeInstall (proj, bs);
				return iri.InstallResult (res, backwards, bs.Context);
			} catch (Exception e) {
				bs.Logger.Error (3012, "Unhandled exception in install routine for " + res.ToString (), e.ToString ());
				return true;
			}
		}
Пример #20
0
 public static bool Build(WrenchProject proj, BuildServices bs)
 {
     return(!BuildValue(proj, bs).IsValid);
 }
Пример #21
0
		public static BuiltItem BuildValueUnconditional (WrenchProject proj, BuildServices bs) {
			bs.Logger.Log ("operation.build", bs.FullName);
			DoBeforeBuild (proj, bs);
			return bs.BuildValue ();
		}
Пример #22
0
	bool BeforeSkipEvent (WrenchProject proj, BuildServices bs) {
		numskipped++;
		return false;
	}
Пример #23
0
		static void DoBeforeClean (WrenchProject proj, BuildServices bs) {
			if (BeforeClean == null)
				return;

			BeforeClean (proj, bs);
		}
Пример #24
0
		public static bool Build (WrenchProject proj, BuildServices bs) {
			return (!BuildValue (proj, bs).IsValid);
		}
Пример #25
0
		static void DoBeforeSkip (WrenchProject proj, BuildServices bs) {
			if (BeforeSkip == null)
				return;

			BeforeSkip (proj, bs);
		}
Пример #26
0
		static void DoBeforeDistribute (WrenchProject proj, BuildServices bs) {
			if (BeforeDistribute == null)
				return;

			BeforeDistribute (proj, bs);
		}
Пример #27
0
		static void DoBeforeUninstall (WrenchProject proj, BuildServices bs) {
			if (BeforeUninstall == null)
				return;

			BeforeUninstall (proj, bs);
		}
Пример #28
0
		static void DoBeforeUncache (WrenchProject proj, BuildServices bs) {
			if (BeforeUncache == null)
				return;

			BeforeUncache (proj, bs);
		}
Пример #29
0
		public static bool Distribute (WrenchProject proj, BuildServices bs) {
			Result res = bs.GetValue ().Result;

			if (res == null)
				return true;

			bs.Logger.Log ("operation.distribute", bs.FullName);
			if (res.DistClone (bs.Context))
				// rename this event
				DoBeforeDistribute (proj, bs);
				
			return false;
		}
Пример #30
0
	// Config

	bool ConfigOperation (WrenchProject proj, BuildServices bs) {
		Result res = bs.GetValue ().Result;

		if (res == null)
			return true;

		// prompt
		Result rprompt;
		if (bs.GetTag ("prompt", out rprompt))
			return true;

		string prompt;

		if (rprompt == null) {
			log.PushLocation (bs.FullName);
			log.Warning (2017, "This configurable option does not have a \'prompt\' tag.", null);
			log.PopLocation ();
			prompt = String.Format ("Set value of {0}:", bs.FullName);
		} else {
			// TODO: i18n
			prompt = ((MBString) rprompt).Value;
		}

		if (res is MBBool)
			DoConfigBool (prompt, (MBBool) res);
		else if (res is MBString)
			DoConfigString (prompt, (MBString) res);
		else if (res is MBDirectory)
			DoConfigDirectory (prompt, (MBDirectory) res);
		else {
			string s = String.Format ("Current value is {0}", res);
			log.PushLocation (bs.FullName);
			log.Error (2018, "Don't know how to configure this option.", s);
			log.PopLocation ();
			return true;
		}

		bs.FixValue (res);
		return false;
	}
Пример #31
0
 public static bool Install(WrenchProject proj, BuildServices bs)
 {
     return(Install(proj, bs, false));
 }
Пример #32
0
	bool DoRemoteInstall (WrenchProject proj, BuildServices bs) {
		IResultInstaller iri;
		Result res;

		if (WrenchOperations.GetInstallerAndResult (proj, bs, out iri, out res))
			return true;

		if (iri == null)
			return false;
		
		bs.Logger.Log ("operation.install", bs.FullName);
		Console.WriteLine (" + {0}", bs.FullName);

		return install_svc.Install ((Result) iri, res, install_is_uninstall, 
					    new BuildContextProxy (bs.Context));
	}
Пример #33
0
	bool BeforeCleanEvent (WrenchProject proj, BuildServices bs) {
		Console.WriteLine (" + {0}", bs.FullName);
		numcleaned++;
		return false;
	}
Пример #34
0
	Widget MakeStringItem (BuildServices services, string prompt, MBString res) {
		HBox box = new HBox ();
		box.Show ();

		Label label = new Label (prompt);
		label.Show ();
		label.Xalign = 1.0F;

		Entry entry = new Entry (res.Value);
		entry.Show ();
		entry.Data[result_key] = res;
		entry.Data[services_key] = services;
		entry.Changed += new EventHandler (OnStringChanged);

		box.PackStart (label, true, true, 2);
		box.PackStart (entry, false, true, 2);
		return box;
	}
Пример #35
0
	// WrenchOperations events

	bool BeforeBuildEvent (WrenchProject proj, BuildServices bs) {
		Console.WriteLine ("Building `{0}\' ...", bs.FullName);
		numbuilt++;
		return false;
	}
Пример #36
0
	bool DescribeInstall (WrenchProject proj, BuildServices bs) {
		IResultInstaller iri;
		Result res;

		if (WrenchOperations.GetInstallerAndResult (proj, bs, out iri, out res))
			return true;

		if (iri == null)
			return false;
		
		Console.WriteLine (" + {0}", iri.DescribeAction (res, bs.Context));
		return false;
	}
Пример #37
0
	bool ExportAsXml (WrenchProject proj, BuildServices bs) {
		Result r = WrenchOperations.BuildValue (proj, bs).Result;
		if (r == null)
			return true;

		r.ExportXml (export_writer, bs.FullName);
		return false;
	}
Пример #38
0
		public static bool Uninstall (WrenchProject proj, BuildServices bs) {
			return Install (proj, bs, true);
		}
Пример #39
0
 public static bool ForceBuild(WrenchProject proj, BuildServices bs)
 {
     return(!BuildValueUnconditional(proj, bs).IsValid);
 }
Пример #40
0
	bool BeforeDistributeEvent (WrenchProject proj, BuildServices bs) {
		Console.WriteLine (" + {0}", bs.FullName);
		numdisted++;
		return false;
	}
Пример #41
0
		public static bool ForceBuild (WrenchProject proj, BuildServices bs) {
			return (!BuildValueUnconditional (proj, bs).IsValid);
		}
Пример #42
0
		public static bool GetInstallerAndResult (WrenchProject proj,
							  BuildServices bs, out IResultInstaller iri,
							  out Result obj) {
			obj = null;

			if (GetInstaller (proj, bs, out iri))
				return true;

			if (iri == null)
				return false;

			obj = bs.GetValue ().Result;

			if (obj == null)
				// error already reported
				return true;

			bs.Logger.PushLocation (bs.FullName);
			obj = CompositeResult.FindCompatible (obj, iri.OtherType);
			bs.Logger.PopLocation ();

			if (obj == null) {
				bs.Logger.Error (2031, "Trying to install result with incompatible installer", 
					      iri.OtherType.ToString ());
				return true;
			}

			return false;
		}
Пример #43
0
 public static bool Uninstall(WrenchProject proj, BuildServices bs)
 {
     return(Install(proj, bs, true));
 }
Пример #44
0
		public static bool Uncache (WrenchProject proj, BuildServices bs) {
			bs.Logger.Log ("operation.uncache", bs.FullName);
			DoBeforeUncache (proj, bs);
			bs.UncacheValue ();
			return false;
		}
Пример #45
0
	Widget MakeBoolItem (BuildServices services, string prompt, MBBool res) {
		CheckButton cb = new CheckButton (prompt);
		cb.Active = res.Value;
		cb.Data[result_key] = res;
		cb.Data[services_key] = services;
		cb.Toggled += new EventHandler (OnBoolToggled);

		return cb;
	}
Пример #46
0
		public static bool Install (WrenchProject proj, BuildServices bs) {
			return Install (proj, bs, false);
		}
Пример #47
0
	bool LoadConfigItem (WrenchProject proj, BuildServices bs) {
		string prompt, group;
		string target = bs.FullName;
		Result res = bs.GetValue ().Result;

		if (res == null)
			return true;

		Result tag;
		if (bs.GetTag ("prompt", out tag))
			return true;

		MBString rstr = tag as MBString;

		if (rstr == null) {
			// FIXME
			Console.Error.WriteLine ("Configurable option " + target + " does not have a string \'prompt\' tag.");
			prompt = target;
		} else {
			// TODO: i18n
			prompt = rstr.Value;
		}

		if (bs.GetTag ("config_group", out tag))
			return true;

		rstr = tag as MBString;

		if (rstr == null)
			group = DefaultGroupName;
		else {
			// TODO: i18n
			group = rstr.Value;
		}

		Widget widget = null;

		if (res is MBBool)
			widget = MakeBoolItem (bs, prompt, (MBBool) res);
		else if (res is MBString)
			widget = MakeStringItem (bs, prompt, (MBString) res);
		else {
			// FIXME
			Console.Error.WriteLine ("Don't know how to configure the option {0}.", target);
			return true;
		}

		AddGuiItem (group, widget);
		return false;
	}
Пример #48
0
	bool PrintOperation (WrenchProject proj, BuildServices bs) {
		Console.WriteLine ("{0}", bs.FullName);
		return false;
	}