Hey guys,

I'm currently working on improving the toolchain configuration.

With my latest changes it is possible to tweak commandline arguments
also for visualcpp toolchain:

model {
            toolChains {
                visualCpp(VisualCpp) {
                    cppCompiler.withArguments { args ->
                            args << "-DFRENCH"
                    }
                }
            }
}

Furthermore I tweaked the AbstractGccToolchain to allow a custom
executable per targetplatform:

model {
                toolChains {
                    clang(Clang) {
                        target("arm"){
                            cCompiler.executable = '/usr/bin/my-c-compiler'
                        }
                    }
                }
                platforms {
                    arm {
                        architecture "arm" // uses custom-c-compiler
                    }
                    i386 {
                        architecture "i386" // uses default clang
                    }
                }
            }

I'm not sure if customizing the executable for a visualcpp toolchain is
necessary. I don't have a usecase for that in mind.

In
https://github.com/gradle/gradle/blob/master/design-docs/continuous-delivery-for-c-plus-plus.md#story-improved-dsl-for-tool-chain-configuration
we replace the withArgument method with a "withInvocation" block:

model {
    toolChains {
        gcc(Gcc) {
            cppCompiler.withInvocation {
                executable "my-cpp-compiler"
                args.replace("-m32", "-march=i386")
            }
         }
    }
} 


This defers the configuration of the executable just before the
compilation is started. IMO has different pros & cons

- we can react on the default selected executable (e.g. pipe all clang++
calls via my own clang script)
- a possible expensive configuration is only done when compilation is
done in the build
- every toolchain evaluates if the necessary tools are available. in the
last example this would look for a clang executable when detecting
available toolchains, even though it is not used.

I discussed the current need for "withInvocation" with Daz a while ago
and I'm not sure about the benefit of this atm. Are there usecases here
I havn't thought of?

cheers,
René


Reply via email to