static void Main(string[] args) { bool rhinocommon_build = false; string dirCPP=null; string dirCS=null; if (args.Length >= 2) { dirCPP = args[0]; dirCS = args[1]; } else { // See if there is a configuration file sitting in the same directory string location = System.Reflection.Assembly.GetExecutingAssembly().Location; string path = System.IO.Path.GetDirectoryName(location); path = System.IO.Path.Combine(path, "methodgen.cfg.txt"); if (System.IO.File.Exists(path)) { string[] lines = System.IO.File.ReadAllLines(path); dirCPP = System.IO.Path.GetFullPath(lines[0]); dirCS = System.IO.Path.GetFullPath(lines[1]); } else { rhinocommon_build = true; // find directories for rhcommon_c and RhinoCommon GetProjectDirectories(out dirCPP, out dirCS, false); } } if (System.IO.Directory.Exists(dirCPP) && !string.IsNullOrWhiteSpace(dirCS)) { Console.WriteLine("Parsing C files from {0}", dirCPP); Console.WriteLine("Saving AutoNativeMethods.cs to {0}", dirCS); } else { var color = System.Console.ForegroundColor; System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine("ERROR: Unable to locate project directories"); System.Console.ForegroundColor = color; System.Console.WriteLine("Press any key to exit"); System.Console.Read(); return; } CommandlineParser cmd = new CommandlineParser(args); m_namespace = cmd["namespace"]; if (cmd.ContainsKey("IncludeRhinoDeclarations")) m_includeRhinoDeclarations = bool.Parse(cmd["IncludeRhinoDeclarations"]); NativeMethodDeclares nmd = new NativeMethodDeclares(); // get all of the .cpp files string[] files = System.IO.Directory.GetFiles(dirCPP, "*.cpp"); foreach (var file in files) nmd.BuildDeclarations(file); // get all of the .h files files = System.IO.Directory.GetFiles(dirCPP, "*.h"); foreach (var file in files) nmd.BuildDeclarations(file); string outputfile = System.IO.Path.Combine(dirCS, "AutoNativeMethods.cs"); nmd.Write(outputfile, "lib"); if(rhinocommon_build) { if (!GetProjectDirectories(out dirCPP, out dirCS, true)) { System.Console.WriteLine("ERROR: Unable to locate RDK project directoies"); return; } //write native methods for rdk nmd = new NativeMethodDeclares(); // get all of the .cpp files files = System.IO.Directory.GetFiles(dirCPP, "*.cpp"); foreach (var file in files) nmd.BuildDeclarations(file); // get all of the .h files files = System.IO.Directory.GetFiles(dirCPP, "*.h"); foreach (var file in files) nmd.BuildDeclarations(file); outputfile = System.IO.Path.Combine(dirCS, "AutoNativeMethodsRdk.cs"); nmd.Write(outputfile, "librdk"); } }