Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularize path to gsi and gsi-script #40

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
24 changes: 16 additions & 8 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
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
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
Expand Down Expand Up @@ -39,18 +40,18 @@ target_setup () {

compile_runtime () {
local target_lib="${1}"
(cd gerbil/runtime && ./build.scm "${target_lib}")
(cd gerbil/runtime && "${GERBIL_GSI}" build.scm "${target_lib}")
}

finalize_build () {
local target_lib="${1}"
local target_bin="${2}"
cp -v gerbil/boot/*.scm \
gerbil/interactive/*.ss \
"${GERBIL_CONFIG}" \
"${target_lib}"
cp -v gerbil/gxi \
gerbil/gxc \
gerbil/gxi-build-script \
"${target_bin}"
(cd "${target_bin}" && ln -s gxi gxi-script)
}
Expand All @@ -76,7 +77,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
Expand Down Expand Up @@ -144,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 () {
Expand All @@ -155,8 +160,6 @@ build_lang () {
(cd lang && ./build.ss)
}

#===============================================================================
## main
build_gerbil() {
feedback_low "Building Gerbil"
stage0 || die
Expand All @@ -166,6 +169,11 @@ build_gerbil() {
build_tools || die
}

## main
#===============================================================================
## load configuration file
source "${GERBIL_CONFIG}" || die

## handling command line
if [ -z "${1+x}" ]; then
build_gerbil
Expand Down
1 change: 1 addition & 0 deletions src/build/build0.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@;gsi-script
(##namespace (""))

(define file-list ".build.stage0")
Expand Down
2 changes: 2 additions & 0 deletions src/conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# User configuration file
export GERBIL_GSI="gsi"
15 changes: 12 additions & 3 deletions src/gerbil/gxi
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
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

if [ -z "${GERBIL_GSI:-}" ]; then
source "${GERBIL_HOME}/lib/conf.sh"
fi

if [ $# -gt 0 ]; then
case $1 in
-:*)
Expand All @@ -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
22 changes: 0 additions & 22 deletions src/gerbil/gxi-build-script

This file was deleted.

3 changes: 2 additions & 1 deletion src/gerbil/runtime/build.scm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env gsi-script
@;gsi-script
; the above line is a directive for the gambit interpreter

(##namespace (""))

Expand Down
1 change: 0 additions & 1 deletion src/std/build-deps-gen.ss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env gxi-build-script
;; -*- Gerbil -*-
;; build-deps depgraph generator
(import "make" "build-config")
Expand Down