Small addition to eclipse guide

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

Small addition to eclipse guide

Post by DrunkenDonkey »

Happy new year everyone :D

I feel like having few words about eclipse's stubborn indexer and syntax check could be great. I don't know if I'm doing it right, but here is how I proceed initially with chibi project to kick the discovery working:
- ensure project compiles
- go to project makefile and set USE_VERBOSE_COMPILE = yes
- Project->C/C++ Build->Discovery options should be enabled by default
- Project->C/C++ Build->Discovery options: Clear
- Clean & Build the project (note the tasty list in Includes)
- Project->Index->Rebuild
- (optional) go to project makefile and set USE_VERBOSE_COMPILE = no to enjoy nice clean console

This is by far the easiest and best way I have found, went through manual paths and symbols, then trying with linked folders and was hit and miss.

ps: If you are adding some other folders to the project, turn the USE_VERBOSE_COMPILE = yes in order for the automated discovery to smell them.
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Been thanked: 1 time

Re: Small addition to eclipse guide

Post by mabl »

Hey DrunkenDonkey, thx for the neat trick! That auto-discovery really works well. Too bad it does only work with verbose compiling..
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: Small addition to eclipse guide

Post by DrunkenDonkey »

Yeah, but it rarely needs changing, it is fine, compared to alternatives ;)
Another trick, the parallel build made my full rebuilds almost instant -> Project->C/C++ Built (the main tab)->Behavior->Use parallel build: use optimal jobs number (well, technically set it to the real number of cores you have). The only drawback is that when you perform clear, the first build fails, as it tries to do something with folders that do not exist yet, but the speed gained (esp with something with real 4 cores) is so huge, that I don't notice the error at all ;)

ps: the error with the parallel build can be fixed, but requires changing rules.mk clean operation to actually leave build, build/lst and build/obj folders intact, but delete everything inside
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Been thanked: 1 time

Re: Small addition to eclipse guide

Post by mabl »

Yeah, knew about this. Btw. the build error is easy to fix (Giovanni left out some dependencies because he thought to sequential :mrgreen:) :

Code: Select all

diff --git a/os/ports/GCC/ARMCMx/rules.mk b/os/ports/GCC/ARMCMx/rules.mk
index e53105e..110ccc2 100644
--- a/os/ports/GCC/ARMCMx/rules.mk
+++ b/os/ports/GCC/ARMCMx/rules.mk
@@ -112,13 +112,13 @@ $(BUILDDIR):
        @echo $(SRCPATHS)
        mkdir $(BUILDDIR)
 
-$(OBJDIR):
+$(OBJDIR): $(BUILDDIR)
        mkdir $(OBJDIR)
 
-$(LSTDIR):
+$(LSTDIR): $(BUILDDIR)
        mkdir $(LSTDIR)
 
-$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
+$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp $(OBJDIR) $(LSTDIR) Makefile
 ifeq ($(USE_VERBOSE_COMPILE),yes)
        @echo
        $(CPPC) -c $(CPPFLAGS) $(AOPT) -I . $(IINCDIR) $< -o $@
@@ -127,7 +127,7 @@ else
        @$(CPPC) -c $(CPPFLAGS) $(AOPT) -I . $(IINCDIR) $< -o $@
 endif
 
-$(TCPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
+$(TCPPOBJS) : $(OBJDIR)/%.o : %.cpp $(OBJDIR) $(LSTDIR) Makefile
 ifeq ($(USE_VERBOSE_COMPILE),yes)
        @echo
        $(CPPC) -c $(CPPFLAGS) $(TOPT) -I . $(IINCDIR) $< -o $@
@@ -136,7 +136,7 @@ else
        @$(CPPC) -c $(CPPFLAGS) $(TOPT) -I . $(IINCDIR) $< -o $@
 endif
 
-$(ACOBJS) : $(OBJDIR)/%.o : %.c Makefile
+$(ACOBJS) : $(OBJDIR)/%.o : %.c $(OBJDIR) $(LSTDIR) Makefile
 ifeq ($(USE_VERBOSE_COMPILE),yes)
        @echo
        $(CC) -c $(CFLAGS) $(AOPT) -I . $(IINCDIR) $< -o $@
@@ -145,7 +145,7 @@ else
        @$(CC) -c $(CFLAGS) $(AOPT) -I . $(IINCDIR) $< -o $@
 endif
 
-$(TCOBJS) : $(OBJDIR)/%.o : %.c Makefile
+$(TCOBJS) : $(OBJDIR)/%.o : %.c $(OBJDIR) $(LSTDIR) Makefile
 ifeq ($(USE_VERBOSE_COMPILE),yes)
        @echo
        $(CC) -c $(CFLAGS) $(TOPT) -I . $(IINCDIR) $< -o $@
@@ -154,7 +154,7 @@ else
        @$(CC) -c $(CFLAGS) $(TOPT) -I . $(IINCDIR) $< -o $@
 endif
 
-$(ASMOBJS) : $(OBJDIR)/%.o : %.s Makefile
+$(ASMOBJS) : $(OBJDIR)/%.o : %.s $(OBJDIR) $(LSTDIR) Makefile
 ifeq ($(USE_VERBOSE_COMPILE),yes)
        @echo
        $(AS) -c $(ASFLAGS) -I . $(IINCDIR) $< -o $@


We might also think about adding the -p flag to the mkdirs..
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: Small addition to eclipse guide

Post by DrunkenDonkey »

I'm starting to like where this is going, there is pretty much no single core desktop/laptop cpu left and the dual core ones are speedily going into the archives too, so problem free parallel building right off the bat is nothing short of great... if we can bribe Giovanni to get it into the trunk xD
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Small addition to eclipse guide

Post by Giovanni »

I'll do that tomorrow, sequentially :-)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Small addition to eclipse guide

Post by Giovanni »

Done, now the build also allows path discovery without having to do that trick (it emits one dummy compilation command, this is useful also to see the used options).

Thanks for the patch.

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

Re: Small addition to eclipse guide

Post by DrunkenDonkey »

Very cool, it works :D
Thanks
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: Small addition to eclipse guide

Post by DrunkenDonkey »

Giovanni, there is a small issue, the project builds fine after clean, but second and all subsequent builds result in:

Code: Select all

make -j all 
mkdir build/obj
mkdir build/lst
mkdir: cannot create directory `build/obj': File exists
mkdir: cannot create directory `build/lst': File exists
make: *** [build/obj] Error 1
make: *** Waiting for unfinished jobs....
make: *** [build/lst] Error 1
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Small addition to eclipse guide

Post by Giovanni »

Verified, it should be resolved now.

The build now is very fast (a reason good enough to buy a 4+ cores new PC, the current one is almost 6 years old).

Giovanni
Post Reply