Object files location

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Object files location

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Object files location

Post 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
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: Object files location

Post 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)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Object files location

Post 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
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: Object files location

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Object files location

Post 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
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: Object files location

Post by DrunkenDonkey »

Ain't that pretty now, thanks :D
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: Object files location

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Object files location

Post 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
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Object files location

Post 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.
Post Reply