开发者

Per-file CPPFLAGS in Android.mk

开发者 https://www.devze.com 2023-04-05 15:16 出处:网络
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.

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 sh开发者_StackOverflow社区ould 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.)


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.

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.


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 in LOCAL_STATIC_LIBRARIES for the resulting shared object.

0

精彩评论

暂无评论...
验证码 换一张
取 消