def main(args): # Default invocation will verify the golden files are unchanged. failed = 0 if not args: args = ['--wnone', '--diff', '--test', '--dstroot=.'] ParseOptions(args) idldir = os.path.split(sys.argv[0])[0] idldir = os.path.join(idldir, 'test_cgen', '*.idl') filenames = glob.glob(idldir) ast = ParseFiles(filenames) if hgen.GenerateRelease(ast, 'M14', {}): print "Golden file for M14 failed." failed = 1 else: print "Golden file for M14 passed." idldir = os.path.split(sys.argv[0])[0] idldir = os.path.join(idldir, 'test_cgen_range', '*.idl') filenames = glob.glob(idldir) ast = ParseFiles(filenames) if hgen.GenerateRange(ast, ['M13', 'M14', 'M15'], {}): print "Golden file for M13-M15 failed." failed = 1 else: print "Golden file for M13-M15 passed." return failed
def Main(args): filenames = ParseOptions(args) if GetOption('test'): return TestFiles(filenames) ast = ParseFiles(filenames) for f in ast.GetListOf('File'): if f.GetProperty('ERRORS') > 0: print 'Skipping %s' % f.GetName() continue print DefineDepends(node) for node in f.GetChildren()[2:]: print Define(node, comment=True, prefix='tst_')
def main(args): filenames = ParseOptions(args) if GetOption('test'): return TestFiles(filenames) ast = ParseFiles(filenames) cgen = CSGen() for f in ast.GetListOf('File'): if f.GetProperty('ERRORS') > 0: print 'Skipping %s' % f.GetName() continue for node in f.GetChildren()[2:]: print cgen.Define(node, ast.releases, comment=True, prefix='tst_')
def Main(args): # If no arguments are provided, assume we are trying to rebuild the # C headers with warnings off. try: if not args: args = [ '--wnone', '--cgen', '--range=start,end', '--pnacl', '--pnaclshim', '../native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c', '--tgen', ] current_dir = os.path.abspath(os.getcwd()) script_dir = os.path.abspath(os.path.dirname(__file__)) if current_dir != script_dir: print '\nIncorrect CWD, default run skipped.' print 'When running with no arguments set CWD to the scripts directory:' print '\t' + script_dir + '\n' print 'This ensures correct default paths and behavior.\n' return 1 filenames = ParseOptions(args) ast = ParseFiles(filenames) if ast.errors: print 'Found %d errors. Aborting build.\n' % ast.errors return 1 return Generator.Run(ast) except SystemExit, ec: print 'Exiting with %d' % ec.code sys.exit(ec.code)
def Main(): args = sys.argv[1:] # If no arguments are provided, assume we are trying to rebuild the # C headers with warnings off. if not args: args = [ '--wnone', '--cgen', '--range=start,end', '--pnacl', '--pnaclshim', '../native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c', ] current_dir = os.path.abspath(os.getcwd()) script_dir = os.path.abspath(os.path.dirname(__file__)) if current_dir != script_dir: print '\nIncorrect CWD, default run skipped.' print 'When running with no arguments set CWD to the scripts directory:' print '\t' + script_dir + '\n' print 'This ensures correct default paths and behavior.\n' return 1 filenames = ParseOptions(args) ast = ParseFiles(filenames) return Generator.Run(ast)
def main(args): filenames = ParseOptions(args) ast = ParseFiles(filenames) rpcgen = RPCGen() files = ast.GetListOf('File') outname = GetOption('out') if outname == '': outname = 'out.cc' outfile = IDLOutFile(outname) emitted = set() for f in files: if f.GetName() == 'pp_macros.idl': GenerateDep(outfile, emitted, f, ast.releases) for f in files: GenerateDep(outfile, emitted, f, ast.releases) out = '' out += '#include "host/rpc.h"\n' out += '#include "json/json.cpp"\n' out += 'using namespace std;\n' out += 'using namespace JSON;\n' for declareOnly in [True, False]: for f in files: if f.GetProperty('ERRORS') > 0: print 'Skipping %s' % f.GetName() continue for node in f.GetChildren()[2:]: out += rpcgen.Define(node, ast.releases, declareOnly) out += 'static map<string, void*> gInterfaces;\n' out += '\n' out += 'typedef char* (*InterfaceMemberCallFunc)(const void*, JSONIterator&);\n' out += 'static map<string, InterfaceMemberCallFunc> gInterfaceMemberCallers;\n' out += '\n' out += 'void InitializeInterfaceList() {\n' for (interfaceString, interfaceStruct) in rpcgen.interfaceStructs: if interfaceString == "PPB_Flash_File_FileRef;2.0": interfaceString = "PPB_Flash_File_FileRef;2" elif interfaceString == "PPB_Flash_File_ModuleLocal;3.0": interfaceString = "PPB_Flash_File_ModuleLocal;3" elif interfaceString == "PPB_PDF;0.1": interfaceString = "PPB_PDF;1" out += ' gInterfaces.insert(pair<string, void*>("' + interfaceString + '", &' + interfaceStruct + '));\n' for (interfaceString, caller) in rpcgen.pppInterfaceGetters: out += ' gInterfaceMemberCallers.insert(pair<string, InterfaceMemberCallFunc>("' + interfaceString + '", ' + caller + '));\n' out += '};\n' out += '\n' outfile.Write(out) outfile.Close()
def TestFiles(filenames, test_releases): ast = ParseFiles(filenames) iface_releases = pnaclgen.DetermineInterfaces(ast, test_releases) new_output = CleanString( pnaclgen.GenerateWrapperForMethods(iface_releases, comments=False)) old_output = GetOldTestOutput(ast) if new_output != old_output: PrintErrorDiff(old_output, new_output) ErrOut.Log('Failed pnacl generator test.') return 1 else: InfoOut.Log('Passed pnacl generator test.') return 0
def TestFiles(filenames): if not filenames: idldir = os.path.split(sys.argv[0])[0] idldir = os.path.join(idldir, 'test_cgen', '*.idl') filenames = glob.glob(idldir) filenames = sorted(filenames) ast = ParseFiles(filenames) total_errs = 0 for filenode in ast.GetListOf('File'): errs = TestFile(filenode) if errs: ErrOut.Log('%s test failed with %d error(s).' % (filenode.GetName(), errs)) total_errs += errs if total_errs: ErrOut.Log('Failed generator test.') else: InfoOut.Log('Passed generator test.') return total_errs
def Main(args): filenames = ParseOptions(args) test_releases = ['M13', 'M14', 'M15'] if not filenames: idldir = os.path.split(sys.argv[0])[0] idldir = os.path.join(idldir, 'test_gen_pnacl', '*.idl') filenames = glob.glob(idldir) filenames = sorted(filenames) if GetOption('test'): # Run the tests. return TestFiles(filenames, test_releases) # Otherwise, generate the output file (for potential use as golden file). ast = ParseFiles(filenames) return pnaclgen.GenerateRange(ast, test_releases, filenames)
def Main(args): filenames = ParseOptions(args) ast = ParseFiles(filenames) return Generator.Run(ast)
def Main(args): if not args: return Test() filenames = ParseOptions(args) ast = ParseFiles(filenames) return Generator.Run(ast)