c project component issues

I am trying to get gradle to build a c project not c++

This is a sub module from an eventually larger project the structure is like this

now when i run gradle components I get this output
source sets
C source 'core_engine:c’
srcDir: ‘src/core_engine/c’

this seems to not pick up the header/ src project structure. I was watching this talk:

for how to structure the project. That talk says that gradle uses sane defaults with exported src and header files being in src & headers directories but this output doesn’t seem like its being setup properly.

I almost forgot, here is the build.gradle file that’s is outputting this

apply plugin: ‘c’

model {
components {
core_engine(NativeLibrarySpec) {

am i doing something wrong? I don’t seem to be setting something wrong.

The defaults are “src/${}/${language}” and “src/${}/headers”, so in your case it would be “src/core_engine/c” and “src/core_engine/headers”.

Here’s a sample for changing the source directories to something else (src/source):

thank you for the link and the explanation.

I apologize for bringing this issue back up but I restructured my code a little bit to fit in with the default gradle folder structure and tried to build a shared library but the build directory comes out empty.

Here are some screenshots of my process

This is the first screenshot showing the directory layout and the source files

this is the components view from gradle

this is the tasks view from gradle

This is me running the build command which turns out successful

This is the tree view after running the build shared library command, the folder is empty

I don’t have an executable atm since I am working on these components and will add an executable later.

Just a quick edit:
I am able to use gcc to compile the shared library like this:
bash-3.2$ gcc -shared -I/Users/blubee/SDL/bluengine/source/core_engine/headers/core_engin
e.h -lSDL2 -o ce src/c/core_engine.c

so by manually adding the linker args to gcc I can build. I tried editing my build.gradle to add -lSDL2 to the binaries.all but that’s still giving me a empty build directory with a successful build.

Here’s is the text of my build.gradle

apply plugin: ‘c’

model {
components {
core_engine(NativeLibrarySpec) {
binaries.all {
cCompiler.args “-lSDL2”

Take a look at the component report again (srcDir for core_engine is src/core_engine/c) and the layout you have now (src/c/).

oh wow, you are correct… That file structure thing seems a bit excessive

I had to change the directory structure to: src/core_engine/c/core_engine.c

Although since this is a fairly young project with not too much outside dependencies I’d just stick with gradle’s default.

Thanks for the tip again @sterling