问题描述
我工作的一个Android.mk文件中,对于单个模块,其中一个文件需要不同的CPPFLAGS;即,它需要-frtti启用,而另一些则需要-fno-RTTI的Android的默认值。
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.
下面是从我的Android.mk提取物(名称变更为保护我):
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
我已经尝试了简单地做 foo_baz.o:
代替$(my_intermediates),并试图取代 + =
为:=
来没有变化。
I have tried simply doing foo_baz.o:
in lieu of $(my_intermediates), and have tried substituting +=
for :=
to no change.
那么,有没有一个Android特定的方式来覆盖CPPFLAGS(或CFLAGS)特定的源文件?
So, is there an Android-specific way to override CPPFLAGS (or CFLAGS) for a specific source file?
(在这种情况下,我使用了Eclair的Android的人士透露,尽管它可以向NDK;见我的回答,下同)
(In this case I'm using the Eclair Android sources, though it may apply to the NDK; see my answer, below.)
推荐答案
正如往常一样,问了它花费了大量的时间之后,我发现在很短的时间回答问题。我需要使用 PRIVATE_CPPFLAGS
而不是 LOCAL_CPPFLAGS
。
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 of LOCAL_CPPFLAGS
.
不过,这只是似乎是为Android源代码分发的情况下(至少埃克莱尔)和NDK R6B。如果我是使用NDK R6,这很可能会担任它的立场。
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.
这篇关于按文件CPPFLAGS在Android.mk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!