From afcec9db96f02a3ef2a8b1173a7cdec941602048 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Wed, 18 Oct 2017 04:12:41 +0000 Subject: [PATCH 1/7] Modularize path to gsi and gsi-script --- src/build.sh | 9 +++++++-- src/conf.sh | 3 +++ src/gerbil/gxi | 13 +++++++++++-- src/gerbil/gxi-build-script | 11 +++++++++-- 4 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/conf.sh diff --git a/src/build.sh b/src/build.sh index 811fcfa8b..3ce21a4c6 100755 --- a/src/build.sh +++ b/src/build.sh @@ -10,6 +10,7 @@ readonly GERBIL_SOURCE="$(pwd -P)" readonly GERBIL_BASE="$(dirname "${GERBIL_SOURCE}")" readonly GERBIL_BUILD="${GERBIL_SOURCE}/build" readonly GERBIL_STAGE0="${GERBIL_BASE}/bootstrap" +readonly GERBIL_CONFIG="${GERBIL_SOURCE}/conf.sh" #=============================================================================== ## feedback @@ -39,7 +40,7 @@ target_setup () { compile_runtime () { local target_lib="${1}" - (cd gerbil/runtime && ./build.scm "${target_lib}") + (cd gerbil/runtime && "${GERBIL_GSI_SCRIPT}" build.scm "${target_lib}") } finalize_build () { @@ -47,6 +48,7 @@ finalize_build () { local target_bin="${2}" cp -v gerbil/boot/*.scm \ gerbil/interactive/*.ss \ + "${GERBIL_CONFIG}" \ "${target_lib}" cp -v gerbil/gxi \ gerbil/gxc \ @@ -76,7 +78,7 @@ stage0 () { find "${target_lib}" -name \*.scm > .build.stage0 feedback_mid "compiling gerbil core" - gsi "${GERBIL_BUILD}/build0.scm" || die + "${GERBIL_GSI}" "${GERBIL_BUILD}/build0.scm" || die ## cleaning up rm -f .build.stage0 @@ -166,6 +168,9 @@ build_gerbil() { build_tools || die } +## load configuration file +source "${GERBIL_CONFIG}" || die + ## handling command line if [ -z "${1+x}" ]; then build_gerbil diff --git a/src/conf.sh b/src/conf.sh new file mode 100644 index 000000000..3a27ebee6 --- /dev/null +++ b/src/conf.sh @@ -0,0 +1,3 @@ +# User configuration file +export GERBIL_GSI="gsi" +export GERBIL_GSI_SCRIPT="gsi-script" diff --git a/src/gerbil/gxi b/src/gerbil/gxi index 503e2a1d3..705b3a853 100755 --- a/src/gerbil/gxi +++ b/src/gerbil/gxi @@ -6,6 +6,10 @@ if [ -z "${GERBIL_HOME:-}" ]; then export GERBIL_HOME fi +if [ -z "${GERBIL_GSI:-}" ]; then + source "${GERBIL_HOME}/lib/conf.sh" +fi + if [ $# -gt 0 ]; then case $1 in -:*) @@ -25,7 +29,12 @@ if [ $# -gt 0 ]; then fi if [[ "x" = "x$@" ]]; then - gsi ${GSIOPTIONS:-} $GERBIL_HOME/lib/gxi-init $GERBIL_HOME/lib/gxi-interactive - + "${GERBIL_GSI}" ${GSIOPTIONS:-} \ + "${GERBIL_HOME}/lib/gxi-init" \ + "${GERBIL_HOME}/lib/gxi-interactive" \ + - else - gsi ${GSIOPTIONS:-} $GERBIL_HOME/lib/gxi-init "$@" + "${GERBIL_GSI}" ${GSIOPTIONS:-} \ + "${GERBIL_HOME}/lib/gxi-init" \ + "$@" fi diff --git a/src/gerbil/gxi-build-script b/src/gerbil/gxi-build-script index 409f87f16..1f1cd57d7 100755 --- a/src/gerbil/gxi-build-script +++ b/src/gerbil/gxi-build-script @@ -16,7 +16,14 @@ if [ $# -gt 0 ]; then fi if [[ "x" = "x$@" ]]; then - gsi ${GSIOPTIONS:-} -e '(include "~~lib/_gambit#.scm")' $GERBIL_HOME/lib/gxi-init $GERBIL_HOME/lib/gxi-interactive - + "${GERBIL_GSI}" ${GSIOPTIONS:-} \ + -e '(include "~~lib/_gambit#.scm")' \ + "${GERBIL_HOME}/lib/gxi-init" \ + "${GERBIL_HOME}/lib/gxi-interactive" \ + - else - gsi ${GSIOPTIONS:-} -e '(include "~~lib/_gambit#.scm")' $GERBIL_HOME/lib/gxi-init "$@" + "${GERBIL_GSI}" ${GSIOPTIONS:-} \ + -e '(include "~~lib/_gambit#.scm")' \ + "${GERBIL_HOME}/lib/gxi-init" \ + "$@" fi From a94080ed66e4fd968d3afe6308243776ba5553a8 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Wed, 18 Oct 2017 04:19:17 +0000 Subject: [PATCH 2/7] Add documentation on specifying gsi path --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 0766b8fa7..370e6860b 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,22 @@ $ LDFLAGS=-L/usr/local/opt/openssl/lib \ ./build.sh ``` +Gerbil expects the Gambit interpreter to be called `gsi`; +if the Gambit interpreter has a nonstandard name or installation path +(e.g., `gsi` is the name for the ghostscript interpreter in Arch Linux) +then: +1. Manually edit the file at `$GAMBIT_HOME/src/conf.sh` +2. Continue build as normal: `cd $GERBIL_HOME/src && ./build.sh` + +For example, if the gambit interpreter is called `gambit-interpreter` +instead of `gsi`, `conf.sh` should look like this: +``` +$ export GERBIL_GSI="gambit-interpreter" +``` +Acceptable values include: +1. a name visible through `$PATH` +2. an absolute path to the executable + # Using Gerbil The Gerbil interpreter is `$GERBIL_HOME/bin/gxi`, and the compiler is `$GERBIL_HOME/bin/gxc`. From 579598ea4b188e2e5ac713ebd86a8027497788b7 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Wed, 18 Oct 2017 04:20:22 +0000 Subject: [PATCH 3/7] Minor build script clean up --- src/build.sh | 6 +++--- src/gerbil/gxi | 2 +- src/gerbil/gxi-build-script | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/build.sh b/src/build.sh index 3ce21a4c6..1c34c83ab 100755 --- a/src/build.sh +++ b/src/build.sh @@ -2,7 +2,7 @@ set -eu #=============================================================================== -# Assuming this script is run with: `cd $GERBIL_BASE/src && ./build.sh` +# This script must be run with: `cd $GERBIL_BASE/src && ./build.sh` #=============================================================================== ## global constants @@ -157,8 +157,6 @@ build_lang () { (cd lang && ./build.ss) } -#=============================================================================== -## main build_gerbil() { feedback_low "Building Gerbil" stage0 || die @@ -168,6 +166,8 @@ build_gerbil() { build_tools || die } +## main +#=============================================================================== ## load configuration file source "${GERBIL_CONFIG}" || die diff --git a/src/gerbil/gxi b/src/gerbil/gxi index 705b3a853..e5b03af34 100755 --- a/src/gerbil/gxi +++ b/src/gerbil/gxi @@ -2,7 +2,7 @@ set -eu if [ -z "${GERBIL_HOME:-}" ]; then - GERBIL_HOME=$(dirname $(cd ${0%/*} && echo $PWD)) + GERBIL_HOME="$(dirname "$(cd ${0%/*} && echo $PWD)")" export GERBIL_HOME fi diff --git a/src/gerbil/gxi-build-script b/src/gerbil/gxi-build-script index 1f1cd57d7..cea8e544e 100755 --- a/src/gerbil/gxi-build-script +++ b/src/gerbil/gxi-build-script @@ -2,7 +2,7 @@ set -eu if [ -z "${GERBIL_HOME:-}" ]; then - GERBIL_HOME=$(dirname $(cd ${0%/*} && echo $PWD)) + GERBIL_HOME="$(dirname "$(cd ${0%/*} && echo $PWD)")" export GERBIL_HOME fi From a8e2a5a4c03b54621adf7f44a26e53f05683c9c2 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Wed, 18 Oct 2017 20:43:17 +0000 Subject: [PATCH 4/7] Hardcode `gxi-build-script` into `build.sh` --- src/build.sh | 9 ++++++--- src/gerbil/gxi-build-script | 29 ----------------------------- src/std/build-deps-gen.ss | 1 - 3 files changed, 6 insertions(+), 33 deletions(-) delete mode 100755 src/gerbil/gxi-build-script diff --git a/src/build.sh b/src/build.sh index 1c34c83ab..6f67226b6 100755 --- a/src/build.sh +++ b/src/build.sh @@ -52,7 +52,6 @@ finalize_build () { "${target_lib}" cp -v gerbil/gxi \ gerbil/gxc \ - gerbil/gxi-build-script \ "${target_bin}" (cd "${target_bin}" && ln -s gxi gxi-script) } @@ -146,8 +145,12 @@ build_tools () { build_stdlib () { feedback_low "Building gerbil stdlib" export PATH="${GERBIL_BASE}/bin:${PATH}" - export GERBIL_HOME="${GERBIL_BASE}" #required by gxi-build-script and build.ss - (cd std && ./build-deps-gen.ss && ./build.ss) + export GERBIL_HOME="${GERBIL_BASE}" #required by build.ss + (cd std \ + && "${GERBIL_GSI}" -e '(include "~~lib/_gambit#.scm")' \ + "${GERBIL_BASE}/lib/gxi-init" \ + build-deps-gen.ss \ + && ./build.ss) } build_lang () { diff --git a/src/gerbil/gxi-build-script b/src/gerbil/gxi-build-script deleted file mode 100755 index cea8e544e..000000000 --- a/src/gerbil/gxi-build-script +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash -set -eu - -if [ -z "${GERBIL_HOME:-}" ]; then - GERBIL_HOME="$(dirname "$(cd ${0%/*} && echo $PWD)")" - export GERBIL_HOME -fi - -if [ $# -gt 0 ]; then - case $1 in - -:*) - GSIOPTIONS=$1 - shift - ;; - esac -fi - -if [[ "x" = "x$@" ]]; then - "${GERBIL_GSI}" ${GSIOPTIONS:-} \ - -e '(include "~~lib/_gambit#.scm")' \ - "${GERBIL_HOME}/lib/gxi-init" \ - "${GERBIL_HOME}/lib/gxi-interactive" \ - - -else - "${GERBIL_GSI}" ${GSIOPTIONS:-} \ - -e '(include "~~lib/_gambit#.scm")' \ - "${GERBIL_HOME}/lib/gxi-init" \ - "$@" -fi diff --git a/src/std/build-deps-gen.ss b/src/std/build-deps-gen.ss index b8e36f6c0..7312b4204 100755 --- a/src/std/build-deps-gen.ss +++ b/src/std/build-deps-gen.ss @@ -1,4 +1,3 @@ -#!/usr/bin/env gxi-build-script ;; -*- Gerbil -*- ;; build-deps depgraph generator (import "make" "build-config") From aab69384bbc51190d1418863235d981494ad8e13 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Thu, 19 Oct 2017 01:42:58 +0000 Subject: [PATCH 5/7] Hardcode `gsi-script` into `build.sh` --- src/build.sh | 2 +- src/conf.sh | 1 - src/gerbil/runtime/build.scm | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/build.sh b/src/build.sh index 6f67226b6..b06b5695f 100755 --- a/src/build.sh +++ b/src/build.sh @@ -40,7 +40,7 @@ target_setup () { compile_runtime () { local target_lib="${1}" - (cd gerbil/runtime && "${GERBIL_GSI_SCRIPT}" build.scm "${target_lib}") + (cd gerbil/runtime && "gsi-script" build.scm "${target_lib}") } finalize_build () { diff --git a/src/conf.sh b/src/conf.sh index 3a27ebee6..7e8b4fbb1 100644 --- a/src/conf.sh +++ b/src/conf.sh @@ -1,3 +1,2 @@ # User configuration file export GERBIL_GSI="gsi" -export GERBIL_GSI_SCRIPT="gsi-script" diff --git a/src/gerbil/runtime/build.scm b/src/gerbil/runtime/build.scm index c5f2dcdc4..a650f258b 100755 --- a/src/gerbil/runtime/build.scm +++ b/src/gerbil/runtime/build.scm @@ -1,4 +1,6 @@ #!/usr/bin/env gsi-script +;the above line is not used as a shabang +;its purpose is as a directive for gsi-script (##namespace ("")) From 823a2f81c11cbccaf6d3b84c1b3302824157de53 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Thu, 19 Oct 2017 17:32:18 +0000 Subject: [PATCH 6/7] Make purpose of `runtime/build.scm` unambiguous --- src/gerbil/runtime/build.scm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gerbil/runtime/build.scm b/src/gerbil/runtime/build.scm index a650f258b..389b65878 100755 --- a/src/gerbil/runtime/build.scm +++ b/src/gerbil/runtime/build.scm @@ -1,6 +1,5 @@ -#!/usr/bin/env gsi-script -;the above line is not used as a shabang -;its purpose is as a directive for gsi-script +@;gsi-script +; the above line is a directive for the gambit interpreter (##namespace ("")) From 057370bfed12fd8c9fb8a5425531ed775c23bab4 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Fri, 20 Oct 2017 23:53:02 +0000 Subject: [PATCH 7/7] Make access to `gsi` more consistent --- src/build.sh | 2 +- src/build/build0.scm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/build.sh b/src/build.sh index b06b5695f..58667ada6 100755 --- a/src/build.sh +++ b/src/build.sh @@ -40,7 +40,7 @@ target_setup () { compile_runtime () { local target_lib="${1}" - (cd gerbil/runtime && "gsi-script" build.scm "${target_lib}") + (cd gerbil/runtime && "${GERBIL_GSI}" build.scm "${target_lib}") } finalize_build () { diff --git a/src/build/build0.scm b/src/build/build0.scm index 64554fca1..f5a39d986 100644 --- a/src/build/build0.scm +++ b/src/build/build0.scm @@ -1,3 +1,4 @@ +@;gsi-script (##namespace ("")) (define file-list ".build.stage0")