Android NDK 中的调试与发布构建
我正在开发一个必须移植到 Android 的大型游戏引擎。所有代码都是 C/C++,因此我们通过 NDK 进行移植。我已经构建了所有内容,但经过大量搜索后,我仍然不确定构建 .so 文件的调试版本与发布版本的最佳方法是什么。每次都用手改变东西已经很老了。
每个目标都有不同的 Application.mk 文件吗?或者是否有某种方法可以将多个目标包含在 jni/ 目录下的单个 Android.mk 文件中?或者第三种选择可能是编写一个标准 makefile,设置 Android.mk 文件用来通知构建过程的环境变量?
最后,还有一个关于必须在 AndroidManifest.xml 文件中设置的 android:debuggable 标志的问题。这实际上对复制到设备的生成的本机代码有什么影响?
最好的,谢谢,
凯文
I'm working on a large game engine that must be ported to Android. All the code is C/C++, so we are porting via the NDK. I've got everything building, but after lots of scouring, I'm still uncertain what the best method is for building Debug vs. Release versions of our .so file. Changing things by hand every time is getting old.
Do you have different Application.mk files for each target? Or is there some way to include multiple targets in a single Android.mk file under the jni/ directory? Or perhaps a third option might be to write a standard makefile that sets environment variables that the Android.mk file uses to inform the build process?
Finally, one last question regarding the android:debuggable flag that must be set in the AndroidManifest.xml file. What this actually have any effect on the generated native code that's copied to the device?
Best and thanks,
Kevin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不。单独的子目录,都有自己的 Android.mk(共享和静态库),但对我来说只有一个 Application.mk。
我的 Application.mk 只是:
至少对我来说,使用 jni/Android.mk + Application.mk 布局有点分散。
Application.mk 有
APP_OPTIM := debug
然后在 AndroidManifest.xml 的应用程序元素中我有
android:debuggable="true"
当您使用 ndk-build 进行构建时,它使用此清单标志来确定优化(这对于关闭或打开、关闭以进行分析等很有用)
(有点偏离主题)我最近遇到了
https://code.google.com/p/android-ndk-profiler/
与 http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
生成一些漂亮的图像来帮助我很少有人了解手机本身是如何运行的。
No. Separate subdirectories, all with their own Android.mk (shared and static libs) but only one Application.mk for me.
My Application.mk is just:
It's a bit spread out, for me at least, using the jni/Android.mk + Application.mk layout.
Application.mk has
APP_OPTIM := debug
Then in the application element of AndroidManifest.xml I have
android:debuggable="true"
When you build with ndk-build, it uses this manifest flag to determine optimization (which is useful to turn off or on, off for profiling, etc.)
(A Little Off topic) I recently ran across
https://code.google.com/p/android-ndk-profiler/
Which, when combined with http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
Generates some pretty images to help my little mind grasp how things are running over on the phone itself.
您不需要使用 Android.mk 系统来构建 .so。就我个人而言,我将自己的 Makefile 与我需要的目标一起使用,这允许非常标准化的调试与发布构建规范。
You're not required to use the Android.mk system to build your .so's. Personally, I use my own Makefile's with the targets I need and this allows for very standardized debug vs. release build specification.
我使用单个文件为不同的目标构建一个库。在 Application.mk 中添加此“APP_ABI := armeabi armeabi-v7a”,它对我有用。
I use a single file to build a library for diferent targets. In the Application.mk add this "APP_ABI := armeabi armeabi-v7a" it works for me.