Gradle native build folder structure

This native plugin gradle build script fails right around line 21 which is where I tried something outside the ordinary for gradle which is defining a nativelibraryspec with a slash in the folder path.

  apply plugin: 'c'
    
    model { 
        components { 
           project(NativeExecutableSpec) { 
           
           }
    
           core_engine(NativeLibrarySpec) { 
           
           }
    
           core_math(NativeLibrarySpec) { 
           
           }
    
           core_graphics(NativeLibrarySpec) { 
           
           }
    
           core_graphics/sprite(NativeLibrarySpec) {
    
           }
        }
    }

Typically in c projects you’ll have one folder to describe a module then sub folders below that for different implementation of that module.

Example
…/math/
…/math/vector2
…/math/vector3
…ect

currently in gradle this can only be achieved by doing this?

    sources {
        c {
            source {
                srcDir "src/source"
                include "**/*.c"
            }
            exportedHeaders {
                srcDir "src/include"
            }
        }
    }

Note that what you are specifying when you create a component is the name of the component and not necessarily the path to its sources. The path to the sources are derived from the name by convention, but the value being specified is the name of the component. Note that what you are running into, however, is that it’s treating the “/” as an operator. It is possible to create a component name with a “/” by treating it as a string:

model {
  components {
    "core_engine/sprite"(NativeLibrarySpec) {
    }
  }
}

I’m not sure that a component with a “/” in the name is a good idea, however, because it seems like it could create some unintended side effects.

Probably a better approach would be to use a naming convention where the path can be derived from the name in some way, then use a components.all {} rule to set up the source directories based on the conventional name of the component.

thanks for the tips.

I am writing a project that I will use gradle for then come back in hopes to get some critique and ask for advice on improving. The 2015 gradle summit for native offered a lot of great tips.