Skip to content

Commit

Permalink
Update xbuild and Microsoft.Build.* from trunk.
Browse files Browse the repository at this point in the history
In tools/xbuild:
	* xbuild/Microsoft.Common.targets: Remove dummy
	@(_TargetPathItem), since we support item refs with transforms
	as a property value.

2009-08-26  Ankit Jain  <jankit@novell.com>

In class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks:
	* CreateItemTest.cs (TestVariableExpansion): Update test to
	use a transform with a item reference in a property.

2009-08-26  Ankit Jain  <jankit@novell.com>

In class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine:
	* Expression.cs: Correctly handle a item reference with transform
	when allowItems is false. If item ref is ignored, then the transform
	will get incorrectly matched as a metadata ref.
	* ItemReference.cs (.ctor): Add a @original_string param.

2009-08-26  Ankit Jain  <jankit@novell.com>

	* Utilities.cs (UnescapeFromXml): New. From md.
	* BuildProperty.cs (.ctor): Unescape xml codes from the InnerXml
	of the property element.

2009-08-26  Ankit Jain  <jankit@novell.com>


svn path=/branches/mono-2-4-2/mcs/; revision=140704
  • Loading branch information
radical committed Aug 26, 2009
1 parent d9696a1 commit eb787cd
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 18 deletions.
Expand Up @@ -76,7 +76,7 @@ internal BuildProperty (Project parentProject, XmlElement propertyElement)
this.propertyType = PropertyType.Normal;
this.parentProject = parentProject;
this.name = propertyElement.Name;
this.value = propertyElement.InnerXml;
this.value = Utilities.UnescapeFromXml (propertyElement.InnerXml);
this.isImported = false;
}

Expand Down
@@ -1,3 +1,16 @@
2009-08-26 Ankit Jain <jankit@novell.com>

* Expression.cs: Correctly handle a item reference with transform
when allowItems is false. If item ref is ignored, then the transform
will get incorrectly matched as a metadata ref.
* ItemReference.cs (.ctor): Add a @original_string param.

2009-08-26 Ankit Jain <jankit@novell.com>

* Utilities.cs (UnescapeFromXml): New. From md.
* BuildProperty.cs (.ctor): Unescape xml codes from the InnerXml
of the property element.

2009-08-26 Ankit Jain <jankit@novell.com>

* BuildProperty.cs (ConvertToString): New.
Expand Down
Expand Up @@ -97,7 +97,7 @@ public void Parse (string expression, bool allowItems, bool split)
}
}

CopyToExpressionCollection (p3);
CopyToExpressionCollection (p3, allowItems);
}

void Prepare (List <ArrayList> l, int length)
Expand All @@ -106,12 +106,14 @@ void Prepare (List <ArrayList> l, int length)
l.Add (null);
}

void CopyToExpressionCollection (List <ArrayList> lists)
void CopyToExpressionCollection (List <ArrayList> lists, bool allowItems)
{
for (int i = 0; i < lists.Count; i++) {
foreach (object o in lists [i]) {
if (o is string)
expressionCollection.Add (Utilities.Unescape ((string) o));
else if (!allowItems && o is ItemReference)
expressionCollection.Add (((ItemReference) o).OriginalString);
else if (o is IReference)
expressionCollection.Add ((IReference) o);
}
Expand All @@ -122,13 +124,6 @@ void CopyToExpressionCollection (List <ArrayList> lists)

ArrayList SplitItems (string text, bool allowItems)
{
if (!allowItems) {
// FIXME: it's probably larger than 1
ArrayList l = new ArrayList ();
l.Add (text);
return l;
}

ArrayList phase1 = new ArrayList ();
Match m;
m = ItemRegex.Match (text);
Expand All @@ -145,7 +140,8 @@ ArrayList SplitItems (string text, bool allowItems)
if (m.Groups [ItemRegex.GroupNumberFromName ("has_separator")].Success)
separator = m.Groups [ItemRegex.GroupNumberFromName ("separator")].Value;

ir = new ItemReference (name, transform, separator, m.Groups [0].Index, m.Groups [0].Length);
ir = new ItemReference (text.Substring (m.Groups [0].Index, m.Groups [0].Length),
name, transform, separator, m.Groups [0].Index, m.Groups [0].Length);
phase1.Add (ir);
m = m.NextMatch ();
}
Expand Down
Expand Up @@ -39,12 +39,14 @@ internal class ItemReference : IReference {
Expression separator;
int start;
int length;
string original_string;

public ItemReference (string itemName, string transform, string separator, int start, int length)
public ItemReference (string original_string, string itemName, string transform, string separator, int start, int length)
{
this.itemName = itemName;
this.start = start;
this.length = length;
this.original_string = original_string;

if (transform != null) {
this.transform = new Expression ();
Expand Down Expand Up @@ -88,6 +90,10 @@ public string ConvertToString (Project project)
get { return separator; }
}

public string OriginalString {
get { return original_string; }
}

public int Start {
get { return start; }
}
Expand All @@ -98,8 +104,7 @@ public string ConvertToString (Project project)

public override string ToString ()
{
//FIXME: transform
return "@" + itemName;
return original_string;
}
}
}
Expand Down
Expand Up @@ -4,6 +4,7 @@
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
// Lluis Sanchez Gual <lluis@novell.com>
// Michael Hutchinson <mhutchinson@novell.com>
//
// (C) 2005 Marek Sieradzki
// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
Expand Down Expand Up @@ -81,6 +82,43 @@ internal static string Unescape (string escapedExpression)
return sb.ToString ();
}

internal static string UnescapeFromXml (string text)
{
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < text.Length; i++) {
char c1 = text[i];
if (c1 == '&') {
int end = text.IndexOf (';', i);
if (end == -1)
throw new FormatException ("Unterminated XML entity.");
string entity = text.Substring (i+1, end - i - 1);
switch (entity) {
case "lt":
sb.Append ('<');
break;
case "gt":
sb.Append ('>');
break;
case "amp":
sb.Append ('&');
break;
case "apos":
sb.Append ('\'');
break;
case "quot":
sb.Append ('"');
break;
default:
throw new FormatException ("Unrecogised XML entity '&" + entity + ";'.");
}
i = end;
} else
sb.Append (c1);
}
return sb.ToString ();
}


internal static string FromMSBuildPath (string relPath)
{
if (relPath == null || relPath.Length == 0)
Expand Down
@@ -1,3 +1,8 @@
2009-08-26 Ankit Jain <jankit@novell.com>

* CreateItemTest.cs (TestVariableExpansion): Update test to
use a transform with a item reference in a property.

2009-08-26 Ankit Jain <jankit@novell.com>

* CreateItemTest.cs (TestVariableExpansion): New.
Expand Down
Expand Up @@ -199,7 +199,7 @@ public void TestVariableExpansion ()
<P1>FooP1</P1>
<P2>FooP2</P2>
<C>@(IG)</C>
<P3>@(Nine)</P3>
<P3>@(Nine->'%(Identity)')</P3>
</PropertyGroup>
<ItemGroup>
<Nine Include=""Nine""/>
Expand Down Expand Up @@ -247,7 +247,7 @@ public void TestVariableExpansion ()
Assert.AreEqual ("Eight", include[3].FinalItemSpec, "A#6");
Assert.AreEqual ("Nine", include[4].FinalItemSpec, "A#7");

testLogger.CheckLoggedMessageHead ("C: Abc;FooP1;FooP2;Eight;Nine", "A#10");
testLogger.CheckLoggedMessageHead ("C: Abc;FooP1;FooP2;Eight;Nine", "A#9");
testLogger.CheckLoggedMessageHead ("items: Abc;FooP1;FooP2;Eight;Nine", "A#10");

}
Expand Down
6 changes: 6 additions & 0 deletions mcs/tools/xbuild/ChangeLog
@@ -1,3 +1,9 @@
2009-08-26 Ankit Jain <jankit@novell.com>

* xbuild/Microsoft.Common.targets: Remove dummy
@(_TargetPathItem), since we support item refs with transforms
as a property value.

2009-08-26 Ankit Jain <jankit@novell.com>

Fix bug #533903.
Expand Down
3 changes: 1 addition & 2 deletions mcs/tools/xbuild/xbuild/Microsoft.Common.targets
Expand Up @@ -44,11 +44,10 @@

<!-- creating this as a item to use FullPath on it, to build TargetPath -->
<_OutDirItem Include="$(OutDir)"/>
<_TargetPathItem Include="@(_OutDirItem->'%(FullPath)\$(AssemblyName)$(TargetExt)')" />
</ItemGroup>

<PropertyGroup>
<TargetPath>@(_TargetPathItem)</TargetPath>
<TargetPath>@(_OutDirItem->'%(FullPath)\$(AssemblyName)$(TargetExt)')</TargetPath>
</PropertyGroup>

<Target Name="PrepareForBuild">
Expand Down

0 comments on commit eb787cd

Please sign in to comment.