lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


----- Original Message -----
From: Spencer Parkin
Date: 3/8/2013 1:08 AM
Next, the make utility. After a great deal of effort, I finally created a make-file for one of my static library projects. Here's a snippet...

define BUILD_OBJ_RULE =
$(1): $(2)
    $$(CPP) $$(FLAGS) -c $$< -o $$@
endef
$(foreach src, $(SRCS), $(eval $(call BUILD_OBJ_RULE, $(patsubst %.cpp, $(BUILD)/%.o, $(notdir $(src))), $(src))))

Yikes! Yes, it's ugly and LISPY, but it's also probably embarassing, since no real programmer that actually knew what they were doing would write that. Moving on!

How about jam? To do in jam what was just done above in make, (though I really don't want to draw attention to that again), is so much easier to do. Why? Well, I think jam solves a lot of problems with build systems, but 1) it's a dead project, and 2) it's not easy to learn. But remember, this is coming from a guy who really doesn't know what-the-heck he's talking about.
The Perforce Jam project is dead, but there is at least one derivative [1] that is not.

In fact, the JamPlus project does basically everything you ask for. It is very fast, writes IDE project files, can use network caches, knows how to batch build files with compilers that supports it, supports multiple toolchains in the same invocation, has multipass builds, and a bunch of other stuff.

In fact, you can write build scripts in Lua if you so desire.

The LuaPlus project uses JamPlus to build 60+ Lua modules with ease.

Out of box, your library building rule above is written as:

    C.Library MyLibrary : $(SRCS) ;

You may want to take a peek.

-Josh

[1] http://jamplus.org