Skip to content

Commit

Permalink
Merge branch 'feature/graal-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
dundalek committed Mar 15, 2020
2 parents e2ee1da + 1690c1b commit 90e40cf
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 355 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/deploy.yml
@@ -1,5 +1,7 @@
name: deploy

env:
GRAAL_VERSION: "20.0.0.java11"
# on:
# push:
# tags:
Expand Down Expand Up @@ -159,7 +161,7 @@ jobs:
- uses: actions/cache@v1
with:
path: /Users/runner/hostedtoolcache/GraalVM
key: ${{ runner.os }}-graal-19.2.1
key: ${{ runner.os }}-graal-${{ env.GRAAL_VERSION }}
restore-keys: |
${{ runner.os }}-graal-
Expand All @@ -184,9 +186,9 @@ jobs:
path: .

- name: Prepare GraalVM
uses: DeLaGuardo/setup-graalvm@1.0
uses: DeLaGuardo/setup-graalvm@3
with:
graalvm-version: "19.2.1"
graalvm-version: ${{ env.GRAAL_VERSION }}

- name: Install native-image
run: gu install native-image
Expand Down Expand Up @@ -234,7 +236,7 @@ jobs:
- uses: actions/cache@v1
with:
path: /opt/hostedtoolcache/GraalVM
key: ${{ runner.os }}-graal-19.2.1
key: ${{ runner.os }}-graal-${{ env.GRAAL_VERSION }}
restore-keys: |
${{ runner.os }}-graal-
Expand All @@ -259,9 +261,9 @@ jobs:
path: .

- name: Prepare GraalVM
uses: DeLaGuardo/setup-graalvm@1.0
uses: DeLaGuardo/setup-graalvm@3
with:
graalvm-version: "19.2.1"
graalvm-version: ${{ env.GRAAL_VERSION }}

- name: Install native-image
run: gu install native-image
Expand Down
2 changes: 1 addition & 1 deletion boot.properties
@@ -1,7 +1,7 @@
#http://boot-clj.com
#Wed Aug 22 17:16:41 CEST 2018
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.10.1
BOOT_CLOJURE_VERSION=1.10.2-alpha1
BOOT_VERSION=2.8.1

# https://github.com/boot-clj/boot/wiki/JVM-Options#dont-swallow-stacktraces
Expand Down
2 changes: 1 addition & 1 deletion build.boot
Expand Up @@ -3,7 +3,7 @@
(set-env!
:resource-paths #{"resources"}
:dependencies
'[[org.clojure/clojure "1.10.1"]
'[[org.clojure/clojure "1.10.2-alpha1"]
[seancorfield/boot-tools-deps "0.4.6" #_:scope #_"provided"]])

(require '[boot-tools-deps.core :refer [deps]])
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
@@ -1,5 +1,5 @@
{:deps
{org.clojure/clojure {:mvn/version "1.10.1"}
{org.clojure/clojure {:mvn/version "1.10.2-alpha1"}
org.clojure/tools.reader {:mvn/version "1.3.2"}
org.clojure/data.json {:mvn/version "0.2.6"}
com.cemerick/pomegranate {:mvn/version "1.1.0"}
Expand Down
7 changes: 4 additions & 3 deletions project.clj
Expand Up @@ -3,14 +3,15 @@
#=(slurp "resources/CLOSH_VERSION"))
:description "Closh with SCI"
:source-paths ["src/jvm" "src/closh-sci" "src/common" "resources"]
:dependencies [[org.clojure/clojure "1.10.1"]
:dependencies [[org.clojure/clojure "1.10.2-alpha1"]
[borkdude/sci "0.0.11"]
[borkdude/edamame "0.0.9"]
[borkdude/edamame "0.0.10"]
[org.clojure/tools.reader "1.3.2"]
[squarepeg "0.6.1"]
[org.clojure/java.jdbc "0.7.9"]
[com.bhauman/rebel-readline "0.1.4"]
[org.jline/jline-reader "3.5.1"]]
[org.jline/jline-reader "3.5.1"]
[fipp "0.6.22"]]
:global-vars {*warn-on-reflection* true}
:main closh.zero.frontend.sci
:profiles {:uberjar {:global-vars {*assert* false}
Expand Down
15 changes: 0 additions & 15 deletions scripts/compile
Expand Up @@ -15,21 +15,6 @@ if [ -z "$NATIVE_IMAGE" ]; then
NATIVE_IMAGE="$GRAALVM_HOME/bin/native-image"
fi

#CLOSH_VERSION=$(jq ".version" package.json)

# We also need to AOT sci, else something didn't work in the Mac build on CircleCI
# See https://github.com/oracle/graal/issues/1613
( cd /tmp; git clone https://github.com/borkdude/sci 2> /dev/null || true )
mkdir -p src/sci
cp -R /tmp/sci/src/* src


# npm run uberjar-sci

# "-H:IncludeResources=CLOSH_VERSION" \
# "-H:IncludeResources=SCI_VERSION" \
# --initialize-at-build-time=clojure,clojure.spec.gen.alpha,clojure.test.check,clojure.test.check.generators,clojure.test.check.properties \

export __CLOSH_USE_SCI_EVAL__=true

use_lein=false # set to true to build uberjar with project.clj instead of boot
Expand Down
3 changes: 1 addition & 2 deletions src/closh-sci/closh/zero/platform/clojure_compiler.clj
@@ -1,9 +1,8 @@
(ns closh.zero.platform.clojure-compiler
(:refer-clojure :exclude [load load-file eval])
(:refer-clojure :exclude [load load-file])
(:require [closh.zero.reader :as reader]
[closh.zero.parser]
[closh.zero.compiler]
#_[closh.zero.platform.eval :as eval]
[clojure.tools.reader.reader-types :as r])
(:import (clojure.lang Compiler RT LineNumberingPushbackReader LispReader$ReaderException Compiler$CompilerException)
(java.io File FileInputStream InputStreamReader StringReader PipedWriter PipedReader PushbackReader BufferedReader)))
Expand Down
54 changes: 54 additions & 0 deletions src/closh-sci/closh/zero/platform/clojure_platform.clj
@@ -0,0 +1,54 @@
(ns closh.zero.platform.clojure-platform
(:refer-clojure :exclude [eval read load-reader read+string])
(:require [closh.zero.reader :as reader]
[closh.zero.parser]
[closh.zero.compiler]
[closh.zero.platform.eval :as eval]
[closh.zero.platform.clojure-compiler :as compiler])
(:import (clojure.lang LineNumberingPushbackReader)))

(def read reader/read)

(defn eval [form]
(eval/eval
(closh.zero.compiler/compile-interactive
(closh.zero.parser/parse form))))

;; Copied from clojure/core
(defn read+string
"Like read, and taking the same args. stream must be a LineNumberingPushbackReader.
Returns a vector containing the object read and the (whitespace-trimmed) string read."
{:added "1.10"}
([] (read+string *in*))
([stream] (read+string stream true nil))
([stream eof-error? eof-value] (read+string stream eof-error? eof-value false))
([^clojure.lang.LineNumberingPushbackReader stream eof-error? eof-value recursive?]
(try
(.captureString stream)
(let [o (read stream eof-error? eof-value recursive?)
s (.trim (.getString stream))]
[o s])
(catch Throwable ex
(.getString stream)
(throw ex))))
([opts ^clojure.lang.LineNumberingPushbackReader stream]
(try
(.captureString stream)
(let [o (read opts stream)
s (.trim (.getString stream))]
[o s])
(catch Throwable ex
(.getString stream)
(throw ex)))))

(defn load-reader [rdr]
(compiler/load rdr eval))

(defn compiler-load-file [path]
(compiler/load-file path eval))

;; TODO: Does it make sense to reimplement this?
(defn rt-load-resource-script [path]
(binding [*out* *err*]
(println "rt-load-resource-script not implemented:" path))
(System/exit 1))

2 comments on commit 90e40cf

@jeroenvandijk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dundalek Wow, I missed this merge. Means the Sci integration works? Shouldn't this be celebrated?

@dundalek
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jeroenvandijk, I thought I was done but then I noticed there are still things that do not work :/
The main ones are:

  1. Command line arguments do not work, need to find a way how to bind a dynamic var inside Sci context.
  2. Many clojure.core functions are not available, probably need to look how Babashka pulls them in.
  3. The source line/column info is incorrectly mapped when error inside script occurs.

Please sign in to comment.