Android.mk 中的每个文件 CPPFLAGS
我正在处理一个 Android.mk 文件,其中对于单个模块,其中一个文件需要不同的 CPPFLAGS;也就是说,它需要启用 -frtti,而其他则需要 Android 默认的 -fno-rtti。
明显的解决方案是特定于目标的变量,但奇怪的是它们似乎不会影响编译,即使进行了一些调整以确保应在正确的时间确定值。
这是我的 Android.mk 的摘录(名称已更改以保护我):
LOCAL_MODULE := foo_bar
LOCAL_SRC_FILES := \
foo_bar.cpp \
foo_baz.cpp
my_intermediates:= $(local-intermediates-dir)/foo_baz.o
$(my_intermediates): LOCAL_CPPFLAGS := -frtti
我尝试简单地用 foo_baz.o:
代替 $(my_intermediates),并尝试替换 +=< /code> 为
:=
没有变化。
那么,是否有一种特定于 Android 的方法来覆盖特定源文件的 CPPFLAGS(或 CFLAGS)?
(在本例中,我使用的是 Eclair Android 源,尽管它可能适用于 NDK;请参阅下面我的答案。)
I'm working on an Android.mk file in which, for a single module, one of the files needs different CPPFLAGS; namely, it needs -frtti enabled, while others need the Android default of -fno-rtti.
The obvious solution was target-specific variables, but oddly they do not seem to affect compilation, even with some fiddling to ensure the values should be fixed at the right time.
Here's an extract from my Android.mk (names changed to protect me):
LOCAL_MODULE := foo_bar
LOCAL_SRC_FILES := \
foo_bar.cpp \
foo_baz.cpp
my_intermediates:= $(local-intermediates-dir)/foo_baz.o
$(my_intermediates): LOCAL_CPPFLAGS := -frtti
I have tried simply doing foo_baz.o:
in lieu of $(my_intermediates), and have tried substituting +=
for :=
to no change.
So, is there an Android-specific way to override CPPFLAGS (or CFLAGS) for a specific source file?
(In this case I'm using the Eclair Android sources, though it may apply to the NDK; see my answer, below.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像往常一样,在花了很多时间之后提出这个问题后,我很快就找到了答案。我需要使用
PRIVATE_CPPFLAGS
而不是LOCAL_CPPFLAGS
。然而,这似乎仅适用于 Android 源代码发行版(至少是 Eclair)和 NDK r6b。如果我使用 NDK r6,这可能会按原样工作。
As is usual, having asked the question after spending a lot of time on it, I have found the answer in short order. I need to use
PRIVATE_CPPFLAGS
instead ofLOCAL_CPPFLAGS
.However, this only appears to be the case for the Android source distribution (at least Eclair) and NDK r6b. If I was using NDK r6, this probably would have worked as it stands.
对某些源文件使用不同参数的最简单方法是将 Android.mk 中的这些文件组合在一起以生成静态库
include $(BUILD_STATIC_LIBRARY)
,然后该静态库将在LOCAL_STATIC_LIBRARIES
中列出code> 生成的共享对象。The easiest way to have different parameters for some source files is to group these files in Android.mk together to produce a static library
include $(BUILD_STATIC_LIBRARY)
which will then be listed inLOCAL_STATIC_LIBRARIES
for the resulting shared object.