问题描述
我要建立我的图书馆ARMv6的,且有一定的霓虹灯code,我在运行时启用,如果设备支持的话。霓虹灯code使用霓虹灯内部函数,并能够编译它,我必须启用armeabi-V7A,但影响常规的C code(它成为一些低端设备破碎)。
I want to build my library for armv6, and there is some neon code that I enable at runtime if the device supports it. The neon code uses neon intrinsics, and to be able to compile it, I must enable armeabi-v7a, but that affects regular c-code (it becomes broken on some low-end devices).
因此,如果Android编译系统并不过分打扰,我不会要问的问题,但似乎也没有办法,我编一个文件ARMv6及其他文件ARM7的霓虹灯。
So, if the android build system wasn't excessively intrusive, I wouldn't have to ask questions, but it seems that there is no way for me to compile one file for armv6 and the other file for arm7-neon.
任何人都可以给任何线索,如果这是可行的?
Can anybody give any clues if that's doable?
修改
在试图回答,浪费网络墨水,它应该清楚,这些都是要点:
1)进行一次完整库。
2)使构建在运行的ARMv6(pre霓虹灯设备,如armeabi)。
3)允许此版本也包含NEON code(可以根据运行时的CPU检测执行; CPU检测的问题的范围)之外
4) NEON code来自AC / CPP文件,并使用霓虹灯内部函数编写。
Edit
Before trying to reply and wasting internet-ink, it should be clear that these are the main points:
1) make only ONE lib.
2) make build that runs on armv6 (pre neon devices, e.g. armeabi).
3) allow this build to also contain NEON code (which could be executed based on run-time cpu detection; cpu detection is outside the scope of the question).
4) NEON code comes from a c/cpp file and is written using neon intrinsics.
忽略任何部分这些要求完全失去了问题的要点
推荐答案
我最近发现另一种方式来解决NDK的限制。我的情况是不相关的NEON,但你同样的黑客可以做的工作。
I have recently found another way to work around the limitations of NDK. My case was not related to NEON, but for you the same hack could do the job.
的技巧是使用NDK的现有的标签机制,指定特殊的 CFLAGS
的一堆文件。这是你如何做到这一点:
The trick is to use the existing "tag" mechanism of NDK to specify special CFLAGS
for a bunch of files. This is how you do it:
首先,列出霓虹灯具体来源。在的因为build-binary.mk会发现,你的目标不是armeabi-V7A。我用下面的方法:
First, list the neon-specific sources. You cannot use the .neon
suffix as described in docs/CPU-ARM-NEON.html because build-binary.mk will find that you are not targeting armeabi-v7a. I use the following technique:
LOCAL_NEON_SRC_FILES := imgproc/neon_utils.c \
videoproc/usingneon.cpp
LOCAL_SRC_FILES := main.c \
imgproc/img.c \
videoproc/video.cpp
LOCAL_SRC_FILES += $(LOCAL_NEON_SRC_FILES)
现在,定义 CFLAGS
的NEON:
Now, define the CFLAGS
for NEON:
LOCAL_NEON_CFLAGS := -mfloat-abi=softfp -mfpu=neon -march=armv7
最后,下面的神奇行添加到您的Android.mk:
Finally, add the following magical line to your Android.mk:
TARGET-process-src-files-tags += $(call add-src-files-target-cflags, $(LOCAL_NEON_SRC_FILES), $(LOCAL_NEON_CFLAGS))
如果你有多个二进制程序来建立,你可能会想要 $(LOCAL_NEON_SRC_FILES)
通过
If you have more than one binary to build, you will probably want $(LOCAL_NEON_SRC_FILES)
to be reset by
include $(CLEAR_VARS)
对于这一点,以下内容添加到您的 Android.mk
或 Application.mk
:
modules-LOCALS += NEON_SRC_FILES
注:我还没有尝试过这种神奇的霓虹灯,我需要它完全不同的目的。你可能需要一些调整,以达到预期的编译选项为您的文件,并为您的项目。我使用的 NDK r.8b 和我没有检查,如果这将工作在早期(或更高版本)版本。
Note: I have not tried this magic for NEON, I needed it for entirely different purposes. You may need some adaptations to achieve the desired compilation options for your files, and for your project. I am using NDK r.8b, and I did not check if this would work on earlier (or later) versions.
这篇关于Android编译系统,NEON和非NEON构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!