Page 1 of 2

Object files location

Posted: Wed Oct 05, 2011 8:24 pm
by DrunkenDonkey
Hey hey,

I'm very unsure if this is the right place to go, and absolutely sure it is very minor and not exactly worth fighting for, but... well... object files really get in the way, I have all my folders full of them, and even if I add filters to eclipse to not show them, they are still there, grayed, but there. I have seen makefile scripts that allow you to have all the... erm... crap in a folder "obj" or something, so you can freely copy-paste, archive, or whatever the stuff around without getting the garbage along, so I tried to mimic these, editing the rules.mk, but I failed miserably, something changes, it tries to put them there but... yeah, getting some scary amounts of linker errors all over the place and finally gave up. So the real question is, do you see value in the idea to have the defaults scripts altered to stack the trash in one place?

Re: Object files location

Posted: Wed Oct 05, 2011 8:43 pm
by Giovanni
:oops: I failed miserably at that too a while ago and gave up.

Anyway a revamp of makefiles is planned and not just because of OBJ/LST files but also in order to support other compilers.

If you have makefile examples post them here, I'll give it another try.

Giovanni

Re: Object files location

Posted: Thu Oct 06, 2011 5:49 pm
by DrunkenDonkey
Hehe, well, makefiles are quite a mystery. I found a topic on the question http://stackoverflow.com/questions/1814270/gcc-g-option-to-place-all-object-files-into-separate-directory and more importantly, the example of how to make it work:

Code: Select all

OUT = lib/alib.a
CC = g++
ODIR = obj
SDIR = src
INC = -Iinc

_OBJS = a_chsrc.o a_csv.o a_enc.o a_env.o a_except.o \
        a_date.o a_range.o a_opsys.o
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))


$(ODIR)/%.o: $(SDIR)/%.cpp
    $(CC) -c $(INC) -o $@ $< $(CFLAGS)

$(OUT): $(OBJS)
    ar rvs $(OUT) $^

.PHONY: clean

clean:
    rm -f $(ODIR)/*.o $(OUT)

Re: Object files location

Posted: Fri Oct 07, 2011 4:11 pm
by Giovanni
Thanks for hints, I created an updated rules.mk implementing private directories for object and list files, I will commit it during the weekend after implementing some other improvements.

Giovanni

Re: Object files location

Posted: Fri Oct 07, 2011 5:56 pm
by DrunkenDonkey
Great, thanks man, I'm used to having lot of files and even my "learning" project now have 15ish source files, add headers, obj and lst and you can imagine how the list looks, can't wait :D

Re: Object files location

Posted: Sat Oct 08, 2011 10:26 am
by Giovanni
Hi,

I committed the new system on the repository, you just have to take the file rules.mk if you don't want to get everything.

Giovanni

Re: Object files location

Posted: Sat Oct 08, 2011 10:50 am
by DrunkenDonkey
Ain't that pretty now, thanks :D

Re: Object files location

Posted: Sat Oct 08, 2011 12:12 pm
by DrunkenDonkey
Aaa Giovanni, there is a wee bit of a problem with that new build - memmove, memset, etc, all crash into vector tables stuff, not only in my project, but picked random uart sample and added memset in there. New rules stuff linked something not for STM32?

Re: Object files location

Posted: Sat Oct 08, 2011 2:08 pm
by Giovanni
Thanks for finding this, because an extra space (not joking) it was linking ARM mode libraries instead of Thumb ones. Updated on repository.

Giovanni

Re: Object files location

Posted: Sat Oct 08, 2011 6:50 pm
by barthess
It works. One side effect -- if you have files in your project called like ChibiOS files e.g. adc.c or i2c.c than you must rename they to something like my_adc.c to avoid collisions.