Ejemplo n.º 1
0
    static void Main(string[] args)
    {
      bool rhinocommon_build = false;
      string dirCPP=null;
      string dirCS=null;
      List<string> preprocessor_defines = 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]);
          for (int i = 2; i < lines.Length; i++)
          {
            if (lines[i].StartsWith("using"))
            {
              m_includeRhinoDeclarations = false;
              m_extra_usings.Add(lines[i].Trim());
            }
            if (lines[i].StartsWith("define"))
            {
              if (preprocessor_defines == null)
                preprocessor_defines = new List<string>();
              string define = lines[i].Substring("define".Length).Trim();
              preprocessor_defines.Add(define);
            }
          }
        }
        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, preprocessor_defines);
      // get all of the .h files
      files = System.IO.Directory.GetFiles(dirCPP, "*.h");
      foreach (var file in files)
        nmd.BuildDeclarations(file, preprocessor_defines);

      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("Can't locate RDK project directories. This is OK if you are compiling for standalone openNURBS build");
          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, preprocessor_defines);
        // get all of the .h files
        files = System.IO.Directory.GetFiles(dirCPP, "*.h");
        foreach (var file in files)
          nmd.BuildDeclarations(file, preprocessor_defines);

        outputfile = System.IO.Path.Combine(dirCS, "AutoNativeMethodsRdk.cs");
        nmd.Write(outputfile, "librdk");
      }
    }
Ejemplo n.º 2
0
    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");
      }
    }
Ejemplo n.º 3
0
        static int Main(string[] args)
        {
            bool   rhino3dm_build    = false;
            bool   rhinocommon_build = false;
            string dir_cpp;
            string dir_cs;
            string opennurbsPathReplacement = "";

            if (1 == args.Length && string.Equals(args[0], "rhino3dm", StringComparison.InvariantCultureIgnoreCase))
            {
                rhino3dm_build = true;
                // find directories for rhcommon_c and RhinoCommon
                GetProjectDirectories(out dir_cpp, out dir_cs, false);
            }
            else if (args.Length >= 2)
            {
                dir_cpp = args[0];
                dir_cs  = args[1];
                if (args.Length > 2)
                {
                    opennurbsPathReplacement = args[2];
                }
                if (args.Length > 3)
                {
                    if (string.Equals(args[3], "rhino3dm", StringComparison.InvariantCultureIgnoreCase))
                    {
                        rhino3dm_build = true;
                    }
                }
            }
            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);
                    dir_cpp = System.IO.Path.GetFullPath(lines[0]);
                    dir_cs  = System.IO.Path.GetFullPath(lines[1]);
                    for (int i = 2; i < lines.Length; i++)
                    {
                        if (lines[i].StartsWith("using"))
                        {
                            m_includeRhinoDeclarations = false;
                            m_extra_usings.Add(lines[i].Trim());
                        }
                    }
                }
                else
                {
                    rhinocommon_build = true;
                    // find directories for rhcommon_c and RhinoCommon
                    GetProjectDirectories(out dir_cpp, out dir_cs, false);
                }
            }

            if (System.IO.Directory.Exists(dir_cpp) && !string.IsNullOrWhiteSpace(dir_cs))
            {
                Console.WriteLine("Parsing C files from {0}", dir_cpp);
                Console.WriteLine("Saving AutoNativeMethods.cs to {0}", dir_cs);
            }
            else
            {
                var color = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("ERROR: Unable to locate project directories");
                Console.ForegroundColor = color;
                Console.WriteLine("Press any key to exit");
                Console.Read();
                return(0);
            }

            var cmd = new CommandlineParser(args);

            m_namespace = cmd["namespace"];
            if (cmd.ContainsKey("IncludeRhinoDeclarations"))
            {
                m_includeRhinoDeclarations = bool.Parse(cmd["IncludeRhinoDeclarations"]);
            }

            var nmd = new NativeMethodDeclareFile();

            // get all of the .cpp files
            string[] files = System.IO.Directory.GetFiles(dir_cpp, "*.cpp");
            foreach (var file in files)
            {
                if (rhino3dm_build && (System.IO.Path.GetFileName(file).StartsWith("rh_") || System.IO.Path.GetFileName(file).StartsWith("tl_")))
                {
                    continue;
                }
                nmd.BuildDeclarations(file, rhino3dm_build, opennurbsPathReplacement);
            }
            // get all of the .h files
            files = System.IO.Directory.GetFiles(dir_cpp, "*.h");
            foreach (var file in files)
            {
                nmd.BuildDeclarations(file, rhino3dm_build, opennurbsPathReplacement);
            }

            string output_file_methods = System.IO.Path.Combine(dir_cs, "AutoNativeMethods.cs");

            nmd.Write(output_file_methods, "lib");

            string output_file_enums = System.IO.Path.Combine(dir_cs, "AutoNativeEnums.cs");

            nmd.WriteEnums(output_file_enums);

            if (rhinocommon_build)
            {
                if (!GetProjectDirectories(out dir_cpp, out dir_cs, true))
                {
                    System.Console.WriteLine("Can't locate RDK project directories. This is OK if you are compiling for standalone openNURBS build");
                    return(0);
                }
                //write native methods for rdk
                nmd = new NativeMethodDeclareFile();

                // get all of the .cpp files
                files = System.IO.Directory.GetFiles(dir_cpp, "*.cpp");
                foreach (var file in files)
                {
                    nmd.BuildDeclarations(file, false, "");
                }
                // get all of the .h files
                files = System.IO.Directory.GetFiles(dir_cpp, "*.h");
                foreach (var file in files)
                {
                    nmd.BuildDeclarations(file, false, "");
                }

                output_file_methods = System.IO.Path.Combine(dir_cs, "AutoNativeMethodsRdk.cs");
                nmd.Write(output_file_methods, "librdk");

                output_file_enums = System.IO.Path.Combine(dir_cs, "AutoNativeEnumsRdk.cs");

                nmd.WriteEnums(output_file_enums);
            }

            return(0);
        }