Page 1 of 1

Source dir organization

Posted: Tue Dec 22, 2015 10:32 am
by tryphon
Hi,

my project gets bigger and bigger and I'd like to oragnize my source files in directories, like

src/chars/player/ containing c and h files related to player
src/chars/ennemy1/ containing c and h files related to one kind of ennemy
src/stages/stage11/
src/stages/stage12/
src/main.c

Will SGDK be able to find averything or have I to change something in the makefile ?

Re: Source dir organization

Posted: Tue Dec 22, 2015 2:15 pm
by djcouchycouch
Hello!

You'll have to modify the makefile.

You'll need to add those extra foldres to the SRC_C variable.

For example, here's what I have in the PingouinRose makefile.

Code: Select all

SRC_C= $(wildcard source/*.c)
SRC_C+= $(wildcard source/exported/GGAnimations/*.c)
SRC_C+= $(wildcard source/exported/maps/*.c)
SRC_C+= $(wildcard source/exported/spawns/*.c)
SRC_C+= $(wildcard source/exported/tileattributes/*.c)
SRC_C+= $(wildcard source/exported/*.c)
SRC_C+= $(wildcard source/generated/*.c)
SRC_C+= $(wildcard source/Objects/*.c)
SRC_C+= $(wildcard source/Levels/*.c)
And then you need to create those folders for the compiler when bulding .o files from the .c files.

Code: Select all

out/%.o: %.c
	@$(MKDIR) -p out
	@$(MKDIR) -p out/src
	@$(MKDIR) -p out/res
	@$(MKDIR) -p out/source/exported/
	@$(MKDIR) -p out/source/exported/GGAnimations
	@$(MKDIR) -p out/source/exported/maps
	@$(MKDIR) -p out/source/exported/spawns
	@$(MKDIR) -p out/source/exported/tileattributes
	@$(MKDIR) -p out/source/generated
	@$(MKDIR) -p out/source/Objects
	@$(MKDIR) -p out/source/Levels
	
	@$(CC) $(FLAGS) -c $< -o $@
I think that's all you need to do. I'm not a makefile guru so there might be a better solution.

Re: Source dir organization

Posted: Tue Dec 22, 2015 4:04 pm
by tryphon
Thanks. That doesn't seem to work. Lots of 'function' undeclared. I wonder if h files are found.

Or must I give the path in the include ?

#include "chars/player.h" ?

Re: Source dir organization

Posted: Tue Dec 22, 2015 8:02 pm
by Stef
yeah you should also add your subfolder as part of include folder as well !

Re: Source dir organization

Posted: Wed Dec 23, 2015 12:08 am
by tryphon
Thanks, it's okay now :)