简体   繁体   English

如何指定Android NDK CMake构建目录

[英]How to specify Android NDK CMake build directory

I'm building some C++ libraries through Android Studio and I would like not to pollute my source tree with those .externalNativeBuild folders. 我正在通过Android Studio构建一些C ++库,并且我不想用那些.externalNativeBuild文件夹污染我的源代码树。

Is it possible to specify where they should land much like buildDir for Java binaries? 是否可以指定它们应该像Java二进制文件的buildDir那样buildDir在哪里?

I tried using that -B argument like that: 我试过像这样使用-B参数:

   externalNativeBuild
    {
        cmake
        {
            arguments '-DANDROID_PLATFORM=android-14',
                    '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static',
                    '-BC:/Dev/AndroidCMake'
        }
    }

It works to some extent as the specified folder is created and contains some of the build's by-products. 创建指定的文件夹后,它在某种程度上可以正常工作,并且包含构建的一些副产品。 However the build is broken and the .externalNativeBuild folder is still created. 但是,构建已中断,并且仍创建了.externalNativeBuild文件夹。 It contains some files too. 它也包含一些文件。 So it looks like that folder is specified somewhere else in the tool chain. 因此,看起来该文件夹是在工具链中的其他位置指定的。

Here is the error I'm getting: 这是我得到的错误:

Error:Expected json generation to create 'C:\\Dev\\Android\\TestApp\\app\\.externalNativeBuild\\cmake\\debug\\armeabi-v7a\\android_gradle_build.json' but it didn't

That json file landed in the specified -B folder but the toolchain is still expecting it in that other folder. 该json文件位于指定的-B文件夹中,但工具链仍期望该文件位于该其他文件夹中。

I chanced upon the answer to my own question. 我偶然发现了自己的问题的答案。 Apparently you need to use that buildStagingDirectory property. 显然,您需要使用该buildStagingDirectory属性。 I have yet to test it but I'm fairly confident it will do the trick. 我尚未对其进行测试,但我相当有信心它将成功。

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

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