Object files location
Moderators: RoccoMarco, lbednarz, tfAteba
-
DrunkenDonkey
- Posts: 124
- Joined: Sun Aug 28, 2011 5:16 pm
Object files location
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?
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?
- 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
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
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)- 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
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
Giovanni
-
DrunkenDonkey
- Posts: 124
- Joined: Sun Aug 28, 2011 5:16 pm
Re: Object files location
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 
- 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
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
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
-
DrunkenDonkey
- Posts: 124
- Joined: Sun Aug 28, 2011 5:16 pm
Re: Object files location
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?
- 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
Thanks for finding this, because an extra space (not joking) it was linking ARM mode libraries instead of Thumb ones. Updated on repository.
Giovanni
Giovanni
Re: Object files location
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.