简体   繁体   English

Android Studio NDK Build ninja gcc / clang命令行选项

[英]Android Studio NDK Build ninja gcc/clang command line options

In the new Android Studio NDK ninja build system (v 2.3+), what is the best way to dump the actual gcc/clang command line options? 在新的Android Studio NDK ninja生成系统(v 2.3+)中,转储实际gcc / clang命令行选项的最佳方法是什么?

Currently, I'm purposely inserting #error statements in my C file: 当前,我有意在我的C文件中插入#error语句:

...
#include <gperf.h>

#error "Compiler, stop!"

#define LOGI(...) \
  ((void)__android_log_print(ANDROID_LOG_INFO, "hell-libs::", __VA_ARGS__))

So that I can get the following command line dump: 这样我就可以得到以下命令行转储:

Build hello-libs arm64-v8a
[1/2] Building CXX object CMakeFiles/hello-libs.dir/hello-libs.cpp.o
FAILED: /Users/me/android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++  
--target=aarch64-none-linux-android --gcc-toolchain=/Users/me/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/me/android-ndk/platforms/android-21/arch-arm64  
-Dhello_libs_EXPORTS -I/Users/me/src/opensource/android-ndk/hello-libs/app/src/main/cpp/../../../../distribution/gmath/include -I/Users/me/src/opensource/android-ndk/hello-libs/app/src/main/cpp/../../../../distribution/gperf/include 
-isystem /Users/me/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /Users/me/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include -isystem /Users/me/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security  -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security   -std=gnu++11 -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/hello-libs.dir/hello-libs.cpp.o -MF CMakeFiles/hello-libs.dir/hello-libs.cpp.o.d -o CMakeFiles/hello-libs.dir/hello-libs.cpp.o -c /Users/me/src/opensource/android-ndk/hello-libs/app/src/main/cpp/hello-libs.cpp
/Users/me/src/opensource/android-ndk/hello-libs/app/src/main/cpp/hello-libs.cpp:24:2: error: "Compiler, stop!"
#error "Compiler, stop!"
 ^
1 error generated.
ninja: build stopped: subcommand failed.
:app:externalNativeBuildDebug FAILED

According to this CMake PR: https://github.com/Kitware/CMake/commit/ce935ebe50926bde199d86fbde4a78974a4043f9 根据此CMake PR: https : //github.com/Kitware/CMake/commit/ce935ebe50926bde199d86fbde4a78974a4043f9

You're supposed to be able to pass -DCMAKE_VERBOSE_MAKEFILE=ON to get Ninja -v, but I've never been able to get it to work. 您应该能够传递-DCMAKE_VERBOSE_MAKEFILE = ON来获得Ninja -v,但我从来没有能够使其正常工作。 I don't know why at the moment. 我现在不知道为什么。

The way I usually get the flags is to open the file android_gradle_build.json that is automatically generated by Android Studio/Gradle. 我通常获得标志的方法是打开由Android Studio / Gradle自动生成的文件android_gradle_build.json。 This file has all of the flags for each c/cpp file for the given ABI. 该文件具有给定ABI的每个c / cpp文件的所有标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM