Thursday, July 14, 2011

A reminder why make is a beast

At work today was a vivid reminder why make is a beast.
I'm integrating protobuf into a custom build system based on GNU make, call it yamake ("yet another make") and a proprietary IDL-like language, call it SDL ("sort-of definition language"). SDL is firmly rooted in the culture and systems, so it is non-negotiable. Over the course of the past few days, learned the steps:
  1. Write a backend for the Python compiler script which translates SDL to your target language, in my case protobuf.
  2. Hand off protobuf backend to guru colleague who munges it to better match the overall systems, and patches it into yamake.
  3. Work on makefile to actually build usable jar of compiled protobuf for Java.
  4. Watch colleague redo munging to something more permanent, less hacktastic.
  5. Rework on makefile to actually build usable jar of compiled protobuf for Java.
  6. Roll fake maven local repo holding new jar, of course yamake knows nothing about deploying jars.
  7. Build new CORBA IDL jar for Java including new interfaces to access protobuf in other systems.
All this, and finally I can actually do useful work. Tomorrow.
But this is not the point of my post.
Yamake is a wrapper around venerable GNU make, so I am editing makefiles. Ultimately I have this dependency chain: SDL to protobuf to Java to classes to jar. But watch:
$ sdlc -t protobuf foobar.sdl -o proto/foobar.proto
$ protoc --java_out=java proto/foobar.proto
$ javac -sourcepath java java/my/package/FoobarProtos.java
$ jar cf foobar.jar -C java my/package/FoobarProtos*.class
It's actually more Rube-Goldbergesque than this, as the C++ versions of the protobuf play games with namespaces requiring various flags at various stages along with directory changes. So I made Java keep up. You come up with dependency rules that cope with option java_package = "something.random" and option java_outer_classname="SomethingProtos" and mismatched output directories!
I opted for using helper shell scripts for parsing protobuf for proper Java packages with class names and generating dependency makefiles to include in my actual makefile.
Maven, remind me to quit poking on you for your ugly XML and ridiculously noisy output. I forgot all the love you give me.

No comments: