From fe60c924dd6aee915bb2ae0ae510f7bc7e636a16 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 15 Aug 2018 19:11:54 +0200 Subject: [PATCH] mescc: Add dir to include path. * module/mescc/mescc.scm (preprocess): Add dir to include path. (c->info): Likewise. * scaffold/tests/08-assign.c: New file. --- build-aux/GNUmakefile.in | 3 +++ build-aux/check-mescc.sh | 2 ++ build-aux/config.sh | 8 +++++--- build-aux/pre-inst-env.in | 2 +- module/mescc/mescc.scm | 16 ++++++++++------ scaffold/tests/07-include.exit | 1 + scaffold/tests/08-assign.c | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 scaffold/tests/07-include.exit create mode 100644 scaffold/tests/08-assign.c diff --git a/build-aux/GNUmakefile.in b/build-aux/GNUmakefile.in index bd313f7b..ddc198af 100644 --- a/build-aux/GNUmakefile.in +++ b/build-aux/GNUmakefile.in @@ -135,6 +135,9 @@ clean-go: check: ./check.sh +check-mescc: + ./pre-inst-env build-aux/check-mescc.sh + # Mes does not feature post-install checks yet, so we're great! installcheck: true diff --git a/build-aux/check-mescc.sh b/build-aux/check-mescc.sh index 58bcf78b..3b94b8b5 100755 --- a/build-aux/check-mescc.sh +++ b/build-aux/check-mescc.sh @@ -49,6 +49,8 @@ t 04-call-0 05-call-1 06-call-!1 +07-include +08-assign 10-if-0 11-if-1 12-if-== diff --git a/build-aux/config.sh b/build-aux/config.sh index 1049409e..a4b9fdef 100644 --- a/build-aux/config.sh +++ b/build-aux/config.sh @@ -26,15 +26,16 @@ fi export CC export CC CFLAGS export CC32 +export CC32_CPPFLAGS export CC64 +export CC64_CPPFLAGS export CC_CFLAGS -export CC_CFLAGS -export CC_CPPFLAGS export CC_CPPFLAGS export CFLAGS export CPPFLAGS -export CPPFLAGS export GUILE +export GUILE_LOAD_COMPILED_PATH +export GUILE_LOAD_PATH export HEX2 export HEX2FLAGS export LIBC @@ -42,6 +43,7 @@ export M1 export M1FLAGS export MES export MES_CFLAGS +export MES_CPPFLAGS export MES_LIBS export TCC diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in index ed41822d..f02da0ac 100644 --- a/build-aux/pre-inst-env.in +++ b/build-aux/pre-inst-env.in @@ -26,7 +26,7 @@ prefix=${prefix-@prefix@} MES_PREFIX=${MES_PREFIX-${srcdest}mes} export MES_PREFIX -GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/module${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" +GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/scripts:$abs_top_builddir/module${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" GUILE_LOAD_PATH="module:mes:$abs_top_srcdir/guix${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" if [ -n "$srcdest" ]; then GUILE_LOAD_PATH="${srcdest}module:${srcdest}mes:$GUILE_LOAD_PATH" diff --git a/module/mescc/mescc.scm b/module/mescc/mescc.scm index 4f575733..f74df8da 100644 --- a/module/mescc/mescc.scm +++ b/module/mescc/mescc.scm @@ -38,15 +38,17 @@ (GUILE-with-output-to-file file-name thunk))) (define (mescc:preprocess options) - (let* ((defines (reverse (filter-map (multi-opt 'define) options))) - (includes (reverse (filter-map (multi-opt 'include) options))) - (pretty-print/write (string->symbol (option-ref options 'write (if guile? "pretty-print" "write")))) + (let* ((pretty-print/write (string->symbol (option-ref options 'write (if guile? "pretty-print" "write")))) (pretty-print/write (if (eq? pretty-print/write 'pretty-print) pretty-print write)) (files (option-ref options '() '("a.c"))) (input-file-name (car files)) (ast-file-name (cond ((and (option-ref options 'preprocess #f) (option-ref options 'output #f))) (else (replace-suffix input-file-name ".E")))) + (dir (dirname input-file-name)) + (defines (reverse (filter-map (multi-opt 'define) options))) + (includes (reverse (filter-map (multi-opt 'include) options))) + (includes (cons dir includes)) (prefix (option-ref options 'prefix ""))) (with-output-to-file ast-file-name (lambda _ (for-each (cut c->ast prefix defines includes write <>) files))))) @@ -74,9 +76,11 @@ ((.E? file-name) (E->info options file-name)))) (define (c->info options file-name) - (let ((defines (reverse (filter-map (multi-opt 'define) options))) - (includes (reverse (filter-map (multi-opt 'include) options))) - (prefix (option-ref options 'prefix ""))) + (let* ((defines (reverse (filter-map (multi-opt 'define) options))) + (includes (reverse (filter-map (multi-opt 'include) options))) + (dir (dirname file-name)) + (includes (cons dir includes)) + (prefix (option-ref options 'prefix ""))) (with-input-from-file file-name (cut c99-input->info #:prefix prefix #:defines defines #:includes includes)))) diff --git a/scaffold/tests/07-include.exit b/scaffold/tests/07-include.exit new file mode 100644 index 00000000..d81cc071 --- /dev/null +++ b/scaffold/tests/07-include.exit @@ -0,0 +1 @@ +42 diff --git a/scaffold/tests/08-assign.c b/scaffold/tests/08-assign.c new file mode 100644 index 00000000..f25c4386 --- /dev/null +++ b/scaffold/tests/08-assign.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes 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 GNU Mes. If not, see . + */ + +int +main () +{ + int a; + int b; + int c; + a = 2; + b = -2; + c = a + b; + asm ("nop"); + return c; +}