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); } }
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; }
public static bool Uncache(WrenchProject proj, BuildServices bs) { bs.Logger.Log("operation.uncache", bs.FullName); DoBeforeUncache(proj, bs); bs.UncacheValue(); return(false); }
static void DoBeforeSkip(WrenchProject proj, BuildServices bs) { if (BeforeSkip == null) { return; } BeforeSkip(proj, bs); }
static void DoBeforeClean(WrenchProject proj, BuildServices bs) { if (BeforeClean == null) { return; } BeforeClean(proj, bs); }
static void DoBeforeUncache(WrenchProject proj, BuildServices bs) { if (BeforeUncache == null) { return; } BeforeUncache(proj, bs); }
static void DoBeforeUninstall(WrenchProject proj, BuildServices bs) { if (BeforeUninstall == null) { return; } BeforeUninstall(proj, bs); }
static void DoBeforeDistribute(WrenchProject proj, BuildServices bs) { if (BeforeDistribute == null) { return; } BeforeDistribute(proj, bs); }
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); }
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; }
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); }
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)); }
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); }
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); }
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); }
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); }
public static BuiltItem BuildValueUnconditional(WrenchProject proj, BuildServices bs) { bs.Logger.Log("operation.build", bs.FullName); DoBeforeBuild(proj, bs); return(bs.BuildValue()); }
bool BeforeInstallEvent (WrenchProject proj, BuildServices bs) { Console.WriteLine (" + {0}", bs.FullName); numinstalled++; return false; }
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; } }
public static bool Build(WrenchProject proj, BuildServices bs) { return(!BuildValue(proj, bs).IsValid); }
public static BuiltItem BuildValueUnconditional (WrenchProject proj, BuildServices bs) { bs.Logger.Log ("operation.build", bs.FullName); DoBeforeBuild (proj, bs); return bs.BuildValue (); }
bool BeforeSkipEvent (WrenchProject proj, BuildServices bs) { numskipped++; return false; }
static void DoBeforeClean (WrenchProject proj, BuildServices bs) { if (BeforeClean == null) return; BeforeClean (proj, bs); }
public static bool Build (WrenchProject proj, BuildServices bs) { return (!BuildValue (proj, bs).IsValid); }
static void DoBeforeSkip (WrenchProject proj, BuildServices bs) { if (BeforeSkip == null) return; BeforeSkip (proj, bs); }
static void DoBeforeDistribute (WrenchProject proj, BuildServices bs) { if (BeforeDistribute == null) return; BeforeDistribute (proj, bs); }
static void DoBeforeUninstall (WrenchProject proj, BuildServices bs) { if (BeforeUninstall == null) return; BeforeUninstall (proj, bs); }
static void DoBeforeUncache (WrenchProject proj, BuildServices bs) { if (BeforeUncache == null) return; BeforeUncache (proj, bs); }
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; }
// 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; }
public static bool Install(WrenchProject proj, BuildServices bs) { return(Install(proj, bs, false)); }
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)); }
bool BeforeCleanEvent (WrenchProject proj, BuildServices bs) { Console.WriteLine (" + {0}", bs.FullName); numcleaned++; return false; }
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; }
// WrenchOperations events bool BeforeBuildEvent (WrenchProject proj, BuildServices bs) { Console.WriteLine ("Building `{0}\' ...", bs.FullName); numbuilt++; return false; }
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; }
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; }
public static bool Uninstall (WrenchProject proj, BuildServices bs) { return Install (proj, bs, true); }
public static bool ForceBuild(WrenchProject proj, BuildServices bs) { return(!BuildValueUnconditional(proj, bs).IsValid); }
bool BeforeDistributeEvent (WrenchProject proj, BuildServices bs) { Console.WriteLine (" + {0}", bs.FullName); numdisted++; return false; }
public static bool ForceBuild (WrenchProject proj, BuildServices bs) { return (!BuildValueUnconditional (proj, bs).IsValid); }
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; }
public static bool Uninstall(WrenchProject proj, BuildServices bs) { return(Install(proj, bs, true)); }
public static bool Uncache (WrenchProject proj, BuildServices bs) { bs.Logger.Log ("operation.uncache", bs.FullName); DoBeforeUncache (proj, bs); bs.UncacheValue (); return false; }
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; }
public static bool Install (WrenchProject proj, BuildServices bs) { return Install (proj, bs, false); }
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; }
bool PrintOperation (WrenchProject proj, BuildServices bs) { Console.WriteLine ("{0}", bs.FullName); return false; }