Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: Echo on September 28, 2013, 03:19:14 PM

Title: Eclipse project for rockbox
Post by: Echo on September 28, 2013, 03:19:14 PM
Hi
I want to setup an eclipse project for rockbox but I had some trouble figuring out what directory should be the main directory for the project.
I don't want to use the root directory because I don't want the build directory(ies) to be in the project so auto-generated code won't contaminate my index.
Also, if anyone knows how to use the eclipse git plugin I would love some directions.

Thanks
Title: Re: Eclipse project for rockbox
Post by: BenBrown on October 24, 2013, 08:09:21 AM
See, http://www.rockbox.org/wiki/AndroidPort

Most notably  "If you like eclipse: Import the Rockbox eclipse project from the android folder (File->New->Other->Android->Android Project; then select 'Create Project from existing Source')"

TL;DR The /rockbox/android folder.
Title: Re: Eclipse project for rockbox
Post by: Echo on October 24, 2013, 02:53:09 PM
That won't give me only the android project?
I actually need the sansa project...
Title: Re: Eclipse project for rockbox
Post by: BenBrown on October 25, 2013, 08:23:47 AM
My apologies Echo I was mistaken about your post.  To rectify that, let me see if I can help you out.  I'll be back shortly.

Edit:

You can create a build directory outside of the rockbox directory.  So, as long you create your build directory outside of the rockbox sources you needn't worry about them being imported into your eclipse project.

Like this, say I have two directories in my WORKING directory ~/WORKING/build/ and my rockbox sources in ~/WORKING/rockbox/

If I "cd ~/WORKING/build/" and execute "../rockbox/tools/configure" and then "make", it will build my project outside of the rockbox sources directory.

Importing rockbox into eclispe requires the CDT plugin from http://www.eclipse.org/cdt/downloads.php , after that is installed with "help>install new software", OR perhaps you all ready have that, you can import the existing C project rockbox into eclispe using the rockbox directory as the root folder.  However, building rockbox in eclipse is beyond my familiarity with it.  I have an affinity for the command line.  Perhaps if you learn how you could post back here to enlighten the rest of us.
Title: Re: Eclipse project for rockbox
Post by: BenBrown on October 25, 2013, 09:29:55 AM
 ;D I just built rockbox within eclipse.  Let me work out a method and I'll post it here.
Title: Re: Eclipse project for rockbox
Post by: BenBrown on October 25, 2013, 10:22:57 AM
Assuming you have already built the toolchain and are able to build rockbox from the command line.  If not see http://www.rockbox.org/wiki/DevelopmentGuide

Install Eclispe and CDT plugin

Install eclispe http://www.eclipse.org/
install CDT plugin http://www.eclipse.org/cdt/downloads.php

or

Install C/C+ flavor eclipse http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/keplersr1


Creating working directories for Eclispe

Create a working directory i.e. ~/working/

Code: [Select]
mkdir ~/working
Download the rockbox sources into ~/working/rockbox/

Code: [Select]
cd ~/working
git clone git://git.rockbox.org/rockbox

Creating build directories for Eclispe

We want to create a build directory outside of the rockbox sources directory, this is contrary to what is stated on http://www.rockbox.org/wiki/LinuxSimpleGuideToCompiling , but doing it outside will keep our eclispe projects nice, clean and neat.  Also it gives us the ability to have more than one target across multiple directories.


Lets assume we want to build the sansa e200 target.  We would create a directory and execute the configure script in a directory just outside of the rockbox sources and inside our working directory.


Code: [Select]
cd ~/working
mkdir sansa-e200
cd sansa-e200
../rockbox/tools/configure


We would choose option "50" for target Sansa e200 then "N" for a normal build.  This sets up the Makefile we need to build the target in eclipse.

Import the rockbox sources into eclipse

Open eclipse and choose a directory for your workspace NOT the working directories we made earlier i.e. "~/workspace"

Once eclipse has started up completely, choose "File > Import", and at the next dialog window navigate to C/C++.  Then choose "Existing Code as Makefile Project" and click Next.  On the next window give the project a name i.e. "Rockbox".  Then click Browse, next navigate into the "~/working/rockbox/" directory and click OK. Now, uncheck the C++ box under languages, only leaving C checked.  Then under Toolchain for "Indexer Settings" leave it as <none>.  Finally click Finish, this will pull the rockbox project into eclipse.

Import the build directory and Makefile into eclipse

Now to import our targets build directory.  Once again choose "File > Import" and again at the next dialog window navigate to C/C++.  Then choose "Existing Code as Makefile Project" and click Next. On the next window give the project a name i.e. "SANSA-e200" then click Browse.  Next navigate into the "~/working/sansa-e200/" directory then click OK.  Now uncheck the C++ box under languages, leaving only C checked.  Then under Toolchain for "Indexer Settings" leave it as <none>.  Finally click Finish, this will pull the target build directory into eclipse.

These last two steps create a build target for eclipse to work with

In the package explorer inside eclipse, Right click the target project i.e. SANSA-e200 and choose "Make Targets > Create..".  On the "Create Make Target" dialog fill in a name "sansa-e200".  Under Make target uncheck "Same as the target name" and remove the text from the "Make Target:" box so that it is blank.  Leaving all other options at default, click OK.

Once again in the package explorer from eclipse, Right click the target project i.e. SANSA-e200 and choose "Make Targets > Create..". On the Create Make Target dialog fill in a name "zip".  Leaving all other options at default, click OK.

Building rockbox

Now to build, Right Click your target and choose "Make Targets > Build.." highlight SANSA-e200 and click Build.  The output is shown in the console.  Once that has been completed successfully, once again Right Click your target and choose "Make Targets > Build.." this time choose "zip" and click Build.  Once that has completed successfully your rockbox.zip file can be found in your targets directory. i.e. ~/working/sansa-e200

This method can be used to create multiple target directories to be imported and built with eclipse just create them all with different target names and directories.
Title: Re: Eclipse project for rockbox
Post by: BenBrown on October 25, 2013, 11:13:47 AM
If you want to import the rockbox folder into eclipse as a git repository, but have already added the folder in the steps above.  Simply right click the rockbox folder and choose delete, but leave unchecked the "Delete project contents on disk(cannot be undone)" and click OK.

Then "File > Import"  choose GIT then from the drop down menu "Projects from Git" and click next.  Then Highlight "Local" click Next.  Then click the "Add" button and then "Browse".  Navigate to the rockbox directory from the working directory i.e. "~/working/rockbox" and then click OK.  Then highlight the rockbox project and click Next.  On the next screen click Finish.  This will pull the rockbox directory into eclipse as a Git repo.

If you're not concerned about the android project you can safely right click and delete the project from your Package explorer but do not check "Delete project contents on disk(cannot be undone)" leaving it on disk.

I hope this makes up for not reading your post with a clear head yesterday :)
Title: Re: Eclipse project for rockbox
Post by: Echo on October 28, 2013, 06:00:58 PM
Hi,
Thanks for the detailed replay. This is very helpfull.
You don't need to be sorry about anything, missunderstandings happans.
I will tryout your guid soon and let you know if that works.

I think that with some editing this post should go on the dev guid, what do you think?
Title: Re: Eclipse project for rockbox
Post by: BenBrown on October 28, 2013, 10:06:06 PM
I've been thinking it should go in the wiki too.  If you need anything cleared up let me know, I wrote it in a rush so you might run into errors.  ;)