diff options
Diffstat (limited to 'libc/kernel/tools/cpp.py')
-rwxr-xr-x | libc/kernel/tools/cpp.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py index 8538eb006..54886413e 100755 --- a/libc/kernel/tools/cpp.py +++ b/libc/kernel/tools/cpp.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """A glorified C pre-processor parser.""" import ctypes @@ -14,7 +14,7 @@ if top is None: utils.panic('ANDROID_BUILD_TOP not set.\n') # Set up the env vars for libclang. -site.addsitedir(os.path.join(top, 'external/clang/bindings/python')) +site.addsitedir(os.path.join(top, 'prebuilts/clang/host/linux-x86/clang-stable/lib64/python3/site-packages/')) import clang.cindex from clang.cindex import conf @@ -28,7 +28,7 @@ from clang.cindex import TranslationUnit # Set up LD_LIBRARY_PATH to include libclang.so, libLLVM.so, and etc. # Note that setting LD_LIBRARY_PATH with os.putenv() sometimes doesn't help. -clang.cindex.Config.set_library_file(os.path.join(top, 'prebuilts/sdk/tools/linux/lib64/libclang_android.so')) +clang.cindex.Config.set_library_file(os.path.join(top, 'prebuilts/clang/host/linux-x86/clang-stable/lib64/libclang.so')) from defaults import * @@ -254,7 +254,7 @@ class CppTokenizer(object): token_group = TokenGroup(self._tu, tokens_memory, tokens_count) tokens = [] - for i in xrange(0, count): + for i in range(0, count): token = Token(self._tu, token_group, int_data=tokens_array[i].int_data, ptr_data=tokens_array[i].ptr_data, @@ -394,10 +394,10 @@ class CppExpr(object): self._index = 0 if debugCppExpr: - print "CppExpr: trying to parse %s" % repr(tokens) + print("CppExpr: trying to parse %s" % repr(tokens)) self.expr = self.parseExpression(0) if debugCppExpr: - print "CppExpr: got " + repr(self.expr) + print("CppExpr: got " + repr(self.expr)) if self._index != self._num_tokens: self.throw(BadExpectedToken, "crap at end of input (%d != %d): %s" % (self._index, self._num_tokens, repr(tokens))) @@ -405,9 +405,9 @@ class CppExpr(object): def throw(self, exception, msg): if self._index < self._num_tokens: tok = self.tokens[self._index] - print "%d:%d: %s" % (tok.location.line, tok.location.column, msg) + print("%d:%d: %s" % (tok.location.line, tok.location.column, msg)) else: - print "EOF: %s" % msg + print("EOF: %s" % msg) raise exception(msg) def expectId(self, id): @@ -722,7 +722,7 @@ class CppExpr(object): if op == "defined": op, name = e - if macros.has_key(name): + if name in macros: if macros[name] == kCppUndefinedMacro: return ("int", 0) else: @@ -739,7 +739,7 @@ class CppExpr(object): elif op == "ident": op, name = e - if macros.has_key(name): + if name in macros: try: value = int(macros[name]) expanded = ("int", value) @@ -1179,11 +1179,11 @@ class BlockList(object): def dump(self): """Dump all the blocks in current BlockList.""" - print '##### BEGIN #####' + print('##### BEGIN #####') for i, b in enumerate(self.blocks): - print '### BLOCK %d ###' % i - print b - print '##### END #####' + print('### BLOCK %d ###' % i) + print(b) + print('##### END #####') def optimizeIf01(self): """Remove the code between #if 0 .. #endif in a BlockList.""" @@ -1510,7 +1510,7 @@ class BlockParser(object): while i < len(tokens) and tokens[i].location in extent: t = tokens[i] if debugBlockParser: - print ' ' * 2, t.id, t.kind, t.cursor.kind + print(' ' * 2, t.id, t.kind, t.cursor.kind) if (detect_change and t.cursor.extent != extent and t.cursor.kind == CursorKind.PREPROCESSING_DIRECTIVE): break |