Author: peterw
Date: 2005-03-05 01:10:32 -0500 (Sat, 05 Mar 2005)
New Revision: 41463
Modified:
trunk/mbuild/Buildfile.config
trunk/mbuild/Languages.CSharp.bundle
trunk/mbuild/MBuildDynamic.Core/ChangeLog
trunk/mbuild/MBuildDynamic.Core/Core.Clr.bundle
trunk/mbuild/MBuildDynamic.Core/Core.bundle
trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs
trunk/mbuild/Mono.Build.dll.sources
trunk/mbuild/Mono.Build/Mono.Build.RuleLib/BinaryInfo.cs
trunk/mbuild/Mono.Build/Mono.Build.RuleLib/CopyInstaller.cs
trunk/mbuild/Mono.Build/Mono.Build.RuleLib/ExternalBinaryInfo.cs
trunk/mbuild/Mono.Build/Mono.Build.RuleLib/FileBinaryInfo.cs
trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs
trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs
trunk/mbuild/Tools.Monodoc.bundle
trunk/mbuild/mb-bundlegen/Parser.jay
trunk/mbuild/mb-bundlegen/Tokenizer.cs
trunk/mbuild/mbuild/mbuild.cs
Log:
Ugh. Skipping the ChangeLog on this one. Internal rework adding
CompositeResult, allowing us to not use dictionaries for things that
aren't really dictionaries. CompositeResults can have a 'default'
member that they act like when not matching as arguments to rules.
This allows us to replace the Assembly output of CSC with a {
Assembly, DebugInfoFile } pair, which allows us to install debugging
info on mbuild -I. Woo hoo.
Modified: trunk/mbuild/Buildfile.config
===================================================================
--- trunk/mbuild/Buildfile.config 2005-03-04 19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Buildfile.config 2005-03-05 06:10:32 UTC (rev 41463)
@@ -33,8 +33,10 @@
doc_installer = MakeCopyInstaller [ docdir ]
# Exe installing: {libdir}/{compat-name}
+# (The default exe installer puts them in {bindir}, which
+# we don't want -- wrappers go there.
-exe_installer = Clone [ /config/install/pkglibdir_installer ]
+exe_installer = Clone [ /config/lang/csharp/dll_installer ]
# Our compiler options
Modified: trunk/mbuild/Languages.CSharp.bundle
===================================================================
--- trunk/mbuild/Languages.CSharp.bundle 2005-03-04 19:59:54 UTC (rev
41462)
+++ trunk/mbuild/Languages.CSharp.bundle 2005-03-05 06:10:32 UTC (rev
41463)
@@ -7,6 +7,7 @@
using Core.Tools;
using Core.Clr;
using Core.Config;
+ using Core.Install;
using !System.Text;
using !System.IO;
using !System;
@@ -20,6 +21,9 @@
default_csc_options = MakeDefaultCSharpOptions (enable_debug);
+ exe_installer = MakeCSharpCompilerOutputInstaller
(/config/install/bindir);
+ dll_installer = MakeCSharpCompilerOutputInstaller
(/config/install/pkglibdir);
+
enable_debug = ConfigBool (/config/generic/enable_debug) tags {
"prompt" = "Compile C# programs with debugging
symbols?";
"config_group" = "Debugging";
@@ -37,11 +41,66 @@
target regex matcher "GeneratedAssemblyVersionInfo.cs$" =
GenerateAssemblyVersionInfo;
dependency regex matcher "GeneratedAssemblyVersionInfo.cs$" =
GenerateAssemblyVersionInfo;
+ # CSharpCompilerOutput
+
+ result CSharpCompilerOutput : CompositeResult {
+ default field AssemblyFile Output;
+ field MBFile DebugInfo;
+ }
+
+ # CSharpCompilerOutputInstaller
+
+ result CSharpCompilerOutputInstaller : ExecutableCopyInstaller {
+ @{
+
+ public override Type OtherType { get { return typeof
(CSharpCompilerOutput); } }
+
+ public override bool InstallResult (Result other, bool
backwards, IBuildContext ctxt)
+ {
+ CSharpCompilerOutput output = (CSharpCompilerOutput)
other;
+
+ if (CopyFile (output.Output, backwards, ctxt))
+ return true;
+
+ if (output.DebugInfo.Exists (ctxt) && CopyFile
(output.DebugInfo, backwards, ctxt))
+ return true;
+
+ return false;
+ }
+
+ public override string DescribeAction (Result other,
IBuildContext ctxt) {
+ CSharpCompilerOutput o = (CSharpCompilerOutput) other;
+
+ if (o.DebugInfo != null)
+ return String.Format ("Copy {0} and {1} to
{2}",
+ o.Output.GetPath (ctxt),
o.DebugInfo.GetPath (ctxt), DestDir);
+ else
+ return String.Format ("Copy {0} to {2}",
+ o.Output.GetPath (ctxt), DestDir);
+ }
+
+ @}
+ }
+
+ # MakeCSharpCompilerOutputInstaller (phew!)
+
+ rule MakeCSharpCompilerOutputInstaller : MakeExecutableCopyInstaller {
+
+ @{
+
+ protected override CopyInstaller MakeResult () {
+ return new CSharpCompilerOutputInstaller ();
+ }
+
+ @}
+ }
+
# CSharpCompiler
- result CSharpCompiler : MBDictionary {
- dictitem BinaryInfo Binary;
- dictitem MBString NativeArgs;
+ result CSharpCompiler : CompositeResult {
+ field BinaryInfo Binary;
+ field string NativeArgs;
+ field bool McsDebugInfo;
@{
@@ -85,10 +144,21 @@
public string MakeNativeArgs () {
if (NativeArgs != null)
- return NativeArgs.Value;
+ return NativeArgs;
return "";
}
+ internal MBFile MakeMcsDebugInfoFile (MBFile output) {
+ return new MBFile (output.Dir, output.Name + ".mdb");
+ }
+
+ public MBFile MakeDebugInfoFile (MBFile output) {
+ if (!McsDebugInfo)
+ return null;
+
+ return MakeMcsDebugInfoFile (output);
+ }
+
public bool Compile (string args, IBuildContext ctxt) {
return (Launcher.RunTool (Binary, args, ctxt,
"C# compiler returned an error.") != 0);
@@ -120,6 +190,27 @@
return temp;
}
+ public ExeAssembly SimpleExeCompile (CSSource source,
CSharpCompilerOptions opts, IBuildContext ctxt)
+ {
+ ExeAssembly dest = new ExeAssembly ();
+ dest.Dir = ctxt.WorkingDirectory;
+ dest.Name = Path.ChangeExtension (source.Name, "exe");
+
+ string cs_args = String.Format ("{0} {1} {2} {3}",
+ MakeNativeArgs (),
+ MakeOutputArg (dest.GetPath (ctxt)),
+ MakeExeTargetArg (),
+ source.GetPath (ctxt));
+
+ if (opts != null)
+ cs_args = opts.MakeArguments (this, ctxt) + " "
+ cs_args;
+
+ if (Compile (cs_args, ctxt))
+ return null;
+
+ return dest;
+ }
+
@}
}
@@ -141,18 +232,48 @@
res.Binary = (BinaryInfo) r_binary[0];
if (r_native.Length > 0)
- res.NativeArgs = (MBString) r_native[0];
+ res.NativeArgs = ((MBString) r_native[0]).Value;
+ if (CheckDebugFormat (res, ctxt))
+ return null;
+
return res;
@}
+
+ @{
+
+ bool CheckDebugFormat (CSharpCompiler csc, IBuildContext ctxt)
+ {
+ CSharpCompilerOptions opts = new CSharpCompilerOptions
();
+ opts.Debug = true;
+
+ CSSource src = CSharpCompiler.CreateCheckFile
("check_debug", "", "return 0;", ctxt);
+ ExeAssembly output = csc.SimpleExeCompile (src, opts,
ctxt);
+
+ if (output == null) {
+ // Preserve the source file for reference
+ return true;
+ }
+
+ MBFile dinfo = csc.MakeMcsDebugInfoFile (output);
+ if (dinfo.Exists (ctxt)) {
+ csc.McsDebugInfo = true;
+ dinfo.Delete (ctxt);
+ }
+
+ output.Delete (ctxt);
+ return false;
+ }
+
+ @}
}
# CSharpCompilerOptions
- result CSharpCompilerOptions : MBDictionary {
- dictitem MBBool Debug;
- dictitem StrongnameKeypairFile SnkFile;
- dictitem MBString NativeArgs;
+ result CSharpCompilerOptions : CompositeResult {
+ field bool Debug;
+ field StrongnameKeypairFile SnkFile;
+ field string NativeArgs;
# FIXME: refs, sysrefs, resources -- arrays in dicts
@@ -161,14 +282,13 @@
public string MakeArguments (CSharpCompiler csc, IBuildContext
ctxt) {
string res = "";
- if (Debug != null)
- res = csc.MakeDebugArg (Debug.Value);
+ res = csc.MakeDebugArg (Debug);
if (SnkFile != null)
res += " " + csc.MakeKeyfileArg
(SnkFile.GetPath (ctxt));
if (NativeArgs != null)
- res += " " + NativeArgs.Value;
+ res += " " + NativeArgs;
return res;
}
@@ -182,7 +302,7 @@
build (args, ctxt) @{
CSharpCompilerOptions opts = new CSharpCompilerOptions
();
- opts.Debug = (MBBool) (args["debug"])[0];
+ opts.Debug = ((MBBool) (args["debug"])[0]).Value;
return opts;
@}
@@ -216,7 +336,7 @@
opts = (CSharpCompilerOptions) ((Result) bopts[0].Clone
());
if (debug.Length > 0)
- opts.Debug = (MBBool) debug[0];
+ opts.Debug = ((MBBool) debug[0]).Value;
if (snkfile.Length > 0)
opts.SnkFile = (StrongnameKeypairFile)
snkfile[0];
@@ -227,7 +347,7 @@
foreach (MBString piece in native_args)
s += " " + piece.Value;
- opts.NativeArgs = new MBString (s.Substring
(1));
+ opts.NativeArgs = s.Substring (1);
}
return opts;
@@ -255,7 +375,7 @@
return "";
}
- protected virtual MBFile MakeResult () { return null; }
+ protected virtual AssemblyFile MakeResult () { return
null; }
@}
build (args, ctxt) @{
@@ -270,14 +390,18 @@
CSharpCompiler csc = (CSharpCompiler) rcsc[0];
MBString targ = (MBString) targarray[0];
- MBFile res = MakeResult ();
- res.Dir = ctxt.WorkingDirectory;
- res.Name = targ.Value;
+ CSharpCompilerOutput res = new CSharpCompilerOutput ();
+ res.Output = MakeResult ();
+ res.Output.Dir = ctxt.WorkingDirectory;
+ res.Output.Name = targ.Value;
CSharpCompilerOptions opts = CreateOptions (args);
- StringBuilder sb = new StringBuilder (csc.MakeOutputArg
(res.GetPath (ctxt)));
+ if (opts.Debug)
+ res.DebugInfo = csc.MakeDebugInfoFile
(res.Output);
+ StringBuilder sb = new StringBuilder (csc.MakeOutputArg
(res.Output.GetPath (ctxt)));
+
sb.AppendFormat (" {0}", GetExtraArgs (csc));
sb.AppendFormat (" {0}", csc.MakeNativeArgs ());
@@ -309,7 +433,7 @@
Result[] r_sn = args["sn"];
StrongnameProgram sn = (StrongnameProgram)
r_sn[0];
- if (sn.StrongnameAssembly ((AssemblyFile) res,
opts.SnkFile, ctxt))
+ if (sn.StrongnameAssembly ((AssemblyFile)
res.Output, opts.SnkFile, ctxt))
return null;
}
@@ -329,13 +453,13 @@
return csc.MakeDllTargetArg ();
}
- protected override MBFile MakeResult () {
+ protected override AssemblyFile MakeResult () {
return new DllAssembly ();
}
@}
tags {
- "install" = /config/install/pkglibdir_installer;
+ "install" = /config/lang/csharp/dll_installer;
}
}
@@ -347,13 +471,13 @@
return csc.MakeExeTargetArg ();
}
- protected override MBFile MakeResult () {
+ protected override AssemblyFile MakeResult () {
return new ExeAssembly ();
}
@}
tags {
- "install" = /config/install/bindir_installer;
+ "install" = /config/lang/csharp/exe_installer;
}
}
@@ -375,6 +499,8 @@
CSSource source = CSharpCompiler.CreateCheckFile
("dllcheck", "", "return 0;", ctxt);
+ // FIXME: use SimpleExeCompile once
CSharpCompilerOptions can store DLL references.
+
ExeAssembly dest = new ExeAssembly ();
dest.Dir = ctxt.WorkingDirectory;
dest.Name = Path.ChangeExtension (source.Name, "exe");
Modified: trunk/mbuild/MBuildDynamic.Core/ChangeLog
===================================================================
--- trunk/mbuild/MBuildDynamic.Core/ChangeLog 2005-03-04 19:59:54 UTC (rev
41462)
+++ trunk/mbuild/MBuildDynamic.Core/ChangeLog 2005-03-05 06:10:32 UTC (rev
41463)
@@ -1,3 +1,7 @@
+2005-03-04 Peter Williams <[EMAIL PROTECTED]>
+
+ * Core.Clr.bundle: Update for better ArgCollector API.
+
2004-09-29 Peter Williams <[EMAIL PROTECTED]>
* Core.Clr.bundle (GacutilInstaller): Make this an MBDictionary
implemented
Modified: trunk/mbuild/MBuildDynamic.Core/Core.Clr.bundle
===================================================================
--- trunk/mbuild/MBuildDynamic.Core/Core.Clr.bundle 2005-03-04 19:59:54 UTC
(rev 41462)
+++ trunk/mbuild/MBuildDynamic.Core/Core.Clr.bundle 2005-03-05 06:10:32 UTC
(rev 41463)
@@ -38,8 +38,8 @@
@}
}
- result StrongnameProgram : MBDictionary {
- dictitem BinaryInfo Program;
+ result StrongnameProgram : CompositeResult {
+ field BinaryInfo Program;
@{
@@ -64,8 +64,8 @@
@}
}
- result GacutilProgram : MBDictionary {
- dictitem BinaryInfo Program;
+ result GacutilProgram : CompositeResult {
+ field BinaryInfo Program;
# TODO: see if gacutil supports /package
@@ -110,21 +110,21 @@
@}
}
- result GacutilInstaller : MBDictionary {
+ result GacutilInstaller : CompositeResult {
implements IResultInstaller;
- dictitem GacutilProgram Gacutil;
- dictitem MBString RootDir;
- dictitem MBString Package;
+ field GacutilProgram Gacutil;
+ field string RootDir;
+ field string Package;
@{
public GacutilInstaller (GacutilProgram gacutil, string
rootdir, string package)
{
this.Gacutil = gacutil;
- this.RootDir = new MBString (rootdir);
- this.Package = new MBString (package);
+ this.RootDir = rootdir;
+ this.Package = package;
}
public Type OtherType { get { return typeof (AssemblyFile); } }
@@ -133,7 +133,7 @@
{
AssemblyFile assy = (AssemblyFile) r;
- return Gacutil.InstallAssembly (assy, RootDir.Value,
Package.Value, backwards, ctxt);
+ return Gacutil.InstallAssembly (assy, RootDir, Package,
backwards, ctxt);
}
public string DescribeAction (Result other, IBuildContext ctxt)
{
@@ -150,9 +150,9 @@
BinaryInfo program;
build (args, ctxt) @{
- Result[] na = args.EvaluateArg ("program");
+ Result[] r = args["program"];
- return new StrongnameProgram ((BinaryInfo) na[0]);
+ return new StrongnameProgram ((BinaryInfo) r[0]);
@}
}
@@ -162,9 +162,9 @@
# TODO: check for support of /package option
build (args, ctxt) @{
- Result[] na = args.EvaluateArg ("program");
+ Result[] r = args["program"];
- return new GacutilProgram ((BinaryInfo) na[0]);
+ return new GacutilProgram ((BinaryInfo) r[0]);
@}
}
@@ -196,10 +196,10 @@
BinaryInfo runtime = /config/clr/runtime;
build (args, ctxt) @{
- Result[] program = args.EvaluateArg ("program");
+ Result[] program = args["program"];
MBFile p = program[0] as MBFile;
- Result[] runtime = args.EvaluateArg ("runtime");
+ Result[] runtime = args["runtime"];
BinaryInfo r = (runtime[0] as BinaryInfo);
return new ClrBinaryInfo (p, r);
@@ -213,19 +213,19 @@
build (args, ctxt)
@{
- Result[] gacutil_na = args.EvaluateArg ("gacutil");
- Result[] rootdir_na = args.EvaluateArg ("rootdir");
- Result[] package_na = args.EvaluateArg ("package");
+ Result[] gacutil = args["gacutil"];
+ Result[] rootdir = args["rootdir"];
+ Result[] package_r = args["package"];
string package;
- if (package_na.Length < 1)
+ if (package_r.Length < 1)
package = null;
else
- package = ((MBString) package_na[0]).Value;
+ package = ((MBString) package_r[0]).Value;
- return new GacutilInstaller ((GacutilProgram)
gacutil_na[0],
- ((MBString) rootdir_na[0]).Value,
+ return new GacutilInstaller ((GacutilProgram)
gacutil[0],
+ ((MBString) rootdir[0]).Value,
package);
@}
}
Modified: trunk/mbuild/MBuildDynamic.Core/Core.bundle
===================================================================
--- trunk/mbuild/MBuildDynamic.Core/Core.bundle 2005-03-04 19:59:54 UTC (rev
41462)
+++ trunk/mbuild/MBuildDynamic.Core/Core.bundle 2005-03-05 06:10:32 UTC (rev
41463)
@@ -65,8 +65,8 @@
# Better place to land this?
result InterpreterBinaryInfo : BinaryInfo {
- dictitem MBFile Program;
- dictitem BinaryInfo Runtime;
+ field MBFile Program;
+ field BinaryInfo Runtime;
@{
Modified: trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs
===================================================================
--- trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs 2005-03-04
19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Monkeywrench/Monkeywrench/WrenchOperations.cs 2005-03-05
06:10:32 UTC (rev 41463)
@@ -111,6 +111,35 @@
return false;
}
+ public static Result FindInstallCompatibleResult (Result res,
IResultInstaller iri) {
+ // Check types. Take into account CompositeResults
+ // (and composites of composites, etc.)
+
+ bool gotit = false;
+
+ while (!gotit) {
+ if (iri.OtherType.IsInstanceOfType (res)) {
+ gotit = true;
+ break;
+ }
+
+ if (!(res is CompositeResult))
+ break;
+
+ CompositeResult cr = (CompositeResult) res;
+
+ if (!cr.HasDefault || cr.Default == null)
+ break;
+
+ res = cr.Default;
+ }
+
+ if (gotit == false)
+ return null;
+
+ return res;
+ }
+
public static bool Install (WrenchProject proj, BuildServices
bs, bool backwards) {
IResultInstaller iri;
@@ -126,13 +155,17 @@
// error already reported
return true;
- if (!iri.OtherType.IsInstanceOfType (res)) {
+ res = FindInstallCompatibleResult (res, iri);
+
+ if (res == null) {
bs.Logger.SetLocation (bs.FullName);
bs.Logger.Error (2031, "Trying to install
result with incompatible installer", iri.OtherType.ToString ());
bs.Logger.SetLocation (null);
return true;
}
-
+
+ // Ok let's do it.
+
try {
bs.Logger.Log ("operation.install",
bs.FullName);
if (backwards)
Modified: trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs 2005-03-04 19:59:54 UTC
(rev 41462)
+++ trunk/mbuild/Mono.Build/Mono.Build/ArgCollector.cs 2005-03-05 06:10:32 UTC
(rev 41463)
@@ -189,15 +189,28 @@
ArgData ad = (ArgData) info[arg];
Type t = r.GetType ();
- if (! TypeIs (t, ad.ai.type)) {
- string s = String.Format ("Argument value
should be of type {0}, but its type is {1}",
- ad.ai.type, t);
- logger.Error (2036, s, r.ToString ());
- return true;
+ if (TypeIs (t, ad.ai.type)) {
+ AddToAD (ad, r, index_into_values);
+ return false;
}
- AddToAD (ad, r, index_into_values);
- return false;
+ // Maybe it is a composite result?
+
+ if (r is CompositeResult) {
+ CompositeResult cr = (CompositeResult) r;
+
+ if (cr.HasDefault) {
+ if (AddInternal (arg, cr.Default,
index_into_values, logger) == false)
+ return false;
+ }
+ }
+
+ // That didn't work either.
+
+ string err = String.Format ("Argument value should be
of type {0}, but its type is {1}",
+ ad.ai.type, t);
+ logger.Error (2036, err, r.ToString ());
+ return true;
}
// adding values
@@ -250,33 +263,51 @@
return false;
}
- if (possible_args.Count == 0) {
- string s = String.Format ("Dependency {0} of
type {1} isn't compatible " +
- "with any defined
arguments.", r, t);
- logger.Error (2034, s, null);
+ if (possible_args.Count > 0) {
+
+ // Several possible choices. Check for a default
+
+ foreach (ArgData ad in possible_args) {
+ if ((ad.ai.flags &
ArgInfoFlags.Default) != 0) {
+ AddToAD (ad, r, -1);
+ return false;
+ }
+ }
+
+ // No dice. Ambiguity not tolerated. Ah,
computers.
+
+ StringBuilder sb = new StringBuilder ();
+ sb.AppendFormat ("Ambiguous dependency {0}
could " +
+ "be one of these arguments:",
t);
+ foreach (ArgData ad in possible_args) {
+ sb.Append (" ");
+ sb.Append (ad.ai.name);
+ }
+
+ logger.Error (2035, sb.ToString (), r.ToString
());
return true;
}
- // Still ambiguous, see if one is the default.
+ // Maybe this is a composite result, and it has a
default?
- foreach (ArgData ad in possible_args) {
- if ((ad.ai.flags & ArgInfoFlags.Default) != 0) {
- AddToAD (ad, r, -1);
- return false;
+ if (r is CompositeResult) {
+ CompositeResult cr = (CompositeResult) r;
+
+ if (cr.HasDefault) {
+ if (Add (cr.Default, logger) == false)
+ return false;
+
+ // if that didn't work, continue
+ // and give a warning about the
container
+ // Result, not the default.
}
}
// Bummer.
- StringBuilder sb = new StringBuilder ();
- sb.AppendFormat ("Ambiguous dependency {0} could " +
- "be one of these arguments:", t);
- foreach (ArgData ad in possible_args) {
- sb.Append (" ");
- sb.Append (ad.ai.name);
- }
-
- logger.Error (2035, sb.ToString (), r.ToString ());
+ string s = String.Format ("Dependency {0} of type {1}
isn't compatible " +
+ "with any defined
arguments.", r, t);
+ logger.Error (2034, s, null);
return true;
}
Modified: trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs 2005-03-04
19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Mono.Build/Mono.Build/CompositeFingerprint.cs 2005-03-05
06:10:32 UTC (rev 41463)
@@ -20,6 +20,24 @@
this.children = (Fingerprint[]) children.Clone ();
}
+ public CompositeFingerprint (Result[] r, IBuildContext ctxt,
Fingerprint cached) : base () {
+ children = new Fingerprint[r.Length];
+
+ if (cached is CompositeFingerprint) {
+ CompositeFingerprint cf = cached as
CompositeFingerprint;
+
+ for (int i = 0; i < children.Length; i++) {
+ if (r[i] != null)
+ children[i] =
r[i].GetFingerprint (ctxt, cf.children[i]);
+ }
+ } else {
+ for (int i = 0; i < children.Length; i++) {
+ if (r[i] != null)
+ children[i] =
r[i].GetFingerprint (ctxt, null);
+ }
+ }
+ }
+
public CompositeFingerprint (IDictionary dict) : base () {
// What a sweet constructor!
SortedList sl = new SortedList (dict);
@@ -54,7 +72,12 @@
byte[] data = new byte[count * PreferredHash.Size];
for (int i = 0; i < count; i++) {
- byte[] fp = children[i].Value;
+ Fingerprint item = children[i];
+
+ if (item == null)
+ item = GenericFingerprints.Null;
+
+ byte[] fp = item.Value;
fp.CopyTo (data, PreferredHash.Size * i);
}
Modified: trunk/mbuild/Mono.Build/Mono.Build.RuleLib/BinaryInfo.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build.RuleLib/BinaryInfo.cs 2005-03-04
19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Mono.Build/Mono.Build.RuleLib/BinaryInfo.cs 2005-03-05
06:10:32 UTC (rev 41463)
@@ -14,13 +14,15 @@
namespace Mono.Build.RuleLib {
[Serializable]
- public abstract class BinaryInfo : MBDictionary {
+ public abstract class BinaryInfo : CompositeResult {
- protected const string Env = "env_";
+ MBDictionary environment;
// Construction
- public BinaryInfo () : base () {}
+ public BinaryInfo () : base () {
+ environment = new MBDictionary ();
+ }
// abstract bits
@@ -34,24 +36,39 @@
return "";
}
- // Generic
+ // CompositeResult
- public string ForcedArgs {
- get {
- return GetString ("forced_args");
- }
+ protected override int TotalItems {
+ get { return base.TotalItems + 2; }
+ }
- set {
- SetString ("forced_args", value);
- }
+ protected override void CopyItems (Result[] r) {
+ int t = base.TotalItems;
+
+ base.CopyItems (r);
+ r[t] = new MBString (ForcedArgs);
+ r[t + 1] = environment;
}
+ // Result
+
+ protected override void CloneTo (Result r) {
+ BinaryInfo other = (BinaryInfo) r;
+
+ other.ForcedArgs = ForcedArgs;
+ other.environment = (MBDictionary) environment.Clone ();
+ }
+
+ // Generic
+
+ public string ForcedArgs;
+
public string GetEnvironment (string var) {
- return GetString (Env + var);
+ return environment.GetString (var);
}
public void SetEnvironment (string var, string val) {
- SetString (Env + var, val);
+ environment.SetString (var, val);
}
public IEnumerable EnvironmentKeys { get { return new
EnvironmentEnumerable (this); } }
@@ -102,38 +119,8 @@
}
public IEnumerator GetEnumerator () {
- return new EnvironmentEnumerator (info);
+ return info.environment.GetEnumerator ();
}
}
-
- class EnvironmentEnumerator : IEnumerator {
- IEnumerator key_enum;
-
- public EnvironmentEnumerator (BinaryInfo info) {
- key_enum = info.Keys.GetEnumerator ();
- }
-
- public object Current {
- get {
- string key = (string) key_enum.Current;
- return key.Substring (Env.Length);
- }
- }
-
- public bool MoveNext () {
- while (key_enum.MoveNext ()) {
- string key = (string) key_enum.Current;
-
- if (key.StartsWith (Env))
- return true;
- }
-
- return false;
- }
-
- public void Reset () {
- key_enum.Reset ();
- }
- }
}
}
Modified: trunk/mbuild/Mono.Build/Mono.Build.RuleLib/CopyInstaller.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build.RuleLib/CopyInstaller.cs 2005-03-04
19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Mono.Build/Mono.Build.RuleLib/CopyInstaller.cs 2005-03-05
06:10:32 UTC (rev 41463)
@@ -10,7 +10,7 @@
namespace Mono.Build.RuleLib {
[Serializable]
- public class CopyInstaller : MBDictionary, IResultInstaller {
+ public class CopyInstaller : CompositeResult, IResultInstaller {
// one might expect destdir to be an MBDirectory. However,
// the directory that we install to might not exist in advance;
@@ -27,14 +27,23 @@
// Public
- const string destdir_key = "CopyInstaller::DestDir";
+ public string DestDir;
- public string DestDir {
- get { return GetString (destdir_key); }
+ // CompositeResult
- set { SetString (destdir_key, value); }
+ protected override int TotalItems { get { return
base.TotalItems + 1; } }
+
+ protected override void CopyItems (Result[] r) {
+ r[base.TotalItems] = new MBString (DestDir);
}
+ protected override void CloneTo (Result r) {
+ CopyInstaller other = (CopyInstaller) r;
+
+ base.CloneTo (r);
+ other.DestDir = DestDir;
+ }
+
// Implementation
protected virtual string GetDestName (MBFile file, MBDirectory
dest, IBuildContext ctxt) {
Modified: trunk/mbuild/Mono.Build/Mono.Build.RuleLib/ExternalBinaryInfo.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build.RuleLib/ExternalBinaryInfo.cs
2005-03-04 19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Mono.Build/Mono.Build.RuleLib/ExternalBinaryInfo.cs
2005-03-05 06:10:32 UTC (rev 41463)
@@ -61,16 +61,29 @@
return info;
}
- public string Program {
- get {
- return GetString ("program");
- }
+ // CompositeResult
- set {
- SetString ("program", value);
- }
+ public string Program;
+
+ protected override int TotalItems {
+ get { return base.TotalItems + 1; }
}
+ protected override void CopyItems (Result[] r) {
+ int t = base.TotalItems;
+
+ base.CopyItems (r);
+ r[t] = new MBString (Program);
+ }
+
+ // Result
+
+ protected override void CloneTo (Result r) {
+ ExternalBinaryInfo ebi = (ExternalBinaryInfo) r;
+
+ ebi.Program = Program;
+ }
+
// implementation
public override string GetProgram (IBuildContext ctxt) {
Modified: trunk/mbuild/Mono.Build/Mono.Build.RuleLib/FileBinaryInfo.cs
===================================================================
--- trunk/mbuild/Mono.Build/Mono.Build.RuleLib/FileBinaryInfo.cs
2005-03-04 19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Mono.Build/Mono.Build.RuleLib/FileBinaryInfo.cs
2005-03-05 06:10:32 UTC (rev 41463)
@@ -25,20 +25,31 @@
ForcedArgs = args;
}
- public MBFile Program {
- get {
- object o = this["program"];
+ // CompositeResult
- if (o == null)
- return null;
- return (MBFile) o;
- }
+ protected override int TotalItems {
+ get { return base.TotalItems + 1; }
+ }
- set {
- this["program"] = value;
- }
+ protected override void CopyItems (Result[] r) {
+ int t = base.TotalItems;
+
+ base.CopyItems (r);
+ r[t] = Program;
}
+ // Result
+
+ protected override void CloneTo (Result r) {
+ FileBinaryInfo fbi = (FileBinaryInfo) r;
+
+ fbi.Program = (MBFile) Program.Clone ();
+ }
+
+ // Real stuff
+
+ public MBFile Program;
+
public override string GetProgram (IBuildContext ctxt) {
if (ctxt == null)
return Program.ToString ();
Modified: trunk/mbuild/Mono.Build.dll.sources
===================================================================
--- trunk/mbuild/Mono.Build.dll.sources 2005-03-04 19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Mono.Build.dll.sources 2005-03-05 06:10:32 UTC (rev 41463)
@@ -5,6 +5,7 @@
Mono.Build/Mono.Build/ArgInfoFlags.cs
Mono.Build/Mono.Build/BuildFingerprint.cs
Mono.Build/Mono.Build/CompositeFingerprint.cs
+Mono.Build/Mono.Build/CompositeResult.cs
Mono.Build/Mono.Build/ConstantFingerprint.cs
Mono.Build/Mono.Build/ConstantRule.cs
Mono.Build/Mono.Build/ConstantTarget.cs
Modified: trunk/mbuild/Tools.Monodoc.bundle
===================================================================
--- trunk/mbuild/Tools.Monodoc.bundle 2005-03-04 19:59:54 UTC (rev 41462)
+++ trunk/mbuild/Tools.Monodoc.bundle 2005-03-05 06:10:32 UTC (rev 41463)
@@ -39,9 +39,9 @@
# The program
- result MonodocProgram : MBDictionary {
+ result MonodocProgram : CompositeResult {
- dictitem BinaryInfo Binary;
+ field BinaryInfo Binary;
@{
@@ -78,11 +78,11 @@
@}
}
- result MonodocFiles : MBDictionary {
- dictitem BinFile ZipFile;
- dictitem BinFile TreeFile;
- dictitem MBString ProviderKind;
- dictitem MBString NodePath;
+ result MonodocFiles : CompositeResult {
+ field BinFile ZipFile;
+ field BinFile TreeFile;
+ field MBString ProviderKind;
+ field MBString NodePath;
}
result MonodocFilesInstaller : CopyInstaller {
Modified: trunk/mbuild/mb-bundlegen/Parser.jay
===================================================================
--- trunk/mbuild/mb-bundlegen/Parser.jay 2005-03-04 19:59:54 UTC (rev
41462)
+++ trunk/mbuild/mb-bundlegen/Parser.jay 2005-03-05 06:10:32 UTC (rev
41463)
@@ -100,6 +100,16 @@
StringBuilder dict_hashtext = null;
+ // CompositeResults
+
+ int composite_seq = 0;
+ bool composite_saw_default = false;
+ CodeMemberMethod composite_copy;
+ CodeMemberMethod composite_clone;
+ CodeArgumentReferenceExpression composite_arg;
+ CodeVariableReferenceExpression composite_total;
+ CodeVariableReferenceExpression composite_other;
+
// public
public Parser (StreamReader reader, string file)
@@ -257,6 +267,143 @@
rt_tags.Statements.Add (ifstmt);
}
+ void InitCompositeMembers () {
+ if (composite_copy != null)
+ return;
+
+ composite_seq = 0;
+
+ CodeParameterDeclarationExpression p = new
CodeParameterDeclarationExpression ();
+ p.Name = "r";
+ p.Type = new CodeTypeReference (tr_result, 1);
+
+ composite_copy = new CodeMemberMethod ();
+ composite_copy.Name = "CopyItems";
+ composite_copy.ReturnType = null;
+ composite_copy.Parameters.Add (p);
+ composite_copy.Attributes = MemberAttributes.Family |
MemberAttributes.Override;
+
+ composite_arg = new CodeArgumentReferenceExpression
(p.Name);
+
+ CodeVariableDeclarationStatement vds = new
CodeVariableDeclarationStatement ();
+ vds.Name = "base_total";
+ vds.Type = new CodeTypeReference (typeof (int));
+ vds.InitExpression = new
CodePropertyReferenceExpression (expr_base, "TotalItems");
+
+ composite_total = new CodeVariableReferenceExpression
(vds.Name);
+
+ composite_copy.Statements.Add (vds);
+
+ CodeMethodInvokeExpression mie = new
CodeMethodInvokeExpression (expr_base, "CopyItems",
+ new CodeExpression[] { composite_arg });
+ composite_copy.Statements.Add (new
CodeExpressionStatement (mie));
+
+ // CloneTo method
+
+ p = new CodeParameterDeclarationExpression ();
+ p.Name = "r";
+ p.Type = tr_result;
+
+ composite_clone = new CodeMemberMethod ();
+ composite_clone.Name = "CloneTo";
+ composite_clone.ReturnType = null;
+ composite_clone.Parameters.Add (p);
+ composite_clone.Attributes = MemberAttributes.Family |
MemberAttributes.Override;
+
+ CodeTypeReference tr_self = new CodeTypeReference
(cur_type.Name);
+ CodeArgumentReferenceExpression cp = new
CodeArgumentReferenceExpression (p.Name);
+
+ vds = new CodeVariableDeclarationStatement ();
+ vds.Name = "other";
+ vds.Type = tr_self;
+ vds.InitExpression = new CodeCastExpression (tr_self,
cp);
+
+ composite_clone.Statements.Add (vds);
+ composite_other = new CodeVariableReferenceExpression
(vds.Name);
+
+ mie = new CodeMethodInvokeExpression (expr_base,
"CloneTo",
+ new CodeExpression[] { cp });
+ composite_clone.Statements.Add (new
CodeExpressionStatement (mie));
+
+ }
+
+ void SetupDefaultCompositeField (CodeMemberField f) {
+ if (composite_saw_default)
+ throw new Exception ("Trying to give more than
one default field in composite.");
+
+ composite_saw_default = true;
+
+ // Override the HasDefault property
+
+ CodeMemberProperty p = new CodeMemberProperty ();
+ p.Name = "HasDefault";
+ p.Attributes = MemberAttributes.Public |
MemberAttributes.Override;
+ p.Type = new CodeTypeReference (typeof (bool));
+ p.HasGet = true;
+ p.HasSet = false;
+ p.GetStatements.Add (new CodeMethodReturnStatement (new
CodePrimitiveExpression (true)));
+
+ cur_type.Members.Add (p);
+
+ // Override the Default property
+
+ p = new CodeMemberProperty ();
+ p.Name = "Default";
+ p.Attributes = MemberAttributes.Public |
MemberAttributes.Override;
+ p.Type = tr_result;
+ p.HasGet = true;
+ p.HasSet = false;
+ CodeExpression e = new CodeFieldReferenceExpression
(expr_this, f.Name);
+ p.GetStatements.Add (new CodeMethodReturnStatement (e));
+
+ cur_type.Members.Add (p);
+
+ }
+
+ void FinishCompositeMembers () {
+ if (composite_copy == null)
+ throw new Exception ("Finish composite members
without members?");
+
+ composite_copy.Statements.Add (new
CodeMethodReturnStatement ());
+
+ cur_type.Members.Add (composite_copy);
+
+ // CloneTo impl
+
+ composite_clone.Statements.Add (new
CodeMethodReturnStatement ());
+
+ cur_type.Members.Add (composite_clone);
+
+ // Add the TotalItems override
+
+ CodeMemberProperty p = new CodeMemberProperty ();
+ p.Name = "TotalItems";
+ p.HasGet = true;
+ p.HasSet = false;
+ p.Type = new CodeTypeReference (typeof (int));
+ p.Attributes = MemberAttributes.Family |
MemberAttributes.Override;
+
+ CodeBinaryOperatorExpression add = new
CodeBinaryOperatorExpression ();
+ add.Left = new CodePropertyReferenceExpression
(expr_base, "TotalItems");
+ add.Operator = CodeBinaryOperatorType.Add;
+ add.Right = new CodePrimitiveExpression (composite_seq);
+
+ CodeStatement ret = new CodeMethodReturnStatement (add);
+ p.GetStatements.Add (ret);
+
+ cur_type.Members.Add (p);
+
+ // Cleanup
+
+ composite_seq = 0;
+ composite_saw_default = false;
+ composite_copy = null;
+ composite_clone = null;
+ composite_arg = null;
+ composite_total = null;
+ composite_other = null;
+ }
+
%}
// stuff copied from cs-parser.jay
@@ -286,6 +433,7 @@
%token ABSTRACT
%token DICTITEM
%token ORDERED
+%token FIELD
// punctuation
@@ -403,6 +551,8 @@
CodeAttributeDeclaration attr = new CodeAttributeDeclaration
("System.Serializable");
cur_type.CustomAttributes.Add (attr);
+
+ composite_seq = 0;
}
opt_baseclass OPEN_BRACE opt_in_result_statements CLOSE_BRACE
{
@@ -415,6 +565,9 @@
dict_hashtext = null;
}
+ if (composite_copy != null)
+ FinishCompositeMembers ();
+
cur_ns.Types.Add (cur_type);
cur_type = null;
}
@@ -434,6 +587,7 @@
: native_member
| implements_statement
| dictitem_declaration
+ | field_declaration
;
dictitem_declaration
@@ -506,6 +660,56 @@
}
;
+field_declaration
+ : opt_default_kw FIELD classname IDENTIFIER SEMICOLON
+ {
+ string name = (string) $4;
+ string klass = (string) $3;
+ bool want_default = (bool) $1;
+ CodeLinePragma line = lexer.LinePragma;
+
+ CodeMemberField f = new CodeMemberField ();
+ f.Name = name;
+ f.Attributes = MemberAttributes.Public;
+ f.LinePragma = line;
+ f.Type = new CodeTypeReference (klass);
+
+ InitCompositeMembers ();
+
+ // Add statement to copy result in CopyItems
+
+ CodeBinaryOperatorExpression add = new
CodeBinaryOperatorExpression ();
+ add.Left = composite_total;
+ add.Operator = CodeBinaryOperatorType.Add;
+ add.Right = new CodePrimitiveExpression (composite_seq);
+
+ CodeIndexerExpression index = new CodeIndexerExpression ();
+ index.TargetObject = composite_arg;
+ index.Indices.Add (add);
+
+ CodeFieldReferenceExpression fld = new
CodeFieldReferenceExpression (expr_this, name);
+ CodeMethodInvokeExpression conv = new
CodeMethodInvokeExpression (expr_this, "FieldAsResult",
+ new CodeExpression[] { fld });
+ CodeAssignStatement assg = new CodeAssignStatement (index,
conv);
+
+ composite_copy.Statements.Add (assg);
+ composite_seq++;
+
+ cur_type.Members.Add (f);
+
+ // Add statement to clone result in CloneItems
+
+ CodeFieldReferenceExpression lhs = new
CodeFieldReferenceExpression (composite_other, name);
+ conv = new CodeMethodInvokeExpression (expr_this, "CloneField",
+ new CodeExpression[] { fld });
+ assg = new CodeAssignStatement (lhs, new CodeCastExpression
(f.Type, conv));
+ composite_clone.Statements.Add (assg);
+
+ if (want_default)
+ SetupDefaultCompositeField (f);
+ }
+ ;
+
/* Provider */
provider_statement
@@ -1194,9 +1398,15 @@
string name = (string) $1;
// Limit un-banged full-name references to be within the MBuild
namespace
+ // If the ident is eg "string", CodeDom will try to outsmart us
and write
+ // "@string", so fake it out.
if (name.IndexOf ('.') != -1)
$$ = MBuildNamespace (name);
+ else if (name == "bool")
+ $$ = "System.Boolean";
+ else if (name == "string")
+ $$ = "System.String";
else
$$ = name;
}
Modified: trunk/mbuild/mb-bundlegen/Tokenizer.cs
===================================================================
--- trunk/mbuild/mb-bundlegen/Tokenizer.cs 2005-03-04 19:59:54 UTC (rev
41462)
+++ trunk/mbuild/mb-bundlegen/Tokenizer.cs 2005-03-05 06:10:32 UTC (rev
41463)
@@ -96,6 +96,7 @@
keywords["abstract"] = Token.ABSTRACT;
keywords["dictitem"] = Token.DICTITEM;
keywords["ordered"] = Token.ORDERED;
+ keywords["field"] = Token.FIELD;
}
// StreamReader.Peek () will return -1 on EOS or if the buffer
Modified: trunk/mbuild/mbuild/mbuild.cs
===================================================================
--- trunk/mbuild/mbuild/mbuild.cs 2005-03-04 19:59:54 UTC (rev 41462)
+++ trunk/mbuild/mbuild/mbuild.cs 2005-03-05 06:10:32 UTC (rev 41463)
@@ -274,7 +274,8 @@
// error already reported
return true;
- if (!iri.OtherType.IsInstanceOfType (res)) {
+ res = WrenchOperations.FindInstallCompatibleResult (res, iri);
+ if (res == null) {
bs.Logger.SetLocation (bs.FullName);
bs.Logger.Error (2031, "Trying to install result with
incompatible installer", iri.OtherType.ToString ());
bs.Logger.SetLocation (null);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches