How do you force gradle to print or log all compiler commands executed?

非 Y 不嫁゛ 提交于 2020-02-27 22:26:15

问题


I'm trying to see the exact compiler commands (in my case gcc) used by gradle during execution of all build tasks. Running with --debug doesn't output these commands, and output files in build/tmp don't have them either. I'm currently using Gradle 2.6


回答1:


See $projectDir/build/tmp

You should have a folder structure that looks something like:

├───compileMainSharedLibraryMainCpp
│       options.txt
│       output.txt
│
├───compileMainStaticLibraryMainCpp
│       options.txt
│       output.txt
│
├───createMainStaticLibrary
│       options.txt
│       output.txt
│
└───linkMainSharedLibrary
        options.txt
        output.txt

options.txt contains the options passed to the compiler/linker etc, and output.txt contains the output of the compiler/linker.




回答2:


The following snippet in build.gradle prints options (not complete command line):

toolChains {
    gcc(Gcc) {
        eachPlatform { 
            cppCompiler.withArguments { args ->
                println "----> C++ args: " + args
            }
        }
    }
}    


来源:https://stackoverflow.com/questions/34248120/how-do-you-force-gradle-to-print-or-log-all-compiler-commands-executed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!