From 3a91ff3ac5976769968db419cad64c73b28d0266 Mon Sep 17 00:00:00 2001 From: Kevin Glynn Date: Wed, 29 Dec 2010 13:32:30 +0100 Subject: [PATCH] update xml files project --- CSharpTranslator/antlr3/CSharpTranslator.sln | 28 ++-- .../antlr3/UpdateTxFiles/AssemblyInfo.cs | 27 ++++ CSharpTranslator/antlr3/UpdateTxFiles/Main.cs | 135 ++++++++++++++++++ .../antlr3/UpdateTxFiles/UpdateTxFiles.csproj | 51 +++++++ .../src/NDesk.Options/NDesk.Options.csproj | 41 +++++- .../cs2jTemplateGen/cs2jTemplateGen.csproj | 53 ++++++- 6 files changed, 323 insertions(+), 12 deletions(-) create mode 100644 CSharpTranslator/antlr3/UpdateTxFiles/AssemblyInfo.cs create mode 100644 CSharpTranslator/antlr3/UpdateTxFiles/Main.cs create mode 100644 CSharpTranslator/antlr3/UpdateTxFiles/UpdateTxFiles.csproj diff --git a/CSharpTranslator/antlr3/CSharpTranslator.sln b/CSharpTranslator/antlr3/CSharpTranslator.sln index ff07b40..114a13d 100644 --- a/CSharpTranslator/antlr3/CSharpTranslator.sln +++ b/CSharpTranslator/antlr3/CSharpTranslator.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 +# Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs2j", "src\cs2j\cs2j.csproj", "{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr3.Runtime", "src\Antlr.Runtime\Antlr3.Runtime.csproj", "{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}" @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDesk.Options", "src\NDesk. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs2jTemplateGen", "src\cs2jTemplateGen\cs2jTemplateGen.csproj", "{CC80B16E-0700-4AA5-ABA0-ADBCD9316952}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateTxFiles", "UpdateTxFiles\UpdateTxFiles.csproj", "{4B69CC57-FAC3-464F-9103-5187421DB85F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -22,6 +24,18 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4B69CC57-FAC3-464F-9103-5187421DB85F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B69CC57-FAC3-464F-9103-5187421DB85F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B69CC57-FAC3-464F-9103-5187421DB85F}.Default|Any CPU.ActiveCfg = Debug|Any CPU + {4B69CC57-FAC3-464F-9103-5187421DB85F}.Default|Any CPU.Build.0 = Debug|Any CPU + {4B69CC57-FAC3-464F-9103-5187421DB85F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B69CC57-FAC3-464F-9103-5187421DB85F}.Release|Any CPU.Build.0 = Release|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.ActiveCfg = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.Build.0 = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.Build.0 = Release|Any CPU {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Default|Any CPU.ActiveCfg = Debug|Any CPU @@ -38,19 +52,13 @@ Global {E6ACBB37-AF38-45E1-B399-0CEE63809A15}.Default|Any CPU.Build.0 = Debug|Any CPU {E6ACBB37-AF38-45E1-B399-0CEE63809A15}.Release|Any CPU.ActiveCfg = Release|Any CPU {E6ACBB37-AF38-45E1-B399-0CEE63809A15}.Release|Any CPU.Build.0 = Release|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.ActiveCfg = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.Build.0 = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = src\cs2j\cs2j.csproj EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/CSharpTranslator/antlr3/UpdateTxFiles/AssemblyInfo.cs b/CSharpTranslator/antlr3/UpdateTxFiles/AssemblyInfo.cs new file mode 100644 index 0000000..f182cb3 --- /dev/null +++ b/CSharpTranslator/antlr3/UpdateTxFiles/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("UpdateTxFiles")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/CSharpTranslator/antlr3/UpdateTxFiles/Main.cs b/CSharpTranslator/antlr3/UpdateTxFiles/Main.cs new file mode 100644 index 0000000..f786a78 --- /dev/null +++ b/CSharpTranslator/antlr3/UpdateTxFiles/Main.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.IO; +using NDesk.Options; +using RusticiSoftware.Translator.CLR; +using RusticiSoftware.Translator.Utils; +using System.Xml.Serialization; + +namespace UpdateTxFiles +{ + class MainClass + { + + private const string VERSION = "2010.1.1"; + private static int Verbosity = 0; + private static DirectoryHT oldAppEnv = new DirectoryHT(null); + private static DirectoryHT newAppEnv = new DirectoryHT(null); + + public delegate void FileProcessor(string fName); + + private static void showVersion() + { + Console.Out.WriteLine(Path.GetFileNameWithoutExtension(System.Environment.GetCommandLineArgs()[0]) + ": " + VERSION); + } + + private static void showUsage() + { + Console.Out.WriteLine("Usage: " + Path.GetFileNameWithoutExtension(System.Environment.GetCommandLineArgs()[0])); + Console.Out.WriteLine(" [-help] (this usage message)"); + Console.Out.WriteLine(" [-v] (be [somewhat more] verbose, repeat for more verbosity)"); + Console.Out.WriteLine(" [-inxmldir +] (can be multiple directories, separated by semi-colons)"); + Console.Out.WriteLine(" [-outxmkdir +] "); + Environment.Exit(0); + } + public static void Main (string[] args) + { + long startTime = DateTime.Now.Ticks; + IList remArgs = new List(); + IList inDirs = new List(); + string outDir = ""; + + // Use a try/catch block for parser exceptions + try + { + // if we have at least one command-line argument + if (args.Length > 0) + { + + OptionSet p = new OptionSet () + .Add ("v", v => Verbosity++) + .Add ("version", v => showVersion()) + .Add ("help|h|?", v => showUsage()) + .Add ("inxmldir=", dir => inDirs.Add(Path.Combine(Directory.GetCurrentDirectory(), dir))) + .Add ("outxmldir=", dir => outDir = Path.Combine(Directory.GetCurrentDirectory(), dir)) + ; + + remArgs = p.Parse (args); + + // Load .Net templates + foreach (string r in inDirs) + doFile(r, ".xml", addOldNetTranslation, null); + + foreach (KeyValuePair de in oldAppEnv) + { + String xmlFName = Path.Combine(outDir, + ((string)de.Key).Replace('.', Path.DirectorySeparatorChar) + ".xml"); + String xmlFDir = Path.GetDirectoryName(xmlFName); + if (!Directory.Exists(xmlFDir)) + { + Directory.CreateDirectory(xmlFDir); + } + XmlSerializer s = new XmlSerializer(de.Value.GetType()); + TextWriter w = new StreamWriter(xmlFName); + s.Serialize(w, de.Value); + w.Close(); + } + } + else + { + showUsage(); + } + } + catch (System.Exception e) + { + Console.Error.WriteLine("exception: " + e); + Console.Error.WriteLine(e.StackTrace); // so we can get stack trace + } + double elapsedTime = ((DateTime.Now.Ticks - startTime) / TimeSpan.TicksPerMillisecond) / 1000.0; + if (Verbosity >= 1) + { + System.Console.Out.WriteLine("Total run time was {0} seconds.", elapsedTime); + } + } + + + // Call processFile on all files below f that have the given extension + public static void doFile(string root, string ext, FileProcessor processFile, IList excludes) + { + string canonicalPath = Path.GetFullPath(root); + // If this is a directory, walk each file/dir in that directory + if (excludes == null || !excludes.Contains(canonicalPath.ToLower())) + { + if (Directory.Exists(canonicalPath)) + { + string[] files = Directory.GetFileSystemEntries(canonicalPath); + for (int i = 0; i < files.Length; i++) + doFile(Path.Combine(canonicalPath, files[i]), ext, processFile, excludes); + } + else if ((Path.GetFileName(canonicalPath).Length > ext.Length) && canonicalPath.Substring(canonicalPath.Length - ext.Length).Equals(ext)) + { + if (Verbosity >= 2) Console.WriteLine(" " + canonicalPath); + try + { + + processFile(canonicalPath); + } + catch (Exception e) + { + Console.Error.WriteLine("\nCannot process file: " + canonicalPath); + Console.Error.WriteLine("exception: " + e); + } + } + } + } + + // Here's where we do the real work... + public static void addOldNetTranslation(string fullName) + { + Stream s = new FileStream(fullName, FileMode.Open, FileAccess.Read); + TypeRepTemplate t = TypeRepTemplate.newInstance(s); + oldAppEnv[t.TypeName] = t; + } + } +} + diff --git a/CSharpTranslator/antlr3/UpdateTxFiles/UpdateTxFiles.csproj b/CSharpTranslator/antlr3/UpdateTxFiles/UpdateTxFiles.csproj new file mode 100644 index 0000000..6833597 --- /dev/null +++ b/CSharpTranslator/antlr3/UpdateTxFiles/UpdateTxFiles.csproj @@ -0,0 +1,51 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {4B69CC57-FAC3-464F-9103-5187421DB85F} + Exe + UpdateTxFiles + UpdateTxFiles + v3.5 + + + true + full + false + bin\Debug + DEBUG + prompt + 4 + true + + + none + false + bin\Release + prompt + 4 + true + + + + + + + + + + + + + {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD} + cs2j + + + {E6ACBB37-AF38-45E1-B399-0CEE63809A15} + NDesk.Options + + + \ No newline at end of file diff --git a/CSharpTranslator/antlr3/src/NDesk.Options/NDesk.Options.csproj b/CSharpTranslator/antlr3/src/NDesk.Options/NDesk.Options.csproj index 0cee7c7..5e8a6d8 100644 --- a/CSharpTranslator/antlr3/src/NDesk.Options/NDesk.Options.csproj +++ b/CSharpTranslator/antlr3/src/NDesk.Options/NDesk.Options.csproj @@ -1 +1,40 @@ - Debug AnyCPU 10.0.0 2.0 {E6ACBB37-AF38-45E1-B399-0CEE63809A15} Library NDesk.Options NDesk.Options v3.5 true full false bin\Debug DEBUG prompt 4 false none false bin\Release prompt 4 false \ No newline at end of file + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {E6ACBB37-AF38-45E1-B399-0CEE63809A15} + Library + NDesk.Options + NDesk.Options + v3.5 + + + true + full + false + bin\Debug + DEBUG + prompt + 4 + false + + + none + false + bin\Release + prompt + 4 + false + + + + + + + + + + \ No newline at end of file diff --git a/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj b/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj index f131a73..cfc9190 100644 --- a/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj +++ b/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj @@ -1 +1,52 @@ - Debug AnyCPU 10.0.0 2.0 {CC80B16E-0700-4AA5-ABA0-ADBCD9316952} Exe cs2jTemplateGen cs2jTemplateGen v3.5 true full false bin\Debug DEBUG prompt 4 true -dll /Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/cs2jTest/bin/Debug/cs2jTest.dll cs2jTest.Various.Features.Various none false bin\Release prompt 4 true {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD} cs2j {E6ACBB37-AF38-45E1-B399-0CEE63809A15} NDesk.Options \ No newline at end of file + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952} + Exe + cs2jTemplateGen + cs2jTemplateGen + v3.5 + + + true + full + false + bin\Debug + DEBUG + prompt + 4 + true + -dll /Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/cs2jTest/bin/Debug/cs2jTest.dll cs2jTest.Various.Features.Various + + + none + false + bin\Release + prompt + 4 + true + + + + + + + + + + + + {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD} + cs2j + + + {E6ACBB37-AF38-45E1-B399-0CEE63809A15} + NDesk.Options + + + + \ No newline at end of file