Add custom source directory?


(creativexp) #1

Hi,

I am new to Gradle and trying to create a cross platform build script.
I wish to use a custom source directory. Not src/{ProjectName}/cpp or header/{ProjectName}/cpp.
My source files are in folders named “src” and “include” at the same level as the build.gradle file.

Please see image of my project directory structuregradle_dir

How do i link to those source folders only? The gradle cpp library example does not cover this.
The script i have made builds successfully but does not produce an exe. I guess because it cant find the cpp files.

Better yet how can i see the paths being used by gradle?
options -"-info" and “–debug” don’t seem to output the source paths used.

Below is my full script…

apply plugin: 'cpp' 

model { 

    buildTypes {
        debug
        release
    }

    platforms {

        //osx_64 {
            //architecture "x86_64"
            //operatingSystem "osx"
        //}

        windows_x86 {
            architecture "x86"
            operatingSystem "windows"
        }

        windows_64 {
            architecture "x86_64"
            operatingSystem "windows"
        }
    }

    repositories {
        libs(PrebuiltLibraries) { 
            libcinder { 
                headers.srcDir "/../cinder/include/" 
                binaries.withType(StaticLibraryBinary) {
                    if (targetPlatform.operatingSystem.windows) {
                        if (targetPlatform == platforms.windows_x86) {
                            if(buildType == buildTypes.debug) {
                                staticLibraryFile = file("/../cinder/lib/msw/x86/Debug/v140/cinder.lib") 
                            } else if(buildType == buildTypes.release) {
                                staticLibraryFile = file("/../cinder/lib/msw/x86/Release/v140/cinder.lib") 
                            }
                        } else if(targetPlatform == platforms.windows_64) {
                            if(buildType == buildTypes.debug) {
                                staticLibraryFile = file("/../cinder/lib/msw/x64/Debug/v140/cinder.lib") 
                            } else if(buildType == buildTypes.release) {
                                staticLibraryFile = file("/../cinder/lib/msw/x64/Release/v140/cinder.lib") 
                            }
                        } 
                    } //else if(targetPlatform.operatingSystem.o osx) {
                        //if (targetPlatform == platforms.osx_64) {
                            //if(buildType == buildTypes.debug) {
                                //staticLibraryFile = file("/../cinder/lib/macosx/Debug/libcinder.a") 
                            //} else if(buildType == buildTypes.release) {
                                //staticLibraryFile = file("/../cinder/lib/macosx/Release/libcinder.a") 
                            //}
                        //}
                    //}
                }
            }
        }
    }

    components {
        main(NativeExecutableSpec) {
            sources {
                cpp {
                    source {
                        srcDir "src"
                        include "include"
                        cpp.lib library: "libcinder", linkage: "static" 
                    }
                }
            }
        }
    }

/*
    components {
        main(NativeExecutableSpec) {
            sources {
                cpp.lib library: "libcinder", linkage: "static" 
            }
        }
    }
*/    
}