Inside the model { }, you need 'toolChains' instead of 'toolchain' -- John
On Thursday, March 6, 2014 at 2:46 PM, Xavier Ducrohet [via Gradle] wrote: > Thanks Daz for confirming what John said. > > So here's my current attempt: > > model { > platforms { > linux32 { > architecture "i386" > operatingSystem "linux" > } > linux64 { > architecture "x86_64" > operatingSystem "linux" > } > windows32 { > architecture "i386" > operatingSystem "windows" > } > darwin32 { > architecture "i386" > operatingSystem "osx" > } > } > toolchains { > mingw(Gcc) { > path '/usr/bin/i586-mingw32msvc-gcc' > addPlatformConfiguration(new MingwOnLinuxConfiguration()) > } > } > } > > class MingwOnLinuxConfiguration implements TargetPlatformConfiguration { > boolean supportsPlatform(Platform element) { > return element.getOperatingSystem().name == "windows" > } > > List<String> getCppCompilerArgs() { > [] > } > > List<String> getCCompilerArgs() { > [] > } > > List<String> getObjectiveCCompilerArgs() { > [] > } > > List<String> getObjectiveCppCompilerArgs() { > [] > } > > List<String> getAssemblerArgs() { > [] > } > > List<String> getLinkerArgs() { > [] > } > > List<String> getStaticLibraryArchiverArgs() { > [] > } > } > > > When I try to build the windows exe on linux it says: > > * What went wrong: > Execution failed for task ':compileWindows32MksdcardExecutableMksdcardC'. > > No tool chain is available to build for platform 'windows32': > - Tool chain 'visualCpp' (Visual Studio): Visual Studio is not available > on this operating system. > - Tool chain 'gcc' (GNU GCC): Don't know how to build for platform > 'windows32'. > - Tool chain 'clang' (Clang): Could not find C++ compiler 'clang++' in > system path. > > > It seems it didn't even add my custom toolchain? > > > On Thu, Mar 6, 2014 at 11:52 AM, Daz DeBoer <[hidden email] > (/user/SendEmail.jtp?type=node&node=5712429&i=0)> wrote: > > Hi Xav > > The current DSL for configuring a cross compiler is not great, but it > > should be functional. The way it works is you can define any number of Gcc > > tool chains: Gradle will iterate over them in order, checking if each can > > build for the target platform. By default a Gcc tool chain can target > > 'i386', 'x86-64', and the 'tool chain default' architecture. The last one > > is what you get if you don't define a platform for your binary. > > > > You can specify that a tool chain can support a platform with > > `PlatformConfigurableToolChain.addPlatformConfiguration()`. One ugly part > > of the DSL is that you need to implement TargetPlatformConfiguration to do > > this. > > > > So let's say you have: > > toolChains { > > gcc(Gcc) // The default gcc install > > mingw(Gcc) { > > path "path-to-my-cross-compiler" > > addPlatformConfiguration(new MingwOnLinuxConfiguration()) // returns > > "true" for supportsPlatform(windows), and supplies necessary args > > } > > } > > > > Then when trying to build for windows, Gradle will first check 'gcc', which > > cannot target windows, then mingw, which can. > > > > Let me know if that still doesn't make sense. > > > > There are some plans to improve the DSL for this. Any suggestion would be > > welcome: > > > > https://github.com/gradle/gradle/blob/master/design-docs/continuous-delivery-for-c-plus-plus.md#story-improved-dsl-for-tool-chain-configuration > > https://github.com/gradle/gradle/blob/master/design-docs/continuous-delivery-for-c-plus-plus.md#story-improved-dsl-for-platform-specific-tool-chain-configuration > > > > cheers > > Daz > > > > > > > > On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email] > > (/user/SendEmail.jtp?type=node&node=5712429&i=1)> wrote: > > > thanks for this pointer, I'll take a look. > > > > > > I'm still not clear how the platform thing work and how "Gradle will > > > attempt to locate a ToolChain > > > (http://www.gradle.org/docs/current/dsl/org.gradle.nativebinaries.toolchain.ToolChain.html) > > > that is able to build for the target platform." In my case I need it to > > > use a custom toolchain and all the things that goes with it. I'll > > > experiment. > > > > > > > > > > > > > > > On Wed, Mar 5, 2014 at 7:10 PM, johnrengelman <[hidden email] > > > (/user/SendEmail.jtp?type=node&node=5712429&i=2)> wrote: > > > > I have no experience using the native tools but I think you can > > > > reference the GccToolChainCustomisationIntegrationTest class in > > > > gradle-core. > > > > > > > > In that test they are doing the following: > > > > model { > > > > toolChains { > > > > ${gcc.id (http://gcc.id)} { > > > > addPlatformConfiguration(new ArmArchitecture()) > > > > } > > > > } > > > > platforms { > > > > arm { > > > > architecture "arm" > > > > } > > > > i386 { > > > > architecture "i386" > > > > } > > > > } > > > > } > > > > > > > > class ArmArchitecture implements > > > > TargetPlatformConfiguration { > > > > boolean supportsPlatform(Platform element) { > > > > return element.getArchitecture().name == "arm" > > > > } > > > > > > > > List<String> getCppCompilerArgs() { > > > > ["-m32", "-DFRENCH"] > > > > } > > > > > > > > List<String> getCCompilerArgs() { > > > > ["-m32", "-DFRENCH"] > > > > } > > > > > > > > List<String> getObjectiveCCompilerArgs() { > > > > [] > > > > } > > > > > > > > List<String> getObjectiveCppCompilerArgs() { > > > > [] > > > > } > > > > > > > > List<String> getAssemblerArgs() { > > > > [] > > > > } > > > > > > > > List<String> getLinkerArgs() { > > > > ["-m32"] > > > > } > > > > > > > > List<String> getStaticLibraryArchiverArgs() { > > > > [] > > > > } > > > > } > > > > > > > > > > > > My guess is that you'll want to do something like that. > > > > > > > > -- John > > > > > > > > > > > > On Wednesday, March 5, 2014 at 8:44 PM, Xavier Ducrohet [via Gradle] > > > > wrote: > > > > > > > > > > > > > > > > > Hey all, > > > > > > > > > > I'm looking at the native support to attempt to build the tools part > > > > > of the Android SDK with gradle. We have a few small native tools that > > > > > needs to be compile and we cross compile the windows version on linux > > > > > using mingw32. > > > > > > > > > > I was wondering if that would be supported since it's (like?) gcc? > > > > > also I've been looking for an example of cross compilation but there > > > > > isn't any, and the PlatformConfigurableToolChain DSL reference isn't > > > > > super helpful :\ > > > > > > > > > > A quick pointer on how to define a cross compilation target would be > > > > > awesome, thanks! > > > > > Xav > > > > > > > > > > > > > > > > > > > > If you reply to this email, your message will be added to the > > > > > discussion below: > > > > > http://gradle.1045684.n5.nabble.com/Sample-for-native-cross-compilation-tp5712413.html > > > > > > > > > > To start a new topic under gradle-dev, email [hidden email] > > > > > (http://user/SendEmail.jtp?type=node&node=5712414&i=0) > > > > > To unsubscribe from gradle-dev, click here. > > > > > NAML > > > > > (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml) > > > > > > > > > > > > > > > > > View this message in context: Re: Sample for native cross compilation? > > > > (http://gradle.1045684.n5.nabble.com/Sample-for-native-cross-compilation-tp5712413p5712414.html) > > > > Sent from the gradle-dev mailing list archive > > > > (http://gradle.1045684.n5.nabble.com/gradle-dev-f1436218.html) at > > > > Nabble.com (http://Nabble.com). > > > > > > > > > If you reply to this email, your message will be added to the discussion > below: > http://gradle.1045684.n5.nabble.com/Sample-for-native-cross-compilation-tp5712413p5712429.html > > To start a new topic under gradle-dev, email > ml-node+s1045684n1436218...@n5.nabble.com > (mailto:ml-node+s1045684n1436218...@n5.nabble.com) > To unsubscribe from gradle-dev, click here > (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1436218&code=am9obi5yLmVuZ2VsbWFuQGdtYWlsLmNvbXwxNDM2MjE4fDIyMTUyNjEzNQ==). > NAML > (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml) > -- View this message in context: http://gradle.1045684.n5.nabble.com/Sample-for-native-cross-compilation-tp5712413p5712430.html Sent from the gradle-dev mailing list archive at Nabble.com.