示例#1
0
 def _load_fd(self, lib_name):
   """try to load a fd file for a library from vamos data dir"""
   if lib_name.endswith(".device"):
     is_dev  = True
     fd_name = lib_name.replace(".device","_lib.fd")
   else:
     is_dev  = False
     fd_name = lib_name.replace(".library","_lib.fd")
   pos = fd_name.rfind(":")
   if pos != -1:
     fd_name = fd_name[pos+1:]
   fd_file = os.path.join(self.data_dir,"fd",fd_name)
   # try to load fd file if it exists
   if os.path.exists(fd_file):
     try:
       begin = time.clock()
       fd = FDFormat.read_fd(fd_file)
       if is_dev:
         fd.add_call("BeginIO",30,["IORequest"],["a1"])
         fd.add_call("AbortIO",36,["IORequest"],["a1"])
       end = time.clock()
       delta = end - begin
       self.lib_log("load_fd","loaded fd file '%s' in %fs: base='%s' #funcs=%d" % (fd_file, delta, fd.get_base_name(), len(fd.get_funcs())))
       return fd
     except IOError as e:
       self.lib_log("load_fd","Failed reading fd file '%s'" % fd_file, level=logging.ERROR)
   else:
     self.lib_log("load_fd","no fd file found for library '%s'" % fd_file)
   return None
示例#2
0
 def _load_fd(self, lib_name):
   """try to load a fd file for a library from vamos data dir"""
   if lib_name.endswith(".device"):
     is_dev  = True
     fd_name = lib_name.replace(".device","_lib.fd")
   else:
     is_dev  = False
     fd_name = lib_name.replace(".library","_lib.fd")
   pos = fd_name.rfind(":")
   if pos != -1:
     fd_name = fd_name[pos+1:]
   fd_file = os.path.join(self.data_dir,"fd",fd_name)
   # try to load fd file if it exists
   if os.path.exists(fd_file):
     try:
       begin = time.clock()
       fd = FDFormat.read_fd(fd_file)
       if is_dev:
         fd.add_call("BeginIO",30,["IORequest"],["a1"])
         fd.add_call("AbortIO",36,["IORequest"],["a1"])
       end = time.clock()
       delta = end - begin
       self.lib_log("load_fd","loaded fd file '%s' in %fs: base='%s' #funcs=%d" % (fd_file, delta, fd.get_base_name(), len(fd.get_funcs())))
       return fd
     except IOError as e:
       self.lib_log("load_fd","Failed reading fd file '%s'" % fd_file, level=logging.ERROR)
   else:
     self.lib_log("load_fd","no fd file found for library '%s'" % fd_file)
   return None
示例#3
0
 def _load_fd(self, lib_name):
     """try to load a fd file for a library from vamos data dir"""
     fd_name = lib_name.replace(".library", "_lib.fd")
     pos = fd_name.rfind(":")
     if pos != -1:
         fd_name = fd_name[pos + 1 :]
     fd_file = os.path.join(self.data_dir, "fd", fd_name)
     # try to load fd file if it exists
     if os.path.exists(fd_file):
         try:
             begin = time.clock()
             fd = FDFormat.read_fd(fd_file)
             end = time.clock()
             delta = end - begin
             self.lib_log(
                 "load_fd",
                 "loaded fd file '%s' in %fs: base='%s' #funcs=%d"
                 % (fd_file, delta, fd.get_base_name(), len(fd.get_funcs())),
             )
             return fd
         except IOError as e:
             self.lib_log("load_fd", "Failed reading fd file '%s'" % fd_file, level=logging.ERROR)
     else:
         self.lib_log("load_fd", "no fd file found for library '%s'" % fd_file)
     return None
示例#4
0
def main():
  # parse args
  parser = argparse.ArgumentParser()
  parser.add_argument('files', nargs='+')
  parser.add_argument('-P', '--add-private', action='store_true', default=False, help="add private functions")
  parser.add_argument('-p', '--gen-python', action='store_true', default=False, help="generate python code for vamos")
  parser.add_argument('-f', '--gen-fd', action='store', default=None, help="generate a new fd file")
  parser.add_argument('-c', '--gen-sasc', action='store', default=None, help="generate SAS C code file")
  parser.add_argument('-E', '--prefix', action='store', default='', help="add prefix to functions in C")
  args = parser.parse_args()

  # main loop
  files = args.files
  for fname in files:
    fd = FDFormat.read_fd(fname)
    code_gen = False
    if args.gen_python:
      generate_python_code(fd, args.add_private)
      code_gen = True
    if args.gen_sasc:
      generate_sasc_code(args.gen_sasc, fd, args.add_private, args.prefix)
      code_gen = True
    if args.gen_fd != None:
      FDFormat.write_fd(args.gen_fd, fd, args.add_private)
      code_gen = True
    if not code_gen:
      dump(fname, fd, args.add_private)
示例#5
0
def main(args=None):
    # parse args
    parser = argparse.ArgumentParser()
    parser.add_argument("files", nargs="+")
    parser.add_argument(
        "-P",
        "--add-private",
        action="store_true",
        default=False,
        help="add private functions",
    )
    parser.add_argument(
        "-p",
        "--gen-python",
        action="store_true",
        default=False,
        help="generate python code for vamos",
    )
    parser.add_argument("-f",
                        "--gen-fd",
                        action="store",
                        default=None,
                        help="generate a new fd file")
    parser.add_argument(
        "-c",
        "--gen-sasc",
        action="store",
        default=None,
        help="generate SAS C code file",
    )
    parser.add_argument(
        "-E",
        "--prefix",
        action="store",
        default="",
        help="add prefix to functions in C",
    )
    args = parser.parse_args(args=args)

    # main loop
    files = args.files
    for fname in files:
        fd = FDFormat.read_fd(fname)
        code_gen = False
        if args.gen_python:
            generate_python_code(fd, args.add_private)
            code_gen = True
        if args.gen_sasc:
            generate_sasc_code(args.gen_sasc, fd, args.add_private,
                               args.prefix)
            code_gen = True
        if args.gen_fd != None:
            FDFormat.write_fd(args.gen_fd, fd, args.add_private)
            code_gen = True
        if not code_gen:
            dump(fname, fd, args.add_private)
示例#6
0
def main():
    # parse args
    parser = argparse.ArgumentParser()
    parser.add_argument('files', nargs='+')
    parser.add_argument('-P',
                        '--add-private',
                        action='store_true',
                        default=False,
                        help="add private functions")
    parser.add_argument('-p',
                        '--gen-python',
                        action='store_true',
                        default=False,
                        help="generate python code for vamos")
    parser.add_argument('-f',
                        '--gen-fd',
                        action='store',
                        default=None,
                        help="generate a new fd file")
    parser.add_argument('-c',
                        '--gen-sasc',
                        action='store',
                        default=None,
                        help="generate SAS C code file")
    parser.add_argument('-E',
                        '--prefix',
                        action='store',
                        default='',
                        help="add prefix to functions in C")
    args = parser.parse_args()

    # main loop
    files = args.files
    for fname in files:
        fd = FDFormat.read_fd(fname)
        code_gen = False
        if args.gen_python:
            generate_python_code(fd, args.add_private)
            code_gen = True
        if args.gen_sasc:
            generate_sasc_code(args.gen_sasc, fd, args.add_private,
                               args.prefix)
            code_gen = True
        if args.gen_fd != None:
            FDFormat.write_fd(args.gen_fd, fd, args.add_private)
            code_gen = True
        if not code_gen:
            dump(fname, fd, args.add_private)
示例#7
0
 def _load_fd(self, lib_name):
   """try to load a fd file for a library from vamos data dir"""
   fd_name = lib_name.replace(".library","_lib.fd")
   pos = fd_name.rfind(":")
   if pos != -1:
     fd_name = fd_name[pos+1:]
   fd_file = os.path.join(self.data_dir,"fd",fd_name)
   # try to load fd file if it exists
   if os.path.exists(fd_file):
     try:
       begin = time.clock()
       fd = FDFormat.read_fd(fd_file)
       end = time.clock()
       delta = end - begin
       self.lib_log("load_fd","loaded fd file '%s' in %fs: base='%s' #funcs=%d" % (fd_file, delta, fd.get_base_name(), len(fd.get_funcs())))
       return fd
     except IOError as e:
       self.lib_log("load_fd","Failed reading fd file '%s'" % fd_file, level=logging.ERROR)
   else:
     self.lib_log("load_fd","no fd file found for library '%s'" % fd_file)
   return None