Rewrite chicken example and test-suite building code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5948 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
830e72dba7
commit
acd0b021b1
35 changed files with 315 additions and 844 deletions
|
|
@ -1,49 +1,30 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
INTERFACE = example.i
|
||||
CHICKSRCS = precsi.c oexample.c
|
||||
SRCS = example_wrap.c
|
||||
CXXSRCS =
|
||||
CHICKGEN = $(CHICKSRCS) csi.c example_wrap.c
|
||||
TARGET = constants
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS =
|
||||
TARGET = constants
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = test-constants.scm
|
||||
#VARIANT = _static
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
csi.c:
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
|
||||
INTERFACE='precsi' chicken_csi
|
||||
|
||||
precsi.c: precsi.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
example_wrap.c example.scm: example.i
|
||||
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_swig_c
|
||||
|
||||
oexample.c: example.scm
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='oexample.c' \
|
||||
INTERFACE='$<' chicken_chicken
|
||||
|
||||
$(TARGET): csi.c $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_static
|
||||
|
||||
module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
CHICKSRCS='$(CHICKSRCS)' SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='module' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' chicken_module
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f $(CHICKGEN)
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check:: module
|
||||
check::
|
||||
csi -batch $(TARGET).so test-constants.scm
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
(declare (unit precsi))
|
||||
(declare (uses example))
|
||||
|
||||
;; display prelude to csi
|
||||
(display "constants\n\n")
|
||||
|
||||
(display " A SWIG example for the CHICKEN compiler\n")
|
||||
(display " Author: Jonah Beckford, December 2002\n\n")
|
||||
|
||||
(display "C Procedures:\n")
|
||||
(display " #define ICONST 42\n")
|
||||
(display " #define FCONST 2.1828\n")
|
||||
(display " #define CCONST 'x'\n")
|
||||
(display " #define CCONST2 '\n'\n")
|
||||
(display " #define SCONST \"Hello World\"\n")
|
||||
(display " #define SCONST2 \"\\\"Hello World\\\"\"\n")
|
||||
(display " /* This should work just fine */\n")
|
||||
(display " #define EXPR ICONST + 3*(FCONST)\n")
|
||||
(display " /* This shouldn't do anything */\n")
|
||||
(display " #define EXTERN extern\n")
|
||||
(display " /* Neither should this (BAR isn't defined) */\n")
|
||||
(display " #define FOO (ICONST + BAR)\n")
|
||||
(display " /* The following directives also produce constants. Remember that\n")
|
||||
(display " CHICKEN is normally case-insensitive, so don't rely on differing\n")
|
||||
(display " case to differentiate variable names */\n")
|
||||
(display " %constant int iconstX = 37;\n")
|
||||
(display " %constant double fconstX = 3.14;\n")
|
||||
(display "\n")
|
||||
|
||||
(display "Scheme Procedures:\n")
|
||||
(display " (example:ICONST)\n")
|
||||
(display " (example:FCONST)\n")
|
||||
(display " (example:CCONST)\n")
|
||||
(display " (example:CCONST2)\n")
|
||||
(display " (example:SCONST)\n")
|
||||
(display " (example:SCONST2)\n")
|
||||
(display " (example:EXPR)\n")
|
||||
(display " (example:EXTERN)\n")
|
||||
(display " (example:FOO)\n")
|
||||
(display " (example:iconstX)\n")
|
||||
(display " (example:fconstX)\n")
|
||||
(display "\n")
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
;; run with './constants test-constants.scm'
|
||||
;; feel free to uncomment and comment sections
|
||||
|
||||
(declare (uses example))
|
||||
|
||||
(display "starting test ... you will see 'finished' if successful.\n")
|
||||
(or (= (example:ICONST) 42) (exit 1))
|
||||
(or (< (abs (- (example:FCONST) 2.1828)) 0.00001) (exit 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue