I'm trying to setup waf as a build system for a project I am working on. Compiling and working with the files already in the project works just fine and was easy enough to understand. However, what I want to do now is download newlib, apply a patch to it, build it, and then use it to compile more files in my project. I'm not entirely sure how to do this using waf. Here's what I have so far:
project
+-- src
+-- stuff.c
+-- wscript
+-- newlib
+-- newlib.patch
+-- wscript
+-- wscript
And here's the contents of the newlib/wscript file:
def configure(ctx):
'''
Configure the library.
'''
# tools
ctx.load("flex")
ctx.load("bison")
# locate programs
ctx.find_program("wget", var="WGET")
ctx.find_program("tar", var="TAR")
ctx.find_program("patch", var="PATCH")
ctx.find_program("strip")
# XXX
ctx.env["NEWLIB_URL"] = "ftp://sourceware.org/pub/newlib/newlib-2.0.0.tar.gz"
def build(ctx):
'''
Build the library.
'''
# download the library
ctx(rule="${WGET} -q -O ${TGT} ${NEWLIB_URL}", target="newlib-2.0.0.tar.gz")
ctx(rule="${TAR} -xzf ${SRC} -C newlib", source="newlib-2.0.0.tar.gz")
# apply the patch
ctx(rule="${PATCH} -p0 -i ${SRC}", source="newlib.patch")
The last rule that applies the patch doesn't work, but even if it did I can't help but feel like I'm doing this wrong. What's the correct approach here? Is there a better way of doing this?