Skip to content
dgod edited this page Mar 21, 2015 · 2 revisions

Welcome to the build.js wiki!

Project file name default is build.txt, the content is an javascript run in nodejs environment.

Build command options

build -C path -f build.txt target

cd(path)
change directory to path

env()
set environment variable
env('CFLAGS',':=','-Wall -g -O0');
env('CFLAGS=-Wall -g -O0');

$()
get environment variable
$('CFLAGS')

push()
save current environment variables

pop()
restore current environment variables

cc()
compile c file
cc('1.c','1.o');
cc(['1.c','2.c']);
cc(['1.c','2.c'],['1.o','2.o']);

ld()
link the object files
ld([1.o 2.o],'a.out');

cr(input,output,pattern)
check file timestamp, if output old than input run the pattern command
cr('1.txt','2.txt','cat $^ > $@')

include(file)
include a sub project file

build(path,file,target)
build the project target of file at path

shell(command)
read stdout of command

exec(command)
run the command, abort the build if fail

rm(file)
remove file

rmdir(path)
remove directory

dir(path,filter)
read entries from path which math the filter

wildcard(input,change)
return changed input.
var SRCS=dir('.','*.c');
var SRCS=dir('.',/.c$/);

Clone this wiki locally