[openrtm-commit:00064] r2100 - trunk/OpenRTM-aist/utils/rtm-skelwrapper
openrtm @ openrtm.org
openrtm @ openrtm.org
2011年 5月 21日 (土) 18:03:24 JST
Author: n-ando
Date: 2011-05-21 18:03:23 +0900 (Sat, 21 May 2011)
New Revision: 2100
Modified:
trunk/OpenRTM-aist/utils/rtm-skelwrapper/rtm-skelwrapper
trunk/OpenRTM-aist/utils/rtm-skelwrapper/skel_wrapper.py
Log:
New option "--output-dir/-o" has been added. The meaning of
directory path and basename of --include-dir and --idl-file has
been changed. refs #2127
Modified: trunk/OpenRTM-aist/utils/rtm-skelwrapper/rtm-skelwrapper
===================================================================
--- trunk/OpenRTM-aist/utils/rtm-skelwrapper/rtm-skelwrapper 2011-05-21 07:03:11 UTC (rev 2099)
+++ trunk/OpenRTM-aist/utils/rtm-skelwrapper/rtm-skelwrapper 2011-05-21 09:03:23 UTC (rev 2100)
@@ -46,7 +46,7 @@
def usage():
print """
-Usage: rtc-skelwrapper [OPTIONS]
+Usage: rtm-skelwrapper [OPTIONS]
Options:
@@ -54,13 +54,61 @@
[--idl-file[=IDL_file]] IDL file name
[--skel-suffix[=suffix]] Suffix of server skelton files
[--stub-suffix[=suffix]] Suffix of client stub files
- [--include-dir[=dir] ot -I] include prefix in #include
+ [--include-dir[=dir] or -I] include prefix in #include
+ [--output-dir[=dir] or -o] output directory
+
+Example:
+$ rtm-skelwrapper --idl=file=<IDL path>/<IDL basename>.idl
+ --include-dir=<include dir>
+ --output-dir=<output dir>
+ -skel-suffix=<skel suffix>
+ -stub-suffix=<stub suffix>
+
+In this case, the following files are generated under <output dir>.
+
+ <IDL basename><skel suffix>.h
+ <IDL basename><skel suffix>.cpp
+ <IDL basename><stub suffix>.h
+ <IDL basename><stub suffix>.cpp
+
+And these files include the target IDL file by the following
+#include directive.
+
+#include <<include dir>/<IDL basename>(CORBA impl specific suffix)>
+
+Absolute path is not recommended for the "--include-dir" option.
+When option "--include-dir=my/idl" is specified, the generated
+skeleton's header includes actual CORBA implementation dependent
+skeletons as follows.
+
+#if defined ORB_IS_TAO
+# include "my/idl/RangerC.h"
+# include "my/idl/RangerS.h"
+#elif defined ORB_IS_OMNIORB
+# include "my/idl/Ranger.hh"
+#endif
+
+Therefore, if you compile this skeletons/stubs, you have to specify an
+appropriate include directory in the compiler options.
+
+<IDL path> is used for only include-guard. For example, if
+"--idl-file=/usr/include/idl/MyInterface.idl" is specified, the
+following include guard will be defined.
+
+#ifndef _USR_INCLUDE_IDL_MYINTERFACE_H
+#define _USR_INCLUDE_IDL_MYINTERFACE_H
+
+ : (codes)
+
+#endif // _USR_INCLUDE_IDL_MYINTERFACE_H
+
"""
def main():
try:
- opts, args = getopt.getopt(sys.argv[1:], "f:I:h", opt_args_fmt)
+ opts, args = getopt.getopt(sys.argv[1:], "f:I:o:h",
+ opt_args_fmt)
except getopt.GetoptError:
print "Error: Invalid options.", getopt.GetoptError
usage()
@@ -70,7 +118,8 @@
usage()
sys.exit(-1)
- include_dir = "rtm/idl/"
+ include_dir = ""
+ output_dir = ""
skel_suffix = "Skel"
stub_suffix = "Stub"
idl_file = None
@@ -85,6 +134,9 @@
if opt in ("-I", "--include-dir"):
include_dir = arg
+ if opt in ("-o", "--output-dir"):
+ output_dir = arg
+
if opt in ("--skel-suffix"):
skel_suffix = arg
@@ -100,7 +152,7 @@
import skel_wrapper
s = skel_wrapper.skel_wrapper(idl_file, skel_suffix, stub_suffix,
- include_dir, config_inc)
+ include_dir, config_inc, output_dir)
s.generate()
Modified: trunk/OpenRTM-aist/utils/rtm-skelwrapper/skel_wrapper.py
===================================================================
--- trunk/OpenRTM-aist/utils/rtm-skelwrapper/skel_wrapper.py 2011-05-21 07:03:11 UTC (rev 2099)
+++ trunk/OpenRTM-aist/utils/rtm-skelwrapper/skel_wrapper.py 2011-05-21 09:03:23 UTC (rev 2100)
@@ -210,10 +210,12 @@
"""
class skel_wrapper:
- def __init__(self, idl_fname, skel_suffix = "Skel", stub_suffix = "Stub",
- include_dir = "", config_inc = ""):
+ def __init__(self, idl_fname, skel_suffix = "Skel",
+ stub_suffix = "Stub", include_dir = "",
+ config_inc = "", output_dir = "./"):
self.data = {}
self.data["include_dir"] = include_dir
+ self.data["output_dir"] = output_dir
self.data["idl_fname"] = idl_fname
m = re.search("\.[iI][dD][lL]$", idl_fname)
if m:
@@ -222,14 +224,20 @@
sys.stderr.write("Invalid IDL file name specified.\n")
sys.exit(1)
+ dirname = os.path.dirname(basename) + "/"
+ basename = os.path.basename(basename)
self.data["basename"] = basename
self.data["skel_h"] = basename + skel_suffix + ".h"
self.data["skel_cpp"] = basename + skel_suffix + ".cpp"
self.data["stub_h"] = basename + stub_suffix + ".h"
self.data["stub_cpp"] = basename + stub_suffix + ".cpp"
- skel_h_guard = self.data["skel_h"].replace(".","_").upper()
- stub_h_guard = self.data["stub_h"].replace(".","_").upper()
+ skel_h_guard = dirname + self.data["skel_h"].replace(".","_")
+ skel_h_guard = skel_h_guard.replace("/","_")
+ skel_h_guard = skel_h_guard.upper()
+ stub_h_guard = dirname + self.data["stub_h"].replace(".","_")
+ stub_h_guard = stub_h_guard.replace("/","_")
+ stub_h_guard = stub_h_guard.upper()
self.data["skel_h_inc_guard"] = skel_h_guard
self.data["stub_h_inc_guard"] = stub_h_guard
@@ -243,7 +251,7 @@
return
def print_skel_h(self):
- f = file(self.data["skel_h"], "w")
+ f = file(self.data["output_dir"] + self.data["skel_h"], "w")
t = yat.Template(skel_h)
text=t.generate(self.data)
f.write(text)
@@ -252,7 +260,7 @@
return
def print_skel_cpp(self):
- f = file(self.data["skel_cpp"], "w")
+ f = file(self.data["output_dir"] + self.data["skel_cpp"], "w")
t = yat.Template(skel_cpp)
text=t.generate(self.data)
f.write(text)
@@ -261,7 +269,7 @@
return
def print_stub_h(self):
- f = file(self.data["stub_h"], "w")
+ f = file(self.data["output_dir"] + self.data["stub_h"], "w")
t = yat.Template(stub_h)
text=t.generate(self.data)
f.write(text)
@@ -270,7 +278,7 @@
return
def print_stub_cpp(self):
- f = file(self.data["stub_cpp"], "w")
+ f = file(self.data["output_dir"] + self.data["stub_cpp"], "w")
t = yat.Template(stub_cpp)
text=t.generate(self.data)
f.write(text)
openrtm-commit メーリングリストの案内