将文件复制到 libs 文件夹作为构建脚本的一部分

发布于 2025-01-07 04:46:16 字数 865 浏览 0 评论 0原文

我有一个使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林迷了鹿 2025-01-14 04:46:16

好吧,看起来有一种更简单的方法可以复制 .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/.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文