Android的NDK:如何让编译器架构Android.mk动态 [英] Android NDK: How to get compiler architecture in Android.mk dynamically

查看:3568
本文介绍了Android的NDK:如何让编译器架构Android.mk动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想配置Android.mk交叉编译本土code,以支持不同的芯片组分别是armeabi,MIPS和x86。我知道我可以通过以下方式来编译源文件code代表不同的芯片组配置Application.mk:

  APP_ABI:=所有
 

这将触发的Andr​​oid NDK的构建脚本来编译源文件code对于所有的芯片组。不过,我想动态告诉Android.mk寻找不同的芯片组不同的编译静态库的依赖关系。

 #获取架构信息
ARCH:= ????

包括$(CLEAR_VARS)
LOCAL_MODULE:= MYLIB
LOCAL_SRC_FILES:=编译/ lib目录/ libxxx _ $(ARCH)。A
LOCAL_EXPORT_C_INCLUDES:= $(LOCAL_PATH)
包括$(preBUILT_STATIC_LIBRARY)
 

这是可能的吗?如果是的话,任何人都可以咨询该怎么办呢?

  

更新:我想是这样的Application.mk:

  APP_ABI:= armeabi armeabi-V7A MIPS 64位
 

     

与Android.mk:

 #获取架构信息
ARCH:= $(APP_ABI)

包括$(CLEAR_VARS)
LOCAL_MODULE:= MYLIB
LOCAL_SRC_FILES:=编译/ lib目录/ libxxx _ $(ARCH)。A
LOCAL_EXPORT_C_INCLUDES:= $(LOCAL_PATH)
包括$(preBUILT_STATIC_LIBRARY)
 

     

但具有下列它错误:

 的LOCAL_SRC_FILES为prebuilt静态库应该只包含一个项目
 

     

这是有道理的。我想通过APP_ABI:=所有Application.mk并能够   动态引用它。任何想法?

解决方案

TARGET_ARCH 变量保持当前ABI正在建造的价值。您可以使用它通过以下方式:

  IFEQ($(TARGET_ARCH),86)
    LOCAL_CFLAGS:= $(COMMON_FLAGS_LIST)
其他
    LOCAL_CFLAGS:= -mfpu = VFP -mfloat-ABI = softfp $(COMMON_FLAGS_LIST)
万一
 

如果您指定 APP_ABI:= armeabi-V7A armeabi MIPS 86 APP_ABI:=所有 Application.mk 你会得到每一个单独的ABI值。

I'm trying to configure Android.mk to cross compile native code to support different chipset namely armeabi, mips, and x86. I know I can configure Application.mk in the following way to compile the source code for different chip set:

APP_ABI := all

This will trigger Android-NDK's build script to compile the source code for all the chipsets. However, I want to dynamically tell Android.mk to look for different static library dependencies compiled with different chip set.

# Get the architecture info
ARCH := ????

include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)

Is this possible to do? If so, can anyone advice how to do so?

Update: I tried something like this in Application.mk:

 APP_ABI := armeabi armeabi-v7a mips x64

with Android.mk:

# Get the architecture info
ARCH := $(APP_ABI)

include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)

but it errors with the following:

 The LOCAL_SRC_FILES for a prebuilt static library should only contain one item

which makes sense. I want to pass APP_ABI := all in Application.mk and be able to dynamically reference it. Any ideas?

解决方案

There is TARGET_ARCH variable that holds the value of the current ABI being built. You can use it the following way:

ifeq ($(TARGET_ARCH),x86)
    LOCAL_CFLAGS   := $(COMMON_FLAGS_LIST)
else
    LOCAL_CFLAGS   := -mfpu=vfp -mfloat-abi=softfp $(COMMON_FLAGS_LIST)
endif

If you specify APP_ABI := armeabi-v7a armeabi mips x86 or APP_ABI := all in your Application.mk you will get each and every separate ABI value.

这篇关于Android的NDK:如何让编译器架构Android.mk动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆