Sample for native cross compilation?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Sample for native cross compilation?

Xavier Ducrohet
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
Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

johnrengelman
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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Xavier Ducrohet
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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Daz DeBoer-2
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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Xavier Ducrohet
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]> 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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.



Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

johnrengelman
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]> 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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at 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 [hidden email]
To unsubscribe from gradle-dev, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Xavier Ducrohet
wow, indeed!

Shouldn't gradle complain that it doesn't recognize "toolchains"?

Anyway, now I'm getting errors because my toolchain isn't properly configured but I'm making progress. Thanks a lot!


On Thu, Mar 6, 2014 at 12:53 PM, johnrengelman <[hidden email]> wrote:
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]> 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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at 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 [hidden email]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Luke Daley-2


On 7 March 2014 at 7:04:37 am, Xavier Ducrohet ([hidden email]) wrote:

wow, indeed!

Shouldn't gradle complain that it doesn't recognize "toolchains"?

It will eventually. This is just a current shortcoming of the new incubating model configuration mechanism.




Anyway, now I'm getting errors because my toolchain isn't properly configured but I'm making progress. Thanks a lot!


On Thu, Mar 6, 2014 at 12:53 PM, johnrengelman <[hidden email]> wrote:
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]> 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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML


View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at 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 [hidden email]
To unsubscribe from gradle-dev, click here.
NAML


View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.



Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Xavier Ducrohet
glad to hear. thanks.


On Thu, Mar 6, 2014 at 1:06 PM, Luke Daley <[hidden email]> wrote:


On 7 March 2014 at 7:04:37 am, Xavier Ducrohet ([hidden email]) wrote:

wow, indeed!

Shouldn't gradle complain that it doesn't recognize "toolchains"?

It will eventually. This is just a current shortcoming of the new incubating model configuration mechanism.




Anyway, now I'm getting errors because my toolchain isn't properly configured but I'm making progress. Thanks a lot!


On Thu, Mar 6, 2014 at 12:53 PM, johnrengelman <[hidden email]> wrote:
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]> 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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML


View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at 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 [hidden email]
To unsubscribe from gradle-dev, click here.
NAML


View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.




Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Adam Murdoch
In reply to this post by Xavier Ducrohet

On 7 Mar 2014, at 7:45 am, Xavier Ducrohet <[hidden email]> 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’


This is a path to use to search for the ‘gcc’ binary, rather than the path to the binary itself.

You also need to separately tell the toolchain which binary to use:

mingw(Gcc) {
cCompile.executable = ‘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]> 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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.





--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com



Reply | Threaded
Open this post in threaded view
|

Re: Sample for native cross compilation?

Xavier Ducrohet
hey Adam, yes I've discovered this (see other thread).

A quick note though:

mingw(Gcc) {
cCompile.executable = ‘i586-mingw32msvc-gcc’

doesn't work for some reason. It requires

mingw(Gcc) {
getCCompile().executable = ‘i586-mingw32msvc-gcc’

Also, as mention in the other thread, when it checks on the toolchain it doesn't use the customize compiler name.


On Thu, Mar 6, 2014 at 1:13 PM, Adam Murdoch <[hidden email]> wrote:

On 7 Mar 2014, at 7:45 am, Xavier Ducrohet <[hidden email]> 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’


This is a path to use to search for the ‘gcc’ binary, rather than the path to the binary itself.

You also need to separately tell the toolchain which binary to use:

mingw(Gcc) {
cCompile.executable = ‘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]> 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:


cheers
Daz



On Thu, Mar 6, 2014 at 11:39 AM, Xavier Ducrohet <[hidden email]> 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 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]> 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} {
                        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]
To unsubscribe from gradle-dev, click here.
NAML



View this message in context: Re: Sample for native cross compilation?
Sent from the gradle-dev mailing list archive at Nabble.com.





--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com