def DumpFile(filename, targetDir): cpp_generator = ActionScriptGenerator(targetDir) parser = ProtoParser() parser.RegisterGenerator(cpp_generator) print filename parser.ParseFile(os.path.abspath(filename)) cpp_generator.Generate(parser.tree, os.path.abspath(filename))
def CompileFile(self, filepath): parser = ProtoParser() for generator in self.generator_list: parser.RegisterGenerator(generator) parser.ParseFile(filepath) for generator in self.generator_list: generator.generate(parser.tree, filepath)
def generate_proto(filename, target_dir, pkg_prefix, type_ids): go_generator = GoLangGenerator(target_dir) parser = ProtoParser() parser.RegisterGenerator(go_generator) print filename parser.ParseFile(os.path.abspath(filename)) go_generator.generate(parser.tree, os.path.abspath(filename), pkg_prefix, type_ids)
def DumpFile(filename, targetDir): cpp_generator = CppGenerator(targetDir) parser = ProtoParser() input_file_path = os.path.abspath(filename) # 如果生成文件的更改时间晚于协议定义文件时间,则跳过此文件 #output_file_name, output_file_path = cpp_generator.DetermineOuputPath(input_file_path) #if output_file_path != None: # if os.stat(input_file_path).st_mtime < os.stat(output_file_path).st_mtime: # print("SKIPED %s" % input_file_path) # return print("PROCESS %s" % input_file_path) parser.RegisterGenerator(cpp_generator) parser.ParseFile(input_file_path) cpp_generator.Generate(parser.tree, os.path.abspath(filename))