Ampelofilosofies

homeaboutrss
The mind is like a parachute. If it doesn't open, you're meat.

Building with rake: Introduction

22 Oct 2013

Introduction

This is the introduction to a series of articles I've been meaning to write for a while now. I've been working with Ruby for the last 12 years now and I've never done Rails or - the occasional Sinatra app aside - web applications.

So this series will serve as an example of what you can do with Ruby away from Rails and also help me clarify and organise my own knowledge. Code samples will go up on GitHub.

So let's start by creating a build system from scratch. To simplify the subject but still keep things interesting we will create a build system for a project in C that runs on the RX63N (just because I have one lying around)

The RX63N

RX63N evaluation board

This is a nifty little evaluation board for the RX63N 32bit CPU by Renesas(link is in German). The RX63N has ethernet and USB capabilities baked in, as well as a whole host of other "embedded" stuff. For the acronym, soup you can look up SPI, Single-Wire, GPIO, PWM, EXTAL etc.

I won't really go into the guts of this little system because I won't get to talk about Ruby at all. The idea is to take one of the example applications offered by Renesas and built it without the provided IDE while also talking about structuring C code and moving away from make's legacy (I can hear the cries: "HERETIC! INFIDEL!"")

Moving away from make means we need a replacement for it, a DSL for building systems that can equal and surpass the capabilities offered by the most cryptical of build tools. Enter rake

Rake

Rake is an equivalent of make written in Ruby and well known to Rubyists. It's used every day to run tests, perform database migrations etc. It's "task management" software, but let's not confuse it with a TODO list app. At it's core it's dependency resolution software.

At this point I will skip the introduction to rake and it's capabilities (which I had written and I removed because it turned into another two articles) and assume you know the basics (read Martin Fowler's article from way back in '05 and the documentation to get up to speed)

Rake's strong point is that it is a simple DSL on top of Ruby and that apart from the few primitives it defines everything else in your Rakefile (i.e. the equivalent to a Makefile) is Ruby code.

I cannot even begin to describe what a difference this makes when trying to build stuff. Instead hopefully I will demostrate it over a long series of articles that are going to incrementally compose part of a complex system.

The original "build system" whose structure and concepts are the basis for these articles is ~8K lines of Ruby. It turns out the term "build system" is not accurate anymore. "Total Development Environment Control" is a much more appropriate term. It has spawned a few articles in it's day, mainly concerning Ruby performance under Windows and rake trivia.

The time has come to extract the core of this system, the part that actually builds C applications and see how it holds up after three "incarnations".

So in the next few posts, while we run the RX63N through it's paces, we'll go through:

  • Building C code with rake
  • DRY Build Systems in rake and managing the Ruby code base.
  • A structure for component-based embedded C systems
  • Managing cross-platform compilation and multi-platform C code bases
  • Getting free of the IDE while still being able to debug

And to make matters more interesting I'll do it on Windows but make sure it runs on Linux as well so that we can have as direct a comparison as possible. To that effect, instead of using the Renesas provided (and quite expensive) toolchain I'm going to use the KPIT GNU toolchain

Now all I need is a nifty name for the series!

blog comments powered by Disqus