X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=tools%2Flttng-gen-tp;h=db78a5a82b8358a915982aef0969809c81fb44ec;hb=8ccc745889efb88847e2e2c01cb27c814635e092;hp=d54559a0405444d5184d3dbe8bdfa154db5c597b;hpb=9cc0a74872a3aa091faba829e54eeb204e68085f;p=lttng-ust.git diff --git a/tools/lttng-gen-tp b/tools/lttng-gen-tp index d54559a0..db78a5a8 100755 --- a/tools/lttng-gen-tp +++ b/tools/lttng-gen-tp @@ -31,13 +31,8 @@ class HeaderFile: #undef TRACEPOINT_PROVIDER #define TRACEPOINT_PROVIDER {providerName} -#undef TRACEPOINT_INCLUDE_FILE -#define TRACEPOINT_INCLUDE_FILE ./{headerFilename} - -#ifdef __cplusplus -extern "C"{{ -#endif /* __cplusplus */ - +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./{headerFilename}" #if !defined({includeGuard}) || defined(TRACEPOINT_HEADER_MULTI_READ) #define {includeGuard} @@ -49,11 +44,6 @@ extern "C"{{ #endif /* {includeGuard} */ #include - -#ifdef __cplusplus -}} -#endif /* __cplusplus */ - """ def __init__(self, filename, template): self.outputFilename = filename @@ -61,7 +51,9 @@ extern "C"{{ def write(self): outputFile = open(self.outputFilename,"w") - includeGuard = "_"+self.outputFilename.upper().replace(".","_") + # Include guard macro will be created by uppercasing the filename and + # replacing all non alphanumeric characters with '_' + includeGuard = re.sub('[^0-9a-zA-Z]', '_', self.outputFilename.upper()) outputFile.write(HeaderFile.HEADER_TPL.format(providerName=self.template.domain, includeGuard = includeGuard, @@ -207,8 +199,6 @@ def main(argv=None): opts, args = getopt.gnu_getopt(argv[1:], "ho:a", ["help"]) except getopt.error, msg: raise Usage(msg) - if len(args) == 0: - raise Usage("No template file given") except Usage, err: print >>sys.stderr, err.msg @@ -224,6 +214,14 @@ def main(argv=None): outputNames.append(a) if o in ("-a",""): all = True + try: + if len(args) == 0: + raise Usage("No template file given") + + except Usage, err: + print >>sys.stderr, err.msg + print >>sys.stderr, "for help use --help" + return 2 doCFile = None doHeader = None @@ -257,6 +255,9 @@ def main(argv=None): # process arguments for arg in args: + if arg[-3:] != ".tp": + print arg + " does not end in .tp. Skipping." + continue tpl = None try: