Page 1 of 1
resource.rc
Posted: Tue Jul 02, 2013 1:36 pm
by djcouchycouch
Hi,
Every time I modify the contents of a bitmap in the game data, I also need to "touch" or modify the resource.rc file. If I don't, the bitmap don't get converted to binary and integrated into the rom. Is it possible to fix the make file so that not only it checks the resource.rc but also assets like bitmaps?
I've got a work around where I manually "touch" the resource file at every build, but I wonder if there's something more efficient possible.
Thanks!
DJCC
Posted: Tue Jul 02, 2013 5:34 pm
by Chilly Willy
The simplest thing is to clean the project each time. For smaller projects, that's no big deal. Just "make clean" before making the project. For BIG projects that take an hour to compile, you'd want to read up on dependencies in make scripts.
Posted: Tue Jul 02, 2013 8:25 pm
by djcouchycouch
Chilly Willy wrote:The simplest thing is to clean the project each time. For smaller projects, that's no big deal. Just "make clean" before making the project. For BIG projects that take an hour to compile, you'd want to read up on dependencies in make scripts.
At the moment, my needs are at the "no big deal" point. So my workaround is currently fine.
I'd argue that the current behavior is a kind of bug. The files referred to in the resource.rc should be checked for modifications as well.
Posted: Tue Jul 02, 2013 10:47 pm
by Stef
The SGDK makefile is intended to be as much generic as possible but because of that the dependencies are definitely wrong.
I guess you use a specific directory to put your resources attached to the resource.rc file so the default SGDK makefile does not directly convert your bitmap files to binary.
What i can do is to reserve a specific directory for genres resources (genres could be a good name) so the resource.rc file take care of the dependencies in this specific folder. Do you think that is a suitable solution ?
Posted: Wed Jul 03, 2013 12:47 am
by Mask of Destiny
One generic solution would be for the rule that processes resource.rc to generate dependencies when it's run and to include those dependency files from the main make file. That's essentially how you handle include file dependencies for C/C++ in a makefile.
Posted: Wed Jul 03, 2013 9:45 am
by Stef
Generating dependencies this way mean you have to parse resource.rc file (or C files for include dependencies) O_o ??
Posted: Wed Jul 03, 2013 2:04 pm
by djcouchycouch
Stef wrote:Generating dependencies this way mean you have to parse resource.rc file (or C files for include dependencies) O_o ??
That's the idea. Would be real nice!
Posted: Wed Jul 03, 2013 9:00 pm
by Stef
I guess some tools already exists for that, right

Anyway the problem in my case is how to locally modify the makefile ? i want to keep the generic makefile.gen as it is.
Posted: Wed Jul 03, 2013 10:33 pm
by Mask of Destiny
Stef wrote:Generating dependencies this way mean you have to parse resource.rc file (or C files for include dependencies) O_o ??
For C, you can get the compiler do it for you with certain flags (-M and friends in gcc). For resource.rc, either genres would need to be modified to support a similar feature or a little script would need to be written to parse the rc file and spit out dependencies. from my limited understanding of the format, it looks like it could easily be done in sed or awk, though it doesn't look like those tools are currently included with sgdk. I suppose you could grab them from MinGW though.
Stef wrote:Anyway the problem in my case is how to locally modify the makefile ? i want to keep the generic makefile.gen as it is.
You don't need to modify the makefile (well not on the fly anyway). You just add an include command. make will silently ignore missing include files if you put a minus sign in front of the command.
So for instance in a C++ project at work, I do something like the following (assume that OBJS has a list of target object files):
Code: Select all
DEPS=$(OBJS:.o=.d)
%.o: %.cpp:
$(CPP) -c $(CFLAGS) -MMD -MP -MF"$(@:.o=.d)" -MT"$@" -o $@ $<
-include ($DEPS)
-MMD tells gcc to generate dependency information as it compiles, but to exclude system header files, -MP makes it generate some extra phony rules to avoid some harmless error messages when you delete a header, -MF tells gcc what file to stick that dependency info in, and -MT tells gcc what string to use as a target (for some reason, it defaults to the source file name with .c/.cpp replaced with .o rather than using whatever is passed in -o) in the dependency lines.
The result is a bunch of .d files in makefile format get spit out in the build output folder and these get included with the -include in the bottom of the makefile.