Ubuntu编译Android KitKat 4.4出现Chromium gyp HashSet_jni.h报错的解决方法

Ubuntu编译Android KitKat 4.4出现Chromium gyp HashSet_jni.h报错的解决方法


编译出错信息:

out/target/product/mx3/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:10:26: error: extra tokens at end of #ifndef directive [-Werror]
out/target/product/mx3/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:11:26: error: missing whitespace after the macro name [-Werror]
target thumb C++: content_content_common_gyp <= external/chromium_org/content/common/android/surface_texture_peer.cc
In file included from external/chromium_org/content/common/android/hash_set.cc:5:0:
out/target/product/mx3/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:24:20: error: expected initializer before '<' token
out/target/product/mx3/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:26:17: error: expected initializer before '<' token
out/target/product/mx3/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:29:22: error: expected '{' before '<' token
out/target/product/mx3/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:29:22: error: expected unqualified-id before '<' token
external/chromium_org/content/common/android/hash_set.cc:30:1: error: expected '}' at end of input
cc1plus: all warnings being treated as errors
make: *** [out/target/product/mx3/obj/STATIC_LIBRARIES/content_content_common_gyp_intermediates/content/common/android/hash_set.o] 错误 1
make: *** 正在等待未完成的任务....

解决方法:

修改文件:external/chromium_org/base/android/jni_generator/jni_generator.py,diff如下

--- a/base/android/jni_generator/jni_generator.py
+++ b/base/android/jni_generator/jni_generator.py
@@ -555,18 +555,24 @@ class JNIFromJavaSource(object):
                                                                contents)
     return JNIFromJavaSource(contents, fully_qualified_class)
 
+def MultipleReplace(string, rep_dict):
+    pattern = re.compile("|".join([re.escape(k) for k in rep_dict.keys()]), re.M)
+    return pattern.sub(lambda x: rep_dict[x.group(0)], string)
 
 class InlHeaderFileGenerator(object):
   """Generates an inline header file for JNI integration."""
 
   def __init__(self, namespace, fully_qualified_class, natives,
                called_by_natives):
-    self.namespace = namespace
-    self.fully_qualified_class = fully_qualified_class
+#    self.namespace = namespace
+#    self.fully_qualified_class = fully_qualified_class
+    self.namespace = MultipleReplace(namespace, {'<E>':''})
+    self.fully_qualified_class = MultipleReplace(fully_qualified_class, {'<E>':''})
     self.class_name = self.fully_qualified_class.split('/')[-1]
     self.natives = natives
     self.called_by_natives = called_by_natives
-    self.header_guard = fully_qualified_class.replace('/', '_') + '_JNI'
+#    self.header_guard = fully_qualified_class.replace('/', '_') + '_JNI'
+    self.header_guard = MultipleReplace(fully_qualified_class, {'/':'_', '<E>':''}) + '_JNI'
 
   def GetContent(self):
     """Returns the content of the JNI binding file."""


你可能感兴趣的:(android,ubuntu,KitKat)