Author: peterw
Date: 2005-10-10 19:08:43 -0400 (Mon, 10 Oct 2005)
New Revision: 51537
Added:
trunk/mbuild/Mono.Build/Mono.Build/BuiltItem.cs
trunk/mbuild/Mono.Build/Mono.Build/StrUtils.cs
Modified:
trunk/mbuild/ChangeLog
trunk/mbuild/Monkeywrench/ChangeLog
trunk/mbuild/Monkeywrench/Monkeywrench/BuildServices.cs
trunk/mbuild/Monkeywrench/Monkeywrench/FileStateTable.cs
trunk/mbuild/Monkeywrench/Monkeywrench/IProviderPersistence.cs
trunk/mbuild/Monkeywrench/Monkeywrench/StateTable.cs
trunk/mbuild/Monkeywrench/Monkeywrench/TargetBuilder.cs
trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs
trunk/mbuild/Monkeywrench/Monkeywrench/WrenchProject.cs
trunk/mbuild/Mono.Build.dll.sources
trunk/mbuild/Mono.Build/ChangeLog
trunk/mbuild/Mono.Build/Mono.Build.Bundling/BundleManager.cs
trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs
trunk/mbuild/Mono.Build/Mono.Build/BuildFingerprint.cs
trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs
trunk/mbuild/Mono.Build/Mono.Build/IBuildManager.cs
trunk/mbuild/Mono.Build/Mono.Build/MBFile.cs
trunk/mbuild/Mono.Build/Mono.Build/TagTargetBase.cs
trunk/mbuild/mb-bundledoc/ChangeLog
trunk/mbuild/mb-bundledoc/synchronizers.cs
trunk/mbuild/mb-gtkconfig/ChangeLog
trunk/mbuild/mb-gtkconfig/mb-gtkconfig.cs
trunk/mbuild/mb-import/mb-import.cs
trunk/mbuild/mbuild/ChangeLog
trunk/mbuild/mbuild/mbuild.cs
Log:
2005-10-10 Peter Williams <[EMAIL PROTECTED]>
Fix build fingerprints. Add a BuiltItem struct, which passes
around a (Result, result fingerprint, build fingerprint)
tuple. This way an ArgCollector gets correct, up-to-date
fingerprints of its args. And these fingerprints are generated
during the build/cache recovery of the dependent results, so
we can use cached fingerprints sanely to avoid recomputes.
* Mono.Build/BuiltItem.cs: New file. Small struct that holds
a (Result, Result fingerprint, build fingerprint) tuple.
* Mono.Build/BuildFingerprint.cs: Don't inherit from
CompositeFingerprint, because we have nonstandard semantics
that don't map well to it.
* Mono.Build/ArgCollector.cs: No longer IFingerprintable.
(info): Make this a sorted list so our fingerprint ordering
is consistent.
(ArgData): Also keep a list of result fingerprints.
(AddArg): StrUtils.StartsWith.
(AddToAD): Take a fingerprint arg too with the Result. Use it
to cache the FP in the ArgData.
(AddNamed): Rename from AddInternal to reflect better the
distinction between this and Add().
(Add*): Add Fingerprint args and overloads that replicate the
original signatures by passing null for the FP.
(FinalizeOneArg): Use BuiltItems. Pass the FP in to Add* so
that we don't need to recalc it.
(FinalizeArgs): Same.
(CopyFingerprintData): Based on old GetFingerprint. Use the stored
fingerprints instead of trying to recalculate the old ones with
cached data. Use SortedLists and fingerprint values to make
the fingerprint value more well-behaved: invariant to reorderings
in unordered args; invariant to reorderings of arg definitions;
variant on reorderings of ordered args.
* Mono.Build/CompositeFingerprint.cs (Calculate): Make this
static with an argument so other code (BuildFingerprint) can
use the function.
* Mono.Build/TagTargetBase.cs (GetTagValue): Use BuiltItems,
not Results.
* Mono.Build/IBuildManager.cs: Return BuiltItem[] instead of
Result[].
* Mono.Build/MBFile.cs (GetFingerprint): Add some commented out
debugging code; add a using() line for better resource management.
* Mono.Build/StrUtils.cs: New file, copied from Mono's
System.Web. Probably need to go through and fix string compares
too; or just replace string target names with ID numbers.
2005-10-10 Peter Williams <[EMAIL PROTECTED]>
The other half of fixing build fingerprints. Update the
Monkeywrench code to work with BuiltItems and handle their
fingerprints correctly.
* Monkeywrench/IProviderPersistence.cs: Update to use
BuiltItems instead of three get/set pairs for each of {result,
build fp, result fp}.
* Monkeywrench/BuildServices.cs (TryValueRecovery): Renamed
from GetCachedValue. Use BuiltItems; add the logic to check
the validity of the cached value (moved from ProviderInfo).
(BuildValue): Use BuiltItems, not Results.
(GetValue): Same
(CacheValue): Same
(FixValue): Same
(CheckBuildReadiness): Don't need old_build_fp anymore; new
ctor for BuildFingerprint.
* Monkeywrench/WrenchOperations.cs (BuildValue): Work with
BuiltItems instead of results.
* Monkeywrench/StateTable.cs: Rework. Instead of having accessors
for {result, result fp, build fp} separately, just load and save
BuiltItems.
* Monkeywrench/WrenchProject.cs (ProviderInfo): Take the result
caching logic out from here. Just leave wrappers for uncaching
and fixing the new BuiltItem structs.
(operate_tree): StrUtils.StartsWith.
* Monkeywrench/TargetBuilder.cs (fixup_dep): StrUtils.StartsWith
And a few other subdirs.
Modified: trunk/mbuild/ChangeLog
===================================================================
--- trunk/mbuild/ChangeLog 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/ChangeLog 2005-10-10 23:08:43 UTC (rev 51537)
@@ -1,3 +1,9 @@
+2005-10-10 Peter Williams <[EMAIL PROTECTED]>
+
+ * mb-import/mb-import.cs (EvaluateTargets): Result -> BuiltItem.
+
+ * Mono.Build.dll.sources: New files: BuiltItem.cs, StrUtils.cs
+
2005-09-24 Peter Williams <[EMAIL PROTECTED]>
* Tools.Monodoc.bundle: Finally update for the changes to monodoc. Call
'mdassembler'
Modified: trunk/mbuild/Monkeywrench/ChangeLog
===================================================================
--- trunk/mbuild/Monkeywrench/ChangeLog 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/ChangeLog 2005-10-10 23:08:43 UTC (rev 51537)
@@ -1,3 +1,37 @@
+2005-10-10 Peter Williams <[EMAIL PROTECTED]>
+
+ The other half of fixing build fingerprints. Update the
+ Monkeywrench code to work with BuiltItems and handle their
+ fingerprints correctly.
+
+ * Monkeywrench/IProviderPersistence.cs: Update to use
+ BuiltItems instead of three get/set pairs for each of {result,
+ build fp, result fp}.
+
+ * Monkeywrench/BuildServices.cs (TryValueRecovery): Renamed
+ from GetCachedValue. Use BuiltItems; add the logic to check
+ the validity of the cached value (moved from ProviderInfo).
+ (BuildValue): Use BuiltItems, not Results.
+ (GetValue): Same
+ (CacheValue): Same
+ (FixValue): Same
+ (CheckBuildReadiness): Don't need old_build_fp anymore; new
+ ctor for BuildFingerprint.
+
+ * Monkeywrench/WrenchOperations.cs (BuildValue): Work with
+ BuiltItems instead of results.
+
+ * Monkeywrench/StateTable.cs: Rework. Instead of having accessors
+ for {result, result fp, build fp} separately, just load and save
+ BuiltItems.
+
+ * Monkeywrench/WrenchProject.cs (ProviderInfo): Take the result
+ caching logic out from here. Just leave wrappers for uncaching
+ and fixing the new BuiltItem structs.
+ (operate_tree): StrUtils.StartsWith.
+
+ * Monkeywrench/TargetBuilder.cs (fixup_dep): StrUtils.StartsWith
+
2005-09-24 Peter Williams <[EMAIL PROTECTED]>
* Monkeywrench/WrenchProject.cs (GetTargetState): New function.
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/BuildServices.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/BuildServices.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/BuildServices.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -22,8 +22,6 @@
ArgCollector ac;
Fingerprint cur_build_fp;
- Fingerprint old_result_fp;
- Fingerprint old_build_fp;
private BuildServices () {}
@@ -131,95 +129,134 @@
// Value getting / setting
- public bool GetCachedValue (out Result val) {
+ public bool TryValueRecovery (out BuiltItem val) {
// Need to be able to distinguish between "not cached"
// and "error in checking build readiness" (~ "error
// evaluating deps")
- val = null;
+ val = BuiltItem.Null;
+ pi.log.PushLocation (target);
- if (CheckBuildReadiness ())
+ if (CheckBuildReadiness ()) {
+ pi.log.PopLocation ();
return true;
+ }
- val = pi.GetCachedValue (target, basename,
old_build_fp, cur_build_fp, out old_result_fp);
+ val = pi.pp.GetItem (basename);
- if (val != null)
- // We got it from the cache successfully we can
do so in the future
- proj.SetTargetState (target,
WrenchProject.TargetState.BuiltOk);
+ if (!val.IsValid)
+ goto done;
+
+ if (!val.Result.Check (pi.context)) {
+ pi.log.Log ("project.external_invalid",
basename);
+ pi.log.Warning (3008, "The cached result was
not valid; rebuilding.", val.Result.ToString ());
+ val = BuiltItem.Null;
+ goto done;
+ }
+ if (val.IsFixed)
+ goto done;
+
+ if (cur_build_fp != val.BuildPrint) {
+ val = BuiltItem.Null;
+ goto done;
+ }
+
+ // Update the fingerprint in case that's needed. This
can only
+ // happen with results stored external to the state
file (eg MBFiles);
+ // might want a flag on Results to indicate whether
they reference
+ // data outside the cache. Save the new FP ASAP so any
other references
+ // this catch any changes to the value (so build fp's
get updated
+ // and things depending on this result get rebuilt).
+
+ val.ResultPrint = val.Result.GetFingerprint
(pi.context, val.ResultPrint);
+ CacheValue (val);
+
+ // We got it from the cache successfully we can do so
in the future.
+
+ proj.SetTargetState (target,
WrenchProject.TargetState.BuiltOk);
+
+ done:
+ pi.log.PopLocation ();
return false;
}
- public Result GetRawCachedValue () {
- return pi.GetRawCachedValue (basename);
+ public BuiltItem GetRawCachedValue () {
+ return pi.pp.GetItem (basename);
}
- public Result BuildValue () {
+ public BuiltItem BuildValue () {
proj.SetTargetState (target,
WrenchProject.TargetState.Building);
if (CheckBuildReadiness ()) {
proj.SetTargetState (target,
WrenchProject.TargetState.BuiltError);
- return null;
+ return BuiltItem.Null;
}
pi.log.PushLocation (target);
pi.log.Log ("project.build", target);
- Result res;
+ BuiltItem res;
try {
- res = Rule.Build (Args, pi.context);
+ res.Result = Rule.Build (Args, pi.context);
} catch (Exception e) {
pi.log.Error (3009, "Unhandled exception during
build", e.ToString ());
UncacheValue ();
proj.SetTargetState (target,
WrenchProject.TargetState.BuiltError);
pi.log.PopLocation ();
- return null;
+ return BuiltItem.Null;
}
- if (res == null) {
+ if (res.Result == null) {
UncacheValue ();
proj.SetTargetState (target,
WrenchProject.TargetState.BuiltError);
pi.log.PopLocation ();
- return null;
+ return BuiltItem.Null;
}
- if (!res.Check (pi.context)) {
- pi.log.Error (3000, "Target fails check of
result after build", res.ToString ());
+ if (!res.Result.Check (pi.context)) {
+ pi.log.Error (3000, "Result fails check after
build", res.Result.ToString ());
UncacheValue ();
proj.SetTargetState (target,
WrenchProject.TargetState.BuiltError);
pi.log.PopLocation ();
- return null;
+ return BuiltItem.Null;
}
+ res.ResultPrint = res.Result.GetFingerprint
(pi.context, null);
+ res.BuildPrint = cur_build_fp;
+
CacheValue (res);
proj.SetTargetState (target,
WrenchProject.TargetState.BuiltOk);
pi.log.PopLocation ();
return res;
}
- public Result GetValue () {
- Result res;
+ // Unconditionally gets the value. If an unavoidable failure
happens,
+ // returns BuiltItem.Null.
- if (GetCachedValue (out res))
- return null;
+ public BuiltItem GetValue () {
+ BuiltItem res;
- if (res != null)
+ if (TryValueRecovery (out res))
+ return BuiltItem.Null;
+
+ if (res.IsValid)
return res;
return BuildValue ();
}
- public void CacheValue (Result res) {
- pi.CacheValue (basename, res, cur_build_fp,
old_result_fp);
+ public void CacheValue (BuiltItem res) {
+ pi.pp.SetItem (basename, res);
}
public void UncacheValue () {
pi.UncacheValue (basename);
}
- public void FixValue (Result res) {
- pi.FixValue (basename, res, old_result_fp);
+ public void FixValue (Result r) {
+ pi.FixValue (basename, r, null);
}
// Private implementation
@@ -266,9 +303,6 @@
// Error will have been reported
return true;
- if (old_build_fp == null)
- old_build_fp = pi.GetOldBuildFingerprint
(basename);
-
if (!Args.ArgsFinalized) {
if (manager == null)
// This condition is a bug, not a build
issue
@@ -279,7 +313,7 @@
}
if (cur_build_fp == null)
- cur_build_fp = new BuildFingerprint (Rule,
Args, pi.context, old_build_fp);
+ cur_build_fp = new BuildFingerprint (Rule,
Args, pi.context);
return false;
}
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/FileStateTable.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/FileStateTable.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/FileStateTable.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -17,9 +17,6 @@
FileStateTable () : base () {}
- //protected FileStateTable (SerializationInfo info,
StreamingContext context) :
- // base (info, context) {}
-
public static FileStateTable Load (string path, IWarningLogger
log) {
FileStateTable fst;
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/IProviderPersistence.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/IProviderPersistence.cs
2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/IProviderPersistence.cs
2005-10-10 23:08:43 UTC (rev 51537)
@@ -9,15 +9,8 @@
namespace Monkeywrench {
public interface IProviderPersistence : IDisposable {
-
- Fingerprint GetBuildFingerprint (string name);
- void SetBuildFingerprint (string name, Fingerprint fp);
-
- Fingerprint GetResultFingerprint (string name);
- void SetResultFingerprint (string name, Fingerprint fp);
-
- Result GetResult (string name);
- void SetResult (string name, Result result);
+ BuiltItem GetItem (string name);
+ void SetItem (string name, BuiltItem value);
}
}
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/StateTable.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/StateTable.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/StateTable.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -1,6 +1,6 @@
//
-// An IProviderPersistence implemented as a table of results that can
-// be looked up by their name and serialized
+// An backend for IProviderPersistence implementations: as a table of
+// results that can be looked up by their name and serialized
//
using System;
@@ -13,123 +13,49 @@
namespace Monkeywrench {
[Serializable]
- public class StateTable {
+ public class StateTable : IEnumerable {
- protected Hashtable results;
- protected Hashtable resultfps;
- protected Hashtable buildfps;
+ Hashtable items;
- // Constructzors
+ // .ctor
public StateTable () {
- results = new Hashtable ();
- resultfps = new Hashtable ();
- buildfps = new Hashtable ();
+ items = new Hashtable ();
}
- //protected StateTable (SerializationInfo info,
StreamingContext context) {
- // results = (Hashtable) info.GetValue ("res", typeof
(Hashtable));
- // buildfps = (Hashtable) info.GetValue ("buildfps",
typeof (Hashtable));
- //}
-
// Interface stuff
- //public virtual void GetObjectData (SerializationInfo info,
StreamingContext context) {
- // info.AddValue ("res", results);
- // info.AddValue ("buildfps", buildfps);
- //}
-
- public IEnumerator GetResultEnumerator () {
- return results.GetEnumerator ();
+ public IEnumerator GetEnumerator () {
+ return items.GetEnumerator ();
}
- public IEnumerator GetFPEnumerator () {
- return buildfps.GetEnumerator ();
- }
-
- public override string ToString () {
- StringBuilder sb = new StringBuilder (String.Format
("[{0}: R = [", GetType()));
- bool first = true;
-
- foreach (object o in results.Keys) {
- if (!first)
- sb.Append (", ");
-
- sb.Append ((string) o);
- sb.Append (" => ");
- sb.Append (results[o].ToString ());
- first = false;
- }
-
- sb.Append ("] D = [");
- first = true;
-
- foreach (object o in buildfps.Keys) {
- if (!first)
- sb.Append (", ");
-
- sb.Append ((string) o);
- sb.Append (" => ");
- sb.Append (buildfps[o].ToString ());
- first = false;
- }
-
- return sb.ToString ();
- }
-
// Members
- public Result this [string name] {
+ public BuiltItem this [string name] {
get {
- return GetResult (name);
+ return GetItem (name);
}
set {
- SetResult (name, value);
+ SetItem (name, value);
}
}
- public Result GetResult (string name) {
+ public BuiltItem GetItem (string name) {
if (name == null)
throw new ArgumentNullException ("Null argument
to StateTable.GetResult");
- return results[name] as Result;
+ if (!items.Contains (name))
+ return BuiltItem.Null;
+
+ return (BuiltItem) items[name];
}
- public void SetResult (string name, Result r) {
+ public void SetItem (string name, BuiltItem bi) {
if (name == null)
throw new ArgumentNullException ("Result with
null name in StateTable.AddResult");
- results[name] = r;
+ items[name] = bi;
}
-
- public Fingerprint GetResultFingerprint (string name) {
- if (name == null)
- throw new ArgumentNullException ("Null argument
to StateTable.GetResultFingerprint");
-
- return resultfps[name] as Fingerprint;
- }
-
- public void SetResultFingerprint (string name, Fingerprint fp) {
- if (name == null)
- throw new ArgumentNullException ("Null argument
to StateTable.AddResultFingerprint");
-
- resultfps[name] = fp;
- }
-
- public Fingerprint GetBuildFingerprint (string name) {
- if (name == null)
- throw new ArgumentNullException ("Null argument
to StateTable.GetBuildFingerprint");
-
- return buildfps[name] as Fingerprint;
- }
-
- public void SetBuildFingerprint (string name, Fingerprint fp) {
- if (name == null)
- throw new ArgumentNullException ("Null argument
to StateTable.AddBuildFingerprint");
-
- buildfps[name] = fp;
- }
-
}
}
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/TargetBuilder.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/TargetBuilder.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/TargetBuilder.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -150,7 +150,7 @@
if (dep[0] != '/')
dep = WrenchProject.CombinePaths (basis, dep);
- if (dep.StartsWith (basis)) {
+ if (StrUtils.StartsWith (dep, basis)) {
if (dep.IndexOf ('/', basis.Length) == -1) {
// local to this provider, request now,
because we're
// in the pb's done phase
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -18,15 +18,15 @@
public static event OperationFunc BeforeUninstall;
public static event OperationFunc BeforeDistribute;
- public static Result BuildValue (WrenchProject proj,
BuildServices bs) {
- Result r;
+ public static BuiltItem BuildValue (WrenchProject proj,
BuildServices bs) {
+ BuiltItem bi;
- if (bs.GetCachedValue (out r))
- return null;
+ if (bs.TryValueRecovery (out bi))
+ return BuiltItem.Null;
- if (r != null) {
+ if (bi.IsValid) {
DoBeforeSkip (proj, bs);
- return r;
+ return bi;
}
bs.Logger.Log ("operation.build", bs.FullName);
@@ -35,17 +35,17 @@
}
public static bool Build (WrenchProject proj, BuildServices bs)
{
- return (BuildValue (proj, bs) == null);
+ return (!BuildValue (proj, bs).IsValid);
}
public static bool Clean (WrenchProject proj, BuildServices bs)
{
- Result res = bs.GetRawCachedValue ();
+ BuiltItem bi = bs.GetRawCachedValue ();
- if (res == null)
+ if (!bi.IsValid)
return false;
bs.Logger.Log ("operation.clean", bs.FullName);
- if (res.Clean (bs.Context))
+ if (bi.Result.Clean (bs.Context))
// FIXME: rename to After
DoBeforeClean (proj, bs);
@@ -110,7 +110,7 @@
if (iri == null)
return false;
- obj = bs.GetValue ();
+ obj = bs.GetValue ().Result;
if (obj == null)
// error already reported
@@ -153,7 +153,7 @@
}
public static bool Distribute (WrenchProject proj,
BuildServices bs) {
- Result res = bs.GetValue ();
+ Result res = bs.GetValue ().Result;
if (res == null)
return true;
@@ -177,9 +177,9 @@
this.proj = proj;
}
- public Result[] EvaluateTargets (string[] targets) {
- Result[] rs = new Result[targets.Length];
-
+ public BuiltItem[] EvaluateTargets (string[] 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]);
@@ -191,7 +191,7 @@
switch (proj.GetTargetState
(targets[i])) {
case WrenchProject.TargetState.BuiltOk:
//Console.WriteLine ("EVAL {0}:
from cache", targets[i]);
- rs[i] = bs.GetRawCachedValue ();
+ bis[i] = bs.GetRawCachedValue
();
break;
case
WrenchProject.TargetState.BuiltError:
//Console.WriteLine ("EVAL {0}:
errored", targets[i]);
@@ -206,16 +206,16 @@
// State unknown. Load from
cache if possible, otherwise build.
proj.Log.PushLocation
(targets[i]);
- rs[i] =
WrenchOperations.BuildValue (proj, bs);
+ bis[i] =
WrenchOperations.BuildValue (proj, bs);
proj.Log.PopLocation ();
- if (rs[i] == null)
+ if (!bis[i].IsValid)
return null;
break;
}
}
- return rs;
+ return bis;
}
}
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/WrenchProject.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/WrenchProject.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/WrenchProject.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -33,81 +33,18 @@
public ProviderInfo () {}
- public Fingerprint GetOldBuildFingerprint (string
basename) {
- return pp.GetBuildFingerprint (basename);
- }
-
- public Result GetCachedValue (string location, string
basename, Fingerprint old_build_fp,
- Fingerprint cur_build_fp,
out Fingerprint old_res_fp) {
- Result res = null;
- old_res_fp = null;
-
- if (old_build_fp == null)
- // never built -> nothing to recover
- return null;
-
- old_res_fp = pp.GetResultFingerprint (basename);
-
- // if old_build_fp == Null, this target has
been 'fixed'
- // and we should just return the cached result
always
-
- if (cur_build_fp == old_build_fp ||
old_build_fp == GenericFingerprints.Null)
- res = pp.GetResult (basename);
-
- if (res == null)
- // It isn't cached, couldn't be
recovered, or needs to be rebuilt
- // (eg, serialization format change)
- return null;
-
- if (!res.Check (context)) {
- context.Logger.PushLocation (location);
- context.Logger.Log
("project.external_invalid", basename);
- context.Logger.Warning (3008, "The
cached external result was not " +
- "valid;
rebuilding.", res.ToString ());
- context.Logger.PopLocation ();
- return null;
- }
-
- return res;
- }
-
- public Result GetCachedValue (string location, string
basename, Fingerprint cur_build_fp,
- out Fingerprint
old_res_fp) {
- return GetCachedValue (location, basename,
GetOldBuildFingerprint (basename),
- cur_build_fp, out
old_res_fp);
- }
-
- public Result GetRawCachedValue (string basename) {
- return pp.GetResult (basename);
- }
-
- public void CacheValue (string basename, Result res,
Fingerprint cur_build_fp, Fingerprint old_res_fp) {
- if (res == null)
- throw new InvalidOperationException ();
-
- Fingerprint new_res_fp = res.GetFingerprint
(context, old_res_fp);
-
- // Convert the build FP to constant so that it
doesn't get recalculated
- // and that it's stored more efficiently. Don't
do this with the result
- // FP so that metadeta (eg file modtimes) are
saved too so that we don't
- // have to recalc the file FP
-
- pp.SetResult (basename, res);
- pp.SetBuildFingerprint (basename, new
ConstantFingerprint (cur_build_fp));
- //pp.SetBuildFingerprint (basename,
cur_build_fp);
- pp.SetResultFingerprint (basename, new_res_fp);
- }
-
public void UncacheValue (string basename) {
- pp.SetResult (basename, null);
- pp.SetBuildFingerprint (basename, null);
- pp.SetResultFingerprint (basename, null);
+ pp.SetItem (basename, BuiltItem.Null);
}
- public void FixValue (string basename, Result res,
Fingerprint old_res_fp) {
- CacheValue (basename, res,
GenericFingerprints.Null, old_res_fp);
- }
+ public void FixValue (string basename, Result r,
Fingerprint fp) {
+ if (fp == null)
+ fp = r.GetFingerprint (context, null);
+ BuiltItem bi = new BuiltItem (r, fp,
GenericFingerprints.Null);
+ pp.SetItem (basename, bi);
+ }
+
}
internal class InfoContext : IBuildContext {
@@ -905,7 +842,7 @@
toload.Clear ();
foreach (string basis in loadinfos.Keys) {
- if (!basis.StartsWith (here))
+ if (!StrUtils.StartsWith (basis, here))
continue;
if (providers.Contains (basis))
@@ -935,7 +872,7 @@
for (int i = 0; i < keys.Length; i++) {
string basis = keys[i];
- if (!basis.StartsWith (here))
+ if (!StrUtils.StartsWith (basis, here))
continue;
if (operate_provider (basis, (ProviderInfo)
providers[basis], func, tag))
Modified: trunk/mbuild/Mono.Build/ChangeLog
===================================================================
--- trunk/mbuild/Mono.Build/ChangeLog 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Mono.Build/ChangeLog 2005-10-10 23:08:43 UTC (rev 51537)
@@ -1,3 +1,57 @@
+2005-10-10 Peter Williams <[EMAIL PROTECTED]>
+
+ Fix build fingerprints. Add a BuiltItem struct, which passes
+ around a (Result, result fingerprint, build fingerprint)
+ tuple. This way an ArgCollector gets correct, up-to-date
+ fingerprints of its args. And these fingerprints are generated
+ during the build/cache recovery of the dependent results, so
+ we can use cached fingerprints sanely to avoid recomputes.
+
+ * Mono.Build/BuiltItem.cs: New file. Small struct that holds
+ a (Result, Result fingerprint, build fingerprint) tuple.
+
+ * Mono.Build/BuildFingerprint.cs: Don't inherit from
+ CompositeFingerprint, because we have nonstandard semantics
+ that don't map well to it.
+
+ * Mono.Build/ArgCollector.cs: No longer IFingerprintable.
+ (info): Make this a sorted list so our fingerprint ordering
+ is consistent.
+ (ArgData): Also keep a list of result fingerprints.
+ (AddArg): StrUtils.StartsWith.
+ (AddToAD): Take a fingerprint arg too with the Result. Use it
+ to cache the FP in the ArgData.
+ (AddNamed): Rename from AddInternal to reflect better the
+ distinction between this and Add().
+ (Add*): Add Fingerprint args and overloads that replicate the
+ original signatures by passing null for the FP.
+ (FinalizeOneArg): Use BuiltItems. Pass the FP in to Add* so
+ that we don't need to recalc it.
+ (FinalizeArgs): Same.
+ (CopyFingerprintData): Based on old GetFingerprint. Use the stored
+ fingerprints instead of trying to recalculate the old ones with
+ cached data. Use SortedLists and fingerprint values to make
+ the fingerprint value more well-behaved: invariant to reorderings
+ in unordered args; invariant to reorderings of arg definitions;
+ variant on reorderings of ordered args.
+
+ * Mono.Build/CompositeFingerprint.cs (Calculate): Make this
+ static with an argument so other code (BuildFingerprint) can
+ use the function.
+
+ * Mono.Build/TagTargetBase.cs (GetTagValue): Use BuiltItems,
+ not Results.
+
+ * Mono.Build/IBuildManager.cs: Return BuiltItem[] instead of
+ Result[].
+
+ * Mono.Build/MBFile.cs (GetFingerprint): Add some commented out
+ debugging code; add a using() line for better resource management.
+
+ * Mono.Build/StrUtils.cs: New file, copied from Mono's
+ System.Web. Probably need to go through and fix string compares
+ too; or just replace string target names with ID numbers.
+
2005-09-06 Peter Williams <[EMAIL PROTECTED]>
Rework fingerprints to avoid as many recalculations of hashes as
possible
Modified: trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs 2005-10-10 22:52:40 UTC
(rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs 2005-10-10 23:08:43 UTC
(rev 51537)
@@ -8,18 +8,19 @@
namespace Mono.Build {
- public class ArgCollector : IFingerprintable, IEnumerable {
+ public class ArgCollector : IEnumerable {
bool args_finalized = false;
// Arg state info
- Hashtable info;
+ SortedList info;
string default_ordered;
class ArgData {
public ArgInfo ai;
public ArrayList values;
+ public ArrayList fps;
}
// Target arguments to be evaluated
@@ -44,7 +45,7 @@
// Ctor
public ArgCollector (IEnumerable args) {
- info = new Hashtable ();
+ info = new SortedList ();
deferred = new ArrayList ();
default_ordered = null;
@@ -70,7 +71,7 @@
if (!TypeIs (typeof (MBString), ai.type))
throw new ArgumentException (".target
argument should be a string result");
- } else if (ai.name.StartsWith (".")) {
+ } else if (StrUtils.StartsWith (ai.name, ".")) {
throw new ArgumentException (String.Format
("Unknown special argument {0}", ai.name));
}
@@ -81,6 +82,7 @@
ad.ai = ai;
ad.values = new ArrayList ();
+ ad.fps = new ArrayList ();
if (ai.default_to != null) {
if (ai.default_to[0] != '/') {
@@ -158,13 +160,16 @@
// internal adding stuff
- void AddToAD (ArgData ad, Result r, int index_into_values) {
+ void AddToAD (ArgData ad, Result r, Fingerprint fp, int
index_into_values) {
CheckNotEvaluated ();
- if (index_into_values == -1)
+ if (index_into_values == -1) {
ad.values.Add (r);
- else
+ ad.fps.Add (fp);
+ } else {
ad.values[index_into_values] = r;
+ ad.fps[index_into_values] = fp;
+ }
}
void AddToAD (ArgData ad, string target) {
@@ -175,10 +180,11 @@
// marked as Ordered.
ad.values.Add (target);
+ ad.fps.Add (null);
deferred.Add (new TargetArg (ad.ai.name, target,
ad.values.Count - 1));
}
- bool AddInternal (string arg, Result r, int index_into_values,
IWarningLogger logger) {
+ bool AddNamed (string arg, Result r, Fingerprint fp, int
index_into_values, IWarningLogger logger) {
if (info[arg] == null) {
string s = String.Format ("Trying to add {0} to
nonexistant " +
"argument \"{1}\".",
r, arg);
@@ -190,7 +196,7 @@
Type t = r.GetType ();
if (TypeIs (t, ad.ai.type)) {
- AddToAD (ad, r, index_into_values);
+ AddToAD (ad, r, fp, index_into_values);
return false;
}
@@ -200,7 +206,15 @@
CompositeResult cr = (CompositeResult) r;
if (cr.HasDefault) {
- if (AddInternal (arg, cr.Default,
index_into_values, logger) == false)
+ // we lose the fingerprint info here.
This actually sucks
+ // kind of hard. We could in theory
assume that fp is a
+ // CompositeFingerprint and add some
kind of method to
+ // that class to allow extraction of
the fingerprint of
+ // the Default member. Kind of tricky
to do that right now though.
+
+ //logger.Warning (9999, "LOSING
FINGERPRINT INFO IN ARGCOLLECTOR", r.ToString ());
+
+ if (AddNamed (arg, cr.Default, null,
index_into_values, logger) == false)
return false;
}
}
@@ -215,7 +229,7 @@
// adding values
- public bool Add (Result r, IWarningLogger logger) {
+ public bool Add (Result r, Fingerprint fp, IWarningLogger
logger) {
if (r == null)
throw new ArgumentNullException ();
@@ -259,7 +273,7 @@
if (possible_args.Count == 1) {
ArgData ad = (ArgData) possible_args[0];
- AddToAD (ad, r, -1);
+ AddToAD (ad, r, fp, -1);
return false;
}
@@ -269,7 +283,7 @@
foreach (ArgData ad in possible_args) {
if ((ad.ai.flags &
ArgInfoFlags.Default) != 0) {
- AddToAD (ad, r, -1);
+ AddToAD (ad, r, fp, -1);
return false;
}
}
@@ -294,7 +308,11 @@
CompositeResult cr = (CompositeResult) r;
if (cr.HasDefault) {
- if (Add (cr.Default, logger) == false)
+ // See note above about losing FP info
in composite results.
+ // this case happens when we are
guessing the arg; te
+ //logger.Warning (9999, "LOSING
FINGERPRINT INFO in AC (2)", r.ToString ());
+
+ if (Add (cr.Default, null, logger) ==
false)
return false;
// if that didn't work, continue
@@ -311,17 +329,25 @@
return true;
}
+ public bool Add (Result r, IWarningLogger logger) {
+ return Add (r, null, logger);
+ }
+
public void Add (string target) {
deferred.Add (new TargetArg (null, target));
}
- public bool Add (string arg, Result r, IWarningLogger logger) {
+ public bool Add (string arg, Result r, Fingerprint fp,
IWarningLogger logger) {
if (r == null)
throw new ArgumentNullException ();
- return AddInternal (arg, r, -1, logger);
+ return AddNamed (arg, r, fp, -1, logger);
}
+ public bool Add (string arg, Result r, IWarningLogger logger) {
+ return Add (arg, r, null, logger);
+ }
+
public bool Add (string arg, string target, IWarningLogger
logger) {
if (info[arg] == null) {
string s = String.Format ("Trying to add {0} to
nonexistant " +
@@ -335,7 +361,7 @@
return false;
}
- public bool AddDefaultOrdered (Result r, IWarningLogger logger)
{
+ public bool AddDefaultOrdered (Result r, Fingerprint fp,
IWarningLogger logger) {
if (r == null)
throw new ArgumentNullException ();
@@ -346,9 +372,13 @@
return true;
}
- return AddInternal (default_ordered, r, -1, logger);
+ return AddNamed (default_ordered, r, fp, -1, logger);
}
+ public bool AddDefaultOrdered (Result r, IWarningLogger logger)
{
+ return AddDefaultOrdered (r, null, logger);
+ }
+
public bool AddDefaultOrdered (string target, IWarningLogger
logger) {
if (default_ordered == null) {
logger.Error (2037, "Trying to add a dependency
to the default " +
@@ -375,12 +405,12 @@
bool FinalizeOneArg (ArgData ad, IBuildManager manager,
IWarningLogger logger) {
if (ad.ai.default_to != null && ad.values.Count < 1) {
string[] s = new string[] { ad.ai.default_to };
- Result[] r = manager.EvaluateTargets (s);
+ BuiltItem[] bi = manager.EvaluateTargets (s);
- if (r == null)
+ if (bi == null)
return true;
- AddToAD (ad, r[0], -1);
+ AddToAD (ad, bi[0].Result, bi[0].ResultPrint,
-1);
}
if ((ad.ai.flags & ArgInfoFlags.Optional) == 0 &&
ad.values.Count < 1) {
@@ -405,19 +435,19 @@
for (i = 0; i < deferred.Count; i++)
names[i] = ((TargetArg) deferred[i]).target;
- Result[] results = manager.EvaluateTargets (names);
- if (results == null)
+ BuiltItem[] bis = manager.EvaluateTargets (names);
+ if (bis == null)
return true;
for (i = 0; i < deferred.Count; i++) {
string arg = ((TargetArg) deferred[i]).arg;
if (arg == null) {
- if (Add (results[i], logger))
+ if (Add (bis[i].Result,
bis[i].ResultPrint, logger))
return true;
} else {
- if (AddInternal (arg, results[i],
- ((TargetArg)
deferred[i]).index_into_values, logger))
+ if (AddNamed (arg, bis[i].Result,
bis[i].ResultPrint,
+ ((TargetArg)
deferred[i]).index_into_values, logger))
return true;
}
}
@@ -455,32 +485,40 @@
}
}
- // fingerprinting -- fingerprint the argument values, not the
ArgInfos
+ // Fingerprinting is a little weird.. Note that ArgCollector is
not a traditional IFingerprintable,
+ // because it doesn't honor cached fp's in a normal way.
- public Fingerprint GetFingerprint (IBuildContext ctxt,
Fingerprint cached) {
+ internal void CopyFingerprintData (IList list, IBuildContext
ctxt) {
CheckEvaluated ();
- // FIXME! Switching the order of two values within one
argument
- // will change our fingerprint, which shouldn't happen
unless the
- // arg is marked 'ordered'. But the only canonical way
to order
- // the value fp's is by their fp values, which means we
have to
- // calculate them all, which is expensive. We probably
will need
- // a specialized ArgCollectorFingerprint that has all
this logic
- // worked out correctly.
+ foreach (ArgData ad in info.Values) {
+ if ((ad.ai.flags & ArgInfoFlags.Ordered) != 0) {
+ // This arg is ordered, go with the
ordering
+ // we've been given.
- ArrayList l = new ArrayList ();
+ for (int i = 0; i < ad.fps.Count; i++) {
+ if (ad.fps[i] == null)
+ list.Add ((ad.values[i]
as Result).GetFingerprint (ctxt, null));
+ else
+ list.Add (ad.fps[i]);
+ }
+ } else {
+ // this arg is unordered. Sort fp's as
we go so a build file reorder
+ // doesn't affect the fp.
- foreach (ArgData ad in info.Values) {
- for (int i = 0; i < ad.values.Count; i++)
- l.Add (ad.values[i]);
- }
+ SortedList fps = new SortedList ();
- if (l.Count == 0)
- return GenericFingerprints.Null;
+ for (int i = 0; i < ad.fps.Count; i++) {
+ if (ad.fps[i] == null)
+ fps.Add ((ad.values[i]
as Result).GetFingerprint (ctxt, null), null);
+ else
+ fps.Add (ad.fps[i],
null);
+ }
- Fingerprint fp = new CompositeFingerprint (l, ctxt,
cached);
- //Console.WriteLine ("fp args: cached, new = {0}, {1}",
cached, fp);
- return fp;
+ foreach (Fingerprint fp in fps.Keys)
+ list.Add (fp);
+ }
+ }
}
}
}
Modified: trunk/mbuild/Mono.Build/Mono.Build/BuildFingerprint.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/BuildFingerprint.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/BuildFingerprint.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -1,17 +1,25 @@
//
-// BuildFingerprint.cs -- a fingerprint of a whole build action
+// BuildFingerprint.cs -- a fingerprint of a whole build action. We don't
+// make this a CompositeFingerprint to not store a whole nested tree of
+// subfingerprints; the caching semantics of ArgCollector are a little crafty
+// so we don't need to store everything. (In fact, doing so causes problems,
+// as I found out.)
//
using System;
+using System.Collections;
using System.Runtime.Serialization;
namespace Mono.Build {
[Serializable]
- public class BuildFingerprint : CompositeFingerprint {
- public BuildFingerprint (Rule rule, ArgCollector args,
IBuildContext ctxt, Fingerprint cached) : base () {
- object[] tmp = new object[2] { rule, args };
- Calculate (tmp, ctxt, cached);
+ public class BuildFingerprint : Fingerprint {
+ public BuildFingerprint (Rule rule, ArgCollector args,
IBuildContext ctxt) : base () {
+ ArrayList l = new ArrayList ();
+
+ l.Add (rule.GetFingerprint (ctxt, null));
+ args.CopyFingerprintData (l, ctxt);
+ value = CompositeFingerprint.Calculate (l);
}
}
}
Added: trunk/mbuild/Mono.Build/Mono.Build/BuiltItem.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/BuiltItem.cs 2005-10-10 22:52:40 UTC
(rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/BuiltItem.cs 2005-10-10 23:08:43 UTC
(rev 51537)
@@ -0,0 +1,44 @@
+// BuiltItem.cs -- a tuple of information regarding a built target:
+// a result, a fingerprint of the result, and a fingerprint of the
+// build that generated it
+
+using System;
+
+namespace Mono.Build {
+
+
+ [Serializable]
+ public struct BuiltItem {
+
+ public Result Result;
+ public Fingerprint ResultPrint;
+ public Fingerprint BuildPrint;
+
+ public BuiltItem (Result r, Fingerprint vp, Fingerprint bp) {
+ Result = r;
+ ResultPrint = vp;
+ BuildPrint = bp;
+ }
+
+ public bool IsValid {
+ get {
+ return Result != null;
+ }
+ }
+
+ public bool IsFixed {
+ get {
+ if (BuildPrint == null)
+ throw new InvalidOperationException ();
+
+ return BuildPrint == GenericFingerprints.Null;
+ }
+ }
+
+ public override string ToString () {
+ return String.Format ("[BI: {0}, {1}, {2}", Result,
ResultPrint, BuildPrint);
+ }
+
+ public static readonly BuiltItem Null = new BuiltItem (null,
null, null);
+ }
+}
Modified: trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs 2005-10-10
22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs 2005-10-10
23:08:43 UTC (rev 51537)
@@ -48,21 +48,23 @@
}
}
- value = Calculate ();
+ value = Calculate (children);
}
- protected byte[] Calculate () {
- int count = children.Length;
- byte[] data = new byte[count * PreferredHash.Size];
+ public static byte[] Calculate (ICollection fps) {
+ byte[] data = new byte[fps.Count * PreferredHash.Size];
+ int i = 0;
- for (int i = 0; i < count; i++) {
- Fingerprint item = children[i];
+ foreach (Fingerprint item in fps) {
+ byte[] fp;
if (item == null)
- item = GenericFingerprints.Null;
+ fp = GenericFingerprints.Null.Value;
+ else
+ fp = item.Value;
- byte[] fp = item.Value;
fp.CopyTo (data, PreferredHash.Size * i);
+ i++;
}
return PreferredHash.Algo.ComputeHash (data);
Modified: trunk/mbuild/Mono.Build/Mono.Build/IBuildManager.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/IBuildManager.cs 2005-10-10 22:52:40 UTC
(rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/IBuildManager.cs 2005-10-10 23:08:43 UTC
(rev 51537)
@@ -8,6 +8,6 @@
public interface IBuildManager {
// do this as arrays so we can parallelize
- Result[] EvaluateTargets (string[] targets);
+ BuiltItem[] EvaluateTargets (string[] targets);
}
}
Modified: trunk/mbuild/Mono.Build/Mono.Build/MBFile.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/MBFile.cs 2005-10-10 22:52:40 UTC
(rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/MBFile.cs 2005-10-10 23:08:43 UTC
(rev 51537)
@@ -229,21 +229,23 @@
DateTime ondisk = GetModTime (ctxt);
Fingerprint result;
- if (cached != null && modtime == ondisk)
+ if (cached != null && modtime == ondisk) {
+ //string path = GetPath (ctxt);
+ //ctxt.Logger.Log ("io.file_fingerCACHE",
"XXXXXXXX " + path);
result = cached;
- else {
- // skip the buffered stream here, useless
- //Stream stream = OpenRead (ctxt);
+ } else {
+ // Don't use OpenRead: the buffered stream
would be useless
string path = GetPath (ctxt);
-
+ //string s = cached == null ? "nocached " :
"modtime ";
+ //ctxt.Logger.Log ("io.file_fingerprint", s +
path);
ctxt.Logger.Log ("io.file_fingerprint", path);
- //throw new Exception ("asdasd");
- result = new StreamFingerprint (new FileStream
(path, FileMode.Open,
-
FileAccess.Read));
+ using (FileStream fs = new FileStream (path,
FileMode.Open, FileAccess.Read))
+ result = new StreamFingerprint (fs);
+
+ modtime = ondisk;
}
- modtime = ondisk;
return result;
}
Added: trunk/mbuild/Mono.Build/Mono.Build/StrUtils.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/StrUtils.cs 2005-10-10 22:52:40 UTC
(rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/StrUtils.cs 2005-10-10 23:08:43 UTC
(rev 51537)
@@ -0,0 +1,79 @@
+// COPIED FROM: mcs/class/System.Web/System.Web.Util/StrUtils.cs
+
+//
+// System.Web.Util.StrUtils
+//
+// Author(s):
+// Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//
+// (C) 2005 Novell, Inc, (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+
+//namespace System.Web.Util {
+namespace Mono.Build {
+ public sealed class StrUtils {
+ static CultureInfo invariant = CultureInfo.InvariantCulture;
+ private StrUtils () { }
+
+ public static bool StartsWith (string str1, string str2)
+ {
+ return StartsWith (str1, str2, false);
+ }
+
+ public static bool StartsWith (string str1, string str2, bool
ignore_case)
+ {
+ int l2 = str2.Length;
+ if (l2 == 0)
+ return true;
+
+ int l1 = str1.Length;
+ if (l2 > l1)
+ return false;
+
+ return (0 == String.Compare (str1, 0, str2, 0, l2,
ignore_case, invariant));
+ }
+
+ public static bool EndsWith (string str1, string str2)
+ {
+ return EndsWith (str1, str2, false);
+ }
+
+ public static bool EndsWith (string str1, string str2, bool
ignore_case)
+ {
+ int l2 = str2.Length;
+ if (l2 == 0)
+ return true;
+
+ int l1 = str1.Length;
+ if (l2 > l1)
+ return false;
+
+ return (0 == String.Compare (str1, l1 - l2, str2, 0,
l2, ignore_case, invariant));
+ }
+ }
+}
+
Modified: trunk/mbuild/Mono.Build/Mono.Build/TagTargetBase.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/TagTargetBase.cs 2005-10-10 22:52:40 UTC
(rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build/TagTargetBase.cs 2005-10-10 23:08:43 UTC
(rev 51537)
@@ -63,12 +63,12 @@
if (val is Result)
return (Result) val;
- Result[] results = manager.EvaluateTargets (new
string[] { (string) val });
+ BuiltItem[] bis = manager.EvaluateTargets (new string[]
{ (string) val });
- if (results == null)
+ if (bis == null)
return null;
- return results[0];
+ return bis[0].Result;
}
// utility (hacks)
Modified: trunk/mbuild/Mono.Build/Mono.Build.Bundling/BundleManager.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build.Bundling/BundleManager.cs
2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Mono.Build/Mono.Build.Bundling/BundleManager.cs
2005-10-10 23:08:43 UTC (rev 51537)
@@ -296,7 +296,7 @@
if (name == null)
throw new ArgumentNullException ();
- //if (!name.StartsWith (MBuildPrefix))
+ //if (!StrUtils.StartsWith (name, MBuildPrefix))
name = MBuildPrefix + name;
t = null;
Modified: trunk/mbuild/Mono.Build.dll.sources
===================================================================
--- trunk/mbuild/Mono.Build.dll.sources 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/Mono.Build.dll.sources 2005-10-10 23:08:43 UTC (rev 51537)
@@ -4,6 +4,7 @@
Mono.Build/Mono.Build/ArgInfo.cs
Mono.Build/Mono.Build/ArgInfoFlags.cs
Mono.Build/Mono.Build/BuildFingerprint.cs
+Mono.Build/Mono.Build/BuiltItem.cs
Mono.Build/Mono.Build/CompositeFingerprint.cs
Mono.Build/Mono.Build/CompositeResult.cs
Mono.Build/Mono.Build/CompositeResultFieldAttribute.cs
@@ -35,6 +36,7 @@
Mono.Build/Mono.Build/Rule.cs
Mono.Build/Mono.Build/SimpleProvider.cs
Mono.Build/Mono.Build/SimpleTarget.cs
+Mono.Build/Mono.Build/StrUtils.cs
Mono.Build/Mono.Build/StreamFingerprint.cs
Mono.Build/Mono.Build/TagTargetBase.cs
Mono.Build/Mono.Build/TextFingerprint.cs
Modified: trunk/mbuild/mb-bundledoc/ChangeLog
===================================================================
--- trunk/mbuild/mb-bundledoc/ChangeLog 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/mb-bundledoc/ChangeLog 2005-10-10 23:08:43 UTC (rev 51537)
@@ -1,3 +1,7 @@
+2005-10-10 Peter Williams <[EMAIL PROTECTED]>
+
+ * synchronizers.cs: Use StrUtils.StartsWith.
+
2005-01-19 Peter Williams <[EMAIL PROTECTED]>
* BundleDocumenter.cs: Unused variable warning.
Modified: trunk/mbuild/mb-bundledoc/synchronizers.cs
===================================================================
--- trunk/mbuild/mb-bundledoc/synchronizers.cs 2005-10-10 22:52:40 UTC (rev
51536)
+++ trunk/mbuild/mb-bundledoc/synchronizers.cs 2005-10-10 23:08:43 UTC (rev
51537)
@@ -148,7 +148,7 @@
protected override string GetItemIdentifier (object o) {
string ns = (string) o;
- if (ns.StartsWith (BundleDocumenter.MBuildPrefix))
+ if (StrUtils.StartsWith (ns,
BundleDocumenter.MBuildPrefix))
ns = ns.Substring
(BundleDocumenter.MBuildPrefix.Length);
return ns;
Modified: trunk/mbuild/mb-gtkconfig/ChangeLog
===================================================================
--- trunk/mbuild/mb-gtkconfig/ChangeLog 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/mb-gtkconfig/ChangeLog 2005-10-10 23:08:43 UTC (rev 51537)
@@ -1,3 +1,7 @@
+2005-10-10 Peter Williams <[EMAIL PROTECTED]>
+
+ * mb-gtkconfig.cs (LoadConfigItem): Handle BuiltItem changes.
+
2005-09-24 Peter Williams <[EMAIL PROTECTED]>
* Buildfile (glade-sharp-pclibs): Mark this with default = false so that
Modified: trunk/mbuild/mb-gtkconfig/mb-gtkconfig.cs
===================================================================
--- trunk/mbuild/mb-gtkconfig/mb-gtkconfig.cs 2005-10-10 22:52:40 UTC (rev
51536)
+++ trunk/mbuild/mb-gtkconfig/mb-gtkconfig.cs 2005-10-10 23:08:43 UTC (rev
51537)
@@ -95,7 +95,7 @@
bool LoadConfigItem (WrenchProject proj, BuildServices bs) {
string prompt, group;
string target = bs.FullName;
- Result res = bs.GetValue ();
+ Result res = bs.GetValue ().Result;
if (res == null)
return true;
Modified: trunk/mbuild/mb-import/mb-import.cs
===================================================================
--- trunk/mbuild/mb-import/mb-import.cs 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/mb-import/mb-import.cs 2005-10-10 23:08:43 UTC (rev 51537)
@@ -210,9 +210,9 @@
// IBuildManager
- public Result[] EvaluateTargets (string[] targets) {
+ public BuiltItem[] EvaluateTargets (string[] targets) {
if (targets.Length == 0)
- return new Result[0];
+ return new BuiltItem[0];
Console.Error.WriteLine ("Trying to evaluate: ");
foreach (string s in targets)
Modified: trunk/mbuild/mbuild/ChangeLog
===================================================================
--- trunk/mbuild/mbuild/ChangeLog 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/mbuild/ChangeLog 2005-10-10 23:08:43 UTC (rev 51537)
@@ -1,3 +1,7 @@
+2005-10-10 Peter Williams <[EMAIL PROTECTED]>
+
+ * mbuild.cs: Handle Result -> BuiltItem in BuildServices.
+
2005-09-01 Peter Williams <[EMAIL PROTECTED]>
* mbuild.cs: Ifdef out some using statements too.
Modified: trunk/mbuild/mbuild/mbuild.cs
===================================================================
--- trunk/mbuild/mbuild/mbuild.cs 2005-10-10 22:52:40 UTC (rev 51536)
+++ trunk/mbuild/mbuild/mbuild.cs 2005-10-10 23:08:43 UTC (rev 51537)
@@ -309,7 +309,7 @@
// basic operations
bool ShowOperation (WrenchProject proj, BuildServices bs) {
- Result res = bs.GetValue ();
+ Result res = bs.GetValue ().Result;
if (res != null)
Console.WriteLine ("{0} = {1}", bs.FullName, res);
@@ -339,7 +339,7 @@
}
bool ExportAsXml (WrenchProject proj, BuildServices bs) {
- Result r = WrenchOperations.BuildValue (proj, bs);
+ Result r = WrenchOperations.BuildValue (proj, bs).Result;
if (r == null)
return true;
@@ -350,7 +350,7 @@
// Config
bool ConfigOperation (WrenchProject proj, BuildServices bs) {
- Result res = bs.GetValue ();
+ Result res = bs.GetValue ().Result;
if (res == null)
return true;
@@ -470,14 +470,14 @@
string GuessDistDir (WrenchProject proj) {
string[] names = new string[] { "/project/name",
"/project/version" };
- Result[] vals = proj.BuildManager.EvaluateTargets (names);
+ BuiltItem[] vals = proj.BuildManager.EvaluateTargets (names);
if (vals == null)
return null;
return String.Format ("{0}-{1}",
- (vals[0] as MBString).Value,
- (vals[1] as MBString).Value);
+ (vals[0].Result as MBString).Value,
+ (vals[1].Result as MBString).Value);
}
void DoOperation (string here, ProjectManager pm) {
@@ -531,7 +531,7 @@
for (int i = 0; i < RemainingArguments.Length; i++) {
string targ = RemainingArguments[i];
- if (targ.StartsWith ("--")) {
+ if (StrUtils.StartsWith (targ, "--")) {
Console.Error.WriteLine ("Unrecognized
option \"{0}\".", targ);
continue;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches