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."""


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值