Source dir organization

SGDK only sub forum

Moderator: Stef

Post Reply
tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Source dir organization

Post by tryphon » Tue Dec 22, 2015 10:32 am

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 ?

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Re: Source dir organization

Post by djcouchycouch » Tue Dec 22, 2015 2:15 pm

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.

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Re: Source dir organization

Post by tryphon » Tue Dec 22, 2015 4:04 pm

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" ?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Source dir organization

Post by Stef » Tue Dec 22, 2015 8:02 pm

yeah you should also add your subfolder as part of include folder as well !

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Re: Source dir organization

Post by tryphon » Wed Dec 23, 2015 12:08 am

Thanks, it's okay now :)

Post Reply