Thursday, March 26, 2009

Developing for Archimedes

Hello,
With the new team working on Archimedes, I had to help them set up an environment to work with Archimedes. I am pretty proud of the outcome.
In order to code for Archimedes, just follow these steps:
  1. Download and install a Java Virtual Machine S.E. SDK version 1.5 or later compatible with the Sun virtual machine (I suggest sun's one called 'Java SE Development Kit (JDK)' under http://java.sun.com/javase/downloads/index.jsp).
  2. Install Subversion (http://subversion.tigris.org - or "sudo apt-get install subversion" on debian based linux distributions or "sudo port install subversion" on Mac OS X with MacPorts).
  3. Download an Eclipse version above 3.4 (I suggest the one found at http://download.eclipse.org/eclipse/downloads/drops/R-3.4.2-200902111700/ - Eclipse SDK for your platform should be enough). Make sure it has all of the Eclipse RCP plugins. If you pick another version, choose the package Eclipse SDK or the specific build for Eclipse Plug-in Development.
  4. Install it on your system. It usually just involves unpacking the zip or tar.gz file you downloaded.
  5. Open it. Usually, just enter the folder that was created on the previous step, there should be an executable called 'eclipse'. Run that executable.
  6. Install subclipse. Go to "Help"->"Software Updates...". Select the tab "Available Software", click on "Add Site...". Fill in the "Location" field with "http://subclipse.tigris.org/update_1.4.x" (if you installed version 1.6 of Subversion, you can use "http://subclipse.tigris.org/update_1.6.x"). Click on OK. It should list the site on the table with the name "http://subclipse.tigris.org/update_1.4.x". Click the checkbox next to it. Click on the button "Install..." on the upper right corner. Accept the license and let it install. Once it's done, it will ask you to restart Eclipse. Please do.
  7. Download the file "http://svn.archimedes.org.br/public/mainarchimedes/rcparchimedes/br.org.archimedes.config/trunk/ArchimedesProjectsSet.psf". Save it somewhere you can find.
  8. Go back to Eclipse and go to "File"->"Import...". Expand "Team" and choose "Team Project Set". Click "Next". Click "Finish". It will download all the projects needed to work on Archimedes. This will take some time and a lot of bandwith. If you get an "Svn error", please erase all projects and try again.
That's it. Once you've done that, you should have about 100 projects for Archimedes. If you are getting some compile errors ("there are red signs on the projects"), try changing your Java default compile version. To do so, go to "Window"->"Preferences..." (or "Eclipse"->"Preferences..." on Mac), type 'compiler' , select the "Compiler" item on your left pane, change the "Compiler compliance level" to "1.5". It should rebuild the project and remove the compiler errors.

Running Archimedes from within Eclipse should be pretty simple but I've found problems more than once. Here is what you should do:
  1. Find the project "br.org.archimedes.core", expand it. Find the file "archimedes.product", right-click it, "Run As..."->"Eclipse Application". On Mac, that's enough. It all works. On Linux, I've found that this doesn't select all plugins needed. It then pops an error dialog asking if you want to view the log. Answer "No".
  2. Go to "Run"->"Run configurations...". Select the tab "Plug-ins". Click the button "Add Required Plug-ins". Click "Apply" and then "Run". This should do the trick and run Archimedes with all plug-ins.
Ok! This should be enough to work on Archimedes and try your modifications. Last and final step to have a complete Archimedes environment: setting up the build system. This also got greatly improved. The following steps should be enough:
  1. Download an Eclipse version along with its Delta Pack. I suggest you use the same version on development and on building to avoid unpleasant surprises. Therefore, go to http://download.eclipse.org/eclipse/downloads/drops/R-3.4.2-200902111700/ and download "Eclipse SDK" for your platform and "Delta Pack". Extract both files on the same place (it should merge the contents). This means, if you enter the "eclipse/plugins" directory of that new eclipse path, you should find plugins for all platforms (such as "org.eclipse.swt.carbon.macosx_3.4.0.v3448f.jar", "org.eclipse.swt.gtk.linux.ppc_3.4.0.v3448f.jar", "org.eclipse.swt.gtk.linux.x86_3.4.0.v3448f.jar",
    "org.eclipse.swt.win32.win32.x86_3.4.0.v3448f.jar" and others).
  2. Go to your "br.org.archimedes.build" project. Open the "build_local.properties" file. Change all fields. "buildHome" should be the absolute path to your "br.org.archimedes.build" project. "buildDirectory" should be the absolute path to a temporary folder where the build will generate the files. Make sure this is not a folder where you store important files because the build system will erase it. "eclipseDir" should be the absolute path to the Eclipse installation created on step 1. "os" should be the name of your operating system ("linux", "macosx" or "win32"). "ws" should be the name of the widget system of your system ("gtk", "carbon" or "win32"). "arch" should be the architecture of your processor ("x86", "x86_64" or "ppc").
  3. Go to your "br.org.archimedes.build" project and open the folder "maps". Copy the file "all-hugo.map" to "all.map". Open the new "all.map". Replace all occurrences of "/Users/night/Document/Archimedes/" with the path to your workspace (for example "/home/night/" if my workspace if "/home/night/workspace").
  4. On Eclipse, right click the "build.xml" file on "br.org.archimedes.build" project and choose "Run As..."->"Ant Build". On other systems, open a terminal (or cmd.exe), go to the directory where you "br.org.archimedes.build" project is and type 'ant'. If "ant" is not installed, please install it (http://ant.apache.org/manual/install.html or "sudo apt-get install ant" for debian based linux distributions). This should trigger the build process. It takes around 5 minutes to build it all.
On the folder you specified for "buildDirectory", you should find a folder "results" that contains several files. Among them, "Archimedes--...zip" files for macosx, linux (x86 and x86_64) and windows. Those are your executables.

Happy hacking!

The silence of the lambs on Archimedes

It has a been a while since no news were posted, but, as in the movie, silence doesn't mean nothing is happening. Actually, quite a few things happend since the last post.

First, a new team of 6 undergrad students is working on Archimedes again. As for the past 4 years, they'll work on Archimedes as part of an eXtreme Programming laboratory course. This semester's goal is "Portability".
I'll have them focus on making Archimedes compatible with other software. This basically means file support for SVG (exporting only for now -- in order to have post project work on Inkscape), native support to DXF (importing and exporting without file losses -- should allow to work with most of other CAD systems) and working on a few more essential elements such as Spline and Groups. I've also asked them to finish the work that was started on Trim, Extend and Fillet. I am not sure they will manage to do it all, but I'll help them the way I can so we might actually do it.

Other than that, I am happy to say Archimedes' new website is pretty good. It is currently pretty featureless but I intend to improve this with time. My next step is to add a release system plugged into the repository in order to easily generate new versions of Archimedes. If I manage to do it by April, 1st, I'll use it to release the new version with several improvements. For now, please report or request anything you want from Archimedes in the SourceForge website. I hope to remove this dependency with the new website but it will take some time.

Less exciting news. I recently discovered that Archimedes had a few licensing issues. I've spent two months trying to get in touch with every code contributor of Archimedes so far to change the License of Archimedes and had a partial success. The output is: Archimedes cannot be GPL (any version) because it uses code licensed under EPL v1.0 and changes it, which would mean it should be licensed under GPL which isn't allowed by the EPL license. Therefore, Archimedes code is now licensed under EPL. The only implication of this change is that Archimedes' code is no longer as viral as GPL code so people can use parts of it on commercial application as long as they keep Archimedes' code free. This change also implied that every project of the current Archimedes project is now distributed with a License.TXT file. I was also forced to create a small header-inserter ruby script which I made available at rubyforge as a library. The library makes it really easy to list all files within a directory that match a certain pattern and also retrieves subversion data for each file if there is one. The code can also be found at my github page.

Last notice, Jhonny warned me that it wasn't clear which page of archimedes should be check. Please, always refer to www.archimedes.org.br! The incubadora's page is abandoned. Their link is awful and the support is getting thinner and thinner so I guessed it would be better to handle ourselves. That's it for now.
More news soon with the new version.