ocaml bindings for chibi-scheme VM
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Static linking for all C extensions, eliminate runtime .so dependency

Switch from SEXP_USE_DL=1 (dynamic loading) to SEXP_USE_STATIC_LIBS=1
so all chibi-scheme C extension modules are compiled into
libchibi_vendor.a. Users no longer need platform-specific .so/.dylib
files at runtime -- everything is baked into the OCaml library.

Changes:
- install.h: auto-detect platform (macOS/Linux/Windows) and architecture
(arm64/x86_64) instead of hard-coding linux/x86_64
- eval.c: add suffix matching to sexp_find_static_library() so the
static library table works with absolute module paths (needed for
embedded use where module paths are discovered at runtime)
- clibs.c: new file registering 24 C extensions (7 SRFIs, 2 scheme
standard, 15 chibi libs) with unique init symbols
- lib/dune: compile clibs.c into the vendor archive, set
SEXP_USE_DL=0 + SEXP_USE_STATIC_LIBS=1, drop -ldl

This enables (import (scheme char)), (import (chibi string)),
(import (scheme list)), (import (srfi 69)), (import (scheme regex)),
(import (chibi match)), etc. to work on all platforms without any
external shared objects.

Bump version to 0.2.0

+249 -133
+1 -1
chibi-ocaml.opam
··· 1 1 # This file is generated by dune, edit dune-project instead 2 2 opam-version: "2.0" 3 - version: "0.1.1" 3 + version: "0.2.0" 4 4 synopsis: "OCaml bindings for chibi-scheme, an embeddable R7RS Scheme VM" 5 5 description: 6 6 "chibi-ocaml provides OCaml bindings to the chibi-scheme interpreter, allowing you to embed one or more sandboxed Scheme VMs in your OCaml programs. Features include configurable memory limits, capability-based sandboxing, effect-based streaming, and full R7RS support. The chibi-scheme runtime is vendored and compiled automatically - no system installation required."
+1 -1
dune-project
··· 2 2 3 3 (name chibi-ocaml) 4 4 5 - (version 0.1.1) 5 + (version 0.2.0) 6 6 7 7 (generate_opam_files true) 8 8
+52 -24
lib/dune
··· 7 7 (flags 8 8 :standard 9 9 -I%{project_root}/vendor/chibi-scheme/include 10 - -DSEXP_USE_DL=1 11 - -DSEXP_USE_STATIC_LIBS=0 10 + -I%{project_root}/vendor/chibi-scheme 11 + -DSEXP_USE_DL=0 12 + -DSEXP_USE_STATIC_LIBS=1 13 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 12 14 -DSEXP_USE_GREEN_THREADS=1 13 15 -DSEXP_USE_MODULES=1 14 16 -DSEXP_USE_BOEHM=0 15 17 -O2 -g -fPIC)) 16 18 (foreign_archives chibi_vendor) 17 - (c_library_flags -lm -ldl) 19 + (c_library_flags -lm) 18 20 (ocamlopt_flags (:standard -O2))) 19 21 20 - ; Common C flags for chibi-scheme compilation 21 - ; We use a variable to avoid repetition but dune doesn't support that easily, 22 - ; so we spell them out in each command. 22 + ; Chibi-scheme C compilation flags (shared between core and clibs) 23 + ; - SEXP_USE_DL=0: No dynamic loading of .so/.dylib files 24 + ; - SEXP_USE_STATIC_LIBS=1: All C extensions compiled in statically 25 + ; - SEXP_USE_STATIC_LIBS_NO_INCLUDE=1: clibs.c is linked separately, not 26 + ; #included from eval.c -- avoids symbol conflicts 23 27 24 28 (rule 25 29 (targets libchibi_vendor.a dllchibi_vendor.so) ··· 27 31 (source_tree %{project_root}/vendor/chibi-scheme)) 28 32 (action 29 33 (progn 34 + ; --- Core VM --- 30 35 (run %{cc} -c -fPIC -O2 -g 31 36 -I%{project_root}/vendor/chibi-scheme/include 32 37 -I%{project_root}/vendor/chibi-scheme 33 - -DSEXP_USE_DL=1 34 - -DSEXP_USE_STATIC_LIBS=0 38 + -DSEXP_USE_DL=0 39 + -DSEXP_USE_STATIC_LIBS=1 40 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 35 41 -DSEXP_USE_GREEN_THREADS=1 36 42 -DSEXP_USE_MODULES=1 37 43 -DSEXP_USE_BOEHM=0 ··· 40 46 (run %{cc} -c -fPIC -O2 -g 41 47 -I%{project_root}/vendor/chibi-scheme/include 42 48 -I%{project_root}/vendor/chibi-scheme 43 - -DSEXP_USE_DL=1 44 - -DSEXP_USE_STATIC_LIBS=0 49 + -DSEXP_USE_DL=0 50 + -DSEXP_USE_STATIC_LIBS=1 51 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 45 52 -DSEXP_USE_GREEN_THREADS=1 46 53 -DSEXP_USE_MODULES=1 47 54 -DSEXP_USE_BOEHM=0 ··· 50 57 (run %{cc} -c -fPIC -O2 -g 51 58 -I%{project_root}/vendor/chibi-scheme/include 52 59 -I%{project_root}/vendor/chibi-scheme 53 - -DSEXP_USE_DL=1 54 - -DSEXP_USE_STATIC_LIBS=0 60 + -DSEXP_USE_DL=0 61 + -DSEXP_USE_STATIC_LIBS=1 62 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 55 63 -DSEXP_USE_GREEN_THREADS=1 56 64 -DSEXP_USE_MODULES=1 57 65 -DSEXP_USE_BOEHM=0 ··· 60 68 (run %{cc} -c -fPIC -O2 -g 61 69 -I%{project_root}/vendor/chibi-scheme/include 62 70 -I%{project_root}/vendor/chibi-scheme 63 - -DSEXP_USE_DL=1 64 - -DSEXP_USE_STATIC_LIBS=0 71 + -DSEXP_USE_DL=0 72 + -DSEXP_USE_STATIC_LIBS=1 73 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 65 74 -DSEXP_USE_GREEN_THREADS=1 66 75 -DSEXP_USE_MODULES=1 67 76 -DSEXP_USE_BOEHM=0 ··· 70 79 (run %{cc} -c -fPIC -O2 -g 71 80 -I%{project_root}/vendor/chibi-scheme/include 72 81 -I%{project_root}/vendor/chibi-scheme 73 - -DSEXP_USE_DL=1 74 - -DSEXP_USE_STATIC_LIBS=0 82 + -DSEXP_USE_DL=0 83 + -DSEXP_USE_STATIC_LIBS=1 84 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 75 85 -DSEXP_USE_GREEN_THREADS=1 76 86 -DSEXP_USE_MODULES=1 77 87 -DSEXP_USE_BOEHM=0 ··· 80 90 (run %{cc} -c -fPIC -O2 -g 81 91 -I%{project_root}/vendor/chibi-scheme/include 82 92 -I%{project_root}/vendor/chibi-scheme 83 - -DSEXP_USE_DL=1 84 - -DSEXP_USE_STATIC_LIBS=0 93 + -DSEXP_USE_DL=0 94 + -DSEXP_USE_STATIC_LIBS=1 95 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 85 96 -DSEXP_USE_GREEN_THREADS=1 86 97 -DSEXP_USE_MODULES=1 87 98 -DSEXP_USE_BOEHM=0 ··· 90 101 (run %{cc} -c -fPIC -O2 -g 91 102 -I%{project_root}/vendor/chibi-scheme/include 92 103 -I%{project_root}/vendor/chibi-scheme 93 - -DSEXP_USE_DL=1 94 - -DSEXP_USE_STATIC_LIBS=0 104 + -DSEXP_USE_DL=0 105 + -DSEXP_USE_STATIC_LIBS=1 106 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 95 107 -DSEXP_USE_GREEN_THREADS=1 96 108 -DSEXP_USE_MODULES=1 97 109 -DSEXP_USE_BOEHM=0 ··· 100 112 (run %{cc} -c -fPIC -O2 -g 101 113 -I%{project_root}/vendor/chibi-scheme/include 102 114 -I%{project_root}/vendor/chibi-scheme 103 - -DSEXP_USE_DL=1 104 - -DSEXP_USE_STATIC_LIBS=0 115 + -DSEXP_USE_DL=0 116 + -DSEXP_USE_STATIC_LIBS=1 117 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 105 118 -DSEXP_USE_GREEN_THREADS=1 106 119 -DSEXP_USE_MODULES=1 107 120 -DSEXP_USE_BOEHM=0 108 121 -o chibi_simplify.o 109 122 %{project_root}/vendor/chibi-scheme/simplify.c) 123 + ; --- Static C extension libraries (clibs.c) --- 124 + (run %{cc} -c -fPIC -O2 -g 125 + -I%{project_root}/vendor/chibi-scheme/include 126 + -I%{project_root}/vendor/chibi-scheme 127 + -DSEXP_USE_DL=0 128 + -DSEXP_USE_STATIC_LIBS=1 129 + -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=1 130 + -DSEXP_USE_GREEN_THREADS=1 131 + -DSEXP_USE_MODULES=1 132 + -DSEXP_USE_BOEHM=0 133 + -o chibi_clibs.o 134 + %{project_root}/vendor/chibi-scheme/clibs.c) 135 + ; --- Archive everything together --- 110 136 (run ar rcs libchibi_vendor.a 111 137 chibi_gc.o chibi_sexp.o chibi_bignum.o chibi_gc_heap.o 112 - chibi_opcodes.o chibi_vm.o chibi_eval.o chibi_simplify.o) 138 + chibi_opcodes.o chibi_vm.o chibi_eval.o chibi_simplify.o 139 + chibi_clibs.o) 113 140 (run %{cc} -shared -o dllchibi_vendor.so 114 141 chibi_gc.o chibi_sexp.o chibi_bignum.o chibi_gc_heap.o 115 142 chibi_opcodes.o chibi_vm.o chibi_eval.o chibi_simplify.o 116 - -lm -ldl)))) 143 + chibi_clibs.o 144 + -lm))))
+160
vendor/chibi-scheme/clibs.c
··· 1 + /* 2 + * clibs.c -- Static library registration for chibi-scheme embedding 3 + * 4 + * This file is auto-generated for chibi-ocaml static builds. 5 + * It includes all C extension modules and registers them in a lookup 6 + * table so the module system can find them without dlopen(). 7 + * 8 + * Each extension .c file defines sexp_init_library(). We use 9 + * #define/#undef to rename each one to a unique symbol before 10 + * including the source, then build a table mapping module paths 11 + * to init functions. 12 + */ 13 + 14 + #include "include/chibi/eval.h" 15 + 16 + /* --- SRFI extensions --- */ 17 + 18 + #define sexp_init_library sexp_init_lib_srfi_69_hash 19 + #include "lib/srfi/69/hash.c" 20 + #undef sexp_init_library 21 + 22 + #define sexp_init_library sexp_init_lib_srfi_27_rand 23 + #include "lib/srfi/27/rand.c" 24 + #undef sexp_init_library 25 + 26 + #define sexp_init_library sexp_init_lib_srfi_39_param 27 + #include "lib/srfi/39/param.c" 28 + #undef sexp_init_library 29 + 30 + #define sexp_init_library sexp_init_lib_srfi_95_qsort 31 + #include "lib/srfi/95/qsort.c" 32 + #undef sexp_init_library 33 + 34 + #define sexp_init_library sexp_init_lib_srfi_98_env 35 + #include "lib/srfi/98/env.c" 36 + #undef sexp_init_library 37 + 38 + #define sexp_init_library sexp_init_lib_srfi_144_math 39 + #include "lib/srfi/144/math.c" 40 + #undef sexp_init_library 41 + 42 + #define sexp_init_library sexp_init_lib_srfi_151_bit 43 + #include "lib/srfi/151/bit.c" 44 + #undef sexp_init_library 45 + 46 + /* Note: srfi/160 (uniform vectors) and srfi/18 (threads) are excluded 47 + for now -- they have complex platform dependencies and are rarely 48 + needed in embedded use. They can be added later if required. */ 49 + 50 + /* --- Scheme standard library extensions --- */ 51 + 52 + #define sexp_init_library sexp_init_lib_scheme_time 53 + #include "lib/scheme/time.c" 54 + #undef sexp_init_library 55 + 56 + #define sexp_init_library sexp_init_lib_scheme_bytevector 57 + #include "lib/scheme/bytevector.c" 58 + #undef sexp_init_library 59 + 60 + /* --- Chibi extensions --- */ 61 + 62 + #define sexp_init_library sexp_init_lib_chibi_ast 63 + #include "lib/chibi/ast.c" 64 + #undef sexp_init_library 65 + 66 + #define sexp_init_library sexp_init_lib_chibi_weak 67 + #include "lib/chibi/weak.c" 68 + #undef sexp_init_library 69 + 70 + #define sexp_init_library sexp_init_lib_chibi_heap_2dstats 71 + #include "lib/chibi/heap-stats.c" 72 + #undef sexp_init_library 73 + 74 + #define sexp_init_library sexp_init_lib_chibi_io_io 75 + #include "lib/chibi/io/io.c" 76 + #undef sexp_init_library 77 + 78 + #define sexp_init_library sexp_init_lib_chibi_filesystem 79 + #include "lib/chibi/filesystem.c" 80 + #undef sexp_init_library 81 + 82 + #define sexp_init_library sexp_init_lib_chibi_process 83 + #include "lib/chibi/process.c" 84 + #undef sexp_init_library 85 + 86 + #define sexp_init_library sexp_init_lib_chibi_stty 87 + #include "lib/chibi/stty.c" 88 + #undef sexp_init_library 89 + 90 + #define sexp_init_library sexp_init_lib_chibi_system 91 + #include "lib/chibi/system.c" 92 + #undef sexp_init_library 93 + 94 + #define sexp_init_library sexp_init_lib_chibi_time 95 + #include "lib/chibi/time.c" 96 + #undef sexp_init_library 97 + 98 + #define sexp_init_library sexp_init_lib_chibi_net 99 + #include "lib/chibi/net.c" 100 + #undef sexp_init_library 101 + 102 + #define sexp_init_library sexp_init_lib_chibi_json 103 + #include "lib/chibi/json.c" 104 + #undef sexp_init_library 105 + 106 + #define sexp_init_library sexp_init_lib_chibi_disasm 107 + #include "lib/chibi/disasm.c" 108 + #undef sexp_init_library 109 + 110 + #define sexp_init_library sexp_init_lib_chibi_crypto_crypto 111 + #include "lib/chibi/crypto/crypto.c" 112 + #undef sexp_init_library 113 + 114 + #define sexp_init_library sexp_init_lib_chibi_optimize_rest 115 + #include "lib/chibi/optimize/rest.c" 116 + #undef sexp_init_library 117 + 118 + #define sexp_init_library sexp_init_lib_chibi_optimize_profile 119 + #include "lib/chibi/optimize/profile.c" 120 + #undef sexp_init_library 121 + 122 + /* --- Static library lookup table --- 123 + * 124 + * Names are relative paths (without .so/.dylib extension) that the 125 + * module system resolves via suffix matching against absolute paths. 126 + * E.g., "srfi/69/hash" matches "/any/path/to/lib/srfi/69/hash.so" 127 + */ 128 + 129 + struct sexp_library_entry_t sexp_static_libraries_array[] = { 130 + /* SRFIs */ 131 + {"srfi/69/hash", sexp_init_lib_srfi_69_hash}, 132 + {"srfi/27/rand", sexp_init_lib_srfi_27_rand}, 133 + {"srfi/39/param", sexp_init_lib_srfi_39_param}, 134 + {"srfi/95/qsort", sexp_init_lib_srfi_95_qsort}, 135 + {"srfi/98/env", sexp_init_lib_srfi_98_env}, 136 + {"srfi/144/math", sexp_init_lib_srfi_144_math}, 137 + {"srfi/151/bit", sexp_init_lib_srfi_151_bit}, 138 + /* Scheme standard */ 139 + {"scheme/time", sexp_init_lib_scheme_time}, 140 + {"scheme/bytevector", sexp_init_lib_scheme_bytevector}, 141 + /* Chibi */ 142 + {"chibi/ast", sexp_init_lib_chibi_ast}, 143 + {"chibi/weak", sexp_init_lib_chibi_weak}, 144 + {"chibi/heap-stats", sexp_init_lib_chibi_heap_2dstats}, 145 + {"chibi/io/io", sexp_init_lib_chibi_io_io}, 146 + {"chibi/filesystem", sexp_init_lib_chibi_filesystem}, 147 + {"chibi/process", sexp_init_lib_chibi_process}, 148 + {"chibi/stty", sexp_init_lib_chibi_stty}, 149 + {"chibi/system", sexp_init_lib_chibi_system}, 150 + {"chibi/time", sexp_init_lib_chibi_time}, 151 + {"chibi/net", sexp_init_lib_chibi_net}, 152 + {"chibi/json", sexp_init_lib_chibi_json}, 153 + {"chibi/disasm", sexp_init_lib_chibi_disasm}, 154 + {"chibi/crypto/crypto", sexp_init_lib_chibi_crypto_crypto}, 155 + {"chibi/optimize/rest", sexp_init_lib_chibi_optimize_rest}, 156 + {"chibi/optimize/profile", sexp_init_lib_chibi_optimize_profile}, 157 + {NULL, NULL}}; 158 + 159 + struct sexp_library_entry_t *sexp_static_libraries = 160 + sexp_static_libraries_array;
+11 -3
vendor/chibi-scheme/eval.c
··· 1410 1410 1411 1411 static struct sexp_library_entry_t *sexp_find_static_library(const char *file) 1412 1412 { 1413 - size_t base_len; 1413 + size_t base_len, name_len; 1414 1414 struct sexp_library_entry_t *entry, *table; 1415 1415 1416 1416 if(!sexp_static_libraries) ··· 1423 1423 for (table = sexp_static_libraries; 1424 1424 table; 1425 1425 table = (struct sexp_library_entry_t*)entry->init) { 1426 - for (entry = &table[0]; entry->name; entry++) 1427 - if (! strncmp(file, entry->name, base_len)) 1426 + for (entry = &table[0]; entry->name; entry++) { 1427 + name_len = strlen(entry->name); 1428 + /* exact prefix match (original behaviour, relative paths) */ 1429 + if (name_len >= base_len && ! strncmp(file, entry->name, base_len)) 1428 1430 return entry; 1431 + /* suffix match (for absolute module paths in embedded use) */ 1432 + if (name_len <= base_len && base_len > name_len 1433 + && file[base_len - name_len - 1] == '/' 1434 + && ! strncmp(file + base_len - name_len, entry->name, name_len)) 1435 + return entry; 1436 + } 1429 1437 } 1430 1438 return NULL; 1431 1439 }
+24 -1
vendor/chibi-scheme/include/chibi/install.h
··· 1 + /* Platform-adaptive install configuration for chibi-ocaml embedding */ 2 + 3 + #if defined(__APPLE__) && defined(__MACH__) 4 + #define sexp_so_extension ".dylib" 5 + #define sexp_platform "macosx" 6 + #if defined(__aarch64__) || defined(__arm64__) 7 + #define sexp_architecture "aarch64" 8 + #else 9 + #define sexp_architecture "x86_64" 10 + #endif 11 + #elif defined(_WIN32) || defined(_WIN64) 12 + #define sexp_so_extension ".dll" 13 + #define sexp_platform "windows" 14 + #define sexp_architecture "x86_64" 15 + #else 1 16 #define sexp_so_extension ".so" 2 - #define sexp_default_module_path "" 3 17 #define sexp_platform "linux" 18 + #if defined(__aarch64__) 19 + #define sexp_architecture "aarch64" 20 + #elif defined(__x86_64__) 4 21 #define sexp_architecture "x86_64" 22 + #else 23 + #define sexp_architecture "unknown" 24 + #endif 25 + #endif 26 + 27 + #define sexp_default_module_path "" 5 28 #define sexp_version "0.12.0" 6 29 #define sexp_release_name "magnesium"
-43
vendor/chibi-scheme/tests/build/build-opts.txt
··· 1 - CPPFLAGS=-DSEXP_USE_MODULES=0 2 - CPPFLAGS=-DSEXP_USE_GREEN_THREADS=0 3 - CPPFLAGS=-DSEXP_USE_IMAGE_LOADING=0 4 - CPPFLAGS=-DSEXP_USE_DL=0 5 - CPPFLAGS=-DSEXP_USE_SIMPLIFY=0 6 - CPPFLAGS=-DSEXP_USE_TYPE_DEFS=0 7 - SEXP_USE_BOEHM=1;CPPFLAGS=-I/opt/local/include;LDFLAGS=-L/opt/local/lib 8 - CPPFLAGS=-DSEXP_USE_DEBUG_GC=1 9 - CPPFLAGS=-DSEXP_USE_FINALIZERS=0 10 - CPPFLAGS=-DSEXP_USE_CONSERVATIVE_GC=1 11 - CPPFLAGS=-DSEXP_USE_GLOBAL_HEAP=1 12 - CPPFLAGS=-DSEXP_USE_GLOBAL_SYMBOLS=1 13 - CPPFLAGS=-DSEXP_USE_FLONUMS=0 14 - CPPFLAGS=-DSEXP_USE_IMMEDIATE_FLONUMS=1 15 - CPPFLAGS=-DSEXP_USE_BIGNUMS=0 16 - CPPFLAGS=-DSEXP_USE_COMPLEX=0 17 - CPPFLAGS=-DSEXP_USE_RATIOS=0 18 - CPPFLAGS=-DSEXP_USE_CUSTOM_LONG_LONGS=1 19 - CPPFLAGS=-DSEXP_USE_MATH=0 20 - CPPFLAGS=-DSEXP_WARN_UNDEFS=0 21 - CPPFLAGS=-DSEXP_USE_HUFF_SYMS=0 22 - CPPFLAGS=-DSEXP_USE_HASH_SYMS=0 23 - CPPFLAGS=-DSEXP_USE_AUTOCLOSE_PORTS=0 24 - CPPFLAGS=-DSEXP_USE_2010_EPOCH=0 25 - CPPFLAGS=-DSEXP_USE_CHECK_STACK=0 26 - CPPFLAGS=-DSEXP_USE_EXTENDED_FCALL=0 27 - CPPFLAGS=-DSEXP_USE_WEAK_REFERENCES=0 28 - CPPFLAGS=-DSEXP_USE_UNIFY_FILENOS_BY_NUMBER=1 29 - CPPFLAGS=-DSEXP_USE_OBJECT_BRACE_LITERALS=0 30 - CPPFLAGS=-DSEXP_USE_TAIL_JUMPS=0 31 - CPPFLAGS=-DSEXP_USE_RESERVE_OPCODE=0 32 - CPPFLAGS=-DSEXP_USE_PROFILE_VM=1 33 - CPPFLAGS=-DSEXP_USE_UTF8_STRINGS=0 34 - CPPFLAGS=-DSEXP_USE_DISJOINT_STRING_CURSORS=0 35 - CFLAGS=-DSEXP_USE_STATIC_LIBS_NO_INCLUDE=0;CPPFLAGS=-DSEXP_USE_STATIC_LIBS=1 36 - CPPFLAGS=-DSEXP_USE_MUTABLE_STRINGS=0 37 - CPPFLAGS=-DSEXP_USE_STRING_INDEX_TABLE=1 38 - CPPFLAGS=-DSEXP_USE_STRICT_TOPLEVEL_BINDINGS=1 39 - CPPFLAGS=-DSEXP_USE_FIXED_CHUNK_SIZE_HEAPS=1 40 - CPPFLAGS=-DSEXP_USE_FULL_SOURCE_INFO=0 41 - CPPFLAGS=-DSEXP_USE_NO_FEATURES=1 42 - CFLAGS=-std=c89 43 - CFLAGS=-m32;LDFLAGS=-m32
-60
vendor/chibi-scheme/tests/build/build-tests.sh
··· 1 - #!/bin/sh 2 - 3 - # Test basic build options. 4 - 5 - # For bootstrapping reasons this is a shell script, instead of a 6 - # scheme script using (chibi process). 7 - 8 - # We just check each build against r5rs-tests.scm - some of the 9 - # libraries will fail to build (notably if modules or user-defined 10 - # types are disabled). 11 - 12 - BUILDDIR=tests/build 13 - FAILURES=0 14 - MAKE=${MAKE:-make} 15 - vars=CFLAGS="-O0 -g0 -w" 16 - i=0 17 - 18 - for opts in $(cat ${BUILDDIR}/build-opts.txt); do 19 - # If compiling with static libs, we need to bootstrap to build 20 - # clibs.c. 21 - TARGET="chibi-scheme" 22 - if echo ${opts} | grep -q 'SEXP_USE_STATIC_LIBS=1'; then 23 - staticopts=$(echo ${opts} | sed 's/-DSEXP_USE_STATIC_LIBS=1;*//') 24 - staticopts=$(echo ${staticopts} | tr ';' ' ') 25 - $MAKE cleaner 2>&1 >/dev/null 26 - rm -f clibs.c 27 - $MAKE -j 8 "$vars" $staticopts 2>&1 >${BUILDDIR}/build${i}-bootstrap.out 28 - $MAKE -j 8 "$vars" $staticopts clibs.c 2>&1 >${BUILDDIR}/build${i}-clibs.out 29 - TARGET="chibi-scheme-static" 30 - fi 31 - # Try to build then run tests. 32 - opts=$(echo ${opts} | tr ';' ' ') 33 - $MAKE cleaner 2>&1 >/dev/null 34 - sync 35 - if $MAKE -j 8 "$vars" $opts "$TARGET" 2>&1 >${BUILDDIR}/build${i}-make.out; then 36 - if [ "chibi-scheme" != "$TARGET" ]; then 37 - cp "$TARGET" chibi-scheme 38 - fi 39 - sync 40 - if $MAKE test-r5rs 2>&1 | tee ${BUILDDIR}/build${i}-test.out \ 41 - | grep -q -E 'FAIL|ERROR'; then 42 - echo "[FAIL] ${i}: tests failed with $opts" 43 - FAILURES=$((FAILURES + 1)) 44 - else 45 - echo "[PASS] ${i}: tests passed with $opts" 46 - fi 47 - else 48 - echo "[FAIL] ${i}: couldn't build with $opts" 49 - FAILURES=$((FAILURES + 1)) 50 - fi 51 - i=$((i+1)) 52 - done 53 - $MAKE cleaner 2>&1 >/dev/null 54 - 55 - if [ $FAILURES = 0 ]; then 56 - echo "build-tests: all tests passed" 57 - else 58 - echo "build-tests: ${FAILURES} tests failed" 59 - fi 60 -