Browse Source

DUK_PROFILE related build etc trivia; Makefile not fully functional

pull/1/head
Sami Vaarala 11 years ago
parent
commit
7dbdc39f48
  1. 68
      Makefile
  2. 12
      examples/Makefile.example
  3. 2
      make_dist.sh
  4. 186
      runtests/runtests.js

68
Makefile

@ -111,33 +111,10 @@ DUKTAPE_SOURCES = $(DUKTAPE_SOURCES_COMBINED)
DUKTAPE_CMDLINE_SOURCES = \
$(DISTCMD)/duk_cmdline.c
DUK_SHARED_LIBS_NONDEBUG = \
libduktape100.so.1.0.0 libduktape101.so.1.0.0 \
libduktape200.so.1.0.0 libduktape201.so.1.0.0 \
libduktape300.so.1.0.0 libduktape301.so.1.0.0 \
libduktape400.so.1.0.0 libduktape401.so.1.0.0 \
libduktape500.so.1.0.0 libduktape501.so.1.0.0
DUK_SHARED_LIBS_DEBUG = \
libduktape100d.so.1.0.0 libduktape101d.so.1.0.0 \
libduktape200d.so.1.0.0 libduktape201d.so.1.0.0 \
libduktape300d.so.1.0.0 libduktape301d.so.1.0.0 \
libduktape400d.so.1.0.0 libduktape401d.so.1.0.0 \
libduktape500d.so.1.0.0 libduktape501d.so.1.0.0
DUK_CMDLINE_TOOLS_NONDEBUG = \
duk.100 duk.101 \
duk.200 duk.201 \
duk.300 duk.301 \
duk.400 duk.401 \
duk.500 duk.501
DUK_CMDLINE_TOOLS_DEBUG = \
duk.100d duk.101d \
duk.200d duk.201d \
duk.300d duk.301d \
duk.400d duk.401d \
duk.500d duk.501d
DUK_SHARED_LIBS_NONDEBUG = libduktape.so.1.0.0 libduktapep.so.1.0.0
DUK_SHARED_LIBS_DEBUG = libduktaped.so.1.0.0 libduktapepd.so.1.0.0
DUK_CMDLINE_TOOLS_NONDEBUG = duk dukp
DUK_CMDLINE_TOOLS_DEBUG = dukd dukpd
# Compiler setup for Linux
CC = gcc
@ -150,6 +127,8 @@ CCOPTS_SHARED += -DDUK_OPT_DPRINT_COLORS
#CCOPTS_SHARED += -DDUK_OPT_NO_FILE_IO
#CCOPTS_SHARED += '-DDUK_PANIC_HANDLER(code,msg)={printf("*** %d:%s\n",(code),(msg));abort();}'
CCOPTS_SHARED += -DDUK_OPT_SELF_TESTS
#CCOPTS_SHARED += -DDUK_OPT_NO_TRACEBACKS
#CCOPTS_SHARED += -DDUK_OPT_NO_VERBOSE_ERRORS
CCOPTS_NONDEBUG = $(CCOPTS_SHARED) -Os -fomit-frame-pointer
CCOPTS_DEBUG = $(CCOPTS_SHARED) -O0 -g -ggdb
CCLIBS = -lm
@ -157,22 +136,11 @@ CCLIBS += -lreadline
CCLIBS += -lncurses # on some systems -lreadline also requires -lncurses (e.g. RHEL)
.PHONY: default all clean test install
default: all64
all32: $(DUK_CMDLINE_TOOLS_NONDEBUG) \
all: $(DUK_CMDLINE_TOOLS_NONDEBUG) \
$(DUK_CMDLINE_TOOLS_DEBUG) \
$(DUK_SHARED_LIBS_NONDEBUG) \
$(DUK_SHARED_LIBS_DEBUG)
all64: duk.400 duk.401 \
duk.400d duk.401d \
duk.500 duk.501 \
duk.500d duk.501d \
libduktape400.so.1.0.0 libduktape401.so.1.0.0 \
libduktape400d.so.1.0.0 libduktape401d.so.1.0.0 \
libduktape500.so.1.0.0 libduktape501.so.1.0.0 \
libduktape500d.so.1.0.0 libduktape501d.so.1.0.0
clean:
-@rm -rf dist/
-@rm -rf full/
@ -187,32 +155,32 @@ clean:
$(DUK_SHARED_LIBS_NONDEBUG): dist
-rm -f $(subst .so.1.0.0,.so.1,$@) $(subst .so.1.0.0,.so.1.0.0,$@) $(subst .so.1.0.0,.so,$@)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC -DDUK_PROFILE=$(subst d,,$(subst .so.1.0.0,,$(subst libduktape,,$@))) $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
ln -s $@ $(subst .so.1.0.0,.so.1,$@)
ln -s $@ $(subst .so.1.0.0,.so,$@)
$(DUK_SHARED_LIBS_DEBUG): dist
-rm -f $(subst .so.1.0.0,.so.1,$@) $(subst .so.1.0.0,.so.1.0.0,$@) $(subst .so.1.0.0,.so,$@)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC -DDUK_PROFILE=$(subst d,,$(subst .so.1.0.0,,$(subst libduktape,,$@))) $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
ln -s $@ $(subst .so.1.0.0,.so.1,$@)
ln -s $@ $(subst .so.1.0.0,.so,$@)
$(DUK_CMDLINE_TOOLS_NONDEBUG): dist
$(CC) -o $@ -DDUK_PROFILE=$(subst d,,$(subst duk.,,$@)) $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
$(CC) -o $@ $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
$(DUK_CMDLINE_TOOLS_DEBUG): dist
$(CC) -o $@ -DDUK_PROFILE=$(subst d,,$(subst duk.,,$@)) $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
$(CC) -o $@ $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
test: npminst duk.400
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.400 --run-nodejs --run-rhino --num-threads 8 --log-file=/tmp/duk-test.log ecmascript-testcases/
test: npminst duk
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk --run-nodejs --run-rhino --num-threads 8 --log-file=/tmp/duk-test.log ecmascript-testcases/
qtest: npminst duk.400
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.400 --num-threads 16 --log-file=/tmp/duk-test.log ecmascript-testcases/
qtest: npminst duk
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk --num-threads 16 --log-file=/tmp/duk-test.log ecmascript-testcases/
vgtest: npminst duk.400
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.400 --num-threads 1 --test-sleep 30 --log-file=/tmp/duk-vgtest.log --valgrind --verbose ecmascript-testcases/
vgtest: npminst duk
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk --num-threads 1 --test-sleep 30 --log-file=/tmp/duk-vgtest.log --valgrind --verbose ecmascript-testcases/
apitest: npminst libduktape400.so.1.0.0
apitest: npminst libduktape.so.1.0.0
node runtests/runtests.js --num-threads 1 --log-file=/tmp/duk-api-test.log api-testcases/
# FIXME: torturetest; torture + valgrind

12
examples/Makefile.example

@ -19,10 +19,14 @@ CCOPTS += -I./src # for combined sources
CCLIBS = -lm
DEFINES =
# These should not be needed but you might consider them
#CCOPTS += -m32 # force 32-bit compilation on a 64-bit host
#DEFINES += -DDUK_PROFILE=100 # if omitted, profile defaults to 100 on a
# # 32-bit platform, and 400 otherwise
# If you want a 32-bit build on a 64-bit host
#CCOPTS += -m32
# You can provide a lot of feature options as DUK_OPT_xxx, see:
# http://www.duktape.org/guide.html#compiling
#DEFINES += -DDUK_OPT_DEBUG
#DEFINES += -DDUK_OPT_NO_TRACEBACKS
#...
# For debugging, use -O0 -g -ggdb, and don't add -fomit-frame-pointer

2
make_dist.sh

@ -11,7 +11,7 @@
#
# 2. Add the Duktape header files to their include path.
#
# 3. Optionally define a DUK_PROFILE (default profile is used otherwise).
# 3. Optionally define some DUK_OPT_xxx feature options.
#
# 4. Compile their program (which uses Duktape API).
#

186
runtests/runtests.js

@ -158,100 +158,98 @@ function executeTest(options, callback) {
callback(null, res);
});
} catch (e) {
console.log('xml2js parsing failed, should not happen: ' + e);
callback(null, res);
}
} else {
callback(null, res);
}
}
// testcase compilation done (only relevant for API tests), ready to execute
function compileDone(error, stdout, stderr) {
/* FIXME: use child_process.spawn(); we don't currently escape command
* line parameters which is risky.
*/
if (error) {
console.log(error);
execDone(error);
return;
}
if (options.engine.jsPrefix) {
// doesn't work
// tempInput = temp.path({ prefix: 'runtests-', suffix: '.js'})
tempInput = mkTempName();
try {
fs.writeFileSync(tempInput, options.engine.jsPrefix + fs.readFileSync(options.testPath));
} catch (e) {
console.log(e);
callback(e);
return;
}
}
cmd = [];
if (options.valgrind) {
tempVgxml = mkTempName();
tempVgout = mkTempName();
cmd = cmd.concat([ 'valgrind', '--tool=memcheck', '--xml=yes',
'--xml-file=' + tempVgxml,
'--log-file=' + tempVgout,
'--child-silent-after-fork=yes', '-q' ]);
}
if (tempExe) {
cmd.push(tempExe);
} else {
cmd.push(options.engine.fullPath);
if (options.valgrind && options.engine.name === 'duk') {
cmd.push('-m'); // higher memory limit
}
cmd.push(tempInput || options.testPath);
}
cmdline = cmd.join(' ');
if (options.testcase.meta.slow) {
timeout = options.valgrind ? TIMEOUT_SLOW_VALGRIND : TIMEOUT_SLOW;
} else {
timeout = options.valgrind ? TIMEOUT_NORMAL_VALGRIND : TIMEOUT_NORMAL;
}
execopts = {
maxBuffer: 128 * 1024 * 1024,
timeout: timeout,
stdio: 'pipe'
};
//console.log(cmdline);
child = child_process.exec(cmdline, execopts, execDone);
}
function compileApiTest() {
tempSource = mkTempName('.c');
try {
fs.writeFileSync(tempSource, options.engine.cPrefix + fs.readFileSync(options.testPath));
} catch (e) {
console.log(e);
callback(e);
return;
}
tempExe = mkTempName();
// FIXME: listing specific options here is awkward, must match Makefile
cmd = [ 'gcc', '-o', tempExe,
'-L.',
'-Idist/src',
'-Wl,-rpath,.',
'-pedantic', '-ansi', '-std=c99', '-Wall', '-fstrict-aliasing', '-D__POSIX_C_SOURCE=200809L', '-D_GNU_SOURCE', '-D_XOPEN_SOURCE', '-Os', '-fomit-frame-pointer',
'-g', '-ggdb',
'-Werror',
//'-m32',
'-DDUK_PROFILE=400',
'runtests/api_testcase_main.c',
tempSource,
'-lduktape400',
//'-lduktape401',
'-lm' ];
console.log('xml2js parsing failed, should not happen: ' + e);
callback(null, res);
}
} else {
callback(null, res);
}
}
// testcase compilation done (only relevant for API tests), ready to execute
function compileDone(error, stdout, stderr) {
/* FIXME: use child_process.spawn(); we don't currently escape command
* line parameters which is risky.
*/
if (error) {
console.log(error);
execDone(error);
return;
}
if (options.engine.jsPrefix) {
// doesn't work
// tempInput = temp.path({ prefix: 'runtests-', suffix: '.js'})
tempInput = mkTempName();
try {
fs.writeFileSync(tempInput, options.engine.jsPrefix + fs.readFileSync(options.testPath));
} catch (e) {
console.log(e);
callback(e);
return;
}
}
cmd = [];
if (options.valgrind) {
tempVgxml = mkTempName();
tempVgout = mkTempName();
cmd = cmd.concat([ 'valgrind', '--tool=memcheck', '--xml=yes',
'--xml-file=' + tempVgxml,
'--log-file=' + tempVgout,
'--child-silent-after-fork=yes', '-q' ]);
}
if (tempExe) {
cmd.push(tempExe);
} else {
cmd.push(options.engine.fullPath);
if (options.valgrind && options.engine.name === 'duk') {
cmd.push('-m'); // higher memory limit
}
cmd.push(tempInput || options.testPath);
}
cmdline = cmd.join(' ');
if (options.testcase.meta.slow) {
timeout = options.valgrind ? TIMEOUT_SLOW_VALGRIND : TIMEOUT_SLOW;
} else {
timeout = options.valgrind ? TIMEOUT_NORMAL_VALGRIND : TIMEOUT_NORMAL;
}
execopts = {
maxBuffer: 128 * 1024 * 1024,
timeout: timeout,
stdio: 'pipe'
};
//console.log(cmdline);
child = child_process.exec(cmdline, execopts, execDone);
}
function compileApiTest() {
tempSource = mkTempName('.c');
try {
fs.writeFileSync(tempSource, options.engine.cPrefix + fs.readFileSync(options.testPath));
} catch (e) {
console.log(e);
callback(e);
return;
}
tempExe = mkTempName();
// FIXME: listing specific options here is awkward, must match Makefile
cmd = [ 'gcc', '-o', tempExe,
'-L.',
'-Idist/src',
'-Wl,-rpath,.',
'-pedantic', '-ansi', '-std=c99', '-Wall', '-fstrict-aliasing', '-D__POSIX_C_SOURCE=200809L', '-D_GNU_SOURCE', '-D_XOPEN_SOURCE', '-Os', '-fomit-frame-pointer',
'-g', '-ggdb',
'-Werror',
//'-m32',
'runtests/api_testcase_main.c',
tempSource,
'-lduktape',
'-lm' ];
cmdline = cmd.join(' ');
execopts = {

Loading…
Cancel
Save