Generator frontend scripts (./libcevap_gen.sh to be run in libcevap/)

This commit is contained in:
Thomas Schmitt 2007-08-19 18:37:38 +00:00
parent 99fceeb9e4
commit 9b552e9db6
4 changed files with 73 additions and 46 deletions

View File

@ -862,53 +862,10 @@ Notes:
----------------------------------------------------------------------------
Generate C stubs:
test_dir=...where_to_generate_the_stub...
model_dir=...where_to_find_the_model_file_libdax_model.txt...
xtr_dir=...where_to_find_the_extractor_script_extract_cgen_input.sh...
cgen_dir=...where_to_find_the_cgen_binary...
( cd libcevap ; ./libcevap_gen.sh )
/bin/rm "$test_dir"/a.out
cd "$test_dir"/
cat "$model_dir"/libdax_model.txt | \
"$xtr_dir"/extract_cgen_input.sh | \
"$cgen_dir"/cgen -smem_local -ansi -overwrite -global_include cevap_global.h
Compile (a copy of smem.[ch] has to be placed in $test_dir) :
( cd "$test_dir" ; cc -g -c *.c 2>&1 | less )
----------------------------------------------------------------------------
"$xtr_dir"/extract_cgen_input.sh :
#!/bin/sh
copy_mode=0
while true
do
read line
if test "$copy_mode" = "0"
then
if echo " $line" | grep '^ Cgen=' >/dev/null 2>&1
then
copy_mode=1
if echo " $line" | grep '^ Cgen=..' >/dev/null 2>&1
then
echo " $line" | sed -e 's/^ Cgen=//'
fi
elif echo " $line" | grep '^ =end Model=' >/dev/null 2>&1
then
break
fi
else
if test " $line" = " @"
then
copy_mode=0
echo "@"
else
echo " $line" | sed -e 's/^ //'
fi
fi
done
Compile test:
( cd libcevap ; rm cc -g main.c cevap*.c smem.c 2>&1 | less )
----------------------------------------------------------------------------

30
libcevap/extract_cgen_input.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
copy_mode=0
while true
do
read line
if test "$copy_mode" = "0"
then
if echo " $line" | grep '^ Cgen=' >/dev/null 2>&1
then
copy_mode=1
if echo " $line" | grep '^ Cgen=..' >/dev/null 2>&1
then
echo " $line" | sed -e 's/^ Cgen=//'
fi
elif echo " $line" | grep '^ =end Model=' >/dev/null 2>&1
then
break
fi
else
if test " $line" = " @"
then
copy_mode=0
echo "@"
else
echo " $line" | sed -e 's/^ //'
fi
fi
done

16
libcevap/libcevap_gen.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
test_dir=.
model_file=../doc/libdax_model.txt
xtr_dir=.
cgen_dir=.
# cgen_dir=~/projekte/cdrskin_dir/libburn-develop/libcevap
cd "$test_dir" || exit 1
test -e smem.h || exit 1
cat "$model_file" | \
"$xtr_dir"/extract_cgen_input.sh | \
"$cgen_dir"/cgen -smem_local -ansi -global_include cevap_global.h \
-overwrite "$@"

24
libcevap/main.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
#include "cevapi.h"
int main(int argc, char **argv)
{
struct CevapI *cevap= NULL;
int ret;
/* full memory supervision */
Smem_set_record_items(1);
/* one short trip for testing */
ret= Cevapi_new(&cevap,0);
if(ret>0)
Cevapi_destroy(&cevap,0);
/* report any leaked memory */
Smem_stderr(1|2);
exit(ret<=0);
}