如何获得ndk-build使用的全套编译器和链接器标志? [英] How do you get the full set of compiler and linker flags used by ndk-build?

查看:143
本文介绍了如何获得ndk-build使用的全套编译器和链接器标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种直接的方法来获取NDK构建所使用的全套编译器和链接器标志?现在,我们通过浏览将C ++添加到Android Studio项目中时创建的cmake文件来破解事物.

Is there a straightforward way to get the full set of compile and linker flags used by NDK builds? Right now we're hacking things by looking through the cmake files created when you add C++ to an Android Studio project.

问题在于,在大多数情况下,我们正在构建许多现有的第三方项目,每个项目都有自己的构建系统.重写构建系统以使用Android的工具(cmake和ndk-build系统)会很疯狂;我们需要使用现有的make系统,并且在绝大多数时间中,这意味着我们需要向配置脚本提供CFLAGS,CXX_FLAGS,CPPFLAGS,LDFLAGS等内容.除了查看本机Android ndk构建的输出外,这些标记集都没有记录在我发现的任何地方.

The problem is that the vast majority of the time we're building many existing 3rd-party projects that each have their own build systems. Rewriting the build systems to use Android's tools (the cmake and ndk-build systems) would be insane; we need to use the existing make systems, and the vast majority of the time that means we need to provide things like CFLAGS, CXX_FLAGS, CPPFLAGS, LDFLAGS, etc to configuration scripts. And those sets of flags aren't documented anywhere that I've found, other than by watching the output of native Android ndk builds.

更新:我想我不清楚我到底想要什么.

UPDATE: I think I wasn't quite clear on exactly what I wanted.

我们有一些讨厌的脚本,可以使用cmake设法从现有的构建中吸取正确的标志集. (您说这将花费您20分钟的那些项目之一,而您可笑的是错误的.).这些脚本随r16 beta 1一起发布.我真的不必只编写令人讨厌的不稳定脚本来拉出标志,因为无论如何它们可能会与下一个ndk版本一起发布.

We had some nasty scripts that managed to suck the right set of flags out of an existing build using cmake. (One of those projects where you say it'll take you twenty minutes, and you're laughably wrong.). Those scripts broke with r16 beta 1. I'd really not have to write nasty unstable scripts just to pull out flags, since they'll probably break with the next ndk release anyway.

(这是我们脚本的最后输出,以防您想看到我在说的标志:

(Here's the last output from our scripts, in case you'd like to see the flags I'm talking about: https://gist.github.com/banshee/15f1a5fbce0c71af6498656bb02ebc67)

推荐答案

对于自定义生成系统,您应该使用

For custom build systems you should use a standalone toolchain. That'll handle getting all the basic flags right for targeting Android. It won't handle any of the decisions best left to the build system though such as optimization level, debug flags, etc.

不幸的是,您当前的解决方案目前尚可解决.最终,工具链配置将被移至$NDK/meta中的JSON文件中,就像已经拥有的一些(琐碎的)东西一样,因此我们可以在ndk-build和CMake之间共享该信息,但这不会很快发生.

Unfortunately your current solution is as good as it can get for the time being. Eventually the toolchain configuration will be moved into JSON files in $NDK/meta like a few (trivial) things already have so we can share that info between ndk-build and CMake, but that's not happening any time soon.

这篇关于如何获得ndk-build使用的全套编译器和链接器标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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