src += $(wildcard src/*/*.c)
test_dir_all := $(wildcard tests/*)
-test_ignore = tests/import
+test_ignore = tests/plug test/driver tests/module
test_dir := $(filter-out $(test_ignore), $(test_dir_all))
test_dir += examples
#include "gwion.h"
#include "plug.h"
-static DRVRUN(driver_test_run) {
+static DRVRUN(simple_driver_run) {
while(di->is_running) {
di->run(vm);
++di->pos;
}
}
-static DRVINI(driver_test_ini) {
+static DRVINI(simple_driver_ini) {
return GW_OK;
}
-static DRVDEL(driver_test_del) {}
+static DRVDEL(simple_driver_del) {}
-GWMODSTR(driver_test);
-
-GWDRIVER(driver_test) {
- d->ini = driver_test_ini;
- d->run = driver_test_run;
- d->del = driver_test_del;
+GWDRIVER(driver) {
+ d->ini = simple_driver_ini;
+ d->run = simple_driver_run;
+ d->del = simple_driver_del;
}
--- /dev/null
+INC = -I../../include -I../../util/include -I../../ast/include
+CC ?= gcc
+
+NAME := ${NAME}
+SRC = ${NAME}.c
+OBJ = $(SRC:.c=.o)
+CFLAGS += -std=c99 ${INC} -Wall -Wextra -g -Og
+
+# os specific
+ifeq ($(shell uname), Darwin)
+LDFLAGS += -bundle -undefined dynamic_lookup
+else
+ifeq ($(shell uname), Linux)
+LDFLAGS += -shared
+else
+LDFLAGS += -shared -lpsapi -fPIC -Wl,--export-all -Wl,--enable-auto-import
+LDFLAGS += -L../../ -lgwion
+LDLAGS += ../../libgwion.dll.a
+LDLAGS += ../../libgwion.a
+endif
+endif
+
+all: ${NAME}.so
+
+
+${NAME}.so: ${OBJ}
+ifeq (${USE_LD}, 1)
+ ${LD} $^ -o ${NAME}.so ${LDFLAGS}
+else
+ ${CC} $^ -o ${NAME}.so ${LDFLAGS}
+endif
+
+clean:
+ rm -f ${OBJ} ${NAME}.so
+
+.c.o:
+ ${CC} -fPIC ${CFLAGS} -c $< -o $(<:.c=.o) -g
+
+install: ${NAME}.so
+ install ${NAME}.so ${GWION_ADD_DIR}
+
+uninstall:
+ rm ${GWION_ADD_DIR}/${NAME}.so
#include "vm.h"
#include "gwion.h"
-GWMODSTR(basic_module)
-
GWMODINI(basic_module) {
puts("ini module");
if(args) {
#include "gwi.h"
#include "plug.h"
-GWMODSTR(dummy_module);
-
-GWMODINI(dummy_module) {
+GWMODINI(get_module) {
puts(__func__);
- return (void*)2; // we need to return something
+ return (void*)2;
}
-GWMODEND(dummy_module) {
+
+GWMODEND(get_module) {
puts(__func__);
}
#include "gwion.h"
#include "plug.h"
-GWMODSTR(dummy_module);
-
GWMODINI(dummy_module) {
puts(__func__);
return NULL;
--- /dev/null
+INC = -I../../include -I../../util/include -I../../ast/include
+CC ?= gcc
+
+NAME := ${NAME}
+SRC = ${NAME}.c
+OBJ = $(SRC:.c=.o)
+CFLAGS += -std=c99 ${INC} -Wall -Wextra -g -Og
+
+# os specific
+ifeq ($(shell uname), Darwin)
+LDFLAGS += -bundle -undefined dynamic_lookup
+else
+ifeq ($(shell uname), Linux)
+LDFLAGS += -shared
+else
+LDFLAGS += -shared -lpsapi -fPIC -Wl,--export-all -Wl,--enable-auto-import
+LDFLAGS += -L../../ -lgwion
+LDLAGS += ../../libgwion.dll.a
+LDLAGS += ../../libgwion.a
+endif
+endif
+
+all: ${NAME}.so
+
+
+${NAME}.so: ${OBJ}
+ifeq (${USE_LD}, 1)
+ ${LD} $^ -o ${NAME}.so ${LDFLAGS}
+else
+ ${CC} $^ -o ${NAME}.so ${LDFLAGS}
+endif
+
+clean:
+ rm -f ${OBJ} ${NAME}.so
+
+.c.o:
+ ${CC} -fPIC ${CFLAGS} -c $< -o $(<:.c=.o) -g
+
+install: ${NAME}.so
+ install ${NAME}.so ${GWION_ADD_DIR}
+
+uninstall:
+ rm ${GWION_ADD_DIR}/${NAME}.so
#! [contains] already imported
+#require op_already_imported
<<< 1 >>>;
--- /dev/null
+op_already_imported.gw
#!/bin/bash
-# [test] #77
+# [test] #75
n=0
[ "$1" ] && n="$1"
export GWION_ADD_DIR
test_plugin() {
- export NAME=$"$1"
- export PRG=$"../../gwion"
- export SUPP=$"../../scripts/supp"
+ export NAME="$1"
+ export PRG="../../gwion"
+ export SUPP="../../scripts/supp"
make
+# we might have a test file for all now
if [ -f "$NAME.gw" ]
- then GWOPT+=-p. test_gw "$NAME.gw" "$n"
- else GWOPT+=-p. test_gw "no_file" "$n"
+ then GWOPT+="-p." test_gw "$NAME.gw" "$n"
+ else GWOPT+="-p." test_gw "no_file" "$n"
fi
make clean
N=$(printf "% 4i" "$n")
BASE_DIR="$PWD"
-cd tests/import || exit
+pushd tests/plug || exit
for test_file in *.c
do test_plugin "$(basename "$test_file" .c)"
done
+popd
-DRIVER="driver_test:arg" test_plugin driver
-MODULE="dummy_module=with,some,argument" test_plugin module
+pushd tests/driver || exit
+for test_file in *.c
+do
+ NAME="$(basename "$test_file" .c)"
+ GWOPT+="-d $NAME" test_plugin "$(basename "$test_file" .c)"
+done
+popd || exit
+
+pushd tests/module || exit
+for test_file in *.c
+do
+ NAME="$(basename "$test_file" .c)"
+ GWOPT+="-m $NAME" test_plugin "$NAME"
+done
+popd || exit
# clean
rm -f ./*.gcda ./*.gcno vgcore.* ./*.o ./*.so