From 5c941ea62cc140daa06743c38a9accf5fbfe861a Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 6 Apr 2009 18:47:40 +0300 Subject: [PATCH] Out-of-tree building and testing now seems to work --- scheme/Makefile.am | 16 +++++++---- scheme/Makefile.in | 16 +++++++---- scheme/ikarus.compiler.altcogen.ss | 2 +- scheme/ikarus.compiler.ss | 8 ++++-- ...ikarus.compiler.tag-annotation-analysis.ss | 2 +- scheme/ikarus.include-src.ss | 28 +++++++++++++++++++ scheme/ikarus.unicode.ss | 5 ++-- scheme/makefile.ss | 4 ++- scheme/pass-specify-rep.ss | 2 +- scheme/tests/framework.ss | 5 +++- scheme/tests/io.ss | 12 ++++---- scheme/tests/normalization.ss | 4 +-- scheme/tests/parse-flonums.ss | 4 +-- 13 files changed, 78 insertions(+), 30 deletions(-) create mode 100644 scheme/ikarus.include-src.ss diff --git a/scheme/Makefile.am b/scheme/Makefile.am index cf774f6..d92a7c5 100644 --- a/scheme/Makefile.am +++ b/scheme/Makefile.am @@ -29,7 +29,7 @@ EXTRA_DIST=ikarus.boot.4.prebuilt ikarus.boot.8.prebuilt \ ikarus.string-to-number.ss ikarus.compiler.source-optimizer.ss \ ikarus.compiler.tag-annotation-analysis.ss ikarus.ontology.ss \ ikarus.reader.annotated.ss ikarus.pointers.ss ikarus.equal.ss \ - ikarus.symbol-table.ss ikarus.apropos.ss + ikarus.symbol-table.ss ikarus.apropos.ss ikarus.include-src.ss all: $(nodist_pkglib_DATA) @@ -41,7 +41,7 @@ sizeofvoidp = $(shell grep SIZEOF_VOID_P ../config.h | sed "s/.*\(.\)/\1/g") ikarus.config.ss: Makefile last-revision ../config.h echo '(define ikarus-version "$(PACKAGE_VERSION)")' >$@ - echo '(define ikarus-revision "$(shell cat last-revision)")' >>$@ + echo '(define ikarus-revision "$(shell cat $(srcdir)/last-revision)")' >>$@ echo '(define ikarus-lib-dir "$(pkglibdir)")' >>$@ echo '(define target "$(target)")' >>$@ echo '(define wordsize $(sizeofvoidp))' >>$@ @@ -50,8 +50,14 @@ ikarus.config.ss: Makefile last-revision ../config.h CLEANFILES=$(nodist_pkglib_DATA) ikarus.config.ss MAINTAINERCLEANFILES=last-revision -ikarus.boot: $(EXTRA_DIST) ikarus.config.ss - ../src/ikarus -b ./ikarus.boot.$(sizeofvoidp).prebuilt --r6rs-script makefile.ss +ikarus.boot: $(EXTRA_DIST) ikarus.config.ss + IKARUS_SRC_DIR=$(srcdir) \ + IKARUS_BUILD_DIR=$(builddir) \ + IKARUS_LIBRARY_PATH=$(srcdir) \ + ../src/ikarus -b $(srcdir)/ikarus.boot.$(sizeofvoidp).prebuilt \ + --r6rs-script $(srcdir)/makefile.ss check: ikarus.boot - ../src/ikarus -b ikarus.boot --r6rs-script run-tests.ss + IKARUS_SRC_DIR=$(srcdir) \ + IKARUS_LIBRARY_PATH=$(srcdir) \ + ../src/ikarus -b ikarus.boot --r6rs-script $(srcdir)/run-tests.ss diff --git a/scheme/Makefile.in b/scheme/Makefile.in index c9a9d3f..7fe5e88 100644 --- a/scheme/Makefile.in +++ b/scheme/Makefile.in @@ -184,7 +184,7 @@ EXTRA_DIST = ikarus.boot.4.prebuilt ikarus.boot.8.prebuilt \ ikarus.string-to-number.ss ikarus.compiler.source-optimizer.ss \ ikarus.compiler.tag-annotation-analysis.ss ikarus.ontology.ss \ ikarus.reader.annotated.ss ikarus.pointers.ss ikarus.equal.ss \ - ikarus.symbol-table.ss ikarus.apropos.ss + ikarus.symbol-table.ss ikarus.apropos.ss ikarus.include-src.ss revno = "$(shell sed 's/ .*//' ../.bzr/branch/last-revision 2>/dev/null)" sizeofvoidp = $(shell grep SIZEOF_VOID_P ../config.h | sed "s/.*\(.\)/\1/g") @@ -380,16 +380,22 @@ last-revision: $(shell ls ../.bzr/branch/last-revision 2>/dev/null) ikarus.config.ss: Makefile last-revision ../config.h echo '(define ikarus-version "$(PACKAGE_VERSION)")' >$@ - echo '(define ikarus-revision "$(shell cat last-revision)")' >>$@ + echo '(define ikarus-revision "$(shell cat $(srcdir)/last-revision)")' >>$@ echo '(define ikarus-lib-dir "$(pkglibdir)")' >>$@ echo '(define target "$(target)")' >>$@ echo '(define wordsize $(sizeofvoidp))' >>$@ -ikarus.boot: $(EXTRA_DIST) ikarus.config.ss - ../src/ikarus -b ./ikarus.boot.$(sizeofvoidp).prebuilt --r6rs-script makefile.ss +ikarus.boot: $(EXTRA_DIST) ikarus.config.ss + IKARUS_SRC_DIR=$(srcdir) \ + IKARUS_BUILD_DIR=$(builddir) \ + IKARUS_LIBRARY_PATH=$(srcdir) \ + ../src/ikarus -b $(srcdir)/ikarus.boot.$(sizeofvoidp).prebuilt \ + --r6rs-script $(srcdir)/makefile.ss check: ikarus.boot - ../src/ikarus -b ikarus.boot --r6rs-script run-tests.ss + IKARUS_SRC_DIR=$(srcdir) \ + IKARUS_LIBRARY_PATH=$(srcdir) \ + ../src/ikarus -b ikarus.boot --r6rs-script $(srcdir)/run-tests.ss # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/scheme/ikarus.compiler.altcogen.ss b/scheme/ikarus.compiler.altcogen.ss index aa4a5ad..5050d8d 100644 --- a/scheme/ikarus.compiler.altcogen.ss +++ b/scheme/ikarus.compiler.altcogen.ss @@ -319,7 +319,7 @@ (make-codes (map Clambda code*) (Main body))])) (Program x)) -(include "pass-specify-rep.ss") +(include-src "pass-specify-rep.ss") (define parameter-registers '(%edi)) (define return-value-register '%eax) diff --git a/scheme/ikarus.compiler.ss b/scheme/ikarus.compiler.ss index b6913ca..07e131d 100644 --- a/scheme/ikarus.compiler.ss +++ b/scheme/ikarus.compiler.ss @@ -27,6 +27,7 @@ (ikarus system $pairs) (only (ikarus system $codes) $code->closure) (only (ikarus system $structs) $struct-ref $struct/rtd?) + (ikarus.include-src) (except (ikarus) optimize-level debug-optimizer fasl-write scc-letrec optimize-cp @@ -39,6 +40,7 @@ (ikarus.intel-assembler)) + (define-syntax struct-case (lambda (x) (define (enumerate fld* i) @@ -1052,7 +1054,7 @@ ;(pretty-print (unparse x)) x)) -(include "ikarus.compiler.source-optimizer.ss") +(include-src "ikarus.compiler.source-optimizer.ss") (define (rewrite-assignments x) (define who 'rewrite-assignments) @@ -1140,7 +1142,7 @@ [else (error who "invalid expression" (unparse x))])) (Expr x)) -(include "ikarus.compiler.tag-annotation-analysis.ss") +(include-src "ikarus.compiler.tag-annotation-analysis.ss") (define (introduce-vars x) (define who 'introduce-vars) @@ -2408,7 +2410,7 @@ (define eval-core (lambda (x) ((compile-core-expr x)))) -(include "ikarus.compiler.altcogen.ss") +(include-src "ikarus.compiler.altcogen.ss") (define current-primitive-locations (let ([plocs (lambda (x) #f)]) diff --git a/scheme/ikarus.compiler.tag-annotation-analysis.ss b/scheme/ikarus.compiler.tag-annotation-analysis.ss index a7ec02e..2c202c3 100644 --- a/scheme/ikarus.compiler.tag-annotation-analysis.ss +++ b/scheme/ikarus.compiler.tag-annotation-analysis.ss @@ -16,7 +16,7 @@ ;;; THIS IS WIP -(include "ikarus.ontology.ss") +(include-src "ikarus.ontology.ss") (define tag-analysis-output (make-parameter #f)) diff --git a/scheme/ikarus.include-src.ss b/scheme/ikarus.include-src.ss new file mode 100644 index 0000000..b23f06a --- /dev/null +++ b/scheme/ikarus.include-src.ss @@ -0,0 +1,28 @@ +;;; Ikarus Scheme -- A compiler for R6RS Scheme. +;;; Copyright (C) 2009 Abdulaziz Ghuloum +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License version 3 as +;;; published by the Free Software Foundation. +;;; +;;; This program is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + +(library (ikarus.include-src) + (export include-src) + (import (ikarus)) + (define-syntax include-src + (lambda (x) + (syntax-case x () + [(ctxt filename) + (with-syntax ([filename + (string-append + (or (getenv "IKARUS_SRC_DIR") ".") + "/" + (syntax->datum #'filename))]) + #'(include-into ctxt filename))])))) diff --git a/scheme/ikarus.unicode.ss b/scheme/ikarus.unicode.ss index e0f3e9f..c1e1ed6 100644 --- a/scheme/ikarus.unicode.ss +++ b/scheme/ikarus.unicode.ss @@ -31,6 +31,7 @@ string-ci=? string-ci>? string-ci>=? string-normalize-nfd string-normalize-nfkd string-normalize-nfc string-normalize-nfkc ) (import + (ikarus.include-src) (except (ikarus) unicode-printable-char? char-upcase char-downcase char-titlecase char-foldcase @@ -99,8 +100,8 @@ (define (char- x y) (fx- (char->integer x) (char->integer y))) -(include "unicode/unicode-char-cases.ss") -(include "unicode/unicode-charinfo.ss") +(include-src "unicode/unicode-char-cases.ss") +(include-src "unicode/unicode-charinfo.ss") (define-syntax define-char-op (syntax-rules () diff --git a/scheme/makefile.ss b/scheme/makefile.ss index dc27460..fa9287a 100755 --- a/scheme/makefile.ss +++ b/scheme/makefile.ss @@ -1727,6 +1727,8 @@ `([$init-symbol-value! . ,label]) `([,label . (global . ,loc)]))) +(define src-dir (or (getenv "IKARUS_SRC_DIR") ".")) + (define (expand-all files) ;;; remove all re-exported identifiers (those with labels in ;;; subst but not binding in env). @@ -1740,7 +1742,7 @@ (for-each (lambda (file) (debugf " ~s" file) - (load file + (load (string-append src-dir "/" file) (lambda (x) (let-values ([(name code export-subst export-env) (boot-library-expand x)]) diff --git a/scheme/pass-specify-rep.ss b/scheme/pass-specify-rep.ss index a1bb299..8e186ae 100644 --- a/scheme/pass-specify-rep.ss +++ b/scheme/pass-specify-rep.ss @@ -550,4 +550,4 @@ (let ([x (Program x)]) x)) - (include "pass-specify-rep-primops.ss")) + (include-src "pass-specify-rep-primops.ss")) diff --git a/scheme/tests/framework.ss b/scheme/tests/framework.ss index 8dbb1ae..744c70a 100644 --- a/scheme/tests/framework.ss +++ b/scheme/tests/framework.ss @@ -1,7 +1,10 @@ (library (tests framework) - (export define-tests) + (export define-tests src-file) (import (ikarus)) + + (define (src-file x) + (string-append (or (getenv "IKARUS_SRC_DIR") ".") "/" x)) (define-syntax define-tests (syntax-rules () [(_ test-all [p0 e0] ...) diff --git a/scheme/tests/io.ss b/scheme/tests/io.ss index 7262735..d022eea 100755 --- a/scheme/tests/io.ss +++ b/scheme/tests/io.ss @@ -541,16 +541,16 @@ (f (fx+ i 1))))) (define (test-input-files) - (assert (= (file-size-char-by-char "tests/SRFI-1.ss") 56573)) - (assert (= (file-size "tests/SRFI-1.ss") 56573)) - (let ([bv (file->bytevector "tests/SRFI-1.ss")]) + (assert (= (file-size-char-by-char (src-file "tests/SRFI-1.ss")) 56573)) + (assert (= (file-size (src-file "tests/SRFI-1.ss")) 56573)) + (let ([bv (file->bytevector (src-file "tests/SRFI-1.ss"))]) (let-values ([(p extract) (open-bytevector-output-port #f)]) (bytevector->binary-port bv p) (let ([bv2 (extract)]) (assert (bytevector=? bv bv2)) (assert (bytevector=? #vu8() (extract)))))) - (let ([bv (file->bytevector "tests/SRFI-1.ss")]) + (let ([bv (file->bytevector (src-file "tests/SRFI-1.ss"))]) (let-values ([(p extract) (open-bytevector-output-port (native-transcoder))]) (bytevector->textual-port bv p) @@ -558,7 +558,7 @@ (assert (bytevector=? bv bv2)) (assert (bytevector=? #vu8() (extract)))))) - (let ([bv (file->bytevector "tests/SRFI-1.ss")]) + (let ([bv (file->bytevector (src-file "tests/SRFI-1.ss"))]) (let-values ([(p extract) (open-bytevector-output-port (make-transcoder (latin-1-codec)))]) (bytevector->textual-port bv p) @@ -566,7 +566,7 @@ (assert (bytevector=? bv bv2)) (assert (bytevector=? #vu8() (extract)))))) - (let ([bv (file->bytevector "tests/SRFI-1.ss")]) + (let ([bv (file->bytevector (src-file "tests/SRFI-1.ss"))]) (let-values ([(p extract) (open-string-output-port)]) (bytevector->textual-port bv p) (let ([str (extract)]) diff --git a/scheme/tests/normalization.ss b/scheme/tests/normalization.ss index 86a5a5f..031504a 100644 --- a/scheme/tests/normalization.ss +++ b/scheme/tests/normalization.ss @@ -1,7 +1,7 @@ (library (tests normalization) (export run-tests) - (import (ikarus) (unicode-data)) + (import (ikarus) (tests framework) (unicode-data)) (define (reset) (error 'reset "yukk")) (define (enumerate ls) @@ -33,7 +33,7 @@ (let ([data (map (lambda (x) (map conv (list-head x 5))) (filter (lambda (x) (>= (length x) 5)) (get-unicode-data - "unicode/UNIDATA/NormalizationTest.txt")))]) + (src-file "unicode/UNIDATA/NormalizationTest.txt"))))]) (define NFD string-normalize-nfd) (define NFKD string-normalize-nfkd) (define NFC string-normalize-nfc) diff --git a/scheme/tests/parse-flonums.ss b/scheme/tests/parse-flonums.ss index 25baed9..58417aa 100644 --- a/scheme/tests/parse-flonums.ss +++ b/scheme/tests/parse-flonums.ss @@ -1,9 +1,9 @@ (library (tests parse-flonums) (export run-tests) - (import (ikarus)) + (import (ikarus) (tests framework)) - (define file "tests/rn100") + (define file (src-file "tests/rn100")) (define (read-all) (with-input-from-file file