-
Notifications
You must be signed in to change notification settings - Fork 7
Home
erickt edited this page Jan 26, 2011
·
7 revisions
- Install Python 3.1.
- Download fbuild with
curl -L https://github.com/erickt/fbuild/tarball/v0.2 | tar -zx
.
Here's a simple example of using Fbuild. Say you have a simple c file, named test.c
:
#include <stdio.h>
int main(int argc, char** argv) {
printf("%s\n", argv[0]);
return 0;
}
To compile this code with Fbuild, create a Python 3.1 file fbuildroot.py
:
import fbuild.builders.c
def build(ctx):
# Create a c builder.
builder = fbuild.builders.c.guess_static(ctx)
# Compile a test file.
test = builder.build_exe('test', ['test.c'])
# Run the test file.
ctx.execute([test])
Then to compile the code, simply run:
% fbuild-light
determining platform : {'bsd', 'darwin', 'macosx', 'posix'}
looking for program gcc : ok /usr/bin/gcc
checking gcc : ok
looking for program ar : ok /usr/bin/ar
looking for program ranlib : ok /usr/bin/ranlib
checking if gcc can make objects : ok
checking if gcc can make libraries : ok
checking if gcc can make exes : ok
checking if gcc can link lib to exe : ok
* gcc : test.c -> build/test.o
* gcc : build/test.o -> build/test
build/test
Fbuild will cache the results, so if you run it again it won't recompile the code:
% fbuild-light
build/test