Rebuild is a python module that replaces make. It has been tested on Windows XP professional and works fine. See also, API Documentation rebuild is offered under the Open Software License


rebuild 1.0 (July 29, 2003)

Instead of using irritating tabbed makefiles and an outmoded, overly complex method of describing software build instructions, I have chosen to produce my own. After reading several documents about the shortcomings of make, I have incorporated a number of the suggestions and ideas into this package.


Planned features:

How to use the module

The module should be placed in the site-packages directory of your python distribution.

The following is an example project file for the Dosadi kernel :

from rebuild import build

import sys
def IncBuildCount():
       f = open("build.count")
 	   count = int(lines[0])
       f=open("build.count", "w")
       f=open("build.h", "w")
       s = '#ifndef __EXOS_BUILD__\n#define __EXOS_BUILD__\n#define EXOS_VERSION        "v0.0.1"\n#define EXOS_BUILD '+ str(count) +'\n#endif\n\n'
 	   return 1

build.AddSourcePaths(["src/kernel", "src/kernel/isr"])
build.AddIncludePaths(["include", "libc/include"])
# Tell nasm to produce normal win32 object files
build.AddCompilerFlag("-f win32", ".asm")

# Process any command line options, like the debug, optimize, and verbose flags.
# Setup flags for "C"
if build.debug:
   build.AddCompilerFlag("-g", ".c")
if build.optimize:
   build.AddCompilerFlag("-O ", ".c")
build.AddCompilerFlag("-Wall ", ".c")
# Setup Linker
build.AddLinkFlags(["-nostdlib", "-static", "--image-base=0x100000",        "--entry=_start"])
# Add action to increment the build count
build.AddAction("IncBuildCount", IncBuildCount)
build.AddManualOutput("IncBuildCount", "build.h")
# Set custom output for the kernel
build.SetManualLinkCommand("ld $flags -o $output $objects libc/build/memset.o")

This is an example project file for Dosadi's libc:

import rebuild"string")["string/pcre/get.c", "string/pcre/maketables.c", "string/pcre/pcre.c", "string/pcre/study.c"])["./include", "./string/pcre"])"./build")
# Tell nasm to produce normal win32 object files"-f win32", ".asm")
# Tell gcc to not link anything extraneous into the app["-nostdlib", "-nostartfiles", "-Wl,-b,-E,-r"])
# Build static library"libdosadi_c.a")"Archive")

Notice that you can either manually perform the build by calling the check dependencies, build, and link phases, or you can just call AutoBuild() to do it for you. They're mostly equivalent.

There are a lot of details hidden here. The system has many functions which let you control in a very finely grained way what happens to what. By default the project type is "Executable", and object file suffixes are ".o". After the check dependencies stage, the module will have a good idea of all the object files produced by a successful build (that is, all files with a .o suffix, or with the given object suffix if different.). If any of the tools run during the build process fail, their failure code + 1000 is returned to the system. During link, the module figures out what compiler to use either by looking up the extension (for archives), using the given link command (for manual links), or by looking up the compiler registered as "default". There is currently no clean way change the default compiler, but that will change.

The file contains all of the exposed user API commands. A user shouldn't try to access any of the commands from other modules, as their format and use may change.

Comments or questions should be sent to

This site is (C)opyright 2003, Christopher Nelson

Rebuild is Licensed under the Open Software License version 1.1