将文件复制到 libs 文件夹作为构建脚本的一部分
我有一个使用 jni 的 android 应用程序,我正在尝试在 Eclipse 中自动化构建过程(使用 cdt 插件)。我需要构建自己的静态库,并且还需要使用一些预编译的库。
这意味着我需要
a)构建我自己的共享库(这里没有问题)
b)构建完成后,将现有库复制到 libs/armeabi 文件夹中(因为在构建过程中该文件夹将被清除,我必须在每次构建后复制这些文件)
我对 b)有一些问题。我想做的是在 Android.mk 文件中包含 $(BUILD_SHARED_LIBRARY) 之后插入自定义 shell 脚本(按原样执行时有效)。不幸的是,这不起作用,因为显然 /libs/armeabi 文件夹只有在 Android.mk 文件完成后才会被清除。
这是真的吗?有没有办法将构建后脚本插入 Android.mk 中?有什么方法可以在 jni 代码完成构建之后但在整个构建完成之前执行 bash 脚本(例如在构建 java 部分并且应用程序开始执行之前?)?我虽然 eclipse c/c++ 项目构建设置中必须有某种“构建后”脚本,但没有这样的东西。
这是完整的 Android.mk 文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_MODULE := player
LOCAL_SRC_FILES := player.c
include $(BUILD_SHARED_LIBRARY)
$(shell ./copy-libs.sh) #this script will get called, but the files will be erased right after
I have an android application which uses jni and I'm trying to automate build process in Eclipse (using cdt plugin). I need to build my own static library, and I also need to use some precompiled libraries.
That means that I need to
a) build my own shared library (no problems here)
b) after build is complete, copy existing libraries into libs/armeabi folder (because this folder will be cleared during build process I must copy those files after every build)
I have some problems with b). What I'm trying to do is I'm inserting custom shell script (which works when executed as-is) after include $(BUILD_SHARED_LIBRARY) in Android.mk file. Unfortunately, this doesn't work, because apparently /libs/armeabi folder gets cleared only after Android.mk file is complete.
Is that true? Is there a way to insert post-build script into Android.mk? Is there any way I can execute bash script after jni code finished building but before whole build is complete (e.g. before java part is build and application starts executing?)? I though there must be some kind of "post-build" script in eclipse c/c++ project build settings, but there is no such thing.
Here's the complete Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_MODULE := player
LOCAL_SRC_FILES := player.c
include $(BUILD_SHARED_LIBRARY)
$(shell ./copy-libs.sh) #this script will get called, but the files will be erased right after
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,看起来有一种更简单的方法可以复制 .so 和 .a 库,而无需求助于自定义构建脚本。
NDK 支持从 ndk-r5 开始的预构建模块,并且它们允许在构建过程中根据需要将 .a 或 .so 库复制到 obj/lib 文件夹中。
$NDK_INSTALLATION_FOLDER/docs/ 内的 PREBUILTS.html 文件提供了示例和完整说明。
Well, it looks like there is an easier way to copy .so and .a libs without resorting to custom build scripts.
NDK supports prebuilt modules starting from ndk-r5, and they allow to copy .a or .so libraries into obj/lib folder during build process as needed.
Example and complete description are available in PREBUILTS.html file inside $NDK_INSTALLATION_FOLDER/docs/.