From ecea1d6bb5643017d0d0cc87be5a4d34b9352b5d Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 19 Feb 2010 11:51:19 +0000 Subject: [PATCH] In class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine: * BuildItem.cs: Track api changes. (SetMetadata): Allow RecursiveDir to be set, this is set by DirectoryScanner. * DirectoryScanner.cs (ProcessInclude): Set RecursiveDir metadata. In class/Microsoft.Build.Engine/Test/various: * Items.cs (TestItemsWithWildcards): Check for RecursiveDir metadata also. In class/Microsoft.Build.Utilities/Microsoft.Build.Utilities: * TaskItem.cs: Track api changes. In class/Microsoft.Build.Utilities/Mono.XBuild.Utilities: * ReservedNameUtils.cs (GetReservedMetadata): Add dictionary param @metadata. Use this to check for existing value of "RecursiveDir" metadata, use that if present. svn path=/trunk/mcs/; revision=152067 --- .../Microsoft.Build.BuildEngine/BuildItem.cs | 4 +-- .../Microsoft.Build.BuildEngine/ChangeLog | 7 +++++ .../DirectoryScanner.cs | 6 ++++ .../Microsoft.Build.Engine/Test/various/ChangeLog | 4 +++ .../Microsoft.Build.Engine/Test/various/Items.cs | 34 ++++++++++++++++------ .../Microsoft.Build.Utilities/ChangeLog | 4 +++ .../Microsoft.Build.Utilities/TaskItem.cs | 7 +++-- .../Mono.XBuild.Utilities/ChangeLog | 6 ++++ .../Mono.XBuild.Utilities/ReservedNameUtils.cs | 10 ++++--- 9 files changed, 65 insertions(+), 17 deletions(-) diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs index 3112a462ce7..a4a0ac6f95d 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildItem.cs @@ -126,7 +126,7 @@ namespace Microsoft.Build.BuildEngine { public string GetEvaluatedMetadata (string metadataName) { if (ReservedNameUtils.IsReservedMetadataName (metadataName)) { - string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName); + string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, evaluatedMetadata); return (metadataName.ToLower () == "fullpath") ? Utilities.Escape (metadata) : metadata; } @@ -139,7 +139,7 @@ namespace Microsoft.Build.BuildEngine { public string GetMetadata (string metadataName) { if (ReservedNameUtils.IsReservedMetadataName (metadataName)) { - string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName); + string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, unevaluatedMetadata); return (metadataName.ToLower () == "fullpath") ? Utilities.Escape (metadata) : metadata; } else if (unevaluatedMetadata.Contains (metadataName)) return (string) unevaluatedMetadata [metadataName]; diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog index f588ba8ca3d..2e4b799e8e0 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog @@ -1,5 +1,12 @@ 2010-02-19 Ankit Jain + * BuildItem.cs: Track api changes. + (SetMetadata): Allow RecursiveDir to be set, this is set by + DirectoryScanner. + * DirectoryScanner.cs (ProcessInclude): Set RecursiveDir metadata. + +2010-02-19 Ankit Jain + * Import.cs (Evaluate): Add param @ignoreMissingImports. * Project.cs (Load*): Add overloads with param @projectLoadSettings. (Log*): Mark internal. diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs index 22f8be82d2d..904a979b851 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs @@ -106,12 +106,18 @@ namespace Microsoft.Build.BuildEngine { offset = 1; } + string full_path = Path.GetFullPath (Path.Combine (Environment.CurrentDirectory, include_item.ItemSpec)); fileInfo = ParseIncludeExclude (separatedPath, offset, baseDirectory); + int wildcard_offset = full_path.IndexOf ("**"); foreach (FileInfo fi in fileInfo) { if (!excludedItems.ContainsKey (fi.FullName)) { TaskItem item = new TaskItem (include_item); item.ItemSpec = fi.FullName; + string rec_dir = Path.GetDirectoryName (fi.FullName.Substring (wildcard_offset)); + if (rec_dir.Length > 0) + rec_dir += Path.DirectorySeparatorChar; + item.SetMetadata ("RecursiveDir", rec_dir); includedItems.Add (item); } } diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog b/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog index 17dce4392b4..d459cc724b0 100644 --- a/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog +++ b/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog @@ -1,3 +1,7 @@ +2010-02-19 Ankit Jain + + * Items.cs (TestItemsWithWildcards): Check for RecursiveDir metadata also. + 2009-12-22 Ankit Jain * Items.cs (TestItemsWithWildcards): Add Exclude also, update diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs b/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs index 7914b1140b9..caf27575437 100755 --- a/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs +++ b/mcs/class/Microsoft.Build.Engine/Test/various/Items.cs @@ -865,6 +865,8 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { CheckItems (proj, "I2", "A7", "A A", "B B", "C C"); } + + [Test] [Category ("NotWorking")] public void TestItemsInTarget2 () @@ -1420,12 +1422,13 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { '%(FullPath)')"" /> - + + - + "; @@ -1434,16 +1437,29 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various { string projectdir = Path.Combine ("Test", "resources"); File.WriteAllText (Path.Combine (projectdir, "wild1.proj"), documentString); proj.Load (Path.Combine (projectdir, "wild1.proj")); - if (!proj.Build ("Main")) + if (!proj.Build ("Main")) { + logger.DumpMessages (); Assert.Fail ("Build failed"); - + } string full_base_dir = Path.GetFullPath (basedir); - foreach (string prefix in new string[] { "ItemsRelExpanded: ", "ItemsAbs: " }) { - logger.CheckLoggedAny (prefix + PathCombine (full_base_dir, aaa, "foo.dll"), - MessageImportance.Normal, "A1"); - logger.CheckLoggedAny (prefix + PathCombine (full_base_dir, bb, "bar.dll"), MessageImportance.Normal, "A2"); - } + logger.CheckLoggedAny (@"ItemsRel: "+ PathCombine (full_base_dir, aaa, "foo.dll") + + " RecDir: " + aaa + Path.DirectorySeparatorChar, MessageImportance.Normal, "A1"); + + logger.CheckLoggedAny (@"ItemsRel: " + PathCombine (full_base_dir, bb, "bar.dll") + + " RecDir: " + bb + Path.DirectorySeparatorChar, MessageImportance.Normal, "A2"); + + logger.CheckLoggedAny (@"ItemsRelExpanded: " + PathCombine (full_base_dir, aaa, "foo.dll"), MessageImportance.Normal, "A3"); + logger.CheckLoggedAny (@"ItemsRelExpanded: " + PathCombine (full_base_dir, bb, "bar.dll"), MessageImportance.Normal, "A4"); + + logger.CheckLoggedAny (@"ItemsAbs: " + PathCombine (full_base_dir, aaa, "foo.dll") + + @" RecDir: " + aaa + Path.DirectorySeparatorChar, MessageImportance.Normal, "A5"); + logger.CheckLoggedAny (@"ItemsAbs: " + PathCombine (full_base_dir, bb, "bar.dll") + + @" RecDir: " + bb + Path.DirectorySeparatorChar, MessageImportance.Normal, "A6"); + logger.CheckLoggedAny (@"ItemsAbs: " + PathCombine (full_base_dir, "xyz.dll") + + @" RecDir: ", MessageImportance.Normal, "A7"); + + Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found"); } catch (AssertionException) { logger.DumpMessages (); throw; diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog index 4053ed9923a..d7f994b30d9 100644 --- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog +++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog @@ -1,3 +1,7 @@ +2010-02-19 Ankit Jain + + * TaskItem.cs: Track api changes. + 2010-02-10 Ankit Jain * ProcessService.cs (globalEnvironmentVariablesOverride): Use diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TaskItem.cs b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TaskItem.cs index 84183dc6394..d917d3e6a35 100644 --- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TaskItem.cs +++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TaskItem.cs @@ -105,7 +105,7 @@ namespace Microsoft.Build.Utilities public string GetMetadata (string metadataName) { if (ReservedNameUtils.IsReservedMetadataName (metadataName)) - return ReservedNameUtils.GetReservedMetadata (ItemSpec, metadataName); + return ReservedNameUtils.GetReservedMetadata (ItemSpec, metadataName, metadata); else if (metadata.Contains (metadataName)) return (string) metadata [metadataName]; else @@ -133,7 +133,10 @@ namespace Microsoft.Build.Utilities throw new ArgumentNullException ("metadataName"); if (metadataValue == null) throw new ArgumentNullException ("metadataValue"); - if (ReservedNameUtils.IsReservedMetadataName (metadataName)) + + // allow RecursiveDir to be set, it gets set by DirectoryScanner + if (String.Compare (metadataName, "RecursiveDir", StringComparison.InvariantCultureIgnoreCase) != 0 && + ReservedNameUtils.IsReservedMetadataName (metadataName)) throw new ArgumentException ("Can't modify reserved metadata"); if (metadata.Contains (metadataName)) diff --git a/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ChangeLog b/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ChangeLog index eb169a3d9e6..ea036dc93cf 100644 --- a/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ChangeLog +++ b/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ChangeLog @@ -1,3 +1,9 @@ +2010-02-19 Ankit Jain + + * ReservedNameUtils.cs (GetReservedMetadata): Add dictionary param + @metadata. Use this to check for existing value of "RecursiveDir" + metadata, use that if present. + 2009-10-08 Ankit Jain * ReservedNameUtils.cs: Fix 'RootDir', 'Directory'. diff --git a/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs b/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs index d461230dd48..49f489948e7 100644 --- a/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs +++ b/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs @@ -66,9 +66,9 @@ namespace Mono.XBuild.Utilities { { return reservedMetadataHash.Contains (metadataName); } - + public static string GetReservedMetadata (string itemSpec, - string metadataName) + string metadataName, IDictionary metadata) { if (metadataName == null) throw new ArgumentNullException (); @@ -92,8 +92,10 @@ namespace Mono.XBuild.Utilities { return WithTrailingSlash ( Path.GetDirectoryName (fullpath).Substring (Path.GetPathRoot (fullpath).Length)); case "recursivedir": - // FIXME: how to handle this? - return String.Empty; + if (metadata != null && metadata.Contains ("RecursiveDir")) + return (string)metadata ["RecursiveDir"]; + else + return String.Empty; case "identity": return Path.Combine (Path.GetDirectoryName (itemSpec), Path.GetFileName (itemSpec)); case "modifiedtime": -- 2.11.4.GIT