instaparse [skip ci]

This commit is contained in:
Michiel Borkent 2022-12-26 12:06:53 +01:00
commit 988135dac0
192 changed files with 9517 additions and 2410 deletions

View file

@ -2,5 +2,5 @@
:deps {borkdude/gh-release-artifact
#_{:local/root "../gh-release-artifact"}
{:git/url "https://github.com/borkdude/gh-release-artifact"
:sha "f34f3e382e6a0ef7f52748b2f27eb681f799a822"}}
:git/sha "ce060c12a25b552b864dc90f8fb344a2eb91ea9d"}}
:tasks {release-artifact babashka.release-artifact/release}}

View file

@ -3,484 +3,38 @@
# Check https://circleci.com/docs/2.0/language-clojure/ for more details
#
version: 2.1
commands:
setup-docker-buildx:
steps:
- run:
name: Create multi-platform capabale buildx builder
command: |
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx create --name ci-builder --use
jobs:
jvm:
docker:
- image: circleci/clojure:openjdk-11-lein-2.9.6-bullseye
working_directory: ~/repo
environment:
LEIN_ROOT: "true"
BABASHKA_PLATFORM: linux # could be used in jar name
resource_class: large
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- restore_cache:
keys:
- v1-dependencies-{{ checksum "project.clj" }}-{{ checksum "deps.edn" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install Clojure
command: |
sudo script/install-clojure
- run:
name: Run JVM tests
command: |
export BABASHKA_FEATURE_JDBC=true
export BABASHKA_FEATURE_POSTGRESQL=true
script/test
script/run_lib_tests
- run:
name: Run as lein command
command: |
.circleci/script/lein
- run:
name: Create uberjar
command: |
mkdir -p /tmp/release
script/uberjar
VERSION=$(cat resources/BABASHKA_VERSION)
jar=target/babashka-$VERSION-standalone.jar
cp $jar /tmp/release
java -jar $jar script/reflection.clj
reflection="babashka-$VERSION-reflection.json"
java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$jar"
java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$reflection"
- store_artifacts:
path: /tmp/release
destination: release
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "project.clj" }}-{{ checksum "deps.edn" }}
linux:
docker:
- image: circleci/clojure:openjdk-11-lein-2.9.6-bullseye
working_directory: ~/repo
environment:
LEIN_ROOT: "true"
GRAALVM_VERSION: "22.0.0.2"
GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
BABASHKA_PLATFORM: linux # used in release script
BABASHKA_TEST_ENV: native
BABASHKA_XMX: "-J-Xmx6500m"
resource_class: large
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- restore_cache:
keys:
- linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- run:
name: Install Clojure
command: |
sudo script/install-clojure
- run:
name: Install native dev tools
command: |
sudo apt-get update
sudo apt-get -y install build-essential zlib1g-dev
- run:
name: Download GraalVM
command: |
script/install-graalvm
- run:
name: Build binary
command: |
script/uberjar
script/compile
no_output_timeout: 30m
- run:
name: Run tests
command: |
script/test
script/run_lib_tests
- run:
name: Release
command: |
.circleci/script/release
- persist_to_workspace:
root: /tmp
paths:
- release
- save_cache:
paths:
- ~/.m2
- ~/graalvm-ce-java11-22.0.0.2
key: linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- store_artifacts:
path: /tmp/release
destination: release
- run:
name: Publish artifact link to Slack
command: |
./bb .circleci/script/publish_artifact.clj || true
linux-static:
docker:
- image: circleci/clojure:openjdk-11-lein-2.9.6-bullseye
working_directory: ~/repo
environment:
LEIN_ROOT: "true"
GRAALVM_VERSION: "22.0.0.2"
GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
BABASHKA_PLATFORM: linux # used in release script
BABASHKA_TEST_ENV: native
BABASHKA_STATIC: "true"
BABASHKA_MUSL: "true"
BABASHKA_XMX: "-J-Xmx6500m"
resource_class: large
steps:
- checkout
- attach_workspace:
at: /tmp
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
# - run:
# name: "Short circuit on SNAPSHOT"
# command: |
# VERSION=$(cat resources/BABASHKA_VERSION)
# if [[ "$VERSION" == *-SNAPSHOT ]]
# then
# circleci task halt
# fi
- restore_cache:
keys:
- linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- run:
name: Install Clojure
command: |
sudo script/install-clojure
- run:
name: Install native dev tools
command: |
sudo apt-get update
sudo apt-get -y install build-essential zlib1g-dev
sudo -E script/setup-musl
- run:
name: Download GraalVM
command: |
script/install-graalvm
- run:
name: Build binary
command: |
script/uberjar
script/compile
no_output_timeout: 30m
- run:
name: Run tests
command: |
script/test
script/run_lib_tests
- run:
name: Release
command: |
.circleci/script/release
- persist_to_workspace:
root: /tmp
paths:
- release
- save_cache:
paths:
- ~/.m2
- ~/graalvm-ce-java11-22.0.0.2
key: linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- store_artifacts:
path: /tmp/release
destination: release
- run:
name: Publish artifact link to Slack
command: |
./bb .circleci/script/publish_artifact.clj || true
linux-aarch64:
machine:
enabled: true
image: ubuntu-2004:202101-01
resource_class: arm.large
working_directory: ~/repo
environment:
LEIN_ROOT: "true"
GRAALVM_VERSION: "22.0.0.2"
GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
BABASHKA_PLATFORM: linux # used in release script
BABASHKA_ARCH: aarch64
BABASHKA_TEST_ENV: native
BABASHKA_XMX: "-J-Xmx6500m"
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- run:
name: Install Clojure
command: |
sudo script/install-clojure
- restore_cache:
keys:
- linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- run:
name: Install native dev tools
command: |
sudo apt-get update
sudo apt-get -y install build-essential zlib1g-dev
- run:
name: Download GraalVM
command: |
script/install-graalvm
- run:
name: Build binary
command: |
script/uberjar
script/compile
no_output_timeout: 30m
- run:
name: Run tests
command: |
script/test
script/run_lib_tests
- run:
name: Release
command: |
.circleci/script/release
- persist_to_workspace:
root: /tmp
paths:
- release
- save_cache:
paths:
- ~/.m2
- ~/graalvm-ce-java11-22.0.0.2
key: linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- store_artifacts:
path: /tmp/release
destination: release
- run:
name: Publish artifact link to Slack
command: |
./bb .circleci/script/publish_artifact.clj || true
linux-aarch64-static:
machine:
enabled: true
image: ubuntu-2004:202101-01
resource_class: arm.large
working_directory: ~/repo
environment:
LEIN_ROOT: "true"
GRAALVM_VERSION: "22.0.0.2"
GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
BABASHKA_PLATFORM: linux # used in release script
BABASHKA_ARCH: aarch64
BABASHKA_TEST_ENV: native
BABASHKA_XMX: "-J-Xmx6500m"
BABASHKA_STATIC: "true"
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
# - run:
# name: "Short circuit on SNAPSHOT"
# command: |
# VERSION=$(cat resources/BABASHKA_VERSION)
# if [[ "$VERSION" == *-SNAPSHOT ]]
# then
# circleci task halt
# fi
- run:
name: Install Clojure
command: |
sudo script/install-clojure
- restore_cache:
keys:
- linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- run:
name: Install native dev tools
command: |
sudo apt-get update
sudo apt-get -y install build-essential zlib1g-dev
# sudo -E script/setup-musl
- run:
name: Download GraalVM
command: |
script/install-graalvm
- run:
name: Build binary
command: |
script/uberjar
script/compile
no_output_timeout: 30m
- run:
name: Run tests
command: |
script/test
script/run_lib_tests
- run:
name: Release
command: |
.circleci/script/release
- persist_to_workspace:
root: /tmp
paths:
- release
- save_cache:
paths:
- ~/.m2
- ~/graalvm-ce-java11-22.0.0.2
key: linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- store_artifacts:
path: /tmp/release
destination: release
- run:
name: Publish artifact link to Slack
command: |
./bb .circleci/script/publish_artifact.clj || true
mac:
macos:
xcode: "12.0.0"
environment:
MACOSX_DEPLOYMENT_TARGET: 10.13 # 10.12 is EOL
GRAALVM_VERSION: "22.0.0.2"
GRAALVM_HOME: /Users/distiller/graalvm-ce-java11-22.0.0.2/Contents/Home
BABASHKA_PLATFORM: macos # used in release script
BABASHKA_TEST_ENV: native
BABASHKA_XMX: "-J-Xmx6500m"
resource_class: large
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- restore_cache:
keys:
- mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- run:
name: Install Clojure
command: |
script/install-clojure
- run:
name: Install Leiningen
command: |
script/install-leiningen
- run:
name: Download GraalVM
command: |
script/install-graalvm
- run:
name: Build binary
command: |
export PATH=$GRAALVM_HOME/bin:$PATH
script/uberjar
script/compile
no_output_timeout: 30m
- run:
name: Run tests
command: |
export PATH=$GRAALVM_HOME/bin:$PATH
script/test
script/run_lib_tests
- run:
name: Release
command: |
.circleci/script/release
- save_cache:
paths:
- ~/.m2
- ~/graalvm-ce-java11-22.0.0.2/Contents/Home
key: mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- store_artifacts:
path: /tmp/release
destination: release
- run:
name: Publish artifact link to Slack
command: |
./bb .circleci/script/publish_artifact.clj || true
deploy:
resource_class: large
docker:
- image: circleci/clojure:lein-2.9.6
working_directory: ~/repo
environment:
LEIN_ROOT: "true"
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- restore_cache:
keys:
- v1-dependencies-{{ checksum "project.clj" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: .circleci/script/deploy
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "project.clj" }}
docker:
machine:
image: ubuntu-2004:202111-01
steps:
- checkout
- setup-docker-buildx
- attach_workspace:
at: /tmp
- run:
name: Build Docker image
environment:
PLATFORM: linux/amd64,linux/arm64
command: .circleci/script/docker
workflows:
version: 2
ci:
# this allows you to use CircleCI's dynamic configuration feature
setup: true
# the continuation orb is required in order to use dynamic configuration
orbs:
continuation: circleci/continuation@0.1.2
# our defined job, and its steps
jobs:
- jvm
- linux
- linux-static
- mac
- linux-aarch64
- linux-aarch64-static
- deploy:
filters:
branches:
only: master
requires:
- jvm
- linux
- mac
- docker:
filters:
branches:
only:
- master
requires:
- linux
- linux-static
- linux-aarch64
setup:
docker:
- image: cimg/clojure:1.11.1
steps:
- checkout
- run:
name: Bootstrap Babashka
command: |
curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
sudo bash install --dir /tmp
- run:
name: Rename bb binary
command: mv /tmp/bb /tmp/bbb
- run:
name: Generate config
command: |
/tmp/bbb .circleci/script/short_ci.clj > generated_config.yml
- continuation/continue:
configuration_path: generated_config.yml
# our single workflow, that triggers the setup job defined above
workflows:
setup:
jobs:
- setup

View file

@ -1,61 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
image_name="babashka/babashka"
image_tag=$(cat resources/BABASHKA_VERSION)
platform=${PLATFORM:-"linux/amd64"}
latest_tag="latest"
label_args=("--label" "'org.opencontainers.image.description=Native, fast starting Clojure interpreter for scripting'"
"--label" "org.opencontainers.image.title=Babashka"
"--label" "org.opencontainers.image.created=$(date -Iseconds)"
"--label" "org.opencontainers.image.url=${CIRCLE_REPOSITORY_URL}"
"--label" "org.opencontainers.image.documentation=${CIRCLE_REPOSITORY_URL}"
"--label" "org.opencontainers.image.source=${CIRCLE_REPOSITORY_URL}"
"--label" "org.opencontainers.image.revision=${CIRCLE_SHA1}"
"--label" "org.opencontainers.image.ref.name=${CIRCLE_TAG}:${CIRCLE_BRANCH}"
"--label" "org.opencontainers.image.version=${image_tag}")
if [[ $image_tag =~ SNAPSHOT$ ]]; then
echo "This is a snapshot version"
snapshot="true"
else
echo "This is a non-snapshot version"
snapshot="false"
fi
if [ -z "$CIRCLE_PULL_REQUEST" ] && [ "$CIRCLE_BRANCH" = "master" ]; then
echo "Building & pushing $platform Docker image(s) $image_name:$image_tag"
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
IFS=',' read -r -a platforms <<< "$platform"
for p in "${platforms[@]}"; do
tarball_platform=${p//\//-}
if [[ $tarball_platform == "linux-arm64" ]]; then tarball_platform="linux-aarch64"; fi
mkdir -p $p
tar zxvf "/tmp/release/babashka-${image_tag}-${tarball_platform}.tar.gz" -C $p
# this overwrites, but this is to work around having built the uberjar/metabom multiple times
cp "/tmp/release/${tarball_platform}-metabom.jar" ./metabom.jar
done
docker buildx build -t "$image_name:$image_tag" --platform "$platform" "${label_args[@]}" --push -f Dockerfile.ci .
if [[ $snapshot == "false" ]]; then
echo "Building & pushing $platform Docker image(s) $image_name:$latest_tag"
docker buildx build -t "$image_name:$latest_tag" --platform "$platform" "${label_args[@]}" --push -f Dockerfile.ci .
fi
for p in "${platforms[@]}"; do
rm -rf $p
done
# build alpine image for linux-amd64 only (no upstream arm64 support yet)
tar zxvf "/tmp/release/babashka-${image_tag}-linux-amd64-static.tar.gz"
echo "Building & pushing Docker image $image_name:$image_tag-alpine"
docker buildx build -t "$image_name:$image_tag-alpine" --platform=linux/amd64 "${label_args[@]}" --push -f Dockerfile.alpine .
if [[ $snapshot == "false" ]]; then
echo "Building & pushing Docker image $image_name:alpine"
docker buildx build -t "$image_name:alpine" --platform=linux/amd64 "${label_args[@]}" --push -f Dockerfile.alpine .
fi
else
echo "Not publishing Docker image"
fi
exit 0;

View file

@ -0,0 +1,98 @@
(require '[clojure.string :as str]
'[babashka.process :as proc]
'[babashka.fs :as fs])
(import '[java.time Instant])
(defn read-env
([k]
(read-env k nil))
([k default]
(or (System/getenv k)
default)))
(def image-name "babashka/babashka")
(def image-tag (slurp "resources/BABASHKA_VERSION"))
(def latest-tag "latest")
(def platforms (read-env "PLATFORMS" "linux/amd64"))
(def circle-repository-url (read-env "CIRCLE_REPOSITORY_URL"))
(def label-args
["--label" "'org.opencontainers.image.description=Native, fast starting Clojure interpreter for scripting'"
"--label" "org.opencontainers.image.title=Babashka"
"--label" (str "org.opencontainers.image.created=" (Instant/now))
"--label" (str "org.opencontainers.image.url=" circle-repository-url)
"--label" (str "org.opencontainers.image.documentation=" circle-repository-url)
"--label" (str "org.opencontainers.image.source=" circle-repository-url)
"--label" (str "org.opencontainers.image.revision=" (read-env "CIRCLE_SHA1"))
"--label"
(format "org.opencontainers.image.ref.name=%s:%s"
(read-env "CIRCLE_TAG")
(read-env "CIRCLE_BRANCH"))
"--label" (str "org.opencontainers.image.version=" image-tag)])
(def snapshot? (str/includes? image-tag "SNAPSHOT"))
(defn exec
[cmd]
(-> cmd
(proc/process {:out :inherit :err :inherit})
(proc/check)))
(defn docker-login
[username password]
(exec ["docker" "login" "-u" username "-p" password]))
(defn build-push
[image-tag platform docker-file]
(println (format "Building and pushing %s Docker image(s) %s:%s"
platform
image-name
image-tag))
(let [base-cmd ["docker" "buildx" "build"
"-t" (str image-name ":" image-tag)
"--platform" platform
"--push"
"-f" docker-file]]
(exec (concat base-cmd label-args ["."]))))
(defn build-push-images
[]
(doseq [platform (str/split platforms #",")]
(let [tarball-platform (str/replace platform #"\/" "-")
tarball-platform (if (= "linux-arm64" tarball-platform)
"linux-aarch64"
tarball-platform)
tarball-path (format "/tmp/release/babashka-%s-%s.tar.gz"
image-tag
tarball-platform)]
(fs/create-dirs platform)
(exec ["tar" "zxvf" tarball-path "-C" platform])
; this overwrites, but this is to work around having built the uberjar/metabom multiple times
(fs/copy (format "/tmp/release/%s-metabom.jar" tarball-platform) "metabom.jar" {:replace-existing true})))
(build-push image-tag platforms "Dockerfile.ci")
(when-not snapshot?
(build-push latest-tag platforms "Dockerfile.ci")))
(defn build-push-alpine-images
"Build alpine image for linux-amd64 only (no upstream arm64 support yet)"
[]
(exec ["tar" "zxvf" (str "/tmp/release/babashka-" image-tag "-linux-amd64-static.tar.gz")])
(build-push (str image-tag "-alpine") "linux/amd64" "Dockerfile.alpine")
(when-not snapshot?
(build-push "alpine" "linux/amd64" "Dockerfile.alpine")))
(when (= *file* (System/getProperty "babashka.file"))
(if (and (nil? (read-env "CIRCLE_PULL_REQUEST"))
(= "master" (read-env "CIRCLE_BRANCH")))
(do
(if snapshot?
(println "This is a snapshot version")
(println "This is a non-snapshot version"))
(docker-login (read-env "DOCKERHUB_USER") (read-env "DOCKERHUB_PASS"))
(build-push-images)
(build-push-alpine-images))
(println "Not publishing docker image(s).")))

View file

@ -0,0 +1,276 @@
(ns short-ci
(:require
[babashka.tasks :as tasks]
[clj-yaml.core :as yaml]
[clojure.string :as str]
[flatland.ordered.map :refer [ordered-map]]))
(defn run
([cmd-name cmd]
(run cmd-name cmd nil))
([cmd-name cmd no-output-timeout]
(let [base {:run {:name cmd-name
:command cmd}}]
(if no-output-timeout
(assoc-in base [:run :no_output_timeout] no-output-timeout)
base))))
(defn gen-steps
[shorted? steps]
(if shorted?
[(run "Shorted" "echo 'Skipping Run'")]
steps))
(defn gen-job
[shorted? conf]
(if shorted?
(-> conf
(dissoc :machine :macos)
(assoc :resource_class "small" :docker [{:image "ubuntu:latest"}]))
conf))
(defn pull-submodules
[]
(run "Pull Submodules" "git submodule init\ngit submodule update"))
(defn deploy
[shorted?]
(gen-job shorted?
(ordered-map
:resource_class "large"
:docker [{:image "circleci/clojure:lein-2.9.8"}]
:working_directory "~/repo"
:environment {:LEIN_ROOT "true"}
:steps (gen-steps
shorted?
[:checkout
(pull-submodules)
{:restore_cache {:keys ["v1-dependencies-{{ checksum \"project.clj\" }}"
"v1-dependencies-"]}}
{:run ".circleci/script/deploy"}
{:save_cache {:paths ["~/.m2"]
:key "v1-dependencies-{{ checksum \"project.clj\" }}"}}]))))
(defn docker
[shorted?]
(gen-job
shorted?
(ordered-map
:machine {:image "ubuntu-2004:202111-01"}
:steps
(gen-steps
shorted?
[:checkout
(pull-submodules)
"setup-docker-buildx"
{:attach_workspace {:at "/tmp"}}
(run "Build uberjar" "script/uberjar")
{:run
{:name "Build Docker image"
:environment {:PLATFORMS "linux/amd64,linux/arm64"}
:command
"java -jar ./target/babashka-$(cat resources/BABASHKA_VERSION)-standalone.jar .circleci/script/docker.clj"}}]))))
(defn jvm
[shorted? graalvm-home]
(gen-job
shorted?
(ordered-map
:docker [{:image "circleci/clojure:openjdk-11-lein-2.9.8-bullseye"}]
:working_directory "~/repo"
:environment {:LEIN_ROOT "true"
:BABASHKA_PLATFORM "linux"
:GRAALVM_VERSION "22.3.0"
:GRAALVM_HOME graalvm-home}
:resource_class "large"
:steps
(gen-steps
shorted?
[:checkout
(pull-submodules)
{:restore_cache {:keys ["v1-dependencies-{{ checksum \"project.clj\" }}-{{ checksum \"deps.edn\" }}"
"v1-dependencies-"]}}
(run "Install Clojure" "sudo script/install-clojure")
(run "Download GraalVM" "script/install-graalvm")
(run
"Run JVM tests"
"export BABASHKA_FEATURE_JDBC=true
export BABASHKA_FEATURE_POSTGRESQL=true
script/test\nscript/run_lib_tests")
(run "Run as lein command" ".circleci/script/lein")
(run
"Create uberjar"
"mkdir -p /tmp/release
script/uberjar
VERSION=$(cat resources/BABASHKA_VERSION)
jar=target/babashka-$VERSION-standalone.jar
cp $jar /tmp/release
export PATH=$GRAALVM_HOME/bin:$PATH
export JAVA_HOME=$GRAALVM_HOME
java -jar $jar script/reflection.clj
reflection=\"babashka-$VERSION-reflection.json\"
java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$jar\"
java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$reflection\"")
{:store_artifacts {:path "/tmp/release"
:destination "release"}}
{:save_cache {:paths ["~/.m2"]
:key "v1-dependencies-{{ checksum \"project.clj\" }}-{{ checksum \"deps.edn\" }}"}}]))))
(defn unix
[shorted? static? musl? arch executor-conf resource-class graalvm-home platform]
(let [env {:LEIN_ROOT "true"
:GRAALVM_VERSION "22.3.0"
:GRAALVM_HOME graalvm-home
:BABASHKA_PLATFORM (if (= "mac" platform)
"macos"
platform)
:BABASHKA_TEST_ENV "native"
:BABASHKA_XMX "-J-Xmx6500m"}
env (if (= "aarch64" arch)
(assoc env :BABASHKA_ARCH arch)
env)
env (if static?
(assoc env :BABASHKA_STATIC "true")
env)
env (if musl?
(assoc env :BABASHKA_MUSL "true")
env)
env (if (= "mac" platform)
(assoc env :MACOSX_DEPLOYMENT_TARGET 10.13)
env)
base-install-cmd "sudo apt-get update\nsudo apt-get -y install build-essential zlib1g-dev"
cache-key (format "%s-%s{{ checksum \"project.clj\" }}-{{ checksum \".circleci/config.yml\" }}"
platform
(if (= "aarch64" arch)
"aarch64-"
""))]
(gen-job shorted?
(merge
executor-conf
(ordered-map
:working_directory "~/repo"
:environment env
:resource_class resource-class
:steps (gen-steps shorted?
(filter some?
[:checkout
{:attach_workspace {:at "/tmp"}}
(run "Pull Submodules" "git submodule init\ngit submodule update")
{:restore_cache
{:keys [cache-key]}}
(run "Install Clojure" "sudo script/install-clojure")
(when (= "mac" platform)
(run "Install Leiningen" "script/install-leiningen"))
(when (not= "mac" platform)
(run "Install native dev tools"
(if (and static? musl? (not= "aarch64" arch))
(str base-install-cmd "\nsudo -E script/setup-musl")
base-install-cmd)))
(run "Download GraalVM" "script/install-graalvm")
(run "Build binary" "script/uberjar\nscript/compile" "30m")
(run "Run tests" "script/test\nscript/run_lib_tests")
(run "Release" ".circleci/script/release")
{:persist_to_workspace {:root "/tmp"
:paths ["release"]}}
{:save_cache
{:paths ["~/.m2" "~/graalvm-ce-java11-22.3.0"]
:key cache-key}}
{:store_artifacts {:path "/tmp/release"
:destination "release"}}
(run "Publish artifact link to Slack"
"./bb .circleci/script/publish_artifact.clj || true")])))))))
(defn make-config
[shorted?]
(let [docker-executor-conf {:docker [{:image "circleci/clojure:openjdk-11-lein-2.9.8-bullseye"}]}
machine-executor-conf {:machine {:image "ubuntu-2004:202111-01"}}
mac-executor-conf {:macos {:xcode "14.0.0"}}
linux-graalvm-home "/home/circleci/graalvm-ce-java11-22.3.0"
mac-graalvm-home "/Users/distiller/graalvm-ce-java11-22.3.0/Contents/Home"]
(ordered-map
:version 2.1
:commands
{:setup-docker-buildx
{:steps
[{:run
{:name "Create multi-platform capabale buildx builder"
:command
"docker run --privileged --rm tonistiigi/binfmt --install all\ndocker buildx create --name ci-builder --use"}}]}}
:jobs (ordered-map
:jvm (jvm shorted? linux-graalvm-home)
:linux (unix shorted? false false "amd64" docker-executor-conf "large" linux-graalvm-home "linux")
:linux-static
(unix shorted? true true "amd64" docker-executor-conf "large" linux-graalvm-home "linux")
:linux-aarch64 (unix shorted?
false
false
"aarch64"
machine-executor-conf
"arm.large"
linux-graalvm-home
"linux")
:linux-aarch64-static
(unix shorted? true false "aarch64" machine-executor-conf "arm.large" linux-graalvm-home "linux")
:mac (unix shorted? false false "amd64" mac-executor-conf "large" mac-graalvm-home "mac")
:deploy (deploy shorted?)
:docker (docker shorted?))
:workflows (ordered-map
:version 2
:ci {:jobs ["jvm"
"linux"
"linux-static"
"mac"
"linux-aarch64"
"linux-aarch64-static"
{:deploy {:filters {:branches {:only "master"}}
:requires ["jvm" "linux"]}}
{:docker {:filters {:branches {:only "master"}}
:requires ["linux" "linux-static" "linux-aarch64"]}}]}))))
(def skip-config
{:skip-if-only [#".*.md$"
#"^logo\/.*$"]})
(defn get-changes
[]
(-> (tasks/shell {:out :string} "git diff --name-only HEAD~1")
(:out)
(str/split-lines)))
(defn irrelevant-change?
[change regexes]
(some? (some #(re-matches % change) regexes)))
(defn relevant?
[change-set regexes]
(some? (some #(not (irrelevant-change? % regexes)) change-set)))
(defn main
[]
(let [{:keys [skip-if-only]} skip-config
changed-files (get-changes)
conf (make-config (not (relevant? changed-files skip-if-only)))]
(println (yaml/generate-string conf
:dumper-options
{:flow-style :block}))))
(when (= *file* (System/getProperty "babashka.file"))
(main))
(comment
(main)
(def regexes
[#".*.md$"
#".*.clj$" ; ignore clojure files
#"^logo\/.*$"])
(:out (tasks/shell {:out :string} "ls"))
(irrelevant-change? "src/file.png" regexes)
(re-matches #".*.clj$" "src/file.clj.dfff")
(re-matches #"^logo\/.*$" "logo/foo/bar.jpg")
(relevant? ["src/file.clj"] regexes))

39
.cirrus.yml Normal file
View file

@ -0,0 +1,39 @@
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-base:latest
task:
skip: "changesIncludeOnly('logo/*', '**.md')"
env:
LEIN_ROOT: "true"
GRAALVM_VERSION: "22.3.0"
GRAALVM_HOME: ${HOME}/graalvm-ce-java11-22.3.0/Contents/Home
BABASHKA_PLATFORM: macos # used in release script
BABASHKA_ARCH: aarch64
BABASHKA_TEST_ENV: native
BABASHKA_XMX: "-J-Xmx6500m"
GITHUB_TOKEN: ENCRYPTED[d6ff8cdc392157f211c754fa0763875434d1bfde0c00a05e48ba9470003a76c14c9213adb80623f81e13f2f0fa8fbd57]
script: |
git submodule init
git submodule update
sudo script/install-clojure
sudo script/install-leiningen
script/install-graalvm
export PATH=$GRAALVM_HOME/bin:$PATH
export JAVA_HOME=$GRAALVM_HOME
sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license
java -version
script/uberjar
script/compile
# script/test
# script/run_lib_tests
VERSION=$(cat resources/BABASHKA_VERSION)
arch=${BABASHKA_ARCH:-amd64}
archive="babashka-$VERSION-$BABASHKA_PLATFORM-$arch.tar.gz"
tar zcvf "$archive" bb
./bb --config .build/bb.edn --deps-root . release-artifact "$archive" || true
binaries_artifacts:
path: "babashka-*.tar.gz"

View file

@ -5,4 +5,5 @@
babashka.impl.File/gen-wrapper-fn-2 clojure.core/def
babashka.impl.Pattern/gen-wrapper-fn-2 clojure.core/def
babashka.impl.Pattern/gen-constants clojure.core/declare}
:linters {:unsorted-required-namespaces {:level :warning}}}
:linters {:unsorted-required-namespaces {:level :warning}}
:hooks {:analyze-call {clojure.core/requiring-resolve hooks.mine/req-resolve}}}

View file

@ -2,82 +2,77 @@ name: build
on:
push:
paths-ignore:
- "**.md"
- "logo/**"
branches:
- master
pull_request:
paths-ignore:
- "**.md"
- "logo/**"
branches:
- master
# TODO: Add deploy if needed
jobs:
scratch:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- name: Scratch
run: |
echo "Scratch"
jvm:
if: "!contains(github.event.head_commit.message, 'skip ci')"
# ubuntu 18.04 comes with lein + java8 installed
runs-on: ubuntu-18.04
if: ${{ false }} # Disabled
# if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
env:
LEIN_ROOT: "true"
BABASHKA_PLATFORM: linux # could be used in jar name
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Git checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: 'true'
- name: Cache deps
uses: actions/cache@v1
uses: actions/cache@v2
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
restore-keys: |
${{ runner.os }}-maven-
restore-keys: ${{ runner.os }}-maven-
- name: Cache GraalVM
uses: actions/cache@v1
id: cache-graalvm
- name: Prepare java
uses: actions/setup-java@v2
with:
path: ~/graalvm-ce-java11-22.0.0.2
key: ${{ runner.os }}-graalvm-22.0.0.2
restore-keys: |
${{ runner.os }}-graalvm-22.0.0.2
distribution: 'adopt-hotspot'
java-version: '11'
- name: Download GraalVM
run: |
cd ~
if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
tar xzf graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
fi
- name: Fetch deps
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
lein deps
- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@5.0
with:
cli: 1.10.3.1040
lein: 2.9.8
- name: Run tests
env:
BABASHKA_FEATURE_JDBC: "true"
BABASHKA_FEATURE_POSTGRESQL: "true"
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
script/test
- name: Test libraries
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
sudo script/install-clojure
script/run_lib_tests
- name: Run as lein command
run: echo '{:a 1}' | lein bb '(:a *in*)'
- name: Build uberjar
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
mkdir -p /tmp/release
script/uberjar
VERSION=$(cat resources/BABASHKA_VERSION)
jar=target/babashka-$VERSION-standalone.jar
cp $jar /tmp/release
java -jar $jar script/reflection.clj
reflection="babashka-$VERSION-reflection.json"
java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$jar"
java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$reflection"
- name: Babashka version
id: babashka-version
@ -87,260 +82,127 @@ jobs:
- uses: actions/upload-artifact@v1
with:
name: jar
name: babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
path: target/babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
linux:
native:
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs: [jvm]
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- uses: actions/download-artifact@v1
with:
name: jar
path: .
- name: Cache deps
uses: actions/cache@v1
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache GraalVM
uses: actions/cache@v1
id: cache-graalvm
with:
path: ~/graalvm-ce-java11-22.0.0.2
key: ${{ runner.os }}-graalvm-22.0.0.2
restore-keys: |
${{ runner.os }}-graalvm-22.0.0.2
- name: Download GraalVM
run: |
cd ~
if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
tar xzf graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
fi
- name: Babashka version
id: babashka-version
run: |
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
echo "##[set-output name=version;]${BABASHKA_VERSION}"
- name: Build Linux native image
run: |
export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
export BABASHKA_XMX="-J-Xmx6g"
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
script/compile
- name: Test binary
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
BABASHKA_TEST_ENV=native script/test
- name: Install clojure
run: |
sudo script/install-clojure /usr/local
- name: Test libraries
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
BABASHKA_TEST_ENV=native script/run_lib_tests
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-amd64.zip
linux-static:
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs: [jvm]
runs-on: ubuntu-16.04
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- uses: actions/download-artifact@v1
with:
name: jar
path: .
- name: Cache deps
uses: actions/cache@v1
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache GraalVM
uses: actions/cache@v1
id: cache-graalvm
with:
path: ~/graalvm-ce-java11-22.0.0.2
key: ${{ runner.os }}-graalvm-22.0.0.2
restore-keys: |
${{ runner.os }}-graalvm-22.0.0.2
- name: Download GraalVM
run: |
cd ~
if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
tar xzf graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
fi
- name: Babashka version
id: babashka-version
run: |
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
echo "##[set-output name=version;]${BABASHKA_VERSION}"
- name: Build Linux native image
run: |
export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
export BABASHKA_XMX="-J-Xmx6g"
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
export BABASHKA_STATIC=true
script/compile
- name: Test binary
run: |
./bb '(+ 1 2 3)'
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
BABASHKA_TEST_ENV=native script/test
- name: Install clojure
run: |
sudo script/install-clojure
- name: Test libraries
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
BABASHKA_TEST_ENV=native script/run_lib_tests
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-static-amd64.zip
mac:
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs: [jvm]
runs-on: macos-latest
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- uses: actions/download-artifact@v1
with:
name: jar
path: .
- name: Cache GraalVM
uses: actions/cache@v1
id: cache-graalvm
with:
path: ~/graalvm-ce-java11-22.0.0.2
key: ${{ runner.os }}-graalvm-22.0.0.2
restore-keys: |
${{ runner.os }}-graalvm-22.0.0.2
- name: Download GraalVM
run: |
cd ~
if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-darwin-amd64-22.0.0.2.tar.gz
tar xzf graalvm-ce-java11-darwin-amd64-22.0.0.2.tar.gz
fi
- name: Babashka version
id: babashka-version
run: |
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
echo "##[set-output name=version;]${BABASHKA_VERSION}"
- name: Build macOS native image
run: |
export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
export BABASHKA_XMX="-J-Xmx6g"
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2/Contents/Home"
script/compile
- name: Test binary
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2/Contents/Home"
sudo script/install-leiningen
BABASHKA_TEST_ENV=native script/test
- name: Test libraries
run: |
export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2/Contents/Home"
sudo script/install-clojure
BABASHKA_TEST_ENV=native script/run_lib_tests
- uses: actions/upload-artifact@v1
with:
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-macos-amd64.zip
deploy:
if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master'"
needs: [jvm, linux, linux-static, mac]
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
submodules: 'true'
- name: Cache deps
uses: actions/cache@v1
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Deploy
strategy:
matrix:
include:
- os: macos-12
name: macos
static: false
#- os: ubuntu-latest
# name: linux
# static: false
#- os: ubuntu-latest
# name: linux
# static: true
runs-on: ${{ matrix.os }}
env:
CLOJARS_USER: "${{ secrets.CLOJARS_USER }}"
CLOJARS_PASS: "${{ secrets.CLOJARS_PASS }}"
LEIN_ROOT: "true"
GRAALVM_VERSION: "22.3.0"
BABASHKA_PLATFORM: ${{ matrix.name }} # used in release script
BABASHKA_TEST_ENV: native
BABASHKA_XMX: "-J-Xmx6500m"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Git checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: 'true'
- name: Cache deps
uses: actions/cache@v2
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
restore-keys: ${{ runner.os }}-maven-
- name: Setup GraalVM
if: "matrix.static == false"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '11'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup GraalVM+musl
if: "matrix.static == true"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '11'
components: 'native-image'
native-image-musl: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@5.0
with:
cli: 1.10.3.1040
lein: 2.9.8
- name: Install native dev tools
if: matrix.os == 'ubuntu-latest'
run: |
.github/script/deploy
sudo apt-get update
sudo apt-get -y install build-essential zlib1g-dev
- name: Babashka version
id: babashka-version
run: |
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
echo "##[set-output name=version;]${BABASHKA_VERSION}"
- name: Build uberjar
run: script/uberjar
- name: Build native image
if: "matrix.static == false"
run: script/compile
- name: Build static native image
if: "matrix.static == true"
env:
BABASHKA_STATIC: "true"
BABASHKA_MUSL: "true"
run: script/compile
- name: Test binary and libs
run: |
script/test
script/run_lib_tests
- name: Release
run: .circleci/script/release
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-${{ matrix.name }}-amd64
- name: Upload static artifact
if: "matrix.static == true"
uses: actions/upload-artifact@v2
with:
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-${{ matrix.name }}-static-amd64
docker:
if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master'"
if: ${{ false }} # Disabled
# if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master'"
needs:
- linux
- linux-static
runs-on: ubuntu-18.04
- native
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: 'true'
@ -366,9 +228,16 @@ jobs:
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-static-amd64.zip
path: /tmp/release-static
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build uberjar
run: script/uberjar
- name: Docker build
env:
DOCKERHUB_USER: "${{ secrets.DOCKERHUB_USER }}"
DOCKERHUB_PASS: "${{ secrets.DOCKERHUB_PASS }}"
run: |
.github/script/docker
PLATFORMS: linux/amd64,linux/arm64
run: java -jar ./target/babashka-$(cat resources/BABASHKA_VERSION)-standalone.jar .circleci/script/docker.clj

3
.gitignore vendored
View file

@ -33,3 +33,6 @@ org_babashka*.h
.envrc
.lsp
bb.build_artifacts.txt
target
.nrepl-port
.DS_Store

View file

@ -5,6 +5,241 @@ For a list of breaking changes, check [here](#breaking-changes).
A preview of the next release can be installed from
[babashka-dev-builds](https://github.com/babashka/babashka-dev-builds).
[Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting
## Unreleased
- Implement `ns`, `lazy-seq` as macro
- Support `--dev-build` flag in installation script
- [#1451](https://github.com/babashka/babashka/issues/1451): Allow passing explicit file and line number to clojure.test ([@matthewdowney](https://github.com/matthewdowney))
- [#1280](https://github.com/babashka/babashka/issues/1280): babashka REPL doesn't quit right after Ctrl-d ([@formerly-a-trickster](https://github.com/formerly-a-trickster) and Alice Margatroid)
- [#1446](https://github.com/babashka/babashka/issues/1446): add `pprint/code-dispatch`
- Update zlib to version `1.2.13` ([@thiagokokada](https://github.com/thiagokokada))
- [#1454](https://github.com/babashka/babashka/issues/1454): Add `babashka.process` to `print-deps` output
## 1.0.168 (2022-12-07)
- `loop*`, `fn*` are now special forms and `loop`, `fn`, `defn`, `defmacro`, `and` and `or` are implemented as macros. This restores compatibility with [rcf](https://github.com/borkdude/hyperfiddle-rcf)
- fs: don't touch dirs in `split-ext`
- Update to babashka process to v0.4.13: support `(process opts? & args)` syntax everywhere
- [#1438](https://github.com/babashka/babashka/issues/1438): expose `query-string` and `url-encode` functions from org.httpkit.client ([@bobisageek](https://github.com/bobisageek))
- Add `java.util.InputMismatchException`
## 1.0.167 (2022-11-30)
- [#1433](https://github.com/babashka/babashka/issues/1433): spec source as built-in fallback. When not including the
[clojure.spec.alpha](https://github.com/babashka/spec.alpha) fork as a
library, babashka loads a bundled version, when `clojure.spec.alpha` is required.
- [#1430](https://github.com/babashka/babashka/issues/1430): Fix issue with `bb tasks` throwing on empty display tasks list.
- Add note about BSOD when using WSL1, see [README.md/quickstart](https://github.com/LouDnl/babashka#quickstart)
- SCI: performance improvements
- Better error locations for interop ([@bobisageek](https://github.com/bobisageek))
- Fix [babashka/babashka.nrepl#59](https://github.com/babashka/babashka.nrepl/issues/59): do not output extra new line with cider pprint
- Use `namespace-munge` instead of `munge` for doing ns -> file lookup
## 1.0.166 (2022-11-24)
See the [Testing babashka scripts](https://blog.michielborkent.nl/babashka-test-runner.html) blog post for how to run tests with this release.
- Compatibility with Cognitest [test-runner](https://github.com/cognitect-labs/test-runner) and [tools.namespace](https://github.com/clojure/tools.namespace)
- Add `run-test` and `run-test-var` to `clojure.test`
- Compile distributed uberjar using GraalVM, fixes `babashka.process/exec` for Nix
- [#1414](https://github.com/babashka/babashka/issues/1414): preserve metadata on exec task function argument map
- [#1269](https://github.com/babashka/babashka/issues/1269): add lib tests for sluj ([@bobisageek](https://github.com/bobisageek))
- Update nix app example in docs
- Add `java.lang.Error` and `java.net.URLClassLoader` (only for compatibility with the `clojure.java.classpath` lib)
- Deps.clj `deps.clj: 1.11.1.1200`
- Upgrade timbre to `6.0.1`
- Performance improvements in SCI
- SCI: preserve stack information on `throw` expressions
## 1.0.165 (2022-11-01)
- Fix [#1401](https://github.com/babashka/babashka/issues/1401): mutation of `deftype` field should be visible in protocol method
- Fix [#1405](https://github.com/babashka/babashka/issues/1405): drop name metadata from conditionally defined var
- [#602](https://github.com/babashka/babashka/issues/602): add lib tests for clj-commons/fs ([@bobisageek](https://github.com/bobisageek))
- Add `java.net.URLConnection` class
- Add `java.time.zone.ZoneRules` class
- Copy more docstrings for core macros and vars
- Bump `core.async` to `1.6.673`
- Implement `in-ns` as function, rather than special form ([@SignSpice](https://github.com/SignSpice))
- Bump `deps.clj` to `1.11.1.1182`
- Bump GraalVM to `22.3.0`
- SCI: don't rely on metadata for record implementation
## 1.0.164 (2022-10-17)
- SCI: optimizations for `let`
- Add single argument read method support to PipedInputStream proxy ([@retrogradeorbit](https://github.com/retrogradeorbit))
- feat: Honor `*print-namespace-maps*` in pprint ([@ghoseb](https://github.com/ghoseb))
- [#1369](https://github.com/babashka/babashka/issues/1369): provide `.sha256` files for every released asset
- [#1397](https://github.com/babashka/babashka/issues/1397): Add `clojure.lang.Namespace` as alias for `sci.lang.Namespace`, such that `(instance? clojure.lang.Namespace *ns*)` returns `true` in bb
- [#1384](https://github.com/babashka/babashka/issues/1384): allow `.indexOf` on `LazySeq`
- [#1330](https://github.com/babashka/babashka/issues/1330): allow `(set! *warn-on-reflection*)` in programmatic nREPL
- Better error message when failing to load `bb.edn` ([@lispyclouds](https://github.com/lispyclouds))
- Pods: print and flush to `*out*` and `*err*` instead of using `println` ([@justone](https://github.com/justone))
- deps.clj: support for `CLJ_JVM_OPTS` and `JAVA_OPTS` ([@ikappaki](https://github.com/ikappaki))
- Fix `*print-namespace-maps*` when using `clojure.pprint` ([@ghoseb](https://github.com/ghoseb))
- Process: only slurp `*err*` when inputstream ([@ikappaki](https://github.com/ikappaki))
- Process: add `alive?` API function ([@grzm](https://github.com/grzm))
- Bump libraries: tools.cli, babashka.cli
- [#1391](https://github.com/babashka/babashka/issues/1391): include raw in `hiccup2.core` ns
- [#1391](https://github.com/babashka/babashka/issues/1391): support loading `hiccup.page` when adding hiccup to deps
## 0.10.163 (2022-09-24)
- [#808](https://github.com/babashka/babashka/issues/808): support `-Sdeps` option to support passing extra deps map which will be merged last
- [#1336](https://github.com/babashka/babashka/issues/1336): tasks subcommand doesn't work with global `-Sforce` option ([@bobisageek](https://github.com/bobisageek))
- [#1340](https://github.com/babashka/babashka/issues/1340): `defprotocol` methods are missing `:doc` metadata ([@bobisageek](https://github.com/bobisageek))
- [#1368](https://github.com/babashka/babashka/issues/1368): `-x`: do not pick up on aliases in `user` ns
- [#1367](https://github.com/babashka/babashka/issues/1367): Fix line number in clojure.test output ([@retrogradeorbit](https://github.com/retrogradeorbit))
- [#1370](https://github.com/babashka/babashka/issues/1370): Add `core.async` `to-chan!`, `to-chan!!`, `onto-chan!` ([@cap10morgan](https://github.com/cap10morgan))
- [#1358](https://github.com/babashka/babashka/issues/1358): Expose a subset of `java.lang.ref` to enable hooking into the destruction/GC of objects ([@retrogradeorbit](https://github.com/retrogradeorbit))
- [#1364](https://github.com/babashka/babashka/issues/1364): Be tolerant of unknown tags in `bb.edn`
- Add and expose `babashka.classes/all-classes` to get a list of all available classes (as `java.lang.Class` objects) ([@eerohele](https://github.com/eerohele))
- Add more reflection class methods ([@eerohele](https://github.com/eerohele))
- Bump `clj-yaml`
- Add `-x` help
- Set `TCP_NODELAY` in pods for performance
- Expose `clojure.main/with-bindings`
- Add `ThreadPoolExecutor` rejection policy classes ([@eerohele](https://github.com/eerohele))
- Download but don't run pods when `os.name` / `os.arch` don't match ([@cap10morgan](https://github.com/cap10morgan))
- Add `clojure.core.server/stop-server` ([@eerohele](https://github.com/eerohele))
- Add `ns-unalias`
- Add `AtomicInteger` and `AtomicLong` to full interop
- Add `PrintWriter-on`
- Improve `reify` error messages ([@retrogradeorbit](https://github.com/retrogradeorbit))
- Expose `core.async` `ManyToManyChannel`
- fs: add `write-lines`
- fs: add `write-bytes`
- [#1350](https://github.com/babashka/babashka/issues/1350): map `clojure.lang.Var` to `sci.lang.Var`
- Use temporary fork of `clj-yaml` with new `:load-all`, `:unknown-tag-fn`
options and preserves strings with numbers that start with zeros as strings
(this solves a problem when YAML 1.1 output is read as YAML 1.2.). Once
upstream SnakeYAML 1.33 lands, this will be used again.
## 0.9.162 (2022-09-04)
Check out our new project: [bbin](https://github.com/babashka/bbin): install any Babashka script or project with one command. Thanks [@rads](https://github.com/rads)!
- Throw exception on attempt to reify multiple interfaces ([@retrogradeorbit](https://github.com/retrogradeorbit))
- Allow java.lang.Object reify with empty methods ([@retrogradeorbit](https://github.com/retrogradeorbit))
- [#1343](https://github.com/babashka/babashka/issues/1343): Fix postgres feature
- [#1345](https://github.com/babashka/babashka/issues/1345): add `javax.net.ssl.SSLException` and `java.net.SocketTimeoutException` classes ([@lread](https://github.com/lread))
- Fix `satisfies?` with marker protocol (no methods)
- Update `rewrite-clj`
- Update `deps.clj`
- Update `babashka.cli`
- Update `org.clj-commons/clj-yaml`
- `babashka.fs`: fix `expand-home` on Windows
- `babashka.fs`: expose `:win-exts`
- nREPL: preserve stacktrace on exception
- Fix [#1322](https://github.com/babashka/babashka/issues/1322): improve error location
- Fix [#1338](https://github.com/babashka/babashka/issues/1338): `add-watch` segfault
- Fix [#1339](https://github.com/babashka/babashka/issues/1339): resolve record name ending with dot.
## 0.9.161 (2022-07-31)
- Fix `exec`
## 0.9.160 (2022-07-29)
- Breaking: change `exec`, introduced in `0.9.159` to a function instead.
You now write `(exec 'mynamespace.function)` instead.
## 0.9.159 (2022-07-29)
Read the introductory blog post about the new babashka CLI integration [here](https://blog.michielborkent.nl/babashka-tasks-meets-babashka-cli.html).
- [#1324](https://github.com/babashka/babashka/issues/1324): `-x` to invoke a function with babashka CLI
- [#1324](https://github.com/babashka/babashka/issues/1324): `babashka.tasks/exec` to invoke a function with babashka CLI in tasks
- SCI: don't eval metatada on defn body
- SCI issue 774: make interpreter stacktrace available to user
- `babashka.process`: improve `tokenize`
- Upgrade to GraalVM 22.2.0 (#1325)
## 0.8.157 (2022-07-01)
- Add compatibility with [`metosin/malli`](https://github.com/metosin/malli#babashka) `{:mvn/version "0.8.9"}`.
- Expose `babashka.nrepl.server/start-server!`- and `stop-server!`-functions to support programmatically starting
an nrepl-server. `start-server!` is redefined to not require a sci-context as its first argument.
- Fix misspelling in script/uberjar: `BABASHKA_FEATURE_TRANSIT`
## 0.8.156 (2022-06-08)
- macOS aarch64 support. Upgrading via brew or the installer script should
install the aarch64 version on an M1 system.
- Support for running [prismatic/schema](https://github.com/plumatic/schema)
from source. There is an open PR for babashka. Until it is merged you can use
[this](https://github.com/borkdude/schema/tree/bb-test-suite) fork.
- SCI: many small improvements, especially in `defrecord` (discovered while
trying to make `schema.core` work)
- Switch version schema to major.minor.release_count.
- babashka.nrepl: fix completions for static Java interop
- `fs/read-all-lines`, support charset
- fs: `strip` and `split-ext` are less reliant on file system and are now just
string operations
- Bump cheshire
- Add `babashka.process/exec` for exec call (replacing the current process)
- Improve `babashka.process/tokenize`
- [#1264](https://github.com/babashka/babashka/issues/1264): add support for calling `ScheduledExecutorService`
- Add support for `sun.misc.SignalHandler`
- Add `java.net.BindException`, `clojure.lang.AFunction`, `AbstractMethodError`
- Upgrade httpkit to `2.6.0-RC1`
- Add `process/shell`, similar to `babashka.tasks/shell` but in process ns
- pods: fix benign socket closed exception error output
## 0.8.2 (2022-05-06)
- Convey `*print-length*` to pprint and allow `set!`
- `babashka.nrepl`: support pprint length
- SCI: support invoking field, without dash
- Add compatibility with clojure numeric tower
- Update deps.clj to tools jar `1.11.1.1113`
- Compatibility with fipp and puget
- Fix [#1233](https://github.com/babashka/babashka/issues/1233): don't print error to stdout in prepl
- Update process with `:pre-start-fn` option
- Update fs with `cwd` and Windows glob improvements
- Expose edamame, fixes [#549](https://github.com/babashka/babashka/issues/549) and [#1258](https://github.com/babashka/babashka/issues/1258) (#1259)
- Support `BABASBHKA_PODS_DIR` environment variable
## 0.8.1 (2022-04-15)
- Add `prepare` subcommand to download deps & pods and cache pod metadata
- [#1041](https://github.com/babashka/babashka/issues/1041): Improve error message when regex literal in EDN config
- [#1223](https://github.com/babashka/babashka/issues/1223): Ensure that var metadata (specifically `:name`) aligns with the var's symbol (which in turn ensures that `doc` will print the var's name)
- [#556](https://github.com/babashka/babashka/issues/556) Add server-status to org.httpkit.server
- [#1231](https://github.com/babashka/babashka/issues/1231): missing methods in `reify` should fall back to default interface methods
- Fix destructuring in defrecord protocol impls
- Support `*print-dup*`
## 0.8.0 (2022-04-04)
### New
- [#863](https://github.com/babashka/babashka/issues/863): allow pods to be declared in `bb.edn` and load them when required. See [pod library docs](https://github.com/babashka/pods#in-a-babashka-project) and the entry in the [babashka book](https://book.babashka.org/#_pods_in_bb_edn) for details.
### Enhanced
- [#1216](https://github.com/babashka/babashka/issues/1216): support `core.async/alts!` using polyfill
- [#1220](https://github.com/babashka/babashka/issues/1220): add reflection on java.util.concurrent.Future
- [#1211](https://github.com/babashka/babashka/issues/1211): return exit code 130 on sigint
- [#1224](https://github.com/babashka/babashka/issues/1224): add `proxy` support for `java.io.PipedInputStream` and `java.io.PipedOutputStream`. Add reflection for `java.utils.Scanner`.
- [babashka.curl#43](https://github.com/babashka/babashka.curl/issues/43) fix: last set-cookie headers on a page overwrites the ones before
- [#1216](https://github.com/babashka/babashka/issues/1216): fix `core.async` alts example with polyfill
- SCI: support `let*` special form
- Add compatibility with GraalVM 22.1
- Bump timbre
- Bump Clojure to 1.11.0
- Pods: support Rosetta2 fallback
- Process: fix for pprint
- Fs: improvement for which: do not match on local paths
- Proxy support for PipedInputStream and PipedOutputStream
- Expose `java.util.Scanner` for interop
- Bump Selmer
- Add `->Eduction`
- Add `*unchecked-math` for compatibility
## 0.7.8 (2022-03-13)
This release improves compatibility with several libraries: [loom](https://github.com/aysylu/loom), [hugsql.core](https://www.hugsql.org) and [specter](https://github.com/redplanetlabs/specter)!
@ -12,12 +247,9 @@ This release improves compatibility with several libraries: [loom](https://githu
To use specter in babashka, use the following coordinates:
``` clojure
{:deps {com.rpl/specter {:git/url "https://github.com/borkdude/specter"
:git/sha "8ba809a2cd35d3b6f8c5287e6bd3b4e06e42f6dc"}}}
{:deps {com.rpl/specter {:mvn/version "1.1.4"}}}
```
Hopefully the compatibility commit can be upstreamed back into specter at some point.
- Add `clojure.data.priority-map` as built-in library - this makes babashka compatible with [aysylu/loom](https://github.com/aysylu/loom)
- Add part of `clojure.tools.reader.reader-types` to support [hugsql.core](https://www.hugsql.org)
- [#1204](https://github.com/babashka/babashka/issues/1204) add property `babashka.config` to reflect `bb.edn` location ([@mknoszlig](https://github.com/mknoszlig))

View file

@ -5,10 +5,11 @@ RUN apt update
RUN apt install --no-install-recommends -yy build-essential zlib1g-dev
WORKDIR "/opt"
ENV GRAALVM_VERSION="22.0.0.2"
ENV GRAALVM_VERSION="22.3.0"
ARG TARGETARCH
ENV BABASHKA_ARCH=${TARGETARCH}
ENV GRAALVM_ARCH=${TARGETARCH}
# Do not set those directly, use TARGETARCH instead
ENV BABASHKA_ARCH=
ENV GRAALVM_ARCH=
RUN if [ "${TARGETARCH}" = "" ] || [ "${TARGETARCH}" = "amd64" ]; then \
export GRAALVM_ARCH=amd64; export BABASHKA_ARCH=x86_64; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
@ -34,7 +35,7 @@ ARG BABASHKA_FEATURE_CSV=
ARG BABASHKA_FEATURE_JAVA_NET_HTTP=
ARG BABASHKA_FEATURE_JAVA_NIO=
ARG BABASHKA_FEATURE_JAVA_TIME=
ARG BABAHSKA_FEATURE_TRANSIT=
ARG BABASHKA_FEATURE_TRANSIT=
ARG BABASHKA_FEATURE_XML=
ARG BABASHKA_FEATURE_YAML=
ARG BABASHKA_FEATURE_HTTPKIT_CLIENT=
@ -51,7 +52,7 @@ ENV BABASHKA_FEATURE_CSV=$BABASHKA_FEATURE_CSV
ENV BABASHKA_FEATURE_JAVA_NET_HTTP=$BABASHKA_FEATURE_JAVA_NET_HTTP
ENV BABASHKA_FEATURE_JAVA_NIO=$BABASHKA_FEATURE_JAVA_NIO
ENV BABASHKA_FEATURE_JAVA_TIME=$BABASHKA_FEATURE_JAVA_TIME
ENV BABAHSKA_FEATURE_TRANSIT=$BABAHSKA_FEATURE_TRANSIT
ENV BABASHKA_FEATURE_TRANSIT=$BABASHKA_FEATURE_TRANSIT
ENV BABASHKA_FEATURE_XML=$BABASHKA_FEATURE_XML
ENV BABASHKA_FEATURE_YAML=$BABASHKA_FEATURE_YAML
ENV BABASHKA_FEATURE_HTTPKIT_CLIENT=$BABASHKA_FEATURE_HTTPKIT_CLIENT

View file

@ -4,9 +4,11 @@ COPY bb /bin/bb
RUN chmod +x /bin/bb
# TODO: See https://github.com/sgerrand/alpine-pkg-glibc/issues/185 and remove the `--force-overwrite`s when resolved.
RUN apk --no-cache add curl ca-certificates tar && \
curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \
apk add --allow-untrusted /tmp/glibc-2.28-r0.apk
apk add --allow-untrusted --force-overwrite /tmp/glibc-2.28-r0.apk
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
# TODO: Run actual native tests when they are ported
@ -21,7 +23,7 @@ FROM alpine:3
RUN apk --no-cache add curl ca-certificates tar && \
curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \
apk add --allow-untrusted /tmp/glibc-2.28-r0.apk
apk add --allow-untrusted --force-overwrite /tmp/glibc-2.28-r0.apk
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
COPY metabom.jar /opt/babashka-metabom.jar

145
README.md
View file

@ -1,4 +1,4 @@
<img src="logo/babashka.svg" width="425px">
[<img src="logo/babashka.svg" alt="Babashka" width="425px">](https://babashka.org)
[![CircleCI](https://circleci.com/gh/babashka/babashka/tree/master.svg?style=shield)](https://circleci.com/gh/babashka/babashka/tree/master)
[![project chat](https://img.shields.io/badge/slack-join_chat-brightgreen.svg)](https://app.slack.com/client/T03RZGPFR/CLX41ASCS)
@ -12,12 +12,6 @@
<a href="https://github.com/laheadle">@laheadle</a> on Clojurians Slack
</blockquote>
<hr>
Please leave some feedback about babashka in the [Q1 Survey](https://forms.gle/ko3NjDg2SwXeEoNQ9)!
<hr>
## Introduction
Babashka is a native Clojure interpreter for scripting with fast startup. Its
@ -59,7 +53,7 @@ anywhere on the path.
Then you're ready to go:
``` shellsession
$ ls | bb -i '(filter #(-> % io/file .isDirectory) *input*)'
$ ls | bb -i '(filter fs/directory? *input*)'
("doc" "resources" "sci" "script" "src" "target" "test")
bb took 4ms.
```
@ -115,7 +109,8 @@ $ bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]'
[1 2]
```
Read more about input and output flags [here](https://book.babashka.org/#_input_and_output_flags).
Read more about `*input*` and in- and output flags
[here](https://book.babashka.org/#_input_and_output_flags).
Execute a script. E.g. print the current time in California using the
`java.time` API:
@ -153,15 +148,39 @@ Install:
brew install borkdude/brew/babashka
On macOS with an M1 processor:
<!-- On macOS with an M1 processor: -->
softwareupdate --install-rosetta
arch -x86_64 brew install borkdude/brew/babashka
<!-- softwareupdate --install-rosetta -->
<!-- arch -x86_64 brew install borkdude/brew/babashka -->
Upgrade:
brew upgrade babashka
### Nix
Linux and macOS (including ARM Macs) binaries are provided via nix (see the installation instructions for nix [here](https://nixos.org/download.html)).
Install:
# Adding `nixpkgs-unstable` channel for more up-to-date binaries, skip this if you already have `nixpkgs-unstable` in your channel list
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
nix-channel --update
nix-env -iA nixpkgs-unstable.babashka
Upgrade:
nix-channel --update
nix-env -iA nixpkgs-unstable.babashka
You can find more documentation on how to use babashka with nix [here](./doc/nix.md).
### Alpine
On Alpine it's recommended to download the binary manually from [Github
Releases](https://github.com/babashka/babashka/releases) and use the static
linux binary.
### Arch (Linux)
`babashka` is [available](https://aur.archlinux.org/packages/babashka-bin/) in the [Arch User Repository](https://aur.archlinux.org). It can be installed using your favorite [AUR](https://aur.archlinux.org) helper such as
@ -180,6 +199,8 @@ Babashka can be installed using a plugin as follows:
### Windows
#### Scoop
On Windows you can install using [scoop](https://scoop.sh/) and the
[scoop-clojure](https://github.com/littleli/scoop-clojure) bucket.
@ -194,9 +215,23 @@ scoop bucket add extras
scoop install babashka
```
#### Manual
If scoop does not work for you, then you can also just download the `bb.exe`
binary from [Github releases](https://github.com/babashka/babashka/releases) and
place it on your path manually.
#### WSL1
> Note: WSL1 users might experience a BSOD, please use the --static install option when installing
``` shell
$ curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
$ chmod +x install
$ ./install --static
```
### Installer script
Install via the installer script:
Install via the installer script for linux and macOS:
``` shell
$ curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
@ -260,17 +295,76 @@ Check out the [news](doc/news.md) page to keep track of babashka-related news it
Go [here](https://book.babashka.org/#built-in-namespaces) to see the full list of built-in namespaces.
## [Projects](doc/projects.md)
## [Compatible Projects](doc/projects.md)
A list of projects (scripts, libraries, pods and tools) known to work with babashka.
## Badges
<!-- note to editor: it seems a blank line must appear before code blocks within <details> -->
[![bb compatible](/logo/badge.svg)](https://babashka.org)
The babashka compatible badge indicates that a [library can be used as babashka dependency](doc/projects.md).
If this is the case for your library, we encourage you to proudly display this badge.
<details><summary>Markdown</summary>
```markdown
[![bb compatible](https://raw.githubusercontent.com/babashka/babashka/master/logo/badge.svg)](https://babashka.org)
```
</details>
<details><summary>AsciiDoc</summary>
```asciidoc
https://babashka.org[image:https://raw.githubusercontent.com/babashka/babashka/master/logo/badge.svg[bb compatible]]
```
</details>
<details><summary>HTML</summary>
```html
<a href="https://babashka.org" rel="nofollow"><img src="https://github.com/babashka/babashka/raw/master/logo/badge.svg" alt="bb compatible" style="max-width: 100%;"></a>
```
</details>
<br/>
[![bb built-in](/logo/built-in-badge.svg)](https://babashka.org)
The babashka built-in badge means that a [library has been built directly into babashka](https://book.babashka.org/#built-in-namespaces) and requires no extra dependencies to use it.
If this rare honor belongs to your library, you should display this badge.
<details><summary>Markdown</summary>
```markdown
[![bb built-in](https://raw.githubusercontent.com/babashka/babashka/master/logo/built-in-badge.svg)](https://babashka.org)
```
</details>
<details><summary>AsciiDoc</summary>
```asciidoc
https://babashka.org[image:https://raw.githubusercontent.com/babashka/babashka/master/logo/built-in-badge.svg[bb built-in]]
```
</details>
<details><summary>HTML</summary>
```html
<a href="https://babashka.org" rel="nofollow"><img src="https://github.com/babashka/babashka/raw/master/logo/built-in-badge.svg" alt="bb built-in" style="max-width: 100%;"></a>
```
</details>
</br>
## [Pods](https://github.com/babashka/babashka.pods)
Pods are programs that can be used as a Clojure library by
babashka. Documentation is available in the [pod library
repo](https://github.com/babashka/babashka.pods).
repo](https://github.com/babashka/pods).
A list of available pods can be found [here](doc/projects.md#pods).
A list of available pods can be found in the [pod registry](https://github.com/babashka/pod-registry).
## Differences with Clojure
@ -312,6 +406,23 @@ handling of SIGINT and SIGPIPE. This can be done by setting
## Articles, podcasts and videos
- [Babashka: How GraalVM Helped Create a Fast-Starting Scripting Environment for Clojure](https://medium.com/graalvm/babashka-how-graalvm-helped-create-a-fast-starting-scripting-environment-for-clojure-b0fcc38b0746) by Michiel Borkent
- [Adding Prompts To Your Babashka Scripts With Dialog](https://www.pixelated-noise.com/blog/2022/12/09/dialog-and-babashka/index.html) by A.C. Danvers
- [Using Babashka to Get Electricity Prices](https://www.karimarttila.fi/clojure/2022/12/04/using-babashka-to-get-electricity-prices.html) by Kari Marttila
- [Manage git hooks with babashka tasks](https://blaster.ai/blog/posts/manage-git-hooks-w-babashka.html) by Mykhaylo Bilyanskyy
- [Messing around with babashka](https://ian-muge.medium.com/messing-around-with-babashka-f181a9003faa) by Ian Muge
- [Deleting AWS Glacier vaults with babashka](https://javahippie.net/clojure/2022/07/23/deleting-aws-glacier-vaults-with-babashka.html) by Tim Zöller
- [Recursive document transformations with Pandoc and Clojure](https://play.teod.eu/document-transform-pandoc-clojure/) by Teodor Heggelund
- [Blambda!](https://jmglov.net/blog/2022-07-03-blambda.html) by Josh Glover
- [Babashka CLI](https://blog.michielborkent.nl/babashka-cli.html): turn Clojure functions into CLIs!
- [Breakneck Babashka on K8s](https://www.linkedin.com/pulse/breakneck-babashka-k8s-heow-goodman/) by Heow Goodman
- [Recursive document transformations with Pandoc and Clojure](https://play.teod.eu/document-transform-pandoc-clojure/)
- [Detecting inconsistent aliases in a clojure codebase](https://www.youtube.com/watch?v=bf8KLKkCH2g) by Oxalorg
- [I, too, Wrote Myself a Static Site Generator](https://dawranliou.com/blog/i-too-wrote-myself-a-static-site-generator/) by Daw-Ran Liou
- [Babashka and Clojure](https://youtu.be/ZvOs5Ele6VE) by Rahul Dé at North Virginia Linux Users Group
- [Create a password manager with Clojure using Babashka, sqlite, honeysql and stash](https://youtu.be/jm0RXmyjRJ8) by Daniel Amber
- [Writing Clojure-living-cookbooks](https://www.loop-code-recur.io/live-clojure-cookbooks) by Cyprien Pannier
- [Using babashka with PHP](https://blog.michielborkent.nl/using-babashka-with-php.html) by Michiel Borkent
- [Moldable Emacs: a Clojure Playground with Babashka](https://ag91.github.io/blog/2021/11/05/moldable-emacs-a-clojure-playground-with-babashka/) by Andrea
- [Finding my inner Wes Anderson with #Babashka](https://javahippie.net/clojure/2021/10/18/finding-my-inner-wes-anderson.html) by Tim Zöller
- [Awesome Babashka: Parse & produce HTML and SQLite](https://blog.jakubholy.net/2021/awesome-babashka-dash/) by Jakub Holý
@ -360,7 +471,7 @@ binary, these evaluation criteria are considered:
- The library cannot be interpreted by with babashka using `--classpath`.
- The functionality can't be met by shelling out to another CLI or can't be
written as a small layer over an existing CLI (like `babashka.curl`) instead.
- The library cannot be implemented a
- The library cannot be implemented as a
[pod](https://github.com/babashka/babashka.pods).
If not all of the criteria are met, but adding a feature is still useful to a

View file

@ -7,10 +7,15 @@ image: Visual Studio 2017
clone_folder: C:\projects\babashka
environment:
GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-22.0.0.2
JAVA_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-22.0.0.2
GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-22.3.0
JAVA_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-22.3.0
BABASHKA_XMX: "-J-Xmx5g"
skip_commits:
files:
- "logo/*"
- "**/*.md"
cache:
- C:\ProgramData\chocolatey\lib -> project.clj, appveyor.yml
- '%USERPROFILE%\.m2 -> project.clj'
@ -33,7 +38,7 @@ clone_script:
build_script:
- cmd: >-
powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-windows-amd64-22.0.0.2.zip', 'graalvm.zip') }"
powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-windows-amd64-22.3.0.zip', 'graalvm.zip') }"
powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }"

@ -1 +1 @@
Subproject commit 3d3d117ea0f8a143a06e3cace92e4e8b6a5782df
Subproject commit 99e6d3ba7a7252284b43f9de7d91d3433ecfa8f0

@ -1 +1 @@
Subproject commit d3fce67198b042707f01d841c032f841cc57ab7f
Subproject commit ad763a78f1bc327a493ff0b650aa5408ecbf4819

@ -1 +1 @@
Subproject commit cee6e47de8b59c6386704be0c82c0a1d74c9722c
Subproject commit 2d185718ba2871c96e6cb4a4181d1dcf9d8fde86

View file

@ -10,23 +10,28 @@
"feature-selmer"
"feature-logging"
"feature-priority-map"
"feature-rrb-vector"
"feature-jdbc"
"pods/src"
"babashka.nrepl/src"
"depstar/src" "process/src"
"deps.clj/src" "deps.clj/resources"
"resources" "sci/resources"],
:deps {org.clojure/clojure {:mvn/version "1.11.0-beta1"},
borkdude/sci {:local/root "sci"}
"resources" "sci/resources"
"reify/src"],
:deps {org.clojure/clojure {:mvn/version "1.11.1"},
org.babashka/sci {:local/root "sci"}
org.babashka/babashka.impl.reify {:mvn/version "0.1.3"}
org.babashka/sci.impl.types {:mvn/version "0.0.2"}
babashka/babashka.curl {:local/root "babashka.curl"}
babashka/fs {:local/root "fs"}
babashka/babashka.core {:local/root "babashka.core"}
borkdude/graal.locking {:mvn/version "0.0.2"},
org.clojure/core.async {:mvn/version "1.5.648"},
org.clojure/tools.cli {:mvn/version "1.0.206"},
org.clojure/core.async {:mvn/version "1.6.673"},
org.clojure/tools.cli {:mvn/version "1.0.214"},
org.clojure/data.csv {:mvn/version "1.0.0"},
cheshire/cheshire {:mvn/version "5.10.2"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}
clj-commons/clj-yaml {:mvn/version "0.7.108"}
cheshire/cheshire {:mvn/version "5.11.0"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
clj-commons/clj-yaml {:mvn/version "0.7.169"}
com.cognitect/transit-clj {:mvn/version "1.0.329"}
org.clojure/test.check {:mvn/version "1.1.1"}
nrepl/bencode {:mvn/version "1.1.0"}
@ -34,16 +39,19 @@
org.postgresql/postgresql {:mvn/version "42.2.18"}
org.hsqldb/hsqldb {:mvn/version "2.5.1"}
datascript/datascript {:mvn/version "1.0.1"}
http-kit/http-kit {:mvn/version "2.5.3"}
http-kit/http-kit {:mvn/version "2.6.0-RC1"}
babashka/clojure-lanterna {:mvn/version "0.9.8-SNAPSHOT"}
org.clojure/core.match {:mvn/version "1.0.0"}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
rewrite-clj/rewrite-clj {:mvn/version "1.0.699-alpha"}
selmer/selmer {:mvn/version "1.12.44"}
com.taoensso/timbre {:mvn/version "5.1.2"}
rewrite-clj/rewrite-clj {:mvn/version "1.1.45"}
selmer/selmer {:mvn/version "1.12.50"}
com.taoensso/timbre {:mvn/version "6.0.1"}
org.clojure/tools.logging {:mvn/version "1.1.0"}
org.clojure/data.priority-map {:mvn/version "1.1.0"}
instaparse/instaparse {:mvn/version "1.4.10"}}
instaparse/instaparse {:mvn/version "1.4.10"}
insn/insn {:mvn/version "0.5.2"}
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
org.babashka/cli {:mvn/version "0.6.41"}}
:aliases {:babashka/dev
{:main-opts ["-m" "babashka.main"]}
:profile
@ -56,7 +64,7 @@
:lib-tests
{:extra-paths ["process/src" "process/test" "test-resources/lib_tests"]
:extra-deps {org.clj-commons/clj-http-lite {:mvn/version "0.4.392"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
#_#_org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:sha "0dec1f88cbde74a0470b454396f09a03adb4ae39"}
lambdaisland/regal {:mvn/version "0.0.143"}
cprop/cprop {:mvn/version "0.1.16"}
@ -106,13 +114,15 @@
environ/environ {:mvn/version "1.2.0"}
table/table {:git/url "https://github.com/cldwalker/table", :sha "f6293c5f3dac1dd6f525a80fc80930f8ccdf16b7"}
markdown-clj/markdown-clj {:mvn/version "1.10.8"}
org.clojure/tools.namespace {:git/url "https://github.com/babashka/tools.namespace", :sha "a13b037215e21a2e71aa34b27e1dd52c801a2a7b"}
org.clojure/tools.namespace {:git/sha "daf82a10e70182aea4c0716a48f3922163441b32",
:git/url "https://github.com/clojure/tools.namespace"}
medley/medley {:mvn/version "1.3.0"}
io.github.cognitect-labs/test-runner {:git/tag "v0.5.0", :git/sha "b3fd0d2"}
io.github.cognitect-labs/test-runner {:git/url "https://github.com/cognitect-labs/test-runner",
:git/sha "7284cda41fb9edc0f3bc6b6185cfb7138fc8a023"}
borkdude/missing.test.assertions {:git/url "https://github.com/borkdude/missing.test.assertions", :sha "603cb01bee72fb17addacc53c34c85612684ad70"}
dev.nubank/docopt {:mvn/version "0.6.1-fix7"}
testdoc/testdoc {:mvn/version "1.4.1"}
org.clojars.lispyclouds/contajners {:mvn/version "0.0.4"}
org.clojars.lispyclouds/contajners {:mvn/version "0.0.6"}
borkdude/rewrite-edn {:mvn/version "0.1.0"}
clojure-term-colors/clojure-term-colors {:mvn/version "0.1.0"}
io.aviso/pretty {:mvn/version "1.1.1"}
@ -129,17 +139,48 @@
clojure-msgpack/clojure-msgpack {:mvn/version "1.2.1"}
cli-matic/cli-matic {:git/url "https://github.com/l3nz/cli-matic.git", :git/sha "9cd53ba7336363e3d06650dbad413b6f8b06e471"}
aysylu/loom {:mvn/version "1.0.2"}
com.layerware/hugsql-core {:mvn/version "0.5.1"}
com.github.seancorfield/expectations {:mvn/version "2.0.157"}}
com.layerware/hugsql-core {:mvn/version "0.5.3"}
com.github.seancorfield/expectations {:mvn/version "2.0.157"}
com.rpl/specter {:mvn/version "1.1.4"}
com.github.askonomm/clarktown {:mvn/version "1.1.2"}
org.clojure/math.numeric-tower {:git/tag "math.numeric-tower-0.0.5", :git/sha "12eb9c5", :git/url "https://github.com/clojure/math.numeric-tower"}
prismatic/schema {:git/url "https://github.com/plumatic/schema"
:git/sha "6846dc7c3a9df5bfd718f68f183c683ce0f621ff"
:git/tag "schema-1.3.0"}
metosin/malli {:git/url "https://github.com/metosin/malli"
:git/sha "588147ef49b2e41c7d12a8aa994b39c1c6fedd99"
:git/tag "0.8.9"}
meander/epsilon {:git/url "https://github.com/noprompt/meander"
:git/sha "55f5ce70e6ef717e95c58260f6bc725d70c0cb6d"}
cc.qbits/auspex {:git/url "https://github.com/mpenet/auspex"
:git/sha "1a9d7427e60e1a434a764aa820d1c53f7e22504a"
:deps/manifest :deps}
exoscale/interceptor {:git/url "https://github.com/exoscale/interceptor"
:git/sha "ca115fe00a0abf3a2f78452ab309c3aa4c00fc4e"
:deps/manifest :deps}
lambdaisland/uri {:git/url "https://github.com/lambdaisland/uri"
:git/sha "ac4f1f9c8e4f45a088db1c6383ce2191c973987c"
:deps/manifest :deps}
clj-commons/fs {:mvn/version "1.6.310"}
postmortem/postmortem {:git/url "https://github.com/athos/Postmortem"
:git/sha "1a29775a3d286f9f6fe3f979c78b6e2bf298d5ba"}
com.github.rawleyfowler/sluj {:git/url "https://github.com/rawleyfowler/sluj"
:git/sha "4a92e772b4e07bf127423448d4140748b5782198"
:deps/manifest :deps}}
:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil}}
:clj-nvd
{:extra-deps {clj-nvd/clj-nvd {:git/url "https://github.com/miikka/clj-nvd.git"
:sha "f2ec98699e057a379baf170cb49cf7ad76874a70"}}
:main-opts ["-m" "clj-nvd.core"]}
:test ;; added by neil
:test
{:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}
nubank/matcher-combinators {:mvn/version "3.6.0"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}}
:exec-fn cognitect.test-runner.api/test}
:test-pod
{:extra-paths ["test-resources"]
:main-opts ["-m" "babashka.main" "test-resources/pod.clj"]}}}
;; release

View file

@ -3,24 +3,24 @@
## Prerequisites
- Install [lein](https://leiningen.org/) for producing uberjars
- Download [GraalVM](https://www.graalvm.org/downloads/). Currently we use *java11-22.0.0.2*.
- Download [GraalVM](https://www.graalvm.org/downloads/). Currently we use *java11-22.3.0*.
- For Windows, installing Visual Studio 2019 with the "Desktop development
with C++" workload is recommended.
- Set `$GRAALVM_HOME` to the GraalVM distribution directory. On macOS this can look like:
``` shell
export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-22.0.0.2/Contents/Home
export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-22.3.0/Contents/Home
```
On linux:
``` shell
export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-22.0.0.2
export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-22.3.0
```
On Windows, from the [Visual Studio 2019 x64 Native Tools Command Prompt](https://github.com/oracle/graal/issues/2116#issuecomment-590470806) or `cmd.exe` (not Powershell):
```
set GRAALVM_HOME=%USERPROFILE%\Downloads\graalvm-ce-java11-22.0.0.2
set GRAALVM_HOME=%USERPROFILE%\Downloads\graalvm-ce-java11-22.3.0
```
If you are not running from the x64 Native Tools Command Prompt, you will need to set additional environment variables using:
```

View file

@ -61,6 +61,7 @@ Sponsoring via [Cognitect](https://www.cognitect.com/).
- [Datil](https://datil.com/)
- [Deon Digital](https://www.deondigital.com/)
- [Fluent](https://fluent.to/)
- [Fluree](https://flur.ee/)
- [Hi](https://www.hi.group/)
- [Juxt](https://www.juxt.pro/)
- [Latacora](https://www.latacora.com/)

View file

@ -37,7 +37,7 @@ reasons:
## Requirements
You need [lein](https://leiningen.org/) for running JVM tests and/or producing uberjars. For building binaries you need GraalVM. Currently we use java11-22.0.0.2.
You need [lein](https://leiningen.org/) for running JVM tests and/or producing uberjars. For building binaries you need GraalVM. Currently we use java11-22.3.0.
## Clone repository
@ -81,8 +81,14 @@ Test the native version:
## Tests for Libraries
Babashka runs tests of libraries that are compatible with it through
`script/run_lib_tests`. The script `add-libtest.clj` makes adding new libraries
fairly easy. Some examples:
`script/run_lib_tests`.
You can check out [this
commit](https://github.com/babashka/babashka/commit/8d9ac4c4d18a5588a4a258a61a9db3835b4f4e5c)
for how to add tests for a library that needs no changes to its tests.
The library is cloned as a git dependency, which also includes the tests, that are then added to the test's classpath and ran.
If a library's tests needs changes, we copy the tests using the `add-libtest.clj` script. Examples:
```sh
# To add tests for a new library on clojars

5
doc/fly_io/Dockerfile Normal file
View file

@ -0,0 +1,5 @@
FROM babashka/babashka:0.8.2
COPY example.clj /
ENTRYPOINT bb /example.clj

19
doc/fly_io/README.md Normal file
View file

@ -0,0 +1,19 @@
# Deploying a babashka app to fly.io
[Fly.io](https://fly.io/) is a service that can run full stack apps with minimal
configuration. If you like the ease of Heroku, you might like fly.io and perhaps
even better! This document shows how to get a minimal babashka application up
and running on `fly.io`.
In `example.clj` we start an http-kit web server which spits out some HTML. You
can run this locally by invoking `bb example.clj` from the command line.
To get this site running on `fly.io`, you need to
[install](https://fly.io/docs/getting-started/installing-flyctl/) and [log
in](https://fly.io/docs/getting-started/log-in-to-fly/).
Then run `flyctl launch` to create a new application. After making changes, you
can re-deploy the site with `flyctl deploy`.
That's it! See this
[tweet](https://twitter.com/borkdude/status/1526175120825401344) for a demo.

21
doc/fly_io/example.clj Normal file
View file

@ -0,0 +1,21 @@
(ns example
(:require [hiccup2.core :refer [html]]
[org.httpkit.server :refer [run-server]]))
(def port (or (some-> (System/getenv "PORT")
parse-long)
8092))
(run-server
(fn [_]
{:body
(str (html
[:html
[:body
[:h1 "Hello world!"]
[:p (str "This site is running with babashka v"
(System/getProperty "babashka.version"))]]]))})
{:port port})
(println "Site running on port" port)
@(promise)

41
doc/fly_io/fly.toml Normal file
View file

@ -0,0 +1,41 @@
# fly.toml file generated for shy-sound-2847 on 2022-05-16T14:12:38+02:00
app = "shy-sound-2847"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
PORT = "8092"
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
http_checks = []
internal_port = 8092
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

View file

@ -8,19 +8,24 @@ borkdude/deps,https://github.com/borkdude/deps.clj
borkdude/missing.test.assertions,https://github.com/borkdude/missing.test.assertions
borkdude/rewrite-edn,https://github.com/borkdude/rewrite-edn
camel-snake-kebab/camel-snake-kebab,https://github.com/clj-commons/camel-snake-kebab
cc.qbits/auspex,https://github.com/mpenet/auspex
circleci/bond,https://github.com/circleci/bond
cli-matic/cli-matic,https://github.com/l3nz/cli-matic.git
clj-commons/clj-yaml,https://github.com/clj-commons/clj-yaml
clj-commons/fs,https://github.com/clj-commons/fs
clj-commons/multigrep,https://github.com/clj-commons/multigrep
clj-stacktrace/clj-stacktrace,https://github.com/mmcgrana/clj-stacktrace
clojure-csv/clojure-csv,https://github.com/davidsantiago/clojure-csv
clojure-msgpack/clojure-msgpack,https://github.com/edma2/clojure-msgpack
clojure-term-colors/clojure-term-colors,https://github.com/trhura/clojure-term-colors
com.exoscale/lingo,https://github.com/exoscale/lingo
com.github.askonomm/clarktown,https://github.com/askonomm/clarktown
com.github.rawleyfowler/sluj,https://github.com/rawleyfowler/sluj
com.github.seancorfield/expectations,https://github.com/clojure-expectations/clojure-test
com.github.seancorfield/honeysql,https://github.com/seancorfield/honeysql
com.grammarly/omniconf,https://github.com/grammarly/omniconf
com.layerware/hugsql-core,
com.rpl/specter,https://github.com/redplanetlabs/specter
com.stuartsierra/component,https://github.com/stuartsierra/component
com.stuartsierra/dependency,https://github.com/stuartsierra/dependency
com.wsscode/cljc-misc,https://github.com/wilkerlucio/cljc-misc
@ -34,6 +39,7 @@ douglass/clj-psql,https://github.com/DarinDouglass/clj-psql
edn-query-language/eql,https://github.com/edn-query-language/eql
environ/environ,https://github.com/weavejester/environ
exoscale/coax,https://github.com/exoscale/coax
exoscale/interceptor,https://github.com/exoscale/interceptor
expound/expound,https://github.com/bhb/expound
failjure/failjure,https://github.com/adambard/failjure
ffclj/ffclj,https://github.com/luissantos/ffclj
@ -55,8 +61,10 @@ java-http-clj/java-http-clj,http://www.github.com/schmee/java-http-clj
lambdaisland/regal,https://github.com/lambdaisland/regal
listora/again,https://github.com/liwp/again
markdown-clj/markdown-clj,https://github.com/yogthos/markdown-clj
meander/epsilon,https://github.com/noprompt/meander
medley/medley,https://github.com/weavejester/medley
meta-merge/meta-merge,https://github.com/weavejester/meta-merge
metosin/malli,https://github.com/metosin/malli
minimallist/minimallist,https://github.com/green-coder/minimallist
mvxcvi/arrangement,https://github.com/greglook/clj-arrangement
orchestra/orchestra,https://github.com/jeaye/orchestra
@ -72,9 +80,12 @@ org.clojure/data.generators,https://github.com/clojure/data.generators
org.clojure/data.json,https://github.com/clojure/data.json
org.clojure/data.zip,https://github.com/clojure/data.zip
org.clojure/math.combinatorics,https://github.com/clojure/math.combinatorics
org.clojure/math.numeric-tower,https://github.com/clojure/math.numeric-tower
org.clojure/test.check,https://github.com/clojure/test.check
org.clojure/tools.gitlibs,https://github.com/clojure/tools.gitlibs
org.clojure/tools.namespace,https://github.com/babashka/tools.namespace
postmortem/postmortem,https://github.com/athos/Postmortem
prismatic/schema,https://github.com/plumatic/schema
progrock/progrock,https://github.com/weavejester/progrock
reifyhealth/specmonstah,https://github.com/reifyhealth/specmonstah
rewrite-clj/rewrite-clj,https://github.com/clj-commons/rewrite-clj

1 maven-name git-url
8 borkdude/missing.test.assertions https://github.com/borkdude/missing.test.assertions
9 borkdude/rewrite-edn https://github.com/borkdude/rewrite-edn
10 camel-snake-kebab/camel-snake-kebab https://github.com/clj-commons/camel-snake-kebab
11 cc.qbits/auspex https://github.com/mpenet/auspex
12 circleci/bond https://github.com/circleci/bond
13 cli-matic/cli-matic https://github.com/l3nz/cli-matic.git
14 clj-commons/clj-yaml https://github.com/clj-commons/clj-yaml
15 clj-commons/fs https://github.com/clj-commons/fs
16 clj-commons/multigrep https://github.com/clj-commons/multigrep
17 clj-stacktrace/clj-stacktrace https://github.com/mmcgrana/clj-stacktrace
18 clojure-csv/clojure-csv https://github.com/davidsantiago/clojure-csv
19 clojure-msgpack/clojure-msgpack https://github.com/edma2/clojure-msgpack
20 clojure-term-colors/clojure-term-colors https://github.com/trhura/clojure-term-colors
21 com.exoscale/lingo https://github.com/exoscale/lingo
22 com.github.askonomm/clarktown https://github.com/askonomm/clarktown
23 com.github.rawleyfowler/sluj https://github.com/rawleyfowler/sluj
24 com.github.seancorfield/expectations https://github.com/clojure-expectations/clojure-test
25 com.github.seancorfield/honeysql https://github.com/seancorfield/honeysql
26 com.grammarly/omniconf https://github.com/grammarly/omniconf
27 com.layerware/hugsql-core
28 com.rpl/specter https://github.com/redplanetlabs/specter
29 com.stuartsierra/component https://github.com/stuartsierra/component
30 com.stuartsierra/dependency https://github.com/stuartsierra/dependency
31 com.wsscode/cljc-misc https://github.com/wilkerlucio/cljc-misc
39 edn-query-language/eql https://github.com/edn-query-language/eql
40 environ/environ https://github.com/weavejester/environ
41 exoscale/coax https://github.com/exoscale/coax
42 exoscale/interceptor https://github.com/exoscale/interceptor
43 expound/expound https://github.com/bhb/expound
44 failjure/failjure https://github.com/adambard/failjure
45 ffclj/ffclj https://github.com/luissantos/ffclj
61 lambdaisland/regal https://github.com/lambdaisland/regal
62 listora/again https://github.com/liwp/again
63 markdown-clj/markdown-clj https://github.com/yogthos/markdown-clj
64 meander/epsilon https://github.com/noprompt/meander
65 medley/medley https://github.com/weavejester/medley
66 meta-merge/meta-merge https://github.com/weavejester/meta-merge
67 metosin/malli https://github.com/metosin/malli
68 minimallist/minimallist https://github.com/green-coder/minimallist
69 mvxcvi/arrangement https://github.com/greglook/clj-arrangement
70 orchestra/orchestra https://github.com/jeaye/orchestra
80 org.clojure/data.json https://github.com/clojure/data.json
81 org.clojure/data.zip https://github.com/clojure/data.zip
82 org.clojure/math.combinatorics https://github.com/clojure/math.combinatorics
83 org.clojure/math.numeric-tower https://github.com/clojure/math.numeric-tower
84 org.clojure/test.check https://github.com/clojure/test.check
85 org.clojure/tools.gitlibs https://github.com/clojure/tools.gitlibs
86 org.clojure/tools.namespace https://github.com/babashka/tools.namespace
87 postmortem/postmortem https://github.com/athos/Postmortem
88 prismatic/schema https://github.com/plumatic/schema
89 progrock/progrock https://github.com/weavejester/progrock
90 reifyhealth/specmonstah https://github.com/reifyhealth/specmonstah
91 rewrite-clj/rewrite-clj https://github.com/clj-commons/rewrite-clj

View file

@ -5,6 +5,89 @@ you have anything to add. Also see
[#babashka](https://twitter.com/hashtag/babashka?src=hashtag_click&f=live) on
Twitter.
## [2022-07](https://twitter.com/search?q=(%23babashka)%20until%3A2022-08-01%20since%3A2022-07-01&src=typed_query&f=live)
- [Recursive document transformations with Pandoc and Clojure](https://play.teod.eu/document-transform-pandoc-clojure/) by Teodor Heggelund
- [Babashka toolbox](https://babashka.org/toolbox/): A categorised directory of libraries and tools for Babashka
- [Quickblog](https://github.com/borkdude/quickblog): Light-weight static blog engine for Clojure and babashka
- Win a babashka t-shirt by participating in [this](https://twitter.com/borkdude/status/1547847843381030912) contest!
- [AWS Lambda, now with first class parentheses](https://www.juxt.pro/blog/nbb-lambda) by Ray McDermott (about nbb)
- [bb-github-app](https://github.com/brandonstubbs/bb-github-app): An example Babashka Script authenticating as a Github App and interacting with the Checks API
- [Ruuter](https://github.com/askonomm/ruuter#setting-up-with-babashka) is a routing library which works very well with bb
- [Blambda!](https://jmglov.net/blog/2022-07-03-blambda.html) by Josh Glover
- Files with the `.bb` extension are now correctly highlighted as Clojure code on Github! See [this](https://twitter.com/borkdude/status/1543937735429431298) tweet.
- Encode and decode files as kroki url diagrams, a [gist](https://gist.github.com/henryw374/070845dbd8cfb4672a3c0d06cf8b00e4) by Henry Widd
- Customized bb builds with clj-nix: [tweet](https://twitter.com/jlesquembre/status/1543686641461694470)
- Expose Clojure functions in the CLI with babashka and nix: [tweet](https://twitter.com/jlesquembre/status/1546777332471455745)
- [Meander](https://github.com/noprompt/meander) is now compatible with bb: [tweet](https://twitter.com/borkdude/status/1542881167338250242)
- [Deleting AWS Glacier vaults with babashka](https://javahippie.net/clojure/2022/07/23/deleting-aws-glacier-vaults-with-babashka.html) by Tim Zöller
## [2022-06](https://twitter.com/search?q=(%23babashka)%20until%3A2022-07-01%20since%3A2022-06-01&src=typed_query&f=live)
- Releases: [0.8.156](https://github.com/babashka/babashka/blob/master/CHANGELOG.md).
- [AWS wiki page](https://github.com/babashka/babashka/wiki/AWS)
- [blambda](https://github.com/jmglov/blambda): Blambda! is a custom runtime for AWS Lambda that lets you write functions using Babashka
- [Babashka CLI](https://blog.michielborkent.nl/babashka-cli.html): turn Clojure functions into CLIs!
- [Http-server](https://github.com/babashka/http-server#babashka): Serve static assets
- [Deps-bundler](https://github.com/MrGung/deps-bundler): Bundle dependencies on
a computer that has access to maven and clojars (PC-A) and bring these over to
a computer with limited access (PC-L).
- [Prismatic/schema](https://github.com/plumatic/schema/blob/master/CHANGELOG.md#130-2022-06-10) and babashka are now compatible
- [Logseq bb tasks](https://github.com/logseq/bb-tasks): Reusable babashka tasks used by logseq team
- [Breakneck Babashka on K8s](Breakneck Babashka on K8s) by Heow Goodman
## [2022-05](https://twitter.com/search?q=(%23babashka)%20until%3A2022-06-01%20since%3A2022-05-01&src=typed_query&f=live)
- Releases: [0.8.2](https://github.com/babashka/babashka/blob/master/CHANGELOG.md).
- [Etaoin](https://github.com/clj-commons/etaoin) moved to clj-commons and now works with babashka as well.
- [Nix docs for babashka](https://github.com/babashka/babashka/blob/master/doc/nix.md)
- [Fly.io docs for babashka](https://github.com/babashka/babashka/tree/master/doc/fly_io)
- [Babashka survey results](https://blog.michielborkent.nl/babashka-survey-q1-2022.html)
- [Quickdoc](https://github.com/borkdude/quickdoc): (Quick and minimal API doc generation for Clojure
- [Awyeah-api](https://github.com/grzm/awyeah-api) - Cognitect's aws-api for babashka
## [2022-04](https://twitter.com/search?q=(%23babashka)%20until%3A2022-05-01%20since%3A2022-04-01&src=typed_query&f=live)
- Releases: [0.8.0 - 0.8.1](https://github.com/babashka/babashka/blob/master/CHANGELOG.md).
- [Babashka and Clojure](https://youtu.be/ZvOs5Ele6VE) by Rahul Dé at North Virginia Linux Users Group
- [Setup-Clojure](https://github.com/DeLaGuardo/setup-clojure/releases/tag/5.0) Github action is now able to install babashka!
- Control Chrome via devtools using [clj-chrome-devtools](https://github.com/tatut/clj-chrome-devtools/blob/master/bb.clj) which runs with bb!
- Use pods directly in `bb.edn`: [tweet](https://twitter.com/borkdude/status/1510995356229767172)
## [2022-03](https://twitter.com/search?q=(%23babashka)%20until%3A2022-04-01%20since%3A2022-03-01&src=typed_query&f=live)
- Releases: [0.7.7 - 0.7.8](https://github.com/babashka/babashka/blob/master/CHANGELOG.md).
- [Create a password manager with Clojure using Babashka, sqlite, honeysql and stash](https://youtu.be/jm0RXmyjRJ8) by Daniel Amber
- [Detecting inconsistent aliases in a clojure codebase](https://www.youtube.com/watch?v=bf8KLKkCH2g) by Oxalorg
- [Clj-konmari](https://github.com/oxalorg/clj-konmari/) by Oxalorg
- [Logseq-query](https://github.com/cldwalker/logseq-query) by Gabriel Horner [(announcement tweet with video)](https://twitter.com/cldwalker/status/1506991213030871041)
- The [loom](https://github.com/aysylu/loom) library is now compatible [(tweet)](https://twitter.com/borkdude/status/1502237220811550723)
- The [at-at](https://github.com/overtone/at-at) library is now compatible
## [2022-02](https://twitter.com/search?q=(%23babashka)%20until%3A2022-03-01%20since%3A2022-02-01&src=typed_query&f=live)
- Releases: [0.7.5 - 0.7.6](https://github.com/babashka/babashka/blob/master/CHANGELOG.md).
- [Spire is available as a babashka pod](https://twitter.com/epic_castle/status/1496784352256008194)
- Babashka Clojure template on [Repl.it](https://replit.com/@eccentric-j/Babashka-Clojure-Template?v=1#replit.nix) by Eccentric J
- Create a self-contained executable with [caxa](https://github.com/babashka/babashka/wiki/Self-contained-executable)
- Cli-matic is now compatible due to this [PR](https://github.com/l3nz/cli-matic/pull/145)
- [I, too, Wrote Myself a Static Site Generator](https://dawranliou.com/blog/i-too-wrote-myself-a-static-site-generator/) by Daw-Ran Liou
- [Staplegun](https://github.com/escherize/staplegun): Single file clipboard-manager
- [Bbb](https://github.com/nikvdp/bbb): make executable CLI tools from bb scripts
- [Apptemplate](https://github.com/redstarssystems/apptemplate): Application project template for Clojure featuring bb tasks
## [2022-01](https://twitter.com/search?f=live&q=(%23babashka)%20until%3A2022-02-01%20since%3A2022-01-01&src=typed_query)
- Releases: [0.7.4](https://github.com/babashka/babashka/blob/master/CHANGELOG.md).
- [Babashka dev builds](https://github.com/babashka/babashka-dev-builds)
- [Writing Clojure-living-cookbooks](https://www.loop-code-recur.io/live-clojure-cookbooks/) by Cyprien Pannier
- [HTMX Todo App](https://github.com/prestancedesign/babashka-htmx-todoapp)
- [Better linting for `bb.edn`](https://twitter.com/borkdude/status/1484100071134220291)
- [Unwordle](https://github.com/mknoszlig/unwordle): solver for wordle puzzles
- [Using babashka with PHP](https://blog.michielborkent.nl/using-babashka-with-php.html) by Michiel Borkent
## 2021-12
- Releases: [0.6.8 - 0.7.3](https://github.com/babashka/babashka/blob/master/CHANGELOG.md).
@ -66,7 +149,7 @@ Twitter.
- [Cursive](https://twitter.com/CursiveIDE/status/1439022267187433472) adds support for babashka in 1.11.0
- How to filter tail output with babashka on [StackOverflow](https://stackoverflow.com/questions/69241046/how-to-filter-output-of-tail-with-babashka/69241911?stw=2#69241911)
- [Awesome Babashka: Parse & produce HTML and SQLite](https://blog.jakubholy.net/2021/awesome-babashka-dash/) by Jakub Holy
- [neil](https://github.com/babashka/neil): an installable babashka script to add common aliases and features to deps.edn-based projects.
- [Neil](https://github.com/babashka/neil): an installable babashka script to add common aliases and features to deps.edn-based projects.
## 2021-08

87
doc/nix.md Normal file
View file

@ -0,0 +1,87 @@
# Using Babashka with Nix
Babashka is [packaged](https://search.nixos.org/packages?type=packages&query=babashka) in nixpkgs and can be easily used from the Nix package manager.
The following assumes a recent installation of nix and uses the unstable [nix cli](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html) and [Flakes](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html).
To enable the unstable cli and flakes add the following to `/etc/nix/nix.conf`:
```
extra-experimental-features flakes nix-command
```
## Imperative install on Nix
To imperatively install nix for the current user, run `nix profile install babashka`.
## Declarative global install on NixOS
To install babashka for all users on a NixOS system, place it in `environment.systemPackages` in your `configuration.nix`:
```nix
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
babashka
];
}
```
Then run `nixos-rebuild switch`, to activate the new configuration.
## Declarative per-user install with home-manager
You can install babashka for a specific user using [home-manager](https://github.com/nix-community/home-manager). Add the following to your `~/.config/nixpkgs/home.nix`:
```nix
{ pkgs, ... }:
{
home.packages = with pkgs; [
babashka
];
}
```
Then run `home-manager switch`, to activate the new configuration.
## Per project install with direnv
To make babashka available on a per-project basis, you can use [direnv](https://direnv.net/).
Create a file `.envrc` in the project directory with the following contents:
```
use flake
```
Create a file `flake.nix` in the project directory with the following contents:
```nix
{
outputs = {nixpkgs, ...}: let
supportedSystems = ["x86_64-linux" "x86_64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = system: import nixpkgs {inherit system;};
in {
devShell = forAllSystems (system: let
pkgs = nixpkgsFor system;
in
pkgs.mkShell {
packages = with pkgs; [
babashka
];
});
};
}
```
After running `direnv allow`, babashka should be available on the `$PATH`, when you are inside the project directory.
## Write Babashka Application
You can write babashka scripts with native dependencies using [WriteBabashkaApplication](https://github.com/sohalt/write-babashka-application).
The WriteBabashkaApplication repository has an [example](https://github.com/Sohalt/write-babashka-application/tree/main/example) `flake.nix` using `cowsay` as an external dependency.
You can download that example, and then build the application using `nix build` or run it using `nix run`.

View file

@ -7,7 +7,6 @@ The following libraries and projects are known to work with babashka.
- [tools.namespace](#toolsnamespace)
- [test-runner](#test-runner)
- [spec.alpha](#specalpha)
- [tools.bbuild](#toolsbbuild)
- [clj-http-lite](#clj-http-lite)
- [spartan.spec](#spartanspec)
- [missing.test.assertions](#missingtestassertions)
@ -62,6 +61,11 @@ The following libraries and projects are known to work with babashka.
- [datalog-parser](#datalog-parser)
- [at-at](#at-at)
- [aysylu/loom](#aysyluloom)
- [Clarktown](#clarktown)
- [Malli](#malli)
- [Meander](#meander)
- [Schema](#schema)
- [Sluj](#sluj)
- [Pods](#pods)
- [Projects](#projects-1)
- [babashka-test-action](#babashka-test-action)
@ -88,6 +92,7 @@ The following libraries and projects are known to work with babashka.
- [Babashka + scittle guestbook](#babashka--scittle-guestbook)
- [bb htmx todo app](#bb-htmx-todo-app)
- [bb aws lambda runtime](#bb-aws-lambda-runtime)
- [bb-github-app](#bb-github-app)
Also keep an eye on the [news](news.md) page for new projects, gists and other
developments around babashka.
@ -114,9 +119,9 @@ A fork of `clojure.spec.alpha` that includes support for generation and
instrumentation! Its readme also contains instructions on how to use
`clojure.core.specs.alpha`.
### [tools.bbuild](https://github.com/babashka/tools.bbuild)
<!-- ### [tools.bbuild](https://github.com/babashka/tools.bbuild) -->
A fork of `tools.build`.
<!-- A fork of `tools.build`. -->
### [clj-http-lite](https://github.com/clj-commons/clj-http-lite)
@ -763,7 +768,7 @@ Example:
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {org.clojars.lispyclouds/contajners {:mvn/version "0.0.2"}}})
(deps/add-deps '{:deps {org.clojars.lispyclouds/contajners {:mvn/version "0.0.6"}}})
(require '[contajners.core :as c])
@ -808,6 +813,26 @@ Ahead-of-time function scheduler. Compatible with babashka 0.7.7+.
Graph library for Clojure. Compatible with babashka 0.7.8+.
### [Clarktown](https://github.com/askonomm/clarktown)
An extensible and modular zero-dependency, pure-Clojure Markdown parser.
### [Malli](https://github.com/metosin/malli#babashka)
Data-Driven Schemas for Clojure/Script
### [Meander](https://github.com/noprompt/meander)
Tools for transparent data transformation
### [Schema](https://github.com/plumatic/schema)
Clojure(Script) library for declarative data description and validation
### [Sluj](https://github.com/rawleyfowler/sluj)
Sluj is a very small library for converting strings of UTF-16 text to slugs. A slug is a piece of text that is URL safe.
## Pods
[Babashka pods](https://github.com/babashka/babashka.pods) are programs that can
@ -875,7 +900,7 @@ A babashka script to obtain covid-19 related information.
### [bb-spotify](https://github.com/kolharsam/bb-spotify)
Contol your spotify player using babashka.
Control your spotify player using babashka.
### [lambdaisland/open-source](https://github.com/lambdaisland/open-source)
@ -935,3 +960,8 @@ Quick example of a todo list SPA using Babashka and htmx.
### [bb aws lambda runtime](https://github.com/tatut/bb-lambda)
AWS Lambda custom runtime for Babashka scripts.
### [bb-github-app](https://github.com/brandonstubbs/bb-github-app)
An example Babashka script that can authenticate as a Github Application,
this example focuses on the checks api.

View file

@ -38,6 +38,8 @@
- [Simple logger](#simple-logger)
- [Using GZip streams (memo utility)](#using-gzip-streams-to-make-a-note-utility)
- [Pretty-printing mySQL results](#pretty-printing-mysql-results)
- [Single page application with Babashka + htmx](#single-page-application-with-babashka--htmx)
- [Wikipedia translation](#wikipedia-translation)
Here's a gallery of useful examples. Do you have a useful example? PR welcome!
@ -390,7 +392,7 @@ Example usage:
$ examples/http-server.clj
```
See [file-server.clj](file-server.clj).
See [http-server.clj](http-server.clj).
## Torrent viewer
@ -555,3 +557,14 @@ Example of a todo list SPA using Babashka and htmx
See [htmx_todoapp.clj](htmx_todoapp.clj)
Contributed by [@prestancedesign](https://github.com/prestancedesign).
## Wikipedia translation
[wiki-translate.clj](wiki-translate.clj) uses Wikipedia to translate words from English to Dutch (other languages are available).
``` shell
$ bb wiki-translate.clj window
"Venster (muur) Dutch"
```
Shared by Janne Himanka on Clojurians Slack

View file

@ -1,18 +1,18 @@
(ns normalize-keywords
(:require [babashka.pods :as pods]
[clojure.java.io :as io]
[rewrite-clj.node :as node]
[rewrite-clj.zip :as z]))
(pods/load-pod 'borkdude/clj-kondo "2021.06.18")
(pods/load-pod 'clj-kondo/clj-kondo "2022.11.02")
(require '[pod.borkdude.clj-kondo :as clj-kondo])
(def code (first *command-line-args*))
(def findings
(->> (with-in-str code
(clj-kondo/run! {:lint [code]
:config {:output {:analysis {:keywords true}}}}))
(defn findings [file-path]
(->> (clj-kondo/run! {:lint [file-path]
:config {:output {:analysis {:keywords true}}}})
:analysis
:keywords
(filter (some-fn :alias :auto-resolved))))
@ -33,6 +33,11 @@
zloc (z/replace zloc (node/coerce k))]
(recur zloc (next findings)))
(recur (z/next zloc) findings)))
(println (str (z/root zloc))))))
(str (z/root zloc)))))
(remove-locs (z/of-file code) findings)
(doseq [f (file-seq (io/file code))
:when (re-find #"\.clj[cdsx]?$" (str f))
:let [file-path (str f)]]
(when-let [findings' (findings file-path)]
(prn (format "Rewriting %s" file-path))
(spit f (remove-locs (z/of-file file-path) findings'))))

View file

@ -0,0 +1,11 @@
#!/usr/bin/env bb
;; by Janne Himanka shared on Clojurians Slack
(require '[babashka.curl :as curl])
(let [url (str "https://en.wikipedia.org/wiki/" (first *command-line-args*))
page (:body (curl/get url))]
(cond
(re-find #"Disambiguation" page)
(doseq [item (map last (re-seq #"<li><a href...wiki/([^\"]+)" page))]
(println item))
:else (last (re-find #"nl.wikipedia.org/.+?title..([^\"]+)" page))))

View file

@ -2,11 +2,10 @@
{:no-doc true}
(:require [datascript.core :as d]
[datascript.db :as db]
[sci.impl.namespaces :refer [copy-var]]
[sci.impl.vars :as vars]))
[sci.core :as sci :refer [copy-var]]))
(def datascript-ns (vars/->SciNamespace 'datascript.core nil))
(def datascript-db-ns (vars/->SciNamespace 'datascript.db nil))
(def datascript-ns (sci/create-ns 'datascript.core nil))
(def datascript-db-ns (sci/create-ns 'datascript.db nil))
(def datascript-namespace
{'create-conn (copy-var d/create-conn datascript-ns)

View file

@ -52,10 +52,11 @@
util/raw-string)
(def hiccup-namespace
{'html (copy-var html-1 hns)})
{'html (copy-var html-1 hns {:name 'html})})
(def hiccup2-namespace
{'html (copy-var html-2 hns2)})
{'html (copy-var html-2 hns2 {:name 'html})
'raw (copy-var util/raw-string hns2 {:name 'raw})})
(def html-mode (copy-var util/*html-mode* uns))
(def escape-strings? (copy-var util/*escape-strings?* uns))
@ -63,7 +64,8 @@
(def hiccup-util-namespace
{'*html-mode* html-mode
'*escape-strings?* escape-strings?
'raw-string (copy-var util/raw-string uns)})
'raw-string (copy-var util/raw-string uns)
'to-uri (copy-var util/to-uri uns)})
(defn render-html [& contents]
(binding [util/*html-mode* @html-mode

View file

@ -72,8 +72,10 @@
'acl (copy-var acl cns)
'unlock (copy-var unlock cns)
'default-client (copy-var client/default-client cns)
'*default-client* default-client})
'*default-client* default-client
'query-string (copy-var client/query-string cns)
'url-encode (copy-var client/url-encode cns)})
(def sni-client-namespace
{'ssl-configurer (copy-var sni-client/ssl-configurer sns)
'default-client (sci/new-var 'sni-client sni-client {:ns sns})})
'default-client (sci/new-var 'default-client sni-client {:ns sns})})

View file

@ -8,6 +8,7 @@
{:obj sns
'server-stop! (copy-var server/server-stop! sns)
'server-port (copy-var server/server-port sns)
'server-status (copy-var server/server-status sns)
'run-server (copy-var server/run-server sns)
'sec-websocket-accept (copy-var server/sec-websocket-accept sns)
'websocket-handshake-check (copy-var server/websocket-handshake-check sns)

View file

@ -1,12 +1,12 @@
(ns babashka.impl.jdbc
{:no-doc true}
(:require [next.jdbc :as njdbc]
(:require
[next.jdbc :as njdbc]
[next.jdbc.result-set :as rs]
[next.jdbc.sql :as sql]
[sci.impl.namespaces :refer [copy-var macrofy]]
[sci.impl.vars :as vars]))
[sci.core :as sci]))
(def next-ns (vars/->SciNamespace 'next.jdbc nil))
(def next-ns (sci/create-ns 'next.jdbc nil))
(defn with-transaction
"Given a transactable object, gets a connection and binds it to `sym`,
@ -19,30 +19,30 @@
* `:rollback-only` -- `true` / `false`."
[_ _ [sym transactable opts] & body]
(let [con (vary-meta sym assoc :tag 'java.sql.Connection)]
`(next.jdbc/transact ~transactable (^{:once true} fn* [~con] ~@body) ~(or opts {}))))
`(njdbc/transact ~transactable (^{:once true} fn* [~con] ~@body) ~(or opts {}))))
(def njdbc-namespace
{'get-datasource (copy-var njdbc/get-datasource next-ns)
'execute! (copy-var njdbc/execute! next-ns)
'execute-one! (copy-var njdbc/execute-one! next-ns)
'get-connection (copy-var njdbc/get-connection next-ns)
'plan (copy-var njdbc/plan next-ns)
'prepare (copy-var njdbc/prepare next-ns)
'transact (copy-var njdbc/transact next-ns)
'with-transaction (macrofy 'with-transaction with-transaction next-ns)})
{'get-datasource (sci/copy-var njdbc/get-datasource next-ns)
'execute! (sci/copy-var njdbc/execute! next-ns)
'execute-one! (sci/copy-var njdbc/execute-one! next-ns)
'get-connection (sci/copy-var njdbc/get-connection next-ns)
'plan (sci/copy-var njdbc/plan next-ns)
'prepare (sci/copy-var njdbc/prepare next-ns)
'transact (sci/copy-var njdbc/transact next-ns)
'with-transaction (sci/copy-var with-transaction next-ns)})
(def sns (vars/->SciNamespace 'next.jdbc.sql nil))
(def sns (sci/create-ns 'next.jdbc.sql nil))
(def next-sql-namespace
{'insert-multi! (copy-var sql/insert-multi! sns)})
{'insert-multi! (sci/copy-var sql/insert-multi! sns)})
(def rsns (vars/->SciNamespace 'next.jdbc.result-set nil))
(def rsns (sci/create-ns 'next.jdbc.result-set nil))
(def result-set-namespace
{'as-maps (copy-var rs/as-maps rsns)
'as-unqualified-maps (copy-var rs/as-unqualified-maps rsns)
'as-modified-maps (copy-var rs/as-modified-maps rsns)
'as-unqualified-modified-maps (copy-var rs/as-unqualified-modified-maps rsns)
'as-lower-maps (copy-var rs/as-lower-maps rsns)
'as-unqualified-lower-maps (copy-var rs/as-unqualified-lower-maps rsns)
'as-maps-adapter (copy-var rs/as-maps-adapter rsns)})
{'as-maps (sci/copy-var rs/as-maps rsns)
'as-unqualified-maps (sci/copy-var rs/as-unqualified-maps rsns)
'as-modified-maps (sci/copy-var rs/as-modified-maps rsns)
'as-unqualified-modified-maps (sci/copy-var rs/as-unqualified-modified-maps rsns)
'as-lower-maps (sci/copy-var rs/as-lower-maps rsns)
'as-unqualified-lower-maps (sci/copy-var rs/as-unqualified-lower-maps rsns)
'as-maps-adapter (sci/copy-var rs/as-maps-adapter rsns)})

View file

@ -0,0 +1,7 @@
(ns babashka.impl.rrb-vector
(:require [clojure.core.rrb-vector :as rrb]
[sci.core :as sci]))
(def rrbns (sci/create-ns 'clojure.core.rrb-vector))
(def rrb-vector-namespace {'catvec (sci/copy-var rrb/catvec rrbns)})

View file

@ -60,7 +60,7 @@
(selmer.parser/render-template template context-map)))
(defn sci-ns-resolve [ns fqs]
(sci/eval-form @ctx (list 'clojure.core/ns-resolve ns (list 'quote fqs))))
(sci/eval-form (ctx) (list 'clojure.core/ns-resolve ns (list 'quote fqs))))
(defn force! [x]
(if (instance? clojure.lang.IDeref x) @x x))

View file

@ -4,12 +4,11 @@
[babashka.impl.clojure.spec.gen.alpha :as gen]
[babashka.impl.clojure.spec.test.alpha :as test]
[clojure.core :as c]
[sci.core :as sci :refer [copy-var]]
[sci.impl.vars :as vars]))
[sci.core :as sci :refer [copy-var]]))
(def sns (vars/->SciNamespace 'clojure.spec.alpha nil))
(def tns (vars/->SciNamespace 'clojure.spec.test.alpha nil))
(def gns (vars/->SciNamespace 'clojure.spec.gen.alpha nil))
(def sns (sci/create-ns 'clojure.spec.alpha nil))
(def tns (sci/create-ns 'clojure.spec.test.alpha nil))
(def gns (sci/create-ns 'clojure.spec.gen.alpha nil))
(defn- ns-qualify
"Qualify symbol s by resolving it or using the current *ns*."

View file

@ -1,10 +1,9 @@
(ns babashka.impl.transit
(:require [cognitect.transit :as transit]
[sci.impl.namespaces :refer [copy-var]]
[sci.impl.vars :as vars]))
(:require
[cognitect.transit :as transit]
[sci.core :as sci :refer [copy-var]]))
(def tns (vars/->SciNamespace 'cognitect.transit nil))
(def tns (sci/create-ns 'cognitect.transit nil))
(def transit-namespace
{'write (copy-var transit/write tns)

View file

@ -12,7 +12,7 @@
(def xtns (sci/create-ns 'clojure.data.xml.tree nil))
(defn- clj-ns-name [ns]
(cond (instance? sci.impl.vars.SciNamespace ns) (str ns)
(cond (instance? sci.lang.Namespace ns) (str ns)
(keyword? ns) (name ns)
:else (str ns)))
@ -40,8 +40,8 @@
#_(assert (<= (count ans)) (pr-str ans))
(let [xn (xml/uri-symbol n)
al (symbol (clj-ns-name a))]
(sci/eval-form @ctx `(create-ns (quote ~xn)))
(sci/eval-form @ctx `(alias (quote ~al) (quote ~xn)))
(sci/eval-form (ctx) `(create-ns (quote ~xn)))
(sci/eval-form (ctx) `(alias (quote ~al) (quote ~xn)))
(recur rst)))))
(def xml-namespace

2
fs

@ -1 +1 @@
Subproject commit 2bf527f797d69b3f14247940958e0d7b509f3ce2
Subproject commit d3226cccd9898eba5adb50dfcc30a7223ff5c8cc

32
install
View file

@ -8,6 +8,7 @@ static_binary="false"
default_install_dir="/usr/local/bin"
install_dir="$default_install_dir"
download_dir=""
dev_build=""
print_help() {
echo "Installs latest (or specific) version of babashka. Installation directory defaults to /usr/local/bin."
@ -56,6 +57,10 @@ do
static_binary="true"
shift
;;
--dev-build)
dev_build="true"
shift
;;
*) # unknown option
print_help
shift
@ -74,23 +79,38 @@ if [[ "$checksum" != "" ]] && [[ "$version" == "" ]]; then
fi
if [[ "$version" == "" ]]; then
if [[ "$dev_build" == "true" ]]; then
version="$(curl -sL https://raw.githubusercontent.com/babashka/babashka/master/resources/BABASHKA_VERSION)"
else
version="$(curl -sL https://raw.githubusercontent.com/babashka/babashka/master/resources/BABASHKA_RELEASED_VERSION)"
fi
fi
case "$(uname -s)" in
Linux*) platform=linux;;
Darwin*) platform=macos;;
esac
case "$(uname -m)" in
aarch64) arch=aarch64;;
*) arch=amd64;;
esac
# Ugly ugly conversion of version to a comparable number
IFS='.' read -ra VER <<< "${version//-SNAPSHOT/}"
vernum=$(printf "%03d%03d%03d" "${VER[0]}" "${VER[1]}" "${VER[2]}")
case "$(uname -m)" in
aarch64) arch=aarch64;;
arm64) if [[ 10#$vernum -le 10#000008002 ]]; then
arch="amd64"
else
arch="aarch64"
fi
;;
*) arch=amd64
# always use static image on linux
if [[ "$platform" == "linux" ]]; then
static_binary="true"
fi
;;
esac
if [[ 10#$vernum -le 10#000002013 ]]; then
ext="zip"
util="$(which unzip) -qqo"
@ -119,7 +139,7 @@ fi
download_url="https://github.com/babashka/$repo/releases/download/v$version/$filename"
# macOS only have shasum available by default
# Some Linux distros (RHEL-like) only have sha256sum avaiable by default (others have both)
# Some Linux distros (RHEL-like) only have sha256sum available by default (others have both)
if command -v sha256sum >/dev/null; then
sha256sum_cmd="sha256sum"
elif command -v shasum >/dev/null; then

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="882" height="648" viewBox="0 0 2944 2162" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1742.91 1219.89C1857.93 1138.38 1933 1004.21 1933 852.5C1933 603.972 1761 280.5 1483 139C1207.5 288 1033 603.972 1033 852.5C1033 1004.21 1108.07 1138.38 1223.09 1219.89C1218.98 1220.44 1214.95 1221.14 1211 1222C1123.61 1241.07 1017 1385.05 1017 1385.05H1281C1327.97 1385.05 1372.63 1367.41 1407.96 1347.62C1425.12 1370.32 1452.34 1385 1483 1385C1513.66 1385 1540.89 1370.32 1558.04 1347.62C1593.37 1367.41 1638.03 1385.05 1685 1385.05H1949C1949 1385.05 1842.39 1241.07 1755 1222C1751.05 1221.14 1747.02 1220.44 1742.91 1219.89Z" style="fill-rule: evenodd; fill: rgb(0, 91, 187);"/>
<circle cx="1482.5" cy="878.5" r="311.5" style="fill: rgb(255, 213, 0);"/>
<path d="M1212 745.5C1396.5 758.5 1505.5 713.5 1581 602C1581 602 1435.5 553 1347 602C1258.8 650.834 1212 745.5 1212 745.5Z" fill="#B4B4B4"/>
<path d="M1728 718C1654 710 1588 686 1556.5 595.5C1556.5 595.5 1621.93 610.435 1688 670.614C1756.62 733.114 1728 718 1728 718Z" fill="#B4B4B4"/>
<circle cx="1482.5" cy="878.5" r="311.5" stroke="#0A0000" stroke-width="40"/>
<path d="M1544 745H1421L1451 775V865C1455.5 835.5 1511.5 834.5 1514.5 865L1522 775L1544 745Z" fill="black"/>
<path d="M1098.12 785C1098.12 762.909 1116.03 745 1138.12 745H1423.02C1447.2 745 1465.85 766.292 1462.67 790.264L1437.91 976.764C1435.27 996.646 1418.31 1011.5 1398.26 1011.5H1138.12C1116.03 1011.5 1098.12 993.591 1098.12 971.5V785Z" fill="black"/>
<path d="M1216.1 967.55V951.05H1210.55C1206.95 951.05 1204.55 948.5 1203.35 944.75L1180.55 876.05C1179.05 871.7 1177.25 868.55 1174.85 866.15C1170.35 861.5 1164.5 860 1157.9 860H1150.7V877.25H1155.5C1159.55 877.25 1162.7 878.75 1164.05 883.55L1167.2 894.65L1139 967.55H1159.55L1176.5 919.55L1185.5 948.5C1188.95 959.75 1194.8 967.55 1208 967.55H1216.1Z" fill="white"/>
<path d="M1248.8 951.05V967.55H1304.8V951.05H1248.8Z" fill="white"/>
<path d="M1503.01 790.267C1499.83 766.294 1518.48 745 1542.66 745H1827C1849.09 745 1867 762.909 1867 785V971.096C1867 993.187 1849.09 1011.1 1827 1011.1H1567.38C1547.33 1011.1 1530.37 996.244 1527.73 976.362L1503.01 790.267Z" fill="black"/>
<path d="M1649.3 968V951.5H1643.75C1640.15 951.5 1637.75 948.95 1636.55 945.2L1613.75 876.5C1612.25 872.15 1610.45 869 1608.05 866.6C1603.55 861.95 1597.7 860.45 1591.1 860.45H1583.9V877.7H1588.7C1592.75 877.7 1595.9 879.2 1597.25 884L1600.4 895.1L1572.2 968H1592.75L1609.7 920L1618.7 948.95C1622.15 960.2 1628 968 1641.2 968H1649.3Z" fill="white"/>
<path d="M1682 951.5V968H1738V951.5H1682Z" fill="white"/>
<path d="M 245.923 1712.64 C 254.47 1701.19 264.812 1692.21 276.949 1685.72 C 289.085 1679.05 301.991 1675.72 315.667 1675.72 C 349.684 1675.72 374.897 1688.37 391.308 1713.67 C 407.889 1738.79 416.18 1774.26 416.18 1820.08 C 416.18 1848.45 411.906 1873.67 403.359 1895.72 C 394.983 1917.6 382.59 1934.78 366.18 1947.26 C 349.94 1959.56 330.282 1965.72 307.205 1965.72 C 293.53 1965.72 280.795 1962.81 269 1957 C 257.376 1951.36 247.633 1943.15 239.769 1932.38 L 236.692 1957 L 164.897 1957 L 164.897 1576.49 L 245.923 1568.03 L 245.923 1712.64 Z M 285.923 1906.74 C 317.034 1906.74 332.59 1878.2 332.59 1821.1 C 332.59 1799.22 330.88 1782.04 327.462 1769.56 C 324.043 1756.91 319.171 1748.11 312.846 1743.15 C 306.692 1738.03 299.085 1735.46 290.026 1735.46 C 273.274 1735.46 258.573 1745.97 245.923 1767 L 245.923 1881.87 C 251.222 1890.25 257.034 1896.49 263.359 1900.59 C 269.855 1904.69 277.376 1906.74 285.923 1906.74 Z" style="fill: rgb(0, 91, 187);"/>
<path d="M 701.745 1878.54 C 701.745 1888.62 703.113 1896.06 705.848 1900.85 C 708.583 1905.46 713.198 1908.97 719.694 1911.36 L 703.027 1964.69 C 686.446 1963.15 672.686 1959.56 661.745 1953.92 C 650.976 1948.11 642.515 1939.74 636.361 1928.79 C 626.275 1940.93 613.198 1950.16 597.13 1956.49 C 581.233 1962.64 564.395 1965.72 546.617 1965.72 C 528.156 1965.72 511.916 1962.13 497.899 1954.95 C 484.053 1947.6 473.369 1937.51 465.848 1924.69 C 458.327 1911.7 454.566 1896.83 454.566 1880.08 C 454.566 1860.59 459.78 1843.92 470.207 1830.08 C 480.634 1816.23 495.763 1805.72 515.592 1798.54 C 535.421 1791.19 559.267 1787.51 587.13 1787.51 L 623.797 1787.51 L 623.797 1777.26 C 623.797 1749.39 605.848 1735.46 569.951 1735.46 C 560.891 1735.46 549.438 1736.74 535.592 1739.31 C 521.916 1741.87 508.498 1745.38 495.335 1749.82 L 476.617 1695.97 C 493.711 1689.48 511.745 1684.52 530.72 1681.1 C 549.694 1677.51 567.045 1675.72 582.771 1675.72 C 622.771 1675.72 652.6 1683.84 672.258 1700.08 C 691.916 1716.32 701.745 1740.25 701.745 1771.87 L 701.745 1878.54 Z M 574.566 1907.77 C 583.797 1907.77 593.113 1905.12 602.515 1899.82 C 611.916 1894.35 619.01 1887 623.797 1877.77 L 623.797 1833.67 L 603.797 1833.67 C 581.574 1833.67 565.079 1837.09 554.31 1843.92 C 543.54 1850.76 538.156 1860.93 538.156 1874.44 C 538.156 1885.03 541.318 1893.24 547.643 1899.05 C 554.139 1904.86 563.113 1907.77 574.566 1907.77 Z" style="fill: rgb(0, 91, 187);"/>
<path d="M984.204 1711.64C992.751 1700.19 1003.09 1691.21 1015.23 1684.72C1027.37 1678.05 1040.27 1674.72 1053.95 1674.72C1087.97 1674.72 1113.18 1687.37 1129.59 1712.67C1146.17 1737.79 1154.46 1773.26 1154.46 1819.08C1154.46 1847.45 1150.19 1872.67 1141.64 1894.72C1133.26 1916.6 1120.87 1933.78 1104.46 1946.26C1088.22 1958.56 1068.56 1964.72 1045.49 1964.72C1031.81 1964.72 1019.08 1961.81 1007.28 1956C995.657 1950.36 985.914 1942.15 978.05 1931.38L974.974 1956H903.179V1575.49L984.204 1567.03V1711.64ZM1024.2 1905.74C1055.32 1905.74 1070.87 1877.2 1070.87 1820.1C1070.87 1798.22 1069.16 1781.04 1065.74 1768.56C1062.32 1755.91 1057.45 1747.11 1051.13 1742.15C1044.97 1737.03 1037.37 1734.46 1028.31 1734.46C1011.55 1734.46 996.854 1744.97 984.204 1766V1880.87C989.503 1889.25 995.315 1895.49 1001.64 1899.59C1008.14 1903.69 1015.66 1905.74 1024.2 1905.74Z" style="fill: rgb(0, 91, 187);"/>
<path d="M1440.03 1877.54C1440.03 1887.62 1441.39 1895.06 1444.13 1899.85C1446.86 1904.46 1451.48 1907.97 1457.98 1910.36L1441.31 1963.69C1424.73 1962.15 1410.97 1958.56 1400.03 1952.92C1389.26 1947.11 1380.8 1938.74 1374.64 1927.79C1364.56 1939.93 1351.48 1949.16 1335.41 1955.49C1319.51 1961.64 1302.68 1964.72 1284.9 1964.72C1266.44 1964.72 1250.2 1961.13 1236.18 1953.95C1222.33 1946.6 1211.65 1936.51 1204.13 1923.69C1196.61 1910.7 1192.85 1895.83 1192.85 1879.08C1192.85 1859.59 1198.06 1842.92 1208.49 1829.08C1218.92 1815.23 1234.04 1804.72 1253.87 1797.54C1273.7 1790.19 1297.55 1786.51 1325.41 1786.51H1362.08V1776.26C1362.08 1748.39 1344.13 1734.46 1308.23 1734.46C1299.17 1734.46 1287.72 1735.74 1273.87 1738.31C1260.2 1740.87 1246.78 1744.38 1233.62 1748.82L1214.9 1694.97C1231.99 1688.48 1250.03 1683.52 1269 1680.1C1287.98 1676.51 1305.33 1674.72 1321.05 1674.72C1361.05 1674.72 1390.88 1682.84 1410.54 1699.08C1430.2 1715.32 1440.03 1739.25 1440.03 1770.87V1877.54ZM1312.85 1906.77C1322.08 1906.77 1331.39 1904.12 1340.8 1898.82C1350.2 1893.35 1357.29 1886 1362.08 1876.77V1832.67H1342.08C1319.86 1832.67 1303.36 1836.09 1292.59 1842.92C1281.82 1849.76 1276.44 1859.93 1276.44 1873.44C1276.44 1884.03 1279.6 1892.24 1285.92 1898.05C1292.42 1903.86 1301.39 1906.77 1312.85 1906.77Z" style="fill: rgb(0, 91, 187);"/>
<path d="M1627.64 1906.77C1641.49 1906.77 1652.43 1904.63 1660.46 1900.36C1668.67 1895.91 1672.77 1889.5 1672.77 1881.13C1672.77 1875.15 1671.15 1870.27 1667.9 1866.51C1664.65 1862.58 1658.58 1858.91 1649.7 1855.49C1640.81 1851.9 1626.96 1847.54 1608.16 1842.41C1580.81 1835.06 1559.87 1824.97 1545.34 1812.15C1530.98 1799.33 1523.8 1781.56 1523.8 1758.82C1523.8 1742.41 1528.33 1727.88 1537.39 1715.23C1546.62 1702.58 1560.12 1692.67 1577.9 1685.49C1595.68 1678.31 1617.05 1674.72 1642 1674.72C1685.25 1674.72 1722 1685.74 1752.26 1707.79L1719.95 1755.49C1708.16 1748.31 1695.76 1742.67 1682.77 1738.56C1669.95 1734.46 1657.13 1732.41 1644.31 1732.41C1631.15 1732.41 1621.32 1734.21 1614.82 1737.79C1608.5 1741.21 1605.34 1746.43 1605.34 1753.44C1605.34 1758.22 1606.96 1762.24 1610.21 1765.49C1613.63 1768.74 1619.7 1772.07 1628.41 1775.49C1637.3 1778.91 1651.06 1783.26 1669.7 1788.56C1689.35 1794.03 1705.34 1800.1 1717.64 1806.77C1729.95 1813.26 1739.52 1821.98 1746.36 1832.92C1753.37 1843.69 1756.87 1857.62 1756.87 1874.72C1756.87 1893.86 1751.06 1910.27 1739.44 1923.95C1727.99 1937.45 1712.52 1947.62 1693.03 1954.46C1673.54 1961.3 1651.92 1964.72 1628.16 1964.72C1602.69 1964.72 1579.78 1961.13 1559.44 1953.95C1539.1 1946.6 1521.58 1936.51 1506.87 1923.69L1547.64 1878.05C1558.93 1886.94 1571.32 1893.95 1584.82 1899.08C1598.33 1904.21 1612.6 1906.77 1627.64 1906.77Z" style="fill: rgb(0, 91, 187);"/>
<path d="M1907.06 1710.62C1929.79 1686.68 1956.46 1674.72 1987.06 1674.72C2011.16 1674.72 2029.62 1681.81 2042.44 1696C2055.43 1710.02 2061.93 1730.02 2061.93 1756V1956H1980.9V1778.56C1980.9 1767.45 1980.05 1758.74 1978.34 1752.41C1976.8 1746.09 1974.15 1741.56 1970.39 1738.82C1966.63 1735.91 1961.41 1734.46 1954.75 1734.46C1946.54 1734.46 1938.59 1737.28 1930.9 1742.92C1923.21 1748.56 1915.26 1756.77 1907.06 1767.54V1956H1826.03V1575.49L1907.06 1567.54V1710.62Z" style="fill: rgb(0, 91, 187);"/>
<path d="M2337.72 1956H2256.69V1575.49L2337.72 1567.03V1956ZM2425.67 1804.21L2522.59 1956H2430.28L2340.8 1806.77L2430.28 1683.69H2515.16L2425.67 1804.21Z" style="fill: rgb(0, 91, 187);"/>
<path d="M2793.54 1877.54C2793.54 1887.62 2794.91 1895.06 2797.64 1899.85C2800.38 1904.46 2805 1907.97 2811.49 1910.36L2794.82 1963.69C2778.24 1962.15 2764.48 1958.56 2753.54 1952.92C2742.77 1947.11 2734.31 1938.74 2728.16 1927.79C2718.07 1939.93 2705 1949.16 2688.93 1955.49C2673.03 1961.64 2656.19 1964.72 2638.41 1964.72C2619.95 1964.72 2603.71 1961.13 2589.7 1953.95C2575.85 1946.6 2565.17 1936.51 2557.64 1923.69C2550.12 1910.7 2546.36 1895.83 2546.36 1879.08C2546.36 1859.59 2551.58 1842.92 2562 1829.08C2572.43 1815.23 2587.56 1804.72 2607.39 1797.54C2627.22 1790.19 2651.06 1786.51 2678.93 1786.51H2715.59V1776.26C2715.59 1748.39 2697.64 1734.46 2661.75 1734.46C2652.69 1734.46 2641.23 1735.74 2627.39 1738.31C2613.71 1740.87 2600.29 1744.38 2587.13 1748.82L2568.41 1694.97C2585.51 1688.48 2603.54 1683.52 2622.52 1680.1C2641.49 1676.51 2658.84 1674.72 2674.57 1674.72C2714.57 1674.72 2744.4 1682.84 2764.06 1699.08C2783.71 1715.32 2793.54 1739.25 2793.54 1770.87V1877.54ZM2666.36 1906.77C2675.59 1906.77 2684.91 1904.12 2694.31 1898.82C2703.71 1893.35 2710.81 1886 2715.59 1876.77V1832.67H2695.59C2673.37 1832.67 2656.88 1836.09 2646.11 1842.92C2635.34 1849.76 2629.95 1859.93 2629.95 1873.44C2629.95 1884.03 2633.11 1892.24 2639.44 1898.05C2645.94 1903.86 2654.91 1906.77 2666.36 1906.77Z" style="fill: rgb(0, 91, 187);"/>
<path d="M862 1819C862 1848.27 838.271 1872 809 1872C779.729 1872 756 1848.27 756 1819C756 1789.73 779.729 1766 809 1766C838.271 1766 862 1789.73 862 1819Z" style="fill: rgb(255, 213, 0);"/>
<path d="M2215.5 1819C2215.5 1848.27 2191.77 1872 2162.5 1872C2133.23 1872 2109.5 1848.27 2109.5 1819C2109.5 1789.73 2133.23 1766 2162.5 1766C2191.77 1766 2215.5 1789.73 2215.5 1819Z" style="fill: rgb(255, 213, 0);"/>
</svg>

After

Width:  |  Height:  |  Size: 11 KiB

BIN
logo/babashka_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

31
logo/babashka_red.svg Normal file
View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="882" height="648" viewBox="0 0 2944 2162" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1742.91 1219.89C1857.93 1138.38 1933 1004.21 1933 852.5C1933 603.972 1761 280.5 1483 139C1207.5 288 1033 603.972 1033 852.5C1033 1004.21 1108.07 1138.38 1223.09 1219.89C1218.98 1220.44 1214.95 1221.14 1211 1222C1123.61 1241.07 1017 1385.05 1017 1385.05H1281C1327.97 1385.05 1372.63 1367.41 1407.96 1347.62C1425.12 1370.32 1452.34 1385 1483 1385C1513.66 1385 1540.89 1370.32 1558.04 1347.62C1593.37 1367.41 1638.03 1385.05 1685 1385.05H1949C1949 1385.05 1842.39 1241.07 1755 1222C1751.05 1221.14 1747.02 1220.44 1742.91 1219.89Z" fill="url(#paint0_linear)"/>
<circle cx="1482.5" cy="878.5" r="311.5" fill="white"/>
<path d="M1212 745.5C1396.5 758.5 1505.5 713.5 1581 602C1581 602 1435.5 553 1347 602C1258.8 650.834 1212 745.5 1212 745.5Z" fill="#B4B4B4"/>
<path d="M1728 718C1654 710 1588 686 1556.5 595.5C1556.5 595.5 1621.93 610.435 1688 670.614C1756.62 733.114 1728 718 1728 718Z" fill="#B4B4B4"/>
<circle cx="1482.5" cy="878.5" r="311.5" stroke="#0A0000" stroke-width="40"/>
<path d="M1544 745H1421L1451 775V865C1455.5 835.5 1511.5 834.5 1514.5 865L1522 775L1544 745Z" fill="black"/>
<path d="M1098.12 785C1098.12 762.909 1116.03 745 1138.12 745H1423.02C1447.2 745 1465.85 766.292 1462.67 790.264L1437.91 976.764C1435.27 996.646 1418.31 1011.5 1398.26 1011.5H1138.12C1116.03 1011.5 1098.12 993.591 1098.12 971.5V785Z" fill="black"/>
<path d="M1216.1 967.55V951.05H1210.55C1206.95 951.05 1204.55 948.5 1203.35 944.75L1180.55 876.05C1179.05 871.7 1177.25 868.55 1174.85 866.15C1170.35 861.5 1164.5 860 1157.9 860H1150.7V877.25H1155.5C1159.55 877.25 1162.7 878.75 1164.05 883.55L1167.2 894.65L1139 967.55H1159.55L1176.5 919.55L1185.5 948.5C1188.95 959.75 1194.8 967.55 1208 967.55H1216.1Z" fill="white"/>
<path d="M1248.8 951.05V967.55H1304.8V951.05H1248.8Z" fill="white"/>
<path d="M1503.01 790.267C1499.83 766.294 1518.48 745 1542.66 745H1827C1849.09 745 1867 762.909 1867 785V971.096C1867 993.187 1849.09 1011.1 1827 1011.1H1567.38C1547.33 1011.1 1530.37 996.244 1527.73 976.362L1503.01 790.267Z" fill="black"/>
<path d="M1649.3 968V951.5H1643.75C1640.15 951.5 1637.75 948.95 1636.55 945.2L1613.75 876.5C1612.25 872.15 1610.45 869 1608.05 866.6C1603.55 861.95 1597.7 860.45 1591.1 860.45H1583.9V877.7H1588.7C1592.75 877.7 1595.9 879.2 1597.25 884L1600.4 895.1L1572.2 968H1592.75L1609.7 920L1618.7 948.95C1622.15 960.2 1628 968 1641.2 968H1649.3Z" fill="white"/>
<path d="M1682 951.5V968H1738V951.5H1682Z" fill="white"/>
<path d="M245.923 1711.64C254.47 1700.19 264.812 1691.21 276.949 1684.72C289.085 1678.05 301.991 1674.72 315.667 1674.72C349.684 1674.72 374.897 1687.37 391.308 1712.67C407.889 1737.79 416.18 1773.26 416.18 1819.08C416.18 1847.45 411.906 1872.67 403.359 1894.72C394.983 1916.6 382.59 1933.78 366.18 1946.26C349.94 1958.56 330.282 1964.72 307.205 1964.72C293.53 1964.72 280.795 1961.81 269 1956C257.376 1950.36 247.633 1942.15 239.769 1931.38L236.692 1956H164.897V1575.49L245.923 1567.03V1711.64ZM285.923 1905.74C317.034 1905.74 332.59 1877.2 332.59 1820.1C332.59 1798.22 330.88 1781.04 327.462 1768.56C324.043 1755.91 319.171 1747.11 312.846 1742.15C306.692 1737.03 299.085 1734.46 290.026 1734.46C273.274 1734.46 258.573 1744.97 245.923 1766V1880.87C251.222 1889.25 257.034 1895.49 263.359 1899.59C269.855 1903.69 277.376 1905.74 285.923 1905.74Z" style="fill: rgb(220, 27, 32);"/>
<path d="M701.745 1877.54C701.745 1887.62 703.113 1895.06 705.848 1899.85C708.583 1904.46 713.198 1907.97 719.694 1910.36L703.027 1963.69C686.446 1962.15 672.686 1958.56 661.745 1952.92C650.976 1947.11 642.515 1938.74 636.361 1927.79C626.275 1939.93 613.198 1949.16 597.13 1955.49C581.233 1961.64 564.395 1964.72 546.617 1964.72C528.156 1964.72 511.916 1961.13 497.899 1953.95C484.053 1946.6 473.369 1936.51 465.848 1923.69C458.327 1910.7 454.566 1895.83 454.566 1879.08C454.566 1859.59 459.78 1842.92 470.207 1829.08C480.634 1815.23 495.763 1804.72 515.592 1797.54C535.421 1790.19 559.267 1786.51 587.13 1786.51H623.797V1776.26C623.797 1748.39 605.848 1734.46 569.951 1734.46C560.891 1734.46 549.438 1735.74 535.592 1738.31C521.916 1740.87 508.498 1744.38 495.335 1748.82L476.617 1694.97C493.711 1688.48 511.745 1683.52 530.72 1680.1C549.694 1676.51 567.045 1674.72 582.771 1674.72C622.771 1674.72 652.6 1682.84 672.258 1699.08C691.916 1715.32 701.745 1739.25 701.745 1770.87V1877.54ZM574.566 1906.77C583.797 1906.77 593.113 1904.12 602.515 1898.82C611.916 1893.35 619.01 1886 623.797 1876.77V1832.67H603.797C581.574 1832.67 565.079 1836.09 554.31 1842.92C543.54 1849.76 538.156 1859.93 538.156 1873.44C538.156 1884.03 541.318 1892.24 547.643 1898.05C554.139 1903.86 563.113 1906.77 574.566 1906.77Z" style="fill: rgb(219, 25, 31);"/>
<path d="M984.204 1711.64C992.751 1700.19 1003.09 1691.21 1015.23 1684.72C1027.37 1678.05 1040.27 1674.72 1053.95 1674.72C1087.97 1674.72 1113.18 1687.37 1129.59 1712.67C1146.17 1737.79 1154.46 1773.26 1154.46 1819.08C1154.46 1847.45 1150.19 1872.67 1141.64 1894.72C1133.26 1916.6 1120.87 1933.78 1104.46 1946.26C1088.22 1958.56 1068.56 1964.72 1045.49 1964.72C1031.81 1964.72 1019.08 1961.81 1007.28 1956C995.657 1950.36 985.914 1942.15 978.05 1931.38L974.974 1956H903.179V1575.49L984.204 1567.03V1711.64ZM1024.2 1905.74C1055.32 1905.74 1070.87 1877.2 1070.87 1820.1C1070.87 1798.22 1069.16 1781.04 1065.74 1768.56C1062.32 1755.91 1057.45 1747.11 1051.13 1742.15C1044.97 1737.03 1037.37 1734.46 1028.31 1734.46C1011.55 1734.46 996.854 1744.97 984.204 1766V1880.87C989.503 1889.25 995.315 1895.49 1001.64 1899.59C1008.14 1903.69 1015.66 1905.74 1024.2 1905.74Z" style="fill: rgb(219, 25, 31);"/>
<path d="M1440.03 1877.54C1440.03 1887.62 1441.39 1895.06 1444.13 1899.85C1446.86 1904.46 1451.48 1907.97 1457.98 1910.36L1441.31 1963.69C1424.73 1962.15 1410.97 1958.56 1400.03 1952.92C1389.26 1947.11 1380.8 1938.74 1374.64 1927.79C1364.56 1939.93 1351.48 1949.16 1335.41 1955.49C1319.51 1961.64 1302.68 1964.72 1284.9 1964.72C1266.44 1964.72 1250.2 1961.13 1236.18 1953.95C1222.33 1946.6 1211.65 1936.51 1204.13 1923.69C1196.61 1910.7 1192.85 1895.83 1192.85 1879.08C1192.85 1859.59 1198.06 1842.92 1208.49 1829.08C1218.92 1815.23 1234.04 1804.72 1253.87 1797.54C1273.7 1790.19 1297.55 1786.51 1325.41 1786.51H1362.08V1776.26C1362.08 1748.39 1344.13 1734.46 1308.23 1734.46C1299.17 1734.46 1287.72 1735.74 1273.87 1738.31C1260.2 1740.87 1246.78 1744.38 1233.62 1748.82L1214.9 1694.97C1231.99 1688.48 1250.03 1683.52 1269 1680.1C1287.98 1676.51 1305.33 1674.72 1321.05 1674.72C1361.05 1674.72 1390.88 1682.84 1410.54 1699.08C1430.2 1715.32 1440.03 1739.25 1440.03 1770.87V1877.54ZM1312.85 1906.77C1322.08 1906.77 1331.39 1904.12 1340.8 1898.82C1350.2 1893.35 1357.29 1886 1362.08 1876.77V1832.67H1342.08C1319.86 1832.67 1303.36 1836.09 1292.59 1842.92C1281.82 1849.76 1276.44 1859.93 1276.44 1873.44C1276.44 1884.03 1279.6 1892.24 1285.92 1898.05C1292.42 1903.86 1301.39 1906.77 1312.85 1906.77Z" style="fill: rgb(219, 25, 31);"/>
<path d="M1627.64 1906.77C1641.49 1906.77 1652.43 1904.63 1660.46 1900.36C1668.67 1895.91 1672.77 1889.5 1672.77 1881.13C1672.77 1875.15 1671.15 1870.27 1667.9 1866.51C1664.65 1862.58 1658.58 1858.91 1649.7 1855.49C1640.81 1851.9 1626.96 1847.54 1608.16 1842.41C1580.81 1835.06 1559.87 1824.97 1545.34 1812.15C1530.98 1799.33 1523.8 1781.56 1523.8 1758.82C1523.8 1742.41 1528.33 1727.88 1537.39 1715.23C1546.62 1702.58 1560.12 1692.67 1577.9 1685.49C1595.68 1678.31 1617.05 1674.72 1642 1674.72C1685.25 1674.72 1722 1685.74 1752.26 1707.79L1719.95 1755.49C1708.16 1748.31 1695.76 1742.67 1682.77 1738.56C1669.95 1734.46 1657.13 1732.41 1644.31 1732.41C1631.15 1732.41 1621.32 1734.21 1614.82 1737.79C1608.5 1741.21 1605.34 1746.43 1605.34 1753.44C1605.34 1758.22 1606.96 1762.24 1610.21 1765.49C1613.63 1768.74 1619.7 1772.07 1628.41 1775.49C1637.3 1778.91 1651.06 1783.26 1669.7 1788.56C1689.35 1794.03 1705.34 1800.1 1717.64 1806.77C1729.95 1813.26 1739.52 1821.98 1746.36 1832.92C1753.37 1843.69 1756.87 1857.62 1756.87 1874.72C1756.87 1893.86 1751.06 1910.27 1739.44 1923.95C1727.99 1937.45 1712.52 1947.62 1693.03 1954.46C1673.54 1961.3 1651.92 1964.72 1628.16 1964.72C1602.69 1964.72 1579.78 1961.13 1559.44 1953.95C1539.1 1946.6 1521.58 1936.51 1506.87 1923.69L1547.64 1878.05C1558.93 1886.94 1571.32 1893.95 1584.82 1899.08C1598.33 1904.21 1612.6 1906.77 1627.64 1906.77Z" style="fill: rgb(219, 25, 31);"/>
<path d="M1907.06 1710.62C1929.79 1686.68 1956.46 1674.72 1987.06 1674.72C2011.16 1674.72 2029.62 1681.81 2042.44 1696C2055.43 1710.02 2061.93 1730.02 2061.93 1756V1956H1980.9V1778.56C1980.9 1767.45 1980.05 1758.74 1978.34 1752.41C1976.8 1746.09 1974.15 1741.56 1970.39 1738.82C1966.63 1735.91 1961.41 1734.46 1954.75 1734.46C1946.54 1734.46 1938.59 1737.28 1930.9 1742.92C1923.21 1748.56 1915.26 1756.77 1907.06 1767.54V1956H1826.03V1575.49L1907.06 1567.54V1710.62Z" style="fill: rgb(219, 25, 31);"/>
<path d="M2337.72 1956H2256.69V1575.49L2337.72 1567.03V1956ZM2425.67 1804.21L2522.59 1956H2430.28L2340.8 1806.77L2430.28 1683.69H2515.16L2425.67 1804.21Z" style="fill: rgb(219, 25, 31);"/>
<path d="M2793.54 1877.54C2793.54 1887.62 2794.91 1895.06 2797.64 1899.85C2800.38 1904.46 2805 1907.97 2811.49 1910.36L2794.82 1963.69C2778.24 1962.15 2764.48 1958.56 2753.54 1952.92C2742.77 1947.11 2734.31 1938.74 2728.16 1927.79C2718.07 1939.93 2705 1949.16 2688.93 1955.49C2673.03 1961.64 2656.19 1964.72 2638.41 1964.72C2619.95 1964.72 2603.71 1961.13 2589.7 1953.95C2575.85 1946.6 2565.17 1936.51 2557.64 1923.69C2550.12 1910.7 2546.36 1895.83 2546.36 1879.08C2546.36 1859.59 2551.58 1842.92 2562 1829.08C2572.43 1815.23 2587.56 1804.72 2607.39 1797.54C2627.22 1790.19 2651.06 1786.51 2678.93 1786.51H2715.59V1776.26C2715.59 1748.39 2697.64 1734.46 2661.75 1734.46C2652.69 1734.46 2641.23 1735.74 2627.39 1738.31C2613.71 1740.87 2600.29 1744.38 2587.13 1748.82L2568.41 1694.97C2585.51 1688.48 2603.54 1683.52 2622.52 1680.1C2641.49 1676.51 2658.84 1674.72 2674.57 1674.72C2714.57 1674.72 2744.4 1682.84 2764.06 1699.08C2783.71 1715.32 2793.54 1739.25 2793.54 1770.87V1877.54ZM2666.36 1906.77C2675.59 1906.77 2684.91 1904.12 2694.31 1898.82C2703.71 1893.35 2710.81 1886 2715.59 1876.77V1832.67H2695.59C2673.37 1832.67 2656.88 1836.09 2646.11 1842.92C2635.34 1849.76 2629.95 1859.93 2629.95 1873.44C2629.95 1884.03 2633.11 1892.24 2639.44 1898.05C2645.94 1903.86 2654.91 1906.77 2666.36 1906.77Z" style="fill: rgb(220, 27, 32);"/>
<path d="M862 1819C862 1848.27 838.271 1872 809 1872C779.729 1872 756 1848.27 756 1819C756 1789.73 779.729 1766 809 1766C838.271 1766 862 1789.73 862 1819Z" style="fill: rgb(219, 25, 31);"/>
<path d="M2215.5 1819C2215.5 1848.27 2191.77 1872 2162.5 1872C2133.23 1872 2109.5 1848.27 2109.5 1819C2109.5 1789.73 2133.23 1766 2162.5 1766C2191.77 1766 2215.5 1789.73 2215.5 1819Z" style="fill: rgb(219, 25, 31);"/>
<defs>
<linearGradient id="paint0_linear" x1="1499" y1="139" x2="1499" y2="1385.52" gradientUnits="userSpaceOnUse">
<stop stop-color="#E41F26"/>
<stop offset="1" stop-color="#B70000"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 11 KiB

1
logo/badge.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="151" height="20" role="img" aria-label="babashka: compatible"><title>babashka: compatible</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="151" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="80" height="20" fill="#555"/><rect x="80" width="71" height="20" fill="#97ca00"/><rect width="151" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAxNDcyIDE0NzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTk1LjkxMSAxMTkzLjg5QzExMTAuOTMgMTExMi4zOCAxMTg2IDk3OC4yMDYgMTE4NiA4MjYuNUMxMTg2IDU3Ny45NzIgMTAxNCAyNTQuNSA3MzYgMTEzQzQ2MC41IDI2MiAyODYgNTc3Ljk3MiAyODYgODI2LjVDMjg2IDk3OC4yMDYgMzYxLjA3IDExMTIuMzggNDc2LjA4OSAxMTkzLjg5QzQ3MS45ODMgMTE5NC40NCA0NjcuOTQ5IDExOTUuMTQgNDY0IDExOTZDMzc2LjYxMSAxMjE1LjA3IDI3MCAxMzU5LjA1IDI3MCAxMzU5LjA1SDUzNEM1ODAuOTcyIDEzNTkuMDUgNjI1LjYzMSAxMzQxLjQxIDY2MC45NTYgMTMyMS42MkM2NzguMTE1IDEzNDQuMzIgNzA1LjM0NCAxMzU5IDczNiAxMzU5Qzc2Ni42NTYgMTM1OSA3OTMuODg1IDEzNDQuMzIgODExLjA0NCAxMzIxLjYyQzg0Ni4zNjkgMTM0MS40MSA4OTEuMDI4IDEzNTkuMDUgOTM4IDEzNTkuMDVIMTIwMkMxMjAyIDEzNTkuMDUgMTA5NS4zOSAxMjE1LjA3IDEwMDggMTE5NkMxMDA0LjA1IDExOTUuMTQgMTAwMC4wMiAxMTk0LjQ0IDk5NS45MTEgMTE5My44OVoiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcikiLz4KPGNpcmNsZSBjeD0iNzM1LjUiIGN5PSI4NTIuNSIgcj0iMzExLjUiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik00NDMgNzUwLjQxN0M2NjIgNzY1Ljg2NiA3OTEuMzgyIDcxMi4zODggODgxIDU3OS44ODFDODgxIDU3OS44ODEgNzA4LjI5MyA1MjEuNjQ5IDYwMy4yNDQgNTc5Ljg4MUM0OTguNTUgNjM3LjkxNiA0NDMgNzUwLjQxNyA0NDMgNzUwLjQxN1oiIGZpbGw9IiNCNEI0QjQiLz4KPHBhdGggZD0iTTEwMzkuOTkgNzQ4LjI4MkM5MTQuODYyIDczNC43NDUgODAzLjI2NCA2OTQuMTM1IDc1MCA1NDFDNzUwIDU0MSA4NjAuNjMzIDU2Ni4yNzIgOTcyLjM1NSA2NjguMTAxQzEwODguMzkgNzczLjg1NyAxMDM5Ljk5IDc0OC4yODIgMTAzOS45OSA3NDguMjgyWiIgZmlsbD0iI0I0QjRCNCIvPgo8Y2lyY2xlIGN4PSI3MzUuNSIgY3k9Ijg1Mi41IiByPSIzMTEuNSIgc3Ryb2tlPSIjMEEwMDAwIiBzdHJva2Utd2lkdGg9IjQwIi8+CjxwYXRoIGQ9Ik03OTcgNzE5SDY3NEw3MDQgNzQ5VjgzOUM3MDguNSA4MDkuNSA3NjQuNSA4MDguNSA3NjcuNSA4MzlMNzc1IDc0OUw3OTcgNzE5WiIgZmlsbD0iYmxhY2siLz4KPHBhdGggZD0iTTM1MS4xMTcgNzU5QzM1MS4xMTcgNzM2LjkwOSAzNjkuMDI2IDcxOSAzOTEuMTE3IDcxOUg2NzYuMDE4QzcwMC4yIDcxOSA3MTguODUyIDc0MC4yOTIgNzE1LjY3IDc2NC4yNjRMNjkwLjkxIDk1MC43NjRDNjg4LjI3IDk3MC42NDYgNjcxLjMxNCA5ODUuNSA2NTEuMjU4IDk4NS41SDM5MS4xMTdDMzY5LjAyNiA5ODUuNSAzNTEuMTE3IDk2Ny41OTEgMzUxLjExNyA5NDUuNVY3NTlaIiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNNzU2LjAxMiA3NjQuMjY3Qzc1Mi44MjggNzQwLjI5NCA3NzEuNDgxIDcxOSA3OTUuNjY0IDcxOUgxMDgwQzExMDIuMDkgNzE5IDExMjAgNzM2LjkwOSAxMTIwIDc1OVY5NDUuMDk2QzExMjAgOTY3LjE4NyAxMTAyLjA5IDk4NS4wOTYgMTA4MCA5ODUuMDk2SDgyMC4zODFDODAwLjMyNSA5ODUuMDk2IDc4My4zNyA5NzAuMjQ0IDc4MC43MjkgOTUwLjM2Mkw3NTYuMDEyIDc2NC4yNjdaIiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNMTAyNCA5NTJWOTIxLjQ3SDEwMTMuNzFDMTAwNy4wMyA5MjEuNDcgMTAwMi41OCA5MTYuNzUyIDEwMDAuMzUgOTA5LjgxM0w5NTguMDY0IDc4Mi42OTdDOTU1LjI4MiA3NzQuNjQ5IDk1MS45NDQgNzY4LjgyIDk0Ny40OTIgNzY0LjM3OUM5MzkuMTQ2IDc1NS43NzUgOTI4LjI5NiA3NTMgOTE2LjA1NCA3NTNIOTAyLjdWNzg0LjkxOEg5MTEuNjAzQzkxOS4xMTUgNzg0LjkxOCA5MjQuOTU3IDc4Ny42OTMgOTI3LjQ2MSA3OTYuNTc1TDkzMy4zMDMgODE3LjExM0w4ODEgOTUySDkxOS4xMTVMOTUwLjU1MyA4NjMuMTg1TDk2Ny4yNDUgOTE2Ljc1MkM5NzMuNjQ0IDkzNy41NjggOTg0LjQ5NCA5NTIgMTAwOC45OCA5NTJIMTAyNFoiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik01OTAgOTUyVjkyMS40N0g1NzkuNzA2QzU3My4wMjkgOTIxLjQ3IDU2OC41NzggOTE2Ljc1MiA1NjYuMzUyIDkwOS44MTNMNTI0LjA2NCA3ODIuNjk3QzUyMS4yODIgNzc0LjY0OSA1MTcuOTQ0IDc2OC44MiA1MTMuNDkyIDc2NC4zNzlDNTA1LjE0NiA3NTUuNzc1IDQ5NC4yOTYgNzUzIDQ4Mi4wNTQgNzUzSDQ2OC43Vjc4NC45MThINDc3LjYwM0M0ODUuMTE1IDc4NC45MTggNDkwLjk1NyA3ODcuNjkzIDQ5My40NjEgNzk2LjU3NUw0OTkuMzAzIDgxNy4xMTNMNDQ3IDk1Mkg0ODUuMTE1TDUxNi41NTMgODYzLjE4NUw1MzMuMjQ1IDkxNi43NTJDNTM5LjY0NCA5MzcuNTY4IDU1MC40OTQgOTUyIDU3NC45NzcgOTUySDU5MFoiIGZpbGw9IndoaXRlIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXIiIHgxPSI3NTIiIHkxPSIxMTMiIHgyPSI3NTIiIHkyPSIxMzU5LjUyIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiNFNDFGMjYiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjQjcwMDAwIi8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg=="/><text aria-hidden="true" x="495" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">babashka</text><text x="495" y="140" transform="scale(.1)" fill="#fff" textLength="530">babashka</text><text aria-hidden="true" x="1145" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="610">compatible</text><text x="1145" y="140" transform="scale(.1)" fill="#fff" textLength="610">compatible</text></g></svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

1
logo/built-in-badge.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="129" height="20" role="img" aria-label="babashka: built-in"><title>babashka: built-in</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="129" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="80" height="20" fill="#555"/><rect x="80" width="49" height="20" fill="#97ca00"/><rect width="129" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDE0NzIgMTQ3MiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05OTUuOTExIDExOTMuODlDMTExMC45MyAxMTEyLjM4IDExODYgOTc4LjIwNiAxMTg2IDgyNi41QzExODYgNTc3Ljk3MiAxMDE0IDI1NC41IDczNiAxMTNDNDYwLjUgMjYyIDI4NiA1NzcuOTcyIDI4NiA4MjYuNUMyODYgOTc4LjIwNiAzNjEuMDcgMTExMi4zOCA0NzYuMDg5IDExOTMuODlDNDcxLjk4MyAxMTk0LjQ0IDQ2Ny45NDkgMTE5NS4xNCA0NjQgMTE5NkMzNzYuNjExIDEyMTUuMDcgMjcwIDEzNTkuMDUgMjcwIDEzNTkuMDVINTM0QzU4MC45NzIgMTM1OS4wNSA2MjUuNjMxIDEzNDEuNDEgNjYwLjk1NiAxMzIxLjYyQzY3OC4xMTUgMTM0NC4zMiA3MDUuMzQ0IDEzNTkgNzM2IDEzNTlDNzY2LjY1NiAxMzU5IDc5My44ODUgMTM0NC4zMiA4MTEuMDQ0IDEzMjEuNjJDODQ2LjM2OSAxMzQxLjQxIDg5MS4wMjggMTM1OS4wNSA5MzggMTM1OS4wNUgxMjAyQzEyMDIgMTM1OS4wNSAxMDk1LjM5IDEyMTUuMDcgMTAwOCAxMTk2QzEwMDQuMDUgMTE5NS4xNCAxMDAwLjAyIDExOTQuNDQgOTk1LjkxMSAxMTkzLjg5WiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyKSIvPgo8Y2lyY2xlIGN4PSI3MzUuNSIgY3k9Ijg1Mi41IiByPSIzMTEuNSIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ0MyA3NTAuNDE3QzY2MiA3NjUuODY2IDc5MS4zODIgNzEyLjM4OCA4ODEgNTc5Ljg4MUM4ODEgNTc5Ljg4MSA3MDguMjkzIDUyMS42NDkgNjAzLjI0NCA1NzkuODgxQzQ5OC41NSA2MzcuOTE2IDQ0MyA3NTAuNDE3IDQ0MyA3NTAuNDE3WiIgZmlsbD0iI0I0QjRCNCIvPgo8cGF0aCBkPSJNMTAzOS45OSA3NDguMjgyQzkxNC44NjIgNzM0Ljc0NSA4MDMuMjY0IDY5NC4xMzUgNzUwIDU0MUM3NTAgNTQxIDg2MC42MzMgNTY2LjI3MiA5NzIuMzU1IDY2OC4xMDFDMTA4OC4zOSA3NzMuODU3IDEwMzkuOTkgNzQ4LjI4MiAxMDM5Ljk5IDc0OC4yODJaIiBmaWxsPSIjQjRCNEI0Ii8+CjxjaXJjbGUgY3g9IjczNS41IiBjeT0iODUyLjUiIHI9IjMxMS41IiBzdHJva2U9IiMwQTAwMDAiIHN0cm9rZS13aWR0aD0iNDAiLz4KPHBhdGggZD0iTTc5NyA3MTlINjc0TDcwNCA3NDlWODM5QzcwOC41IDgwOS41IDc2NC41IDgwOC41IDc2Ny41IDgzOUw3NzUgNzQ5TDc5NyA3MTlaIiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNMzUxLjExNyA3NTlDMzUxLjExNyA3MzYuOTA5IDM2OS4wMjYgNzE5IDM5MS4xMTcgNzE5SDY3Ni4wMThDNzAwLjIgNzE5IDcxOC44NTIgNzQwLjI5MiA3MTUuNjcgNzY0LjI2NEw2OTAuOTEgOTUwLjc2NEM2ODguMjcgOTcwLjY0NiA2NzEuMzE0IDk4NS41IDY1MS4yNTggOTg1LjVIMzkxLjExN0MzNjkuMDI2IDk4NS41IDM1MS4xMTcgOTY3LjU5MSAzNTEuMTE3IDk0NS41Vjc1OVoiIGZpbGw9ImJsYWNrIi8+CjxwYXRoIGQ9Ik03NTYuMDEyIDc2NC4yNjdDNzUyLjgyOCA3NDAuMjk0IDc3MS40ODEgNzE5IDc5NS42NjQgNzE5SDEwODBDMTEwMi4wOSA3MTkgMTEyMCA3MzYuOTA5IDExMjAgNzU5Vjk0NS4wOTZDMTEyMCA5NjcuMTg3IDExMDIuMDkgOTg1LjA5NiAxMDgwIDk4NS4wOTZIODIwLjM4MUM4MDAuMzI1IDk4NS4wOTYgNzgzLjM3IDk3MC4yNDQgNzgwLjcyOSA5NTAuMzYyTDc1Ni4wMTIgNzY0LjI2N1oiIGZpbGw9ImJsYWNrIi8+CjxwYXRoIGQ9Ik0xMDI0IDk1MlY5MjEuNDdIMTAxMy43MUMxMDA3LjAzIDkyMS40NyAxMDAyLjU4IDkxNi43NTIgMTAwMC4zNSA5MDkuODEzTDk1OC4wNjQgNzgyLjY5N0M5NTUuMjgyIDc3NC42NDkgOTUxLjk0NCA3NjguODIgOTQ3LjQ5MiA3NjQuMzc5QzkzOS4xNDYgNzU1Ljc3NSA5MjguMjk2IDc1MyA5MTYuMDU0IDc1M0g5MDIuN1Y3ODQuOTE4SDkxMS42MDNDOTE5LjExNSA3ODQuOTE4IDkyNC45NTcgNzg3LjY5MyA5MjcuNDYxIDc5Ni41NzVMOTMzLjMwMyA4MTcuMTEzTDg4MSA5NTJIOTE5LjExNUw5NTAuNTUzIDg2My4xODVMOTY3LjI0NSA5MTYuNzUyQzk3My42NDQgOTM3LjU2OCA5ODQuNDk0IDk1MiAxMDA4Ljk4IDk1MkgxMDI0WiIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTU5MCA5NTJWOTIxLjQ3SDU3OS43MDZDNTczLjAyOSA5MjEuNDcgNTY4LjU3OCA5MTYuNzUyIDU2Ni4zNTIgOTA5LjgxM0w1MjQuMDY0IDc4Mi42OTdDNTIxLjI4MiA3NzQuNjQ5IDUxNy45NDQgNzY4LjgyIDUxMy40OTIgNzY0LjM3OUM1MDUuMTQ2IDc1NS43NzUgNDk0LjI5NiA3NTMgNDgyLjA1NCA3NTNINDY4LjdWNzg0LjkxOEg0NzcuNjAzQzQ4NS4xMTUgNzg0LjkxOCA0OTAuOTU3IDc4Ny42OTMgNDkzLjQ2MSA3OTYuNTc1TDQ5OS4zMDMgODE3LjExM0w0NDcgOTUySDQ4NS4xMTVMNTE2LjU1MyA4NjMuMTg1TDUzMy4yNDUgOTE2Ljc1MkM1MzkuNjQ0IDkzNy41NjggNTUwLjQ5NCA5NTIgNTc0Ljk3NyA5NTJINTkwWiIgZmlsbD0id2hpdGUiLz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhciIgeDE9Ijc1MiIgeTE9IjExMyIgeDI9Ijc1MiIgeTI9IjEzNTkuNTIiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0U0MUYyNiIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNCNzAwMDAiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K"/><text aria-hidden="true" x="495" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">babashka</text><text x="495" y="140" transform="scale(.1)" fill="#fff" textLength="530">babashka</text><text aria-hidden="true" x="1035" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="390">built-in</text><text x="1035" y="140" transform="scale(.1)" fill="#fff" textLength="390">built-in</text></g></svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

2
pods

@ -1 +1 @@
Subproject commit 538fc6f4147badf3a457b3eb8f9f95dd3bc947b1
Subproject commit decf791000081ca9e6d2fbea9f20a0aa3fae902e

@ -1 +1 @@
Subproject commit 5db9560eab698f9773537acb0167f38d6fd0d322
Subproject commit 90e4cf0b0cc7856f8c39591c3350cdf156d11042

View file

@ -10,31 +10,38 @@
:source-paths ["src" "sci/src" "babashka.curl/src" "fs/src" "pods/src"
"babashka.core/src"
"babashka.nrepl/src" "depstar/src" "process/src"
"deps.clj/src" "deps.clj/resources"]
"deps.clj/src" "deps.clj/resources"
"reify/src"]
;; for debugging Reflector.java code:
;; :java-source-paths ["sci/reflector/src-java"]
:java-source-paths ["src-java"]
:resource-paths ["resources" "sci/resources"]
:test-selectors {:default (complement :windows-only)
:windows (complement :skip-windows)}
:dependencies [[org.clojure/clojure "1.11.0-beta1"]
[borkdude/edamame "0.0.19"]
:dependencies [[org.clojure/clojure "1.11.1"]
[borkdude/edamame "1.0.16"]
[borkdude/graal.locking "0.0.2"]
[org.clojure/tools.cli "1.0.206"]
[cheshire "5.10.2"]
[org.clojure/tools.cli "1.0.214"]
[cheshire "5.11.0"]
[nrepl/bencode "1.1.0"]
[borkdude/sci.impl.reflector "0.0.1"]
[org.clojure/core.async "1.5.648"]
[org.babashka/sci.impl.types "0.0.2"]
[org.babashka/babashka.impl.reify "0.1.3"]
[org.clojure/core.async "1.6.673"]
[org.clojure/test.check "1.1.1"]
[com.github.clj-easy/graal-build-time "0.1.0"]
[rewrite-clj/rewrite-clj "1.0.699-alpha"]
[instaparse/instaparse "1.4.10"]]
[instaparse/instaparse "1.4.10"]
[rewrite-clj/rewrite-clj "1.1.45"]
[insn/insn "0.5.2"]
[org.babashka/cli "0.6.41"]]
:plugins [[org.kipz/lein-meta-bom "0.1.1"]]
:metabom {:jar-name "metabom.jar"}
:profiles {:feature/xml {:source-paths ["feature-xml"]
:dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]}
:dependencies [[org.clojure/data.xml "0.2.0-alpha8"]]}
:feature/yaml {:source-paths ["feature-yaml"]
:dependencies [[clj-commons/clj-yaml "0.7.108"]]}
:dependencies [[clj-commons/clj-yaml "0.7.169"
#_#_clj-commons/clj-yaml "0.7.110"]]}
:feature/jdbc {:source-paths ["feature-jdbc"]
:dependencies [[seancorfield/next.jdbc "1.1.610"]]}
:feature/sqlite [:feature/jdbc {:dependencies [[org.xerial/sqlite-jdbc "3.36.0.3"]]}]
@ -49,9 +56,9 @@
:feature/datascript {:source-paths ["feature-datascript"]
:dependencies [[datascript "1.3.10"]]}
:feature/httpkit-client {:source-paths ["feature-httpkit-client"]
:dependencies [[http-kit "2.5.3"]]}
:dependencies [[http-kit "2.6.0-RC1"]]}
:feature/httpkit-server {:source-paths ["feature-httpkit-server"]
:dependencies [[http-kit "2.5.3"]]}
:dependencies [[http-kit "2.6.0-RC1"]]}
:feature/lanterna {:source-paths ["feature-lanterna"]
:dependencies [[babashka/clojure-lanterna "0.9.8-SNAPSHOT"]]}
:feature/core-match {:source-paths ["feature-core-match"]
@ -61,12 +68,14 @@
:feature/test-check {:source-paths ["feature-test-check"]}
:feature/spec-alpha {:source-paths ["feature-spec-alpha"]}
:feature/selmer {:source-paths ["feature-selmer"]
:dependencies [[selmer/selmer "1.12.44"]]}
:dependencies [[selmer/selmer "1.12.50"]]}
:feature/logging {:source-paths ["feature-logging"]
:dependencies [[com.taoensso/timbre "5.1.2"]
:dependencies [[com.taoensso/timbre "6.0.1"]
[org.clojure/tools.logging "1.1.0"]]}
:feature/priority-map {:source-paths ["feature-priority-map"]
:dependencies [[org.clojure/data.priority-map "1.1.0"]]}
:feature/rrb-vector {:source-paths ["feature-rrb-vector"]
:dependencies [[org.clojure/core.rrb-vector "0.1.2"]]}
:test [:feature/xml
:feature/lanterna
:feature/yaml
@ -84,8 +93,10 @@
:feature/selmer
:feature/logging
:feature/priority-map
:feature/rrb-vector
{:dependencies [[com.clojure-goes-fast/clj-async-profiler "0.5.0"]
[com.opentable.components/otj-pg-embedded "0.13.3"]]}]
[com.opentable.components/otj-pg-embedded "0.13.3"]
[nubank/matcher-combinators "3.6.0"]]}]
:uberjar {:global-vars {*assert* false}
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
"-Dclojure.spec.skip-macros=true"

2
reify/.dir-locals.el Normal file
View file

@ -0,0 +1,2 @@
((nil
(cider-clojure-cli-global-options . "-A:test:build")))

2
reify/bb.edn Normal file
View file

@ -0,0 +1,2 @@
{:tasks {install (clojure "-T:build install")
deploy (clojure "-T:build deploy")}}

50
reify/build.clj Normal file
View file

@ -0,0 +1,50 @@
(ns build
(:require [build.reify2 :as reify2]
[clojure.tools.build.api :as b]))
(def lib 'org.babashka/babashka.impl.reify)
(def version "0.1.3")
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(defn clean [_]
(b/delete {:path "target"}))
(defn gen-classes [_]
(reify2/gen-classes nil))
(defn jar [_]
(gen-classes nil)
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))
(defn install [_]
(jar nil)
(b/install {:basis basis
:lib lib
:version version
:jar-file jar-file
:class-dir class-dir}))
(defn deploy [opts]
(jar opts)
((requiring-resolve 'deps-deploy.deps-deploy/deploy)
(merge {:installer :remote
:artifact jar-file
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}
opts))
opts)
;;;; Scratch
(comment
(gen-classes nil)
)

188
reify/build/reify2.clj Normal file
View file

@ -0,0 +1,188 @@
(ns build.reify2
{:no-doc true}
(:require [babashka.impl.reify2.interfaces :refer [interfaces]]
[insn.core :as insn]))
(set! *warn-on-reflection* false)
(defn set-symbol! [s]
[[:aconst-null]
[:ldc s]
[:invokestatic clojure.lang.Symbol "intern" [String String clojure.lang.Symbol]]
[:putstatic :this (str "_sym_" s) clojure.lang.Symbol]])
(defn return [desc]
(case (last desc)
:void [:return]
(:boolean :int) [:ireturn]
[:areturn]))
(defn loads [desc cast?]
(let [desc (butlast desc)]
(vec
(mapcat (fn [i e]
(case e
:boolean [[:iload i]
(when cast? [:invokestatic Boolean "valueOf" [:boolean Boolean]])]
:int [[:iload i]
(when cast? [:invokestatic Integer "valueOf" [:int Integer]])]
[[:aload i]]))
(range 1 (inc (count desc)))
desc))))
(defn emit-method [class meth desc default]
(let [args (dec (count desc))]
[[[:aload 0]
[:getfield :this "_methods" java.util.Map]
[:getstatic :this (str "_sym_" meth) clojure.lang.Symbol]
[:invokeinterface java.util.Map "get" [Object Object]]
[:checkcast clojure.lang.IFn]
[:astore (inc args)]
[:aload (inc args)]
[:ifnull :fallback]
[:aload (inc args)]
;; load this, always the first argument of IFn
[:aload 0]]
;; load remaining args
(loads desc true)
[[:invokeinterface clojure.lang.IFn "invoke" (vec (repeat (inc (count desc)) Object))]
(let [ret-type* (last desc)
ret-type (if (class? ret-type*)
(.getName ^Class ret-type*)
ret-type*)]
(case ret-type
:void [:pop]
:boolean [[:checkcast Boolean]
[:invokevirtual Boolean "booleanValue"]]
:int [[:checkcast Integer]
[:invokevirtual Integer "intValue"]]
"java.lang.Object" nil
(when (class? ret-type*)
[[:checkcast ret-type*]])))
(return desc)
[:mark :fallback]]
(if default
[[[:aload 0]]
(loads desc false)
[[:invokespecial class meth desc true]
(return desc)]]
[[:new java.lang.UnsupportedOperationException]
[:dup]
[:ldc (format "No implementation of method found: %s %s" meth desc)]
[:invokespecial java.lang.UnsupportedOperationException :init [String :void]]
[:athrow]])]))
(defn interface-data [^Class interface methods]
(let [class-sym (symbol (.getName interface))
method-names (distinct (map :name methods))]
{:name (symbol (str "babashka.impl." (.getName interface)))
:version 1.8
:interfaces [class-sym
'sci.impl.types.IReified
'clojure.lang.IMeta
'clojure.lang.IObj]
:flags [:super :public]
:fields (into [{:flags #{:private},
:name "_methods" :type java.util.Map}
{:flags #{:private},
:name "_interfaces" :type Object}
{:flags #{:private},
:name "_protocols" :type Object}
{:flags #{:private},
:name "_meta" :type clojure.lang.IPersistentMap}]
(for [name method-names]
{:flags #{:private :static},
:name (str "_sym_" name) :type clojure.lang.Symbol}))
:methods (into [{:name :clinit
:emit (reduce into
[]
(conj
(mapv set-symbol! method-names)
[[:return]]))}
{:name :init
:desc [:void]
:emit [[:aload 0]
[:invokespecial :super :init [:void]]
[:return]]}
{:name :init
:desc [java.util.Map Object Object :void]
:emit [[:aload 0]
[:invokespecial :super :init [:void]]
[:aload 0]
[:aload 1]
[:putfield :this "_methods" java.util.Map]
[:aload 0]
[:aload 2]
[:putfield :this "_interfaces" Object]
[:aload 0]
[:aload 3]
[:putfield :this "_protocols" Object]
[:return]]}
{:name :meta
:desc [clojure.lang.IPersistentMap]
:emit [[:aload 0]
[:getfield :this "_meta" clojure.lang.IPersistentMap]
[:areturn]]}
{:name :withMeta
:desc [clojure.lang.IPersistentMap clojure.lang.IObj]
:emit [[:aload 0]
[:aload 1]
[:putfield :this "_meta" clojure.lang.IPersistentMap]
[:aload 0]
[:areturn]]}
{:name :getInterfaces
:desc [Object]
:emit [[:aload 0]
[:getfield :this "_interfaces" Object]
[:areturn]]}
{:name :getMethods
:desc [Object]
:emit [[:aload 0]
[:getfield :this "_methods" java.util.Map]
[:areturn]]}
{:name :getProtocols
:desc [Object]
:emit [[:aload 0]
[:getfield :this "_protocols" Object]
[:areturn]]}]
(for [{:keys [name desc default]} methods]
{:flags #{:public}, :name name
:desc desc
:emit (emit-method interface name desc default)}
))}))
(set! *warn-on-reflection* true)
(defn type->kw [type]
(condp = type
Void/TYPE :void
Boolean/TYPE :boolean
Integer/TYPE :int
type))
(defn class->methods [^Class clazz]
(let [meths (.getMethods clazz)
meths (mapv bean meths)
;; TODO: fix problems with clojure.lang.IFn, special cased for now
;; The problem is that the 20-arity (highest one) could not be reified
;; meths (filter #(<= (:parameterCount %) 19) meths)
meths (mapv (fn [{:keys [name
parameterTypes
returnType
default]}]
(let [ret-type (type->kw returnType)]
{:name name
:desc (conj (mapv type->kw parameterTypes) ret-type)
:default default}))
meths)]
(distinct meths)))
(let [i clojure.lang.IFn]
(insn/define (insn/visit (interface-data i (class->methods i)))))
(def reified (babashka.impl.clojure.lang.IFn. {'invoke (fn [& _args] :yep)} {} {}))
(defn gen-classes [_]
(doseq [i interfaces]
(insn/write (doto (insn/visit (interface-data i (class->methods i)))
insn/define) "target/classes")))

13
reify/deps.edn Normal file
View file

@ -0,0 +1,13 @@
{:deps {org.babashka/sci.impl.types {:mvn/version "0.0.2"}}
:aliases
{:build ;; added by neil
{:paths ["." "build" "src"]
:deps {io.github.clojure/tools.build {:git/tag "v0.8.1" :git/sha "7d40500"}
slipset/deps-deploy {:mvn/version "0.2.0"}
org.babashka/sci.impl.types {:mvn/version "0.0.2"}
;; insn/insn {:mvn/version "0.5.3"}
insn/insn {
:git/sha "f85da286d429b507480f8527b12ce3e1e0e17296"
:git/url "https://github.com/phronmophobic/insn"
}}
:ns-default build}}}

View file

@ -0,0 +1,90 @@
(ns babashka.impl.reify2
(:require [babashka.impl.reify2.interfaces :refer [interfaces]]))
(set! *warn-on-reflection* false)
(defn method-or-bust [methods k]
(or (get methods k)
(throw (UnsupportedOperationException. "Method not implemented: " k))))
(defn reify-ifn [m]
(let [methods (:methods m)
invoke-fn (or (get methods 'invoke)
(fn [& _args]
(throw (UnsupportedOperationException. "Method not implemented: invoke"))))
apply-fn (or (get methods 'applyTo)
(fn [& _args]
(throw (UnsupportedOperationException. "Method not implemented: applyTo"))))]
(reify
sci.impl.types.IReified
(getMethods [_] (:methods m))
(getInterfaces [_] (:interfaces m))
(getProtocols [_] (:protocols m))
clojure.lang.IFn
(invoke [this] (invoke-fn this))
(invoke [this a0] (invoke-fn this a0))
(invoke [this a0 a1] (invoke-fn this a0 a1))
(invoke [this a0 a1 a2] (invoke-fn this a0 a1 a2))
(invoke [this a0 a1 a2 a3] (invoke-fn this a0 a1 a2 a3))
(invoke [this a0 a1 a2 a3 a4] (invoke-fn this a0 a1 a2 a3 a4))
(invoke [this a0 a1 a2 a3 a4 a5] (invoke-fn this a0 a1 a2 a3 a4 a5))
(invoke [this a0 a1 a2 a3 a4 a5 a6] (invoke-fn this a0 a1 a2 a3 a4 a5 a6))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19))
(invoke [this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20] (invoke-fn this a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20))
(applyTo [this arglist] (apply-fn this arglist)))))
(defn reify-object [m]
(let [methods (:methods m)
toString-fn (or (get methods 'toString)
(fn [this]
(str
(.getName (.getClass this))
"@"
(Integer/toHexString (.hashCode this)))))]
(reify
sci.impl.types.IReified
(getMethods [_] (:methods m))
(getInterfaces [_] (:interfaces m))
(getProtocols [_] (:protocols m))
java.lang.Object
(toString [this] (toString-fn this)))))
(defmacro gen-reify-fn []
`(fn [~'m]
(when (> (count (:interfaces ~'m)) 1)
(throw (UnsupportedOperationException. "babashka reify only supports implementing a single interface")))
(if (empty? (:interfaces ~'m))
(reify
sci.impl.types.IReified
(getMethods [_] (:methods ~'m))
(getInterfaces [_] (:interfaces ~'m))
(getProtocols [_] (:protocols ~'m)))
(case (.getName ~(with-meta `(first (:interfaces ~'m))
{:tag 'Class}))
~@(mapcat identity
(cons
["clojure.lang.IFn"
`(reify-ifn ~'m)
"java.lang.Object"
`(reify-object ~'m)]
(for [i interfaces]
(let [in (.getName ^Class i)]
[in
`(new ~(symbol (str "babashka.impl." in))
(:methods ~'m)
(:interfaces ~'m)
(:protocols ~'m))]))))))))
(def reify-fn (gen-reify-fn))

View file

@ -0,0 +1,34 @@
(ns babashka.impl.reify2.interfaces)
(def interfaces [java.nio.file.FileVisitor
java.io.FileFilter
java.io.FilenameFilter
clojure.lang.Associative
clojure.lang.ILookup
java.util.Map$Entry
;; TODO: fix problems with clojure.lang.IFn, special cased for now
;; The problem is that the 20-arity (highest one) could not be reified
;; clojure.lang.IFn
clojure.lang.IPersistentCollection
clojure.lang.IReduce
clojure.lang.IReduceInit
clojure.lang.IKVReduce
clojure.lang.Indexed
clojure.lang.IPersistentMap
clojure.lang.IPersistentStack
clojure.lang.Reversible
clojure.lang.Seqable
java.lang.Iterable
java.lang.Runnable
java.net.http.WebSocket$Listener
java.util.Iterator
java.util.function.Consumer
java.util.function.BiConsumer
java.util.function.Function
java.util.function.BiFunction
java.util.function.Predicate
java.util.function.Supplier
java.lang.Comparable
javax.net.ssl.X509TrustManager
clojure.lang.LispReader$Resolver
sun.misc.SignalHandler])

View file

@ -1 +1 @@
0.7.8
1.0.168

View file

@ -1 +1 @@
0.7.9-SNAPSHOT
1.0.169-SNAPSHOT

View file

@ -1,145 +0,0 @@
{:paths ["src" "feature-xml"
"feature-yaml" "feature-csv" "feature-transit"
"feature-java-time" "feature-java-nio"
"feature-httpkit-client" "feature-httpkit-server"
"feature-lanterna"
"feature-core-match"
"feature-hiccup"
"feature-test-check"
"feature-spec-alpha"
"feature-selmer"
"feature-logging"
"feature-priority-map"
"pods/src"
"babashka.nrepl/src"
"depstar/src" "process/src"
"deps.clj/src" "deps.clj/resources"
"resources" "sci/resources"],
:deps {org.clojure/clojure {:mvn/version "1.11.0-beta1"},
borkdude/sci {:local/root "sci"}
babashka/babashka.curl {:local/root "babashka.curl"}
babashka/fs {:local/root "fs"}
babashka/babashka.core {:local/root "babashka.core"}
borkdude/graal.locking {:mvn/version "0.0.2"},
org.clojure/core.async {:mvn/version "1.5.648"},
org.clojure/tools.cli {:mvn/version "1.0.206"},
org.clojure/data.csv {:mvn/version "1.0.0"},
cheshire/cheshire {:mvn/version "5.10.2"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}
clj-commons/clj-yaml {:mvn/version "0.7.108"}
com.cognitect/transit-clj {:mvn/version "1.0.329"}
org.clojure/test.check {:mvn/version "1.1.1"}
nrepl/bencode {:mvn/version "1.1.0"}
seancorfield/next.jdbc {:mvn/version "1.1.610"}
org.postgresql/postgresql {:mvn/version "42.2.18"}
org.hsqldb/hsqldb {:mvn/version "2.5.1"}
datascript/datascript {:mvn/version "1.0.1"}
http-kit/http-kit {:mvn/version "2.5.3"}
babashka/clojure-lanterna {:mvn/version "0.9.8-SNAPSHOT"}
org.clojure/core.match {:mvn/version "1.0.0"}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
rewrite-clj/rewrite-clj {:mvn/version "1.0.699-alpha"}
selmer/selmer {:mvn/version "1.12.44"}
com.taoensso/timbre {:mvn/version "5.1.2"}
org.clojure/tools.logging {:mvn/version "1.1.0"}
org.clojure/data.priority-map {:mvn/version "1.1.0"}
instaparse/instaparse {:mvn/version "1.4.10"}}
:aliases {:babashka/dev
{:main-opts ["-m" "babashka.main"]}
:profile
{:extra-deps
{com.clojure-goes-fast/clj-async-profiler {:mvn/version "0.5.0"}}
:extra-paths ["test"]
:jvm-opts ["-Djdk.attach.allowAttachSelf"
"-Dclojure.compiler.direct-linking=true"]
:main-opts ["-m" "babashka.profile"]}
:lib-tests
{:extra-paths ["process/src" "process/test" "test-resources/lib_tests"]
:extra-deps {org.clj-commons/clj-http-lite {:mvn/version "0.4.392"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:sha "0dec1f88cbde74a0470b454396f09a03adb4ae39"}
lambdaisland/regal {:mvn/version "0.0.143"}
cprop/cprop {:mvn/version "0.1.16"}
comb/comb {:mvn/version "0.1.1"}
mvxcvi/arrangement {:mvn/version "2.0.0"}
org.clojure/data.zip {:mvn/version "1.0.0"}
clojure-csv/clojure-csv {:mvn/version "2.0.2"}
org.clojure/math.combinatorics {:mvn/version "0.1.6"}
doric/doric {:mvn/version "0.9.0"}
henryw374/cljc.java-time
{:git/url "https://github.com/henryw374/cljc.java-time.git"
:sha "e3d184b78e933322b3fcaa6ca66cbb8f42a6b35c"}
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}
aero/aero {:mvn/version "1.1.6"}
org.clojure/data.generators {:mvn/version "1.0.0"}
honeysql/honeysql {:mvn/version "1.0.461"}
com.github.seancorfield/honeysql {:mvn/version "2.2.840"}
minimallist/minimallist {:mvn/version "0.0.10"}
circleci/bond {:mvn/version "0.6.0"}
version-clj/version-clj {:mvn/version "2.0.2"}
gaka/gaka {:mvn/version "0.3.0"}
failjure/failjure {:mvn/version "2.2.0"}
io.helins/binf {:mvn/version "1.1.0-beta0"}
rm-hull/jasentaa {:mvn/version "0.2.5"}
slingshot/slingshot {:mvn/version "0.12.2"}
io.replikativ/hasch {:mvn/version "0.3.7"}
com.grammarly/omniconf {:mvn/version "0.4.3"}
crispin/crispin {:mvn/version "0.3.8"}
org.clojure/data.json {:mvn/version "2.4.0"}
clj-commons/multigrep {:mvn/version "0.5.0"}
amperity/vault-clj {:mvn/version "1.0.4"}
java-http-clj/java-http-clj {:mvn/version "0.4.3"}
com.stuartsierra/component {:mvn/version "1.0.0"}
org.clojars.askonomm/ruuter {:mvn/version "1.2.2"}
org.clj-commons/digest {:mvn/version "1.4.100"}
hato/hato {:mvn/version "0.8.2"}
better-cond/better-cond {:mvn/version "2.1.1"}
org.clojure/core.specs.alpha {:mvn/version "0.2.62"}
reifyhealth/specmonstah {:git/url "https://github.com/reifyhealth/specmonstah", :sha "a2b357009a3aa99a0c2d2361f3bbcd0b0e36505e"}
exoscale/coax {:mvn/version "1.0.0-alpha14"}
orchestra/orchestra {:mvn/version "2021.01.01-1"}
expound/expound {:mvn/version "0.8.10"}
integrant/integrant {:mvn/version "0.8.0"}
com.stuartsierra/dependency {:mvn/version "1.0.0"}
listora/again {:mvn/version "1.0.0"}
org.clojure/tools.gitlibs {:mvn/version "2.4.172"}
environ/environ {:mvn/version "1.2.0"}
table/table {:git/url "https://github.com/cldwalker/table", :sha "f6293c5f3dac1dd6f525a80fc80930f8ccdf16b7"}
markdown-clj/markdown-clj {:mvn/version "1.10.8"}
org.clojure/tools.namespace {:git/url "https://github.com/babashka/tools.namespace", :sha "a13b037215e21a2e71aa34b27e1dd52c801a2a7b"}
medley/medley {:mvn/version "1.3.0"}
io.github.cognitect-labs/test-runner {:git/tag "v0.5.0", :git/sha "b3fd0d2"}
borkdude/missing.test.assertions {:git/url "https://github.com/borkdude/missing.test.assertions", :sha "603cb01bee72fb17addacc53c34c85612684ad70"}
dev.nubank/docopt {:mvn/version "0.6.1-fix7"}
testdoc/testdoc {:mvn/version "1.4.1"}
org.clojars.lispyclouds/contajners {:mvn/version "0.0.4"}
borkdude/rewrite-edn {:mvn/version "0.1.0"}
clojure-term-colors/clojure-term-colors {:mvn/version "0.1.0"}
io.aviso/pretty {:mvn/version "1.1.1"}
progrock/progrock {:mvn/version "0.1.2"}
djblue/portal {:mvn/version "0.19.0"}
com.wsscode/cljc-misc {:mvn/version "2021.10.16"}
edn-query-language/eql {:mvn/version "2021.07.18"}
meta-merge/meta-merge {:mvn/version "1.0.0"}
com.exoscale/lingo {:mvn/version "1.0.0-alpha14"}
io.github.swirrl/dogstatsd {:mvn/version "0.1.39"}
org.clojure/algo.monads {:mvn/version "0.1.6"}
io.lambdaforge/datalog-parser {:mvn/version "0.1.9"}
clj-stacktrace/clj-stacktrace {:mvn/version "0.2.8"}
clojure-msgpack/clojure-msgpack {:mvn/version "1.2.1"}
cli-matic/cli-matic {:git/url "https://github.com/l3nz/cli-matic.git", :git/sha "9cd53ba7336363e3d06650dbad413b6f8b06e471"}
aysylu/loom {:mvn/version "1.0.2"}
com.layerware/hugsql-core {:mvn/version "0.5.1"}
com.github.seancorfield/expectations {:mvn/version "2.0.157"}}
:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil}}
:clj-nvd
{:extra-deps {clj-nvd/clj-nvd {:git/url "https://github.com/miikka/clj-nvd.git"
:sha "f2ec98699e057a379baf170cb49cf7ad76874a70"}}
:main-opts ["-m" "clj-nvd.core"]}
:test ;; added by neil
{:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}}

View file

@ -4,8 +4,9 @@ Args=-H:+ReportExceptionStackTraces \
-J-Dborkdude.dynaload.aot=true \
-H:IncludeResources=BABASHKA_VERSION \
-H:IncludeResources=META-INF/babashka/.* \
-H:IncludeResources=src/babashka/.* \
-H:IncludeResources=SCI_VERSION \
-H:Log=registerResource: \
-H:Log=registerResource:3 \
-H:EnableURLProtocols=http,https,jar \
--enable-all-security-services \
-H:+JNI \
@ -13,6 +14,7 @@ Args=-H:+ReportExceptionStackTraces \
--report-unsupported-elements-at-runtime \
--initialize-at-build-time=com.fasterxml.jackson \
--initialize-at-build-time=java.sql.SQLException \
--initialize-at-build-time=org.yaml.snakeyaml \
--initialize-at-run-time=org.postgresql.sspi.SSPIClient \
--initialize-at-run-time=org.httpkit.client.ClientSslEngineFactory$SSLHolder \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileReader \

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,227 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns clojure.spec.gen.alpha
(:refer-clojure :exclude [boolean bytes cat hash-map list map not-empty set vector
char double int keyword symbol string uuid delay shuffle]))
(alias 'c 'clojure.core)
(defonce ^:private dynalock (Object.))
(defn- dynaload
[s]
(let [ns (namespace s)]
(assert ns)
(locking dynalock
(require (c/symbol ns)))
(let [v (resolve s)]
(if v
@v
(throw (RuntimeException. (str "Var " s " is not on the classpath")))))))
(def ^:private quick-check-ref
(c/delay (dynaload 'clojure.test.check/quick-check)))
(defn quick-check
[& args]
(apply @quick-check-ref args))
(def ^:private for-all*-ref
(c/delay (dynaload 'clojure.test.check.properties/for-all*)))
(defn for-all*
"Dynamically loaded clojure.test.check.properties/for-all*."
[& args]
(apply @for-all*-ref args))
(let [g? (c/delay (dynaload 'clojure.test.check.generators/generator?))
g (c/delay (dynaload 'clojure.test.check.generators/generate))
mkg (c/delay (dynaload 'clojure.test.check.generators/->Generator))]
(defn- generator?
[x]
(@g? x))
(defn- generator
[gfn]
(@mkg gfn))
(defn generate
"Generate a single value using generator."
[generator]
(@g generator)))
(defn ^:skip-wiki delay-impl
[gfnd]
;;N.B. depends on test.check impl details
(generator (fn [rnd size]
((:gen @gfnd) rnd size))))
(defmacro delay
"given body that returns a generator, returns a
generator that delegates to that, but delays
creation until used."
[& body]
`(delay-impl (c/delay ~@body)))
(defn gen-for-name
"Dynamically loads test.check generator named s."
[s]
(let [g (dynaload s)]
(if (generator? g)
g
(throw (RuntimeException. (str "Var " s " is not a generator"))))))
(defmacro ^:skip-wiki lazy-combinator
"Implementation macro, do not call directly."
[s]
(let [fqn (c/symbol "clojure.test.check.generators" (name s))
doc (str "Lazy loaded version of " fqn)]
`(let [g# (c/delay (dynaload '~fqn))]
(defn ~s
~doc
[& ~'args]
(apply @g# ~'args)))))
(defmacro ^:skip-wiki lazy-combinators
"Implementation macro, do not call directly."
[& syms]
`(do
~@(c/map
(fn [s] (c/list 'lazy-combinator s))
syms)))
(lazy-combinators hash-map list map not-empty set vector vector-distinct fmap elements
bind choose fmap one-of such-that tuple sample return
large-integer* double* frequency shuffle)
(defmacro ^:skip-wiki lazy-prim
"Implementation macro, do not call directly."
[s]
(let [fqn (c/symbol "clojure.test.check.generators" (name s))
doc (str "Fn returning " fqn)]
`(let [g# (c/delay (dynaload '~fqn))]
(defn ~s
~doc
[& ~'args]
@g#))))
(defmacro ^:skip-wiki lazy-prims
"Implementation macro, do not call directly."
[& syms]
`(do
~@(c/map
(fn [s] (c/list 'lazy-prim s))
syms)))
(lazy-prims any any-printable boolean bytes char char-alpha char-alphanumeric char-ascii double
int keyword keyword-ns large-integer ratio simple-type simple-type-printable
string string-ascii string-alphanumeric symbol symbol-ns uuid)
(defn cat
"Returns a generator of a sequence catenated from results of
gens, each of which should generate something sequential."
[& gens]
(fmap #(apply concat %)
(apply tuple gens)))
(defn- qualified? [ident] (not (nil? (namespace ident))))
(def ^:private
gen-builtins
(c/delay
(let [simple (simple-type-printable)]
{any? (one-of [(return nil) (any-printable)])
some? (such-that some? (any-printable))
number? (one-of [(large-integer) (double)])
integer? (large-integer)
int? (large-integer)
pos-int? (large-integer* {:min 1})
neg-int? (large-integer* {:max -1})
nat-int? (large-integer* {:min 0})
float? (double)
double? (double)
boolean? (boolean)
string? (string-alphanumeric)
ident? (one-of [(keyword-ns) (symbol-ns)])
simple-ident? (one-of [(keyword) (symbol)])
qualified-ident? (such-that qualified? (one-of [(keyword-ns) (symbol-ns)]))
keyword? (keyword-ns)
simple-keyword? (keyword)
qualified-keyword? (such-that qualified? (keyword-ns))
symbol? (symbol-ns)
simple-symbol? (symbol)
qualified-symbol? (such-that qualified? (symbol-ns))
uuid? (uuid)
uri? (fmap #(java.net.URI/create (str "http://" % ".com")) (uuid))
decimal? (fmap #(BigDecimal/valueOf %)
(double* {:infinite? false :NaN? false}))
inst? (fmap #(java.util.Date. %)
(large-integer))
seqable? (one-of [(return nil)
(list simple)
(vector simple)
(map simple simple)
(set simple)
(string-alphanumeric)])
indexed? (vector simple)
map? (map simple simple)
vector? (vector simple)
list? (list simple)
seq? (list simple)
char? (char)
set? (set simple)
nil? (return nil)
false? (return false)
true? (return true)
zero? (return 0)
rational? (one-of [(large-integer) (ratio)])
coll? (one-of [(map simple simple)
(list simple)
(vector simple)
(set simple)])
empty? (elements [nil '() [] {} #{}])
associative? (one-of [(map simple simple) (vector simple)])
sequential? (one-of [(list simple) (vector simple)])
ratio? (such-that ratio? (ratio))
bytes? (bytes)})))
(defn gen-for-pred
"Given a predicate, returns a built-in generator if one exists."
[pred]
(if (set? pred)
(elements pred)
(get @gen-builtins pred)))
(comment
(require :reload 'clojure.spec.gen.alpha)
(in-ns 'clojure.spec.gen.alpha)
;; combinators, see call to lazy-combinators above for complete list
(generate (one-of [(gen-for-pred integer?) (gen-for-pred string?)]))
(generate (such-that #(< 10000 %) (gen-for-pred integer?)))
(let [reqs {:a (gen-for-pred number?)
:b (gen-for-pred ratio?)}
opts {:c (gen-for-pred string?)}]
(generate (bind (choose 0 (count opts))
#(let [args (concat (seq reqs) (c/shuffle (seq opts)))]
(->> args
(take (+ % (count reqs)))
(mapcat identity)
(apply hash-map))))))
(generate (cat (list (gen-for-pred string?))
(list (gen-for-pred ratio?))))
;; load your own generator
(gen-for-name 'clojure.test.check.generators/int)
;; failure modes
(gen-for-name 'unqualified)
(gen-for-name 'clojure.core/+)
(gen-for-name 'clojure.core/name-does-not-exist)
(gen-for-name 'ns.does.not.exist/f)
)

View file

@ -0,0 +1,579 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns clojure.spec.test.alpha
(:refer-clojure :exclude [test])
(:require
[clojure.pprint :as pp]
[clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen]
[clojure.string :as str]))
(in-ns 'clojure.spec.test.check)
(in-ns 'clojure.spec.test.alpha)
(alias 'stc 'clojure.spec.test.check)
(defn- throwable?
[x]
(instance? Throwable x))
(defn ->sym
[x]
(@#'s/->sym x))
(defn- ->var
[s-or-v]
(if (var? s-or-v)
s-or-v
(let [v (and (symbol? s-or-v) (resolve s-or-v))]
(if (var? v)
v
(throw (IllegalArgumentException. (str (pr-str s-or-v) " does not name a var")))))))
(defn- collectionize
[x]
(if (symbol? x)
(list x)
x))
(defn enumerate-namespace
"Given a symbol naming an ns, or a collection of such symbols,
returns the set of all symbols naming vars in those nses."
[ns-sym-or-syms]
(into
#{}
(mapcat (fn [ns-sym]
(map
(fn [name-sym]
(symbol (name ns-sym) (name name-sym)))
(keys (ns-interns ns-sym)))))
(collectionize ns-sym-or-syms)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; instrument ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:private ^:dynamic *instrument-enabled*
"if false, instrumented fns call straight through"
true)
(defn- fn-spec?
"Fn-spec must include at least :args or :ret specs."
[m]
(or (:args m) (:ret m)))
(defmacro with-instrument-disabled
"Disables instrument's checking of calls, within a scope."
[& body]
`(binding [*instrument-enabled* nil]
~@body))
(defn- thunk-frame? [s]
(str/includes? s "--KVS--EMULATION--THUNK--"))
(defn- interpret-stack-trace-element
"Given the vector-of-syms form of a stacktrace element produced
by e.g. Throwable->map, returns a map form that adds some keys
guessing the original Clojure names. Returns a map with
:class class name symbol from stack trace
:method method symbol from stack trace
:file filename from stack trace
:line line number from stack trace
:var-scope optional Clojure var symbol scoping fn def
:local-fn optional local Clojure symbol scoping fn def
For non-Clojure fns, :scope and :local-fn will be absent."
[[cls method file line]]
(let [clojure? (contains? '#{invoke invokeStatic} method)
demunge #(s/demunge %)
degensym #(str/replace % #"--.*" "")
[ns-sym name-sym local] (when clojure?
(->> (str/split (str cls) #"\$" 3)
(map demunge)))]
(merge {:file file
:line line
:method method
:class cls}
(when (and ns-sym name-sym)
{:var-scope (symbol ns-sym name-sym)})
(when local
{:local-fn (symbol (degensym local))
:thunk? (thunk-frame? local)}))))
(defn- stacktrace-relevant-to-instrument
"Takes a coll of stack trace elements (as returned by
StackTraceElement->vec) and returns a coll of maps as per
interpret-stack-trace-element that are relevant to a
failure in instrument."
[elems]
(let [plumbing? (fn [{:keys [var-scope thunk?]}]
(or thunk?
(contains? '#{clojure.spec.test.alpha/spec-checking-fn
clojure.core/apply}
var-scope)))]
(sequence (comp (map StackTraceElement->vec)
(map interpret-stack-trace-element)
(filter :var-scope)
(drop-while plumbing?))
elems)))
(defn- spec-checking-fn
"Takes a function name, a function f, and an fspec and returns a thunk that
first conforms the arguments given then calls f with those arguments if
the conform succeeds. Otherwise, an exception is thrown containing information
about the conform failure."
[fn-name f fn-spec]
(let [fn-spec (@#'s/maybe-spec fn-spec)
conform! (fn [fn-name role spec data args]
(let [conformed (s/conform spec data)]
(if (= ::s/invalid conformed)
(let [caller (->> (.getStackTrace (Thread/currentThread))
stacktrace-relevant-to-instrument
first)
ed (merge (assoc (s/explain-data* spec [] [] [] data)
::s/fn fn-name
::s/args args
::s/failure :instrument)
(when caller
{::caller (dissoc caller :class :method)}))]
(throw (ex-info
(str "Call to " fn-name " did not conform to spec.")
ed)))
conformed)))]
(fn
[& args]
(if *instrument-enabled*
(with-instrument-disabled
(when (:args fn-spec) (conform! fn-name :args (:args fn-spec) args args))
(binding [*instrument-enabled* true]
(.applyTo ^clojure.lang.IFn f args)))
(.applyTo ^clojure.lang.IFn f args)))))
(defn- no-fspec
[v spec]
(ex-info (str "Fn at " v " is not spec'ed.")
{:var v :spec spec ::s/failure :no-fspec}))
(defonce ^:private instrumented-vars (atom {}))
(defn- find-varargs-decl
"Takes an arglist and returns the restargs binding form if found, else nil."
[arglist]
(let [[_ decl :as restargs] (->> arglist
(split-with (complement #{'&}))
second)]
(and (= 2 (count restargs))
decl)))
(defn- has-kwargs? [arglists]
(->> arglists (some find-varargs-decl) map?))
(defn- kwargs->kvs
"Takes the restargs of a kwargs function call and checks for a trailing element.
If found, that element is flattened into a sequence of key->value pairs and
concatenated onto the preceding arguments."
[args]
(if (even? (count args))
args
(concat (butlast args)
(reduce-kv (fn [acc k v] (->> acc (cons v) (cons k)))
()
(last args)))))
(defn- gen-fixed-args-syms
"Takes an arglist and generates a vector of names corresponding to the fixed
args found."
[arglist]
(->> arglist (take-while (complement #{'&})) (map (fn [_] (gensym))) vec))
(defn- build-kwargs-body
"Takes a function name fn-name and arglist and returns code for a function body that
handles kwargs by calling fn-name with any fixed followed by its restargs transformed
from kwargs to kvs."
[fn-name arglist]
(let [alias (gensym "kwargs")
head-args (gen-fixed-args-syms arglist)]
(list (conj head-args '& alias)
`(apply ~fn-name ~@head-args (@#'kwargs->kvs ~alias)))))
(defn- build-varargs-body
"Takes a function name fn-name and arglist and returns code for a function body that
handles varargs by calling fn-name with any fixed args followed by its rest args."
[fn-name arglist]
(let [head-args (gen-fixed-args-syms arglist)
alias (gensym "restargs")]
(list (conj head-args '& alias)
`(apply ~fn-name ~@head-args ~alias))))
(defn- build-fixed-args-body
"Takes a function name fn-name and arglist and returns code for a function body that
handles fixed args by calling fn-name with its fixed args."
[fn-name arglist]
(let [arglist (gen-fixed-args-syms arglist)]
(list arglist
`(~fn-name ~@arglist))))
(defn- build-flattener-code
"Takes argslists and generates code for a HOF that given a function, returns a forwarding thunk
of analogous arglists that ensures that kwargs are passed as kvs to the original function."
[arglists]
(let [closed-over-name (gensym "inner")]
`(fn [~closed-over-name]
(fn ~'--KVS--EMULATION--THUNK--
~@(map (fn [arglist]
(let [varargs-decl (find-varargs-decl arglist)]
(cond (map? varargs-decl) (build-kwargs-body closed-over-name arglist)
varargs-decl (build-varargs-body closed-over-name arglist)
:default (build-fixed-args-body closed-over-name arglist))))
(or arglists
'([& args])))))))
(comment
;; Given a function with the arglists (([a]) ([a b]) ([a b & kvs]))
;; the flattener generated is below (with some gensym name cleanup for readability)
(fn [inner]
(fn
([G__a] (inner G__a))
([G__a G__b] (inner G__a G__b))
([G__a G__b & G__kvs]
(apply inner G__a G__b (if (even? (count G__kvs))
G__kvs
(reduce-kv (fn [acc k v]
(->> acc (cons v) (cons k)))
(butlast G__kvs)
(last G__kvs)))))))
)
(defn- maybe-wrap-kvs-emulation
"Takes an argslist and function f and returns f except when arglists
contains a kwargs binding, else wraps f with a forwarding thunk that
flattens a trailing map into kvs if present in the kwargs call."
[f arglists]
(if (has-kwargs? arglists)
(let [flattener-code (build-flattener-code arglists)
kvs-emu (eval flattener-code)]
(kvs-emu f))
f))
(defn- instrument-choose-fn
"Helper for instrument."
[f spec sym {over :gen :keys [stub replace]}]
(if (some #{sym} stub)
(-> spec (s/gen over) gen/generate)
(get replace sym f)))
(defn- instrument-choose-spec
"Helper for instrument"
[spec sym {overrides :spec}]
(get overrides sym spec))
(defn- instrument-1
[s opts]
(when-let [v (resolve s)]
(when-not (-> v meta :macro)
(let [spec (s/get-spec v)
{:keys [raw wrapped]} (get @instrumented-vars v)
current @v
to-wrap (if (= wrapped current) raw current)
ospec (or (instrument-choose-spec spec s opts)
(throw (no-fspec v spec)))
ofn (instrument-choose-fn to-wrap ospec s opts)
checked (spec-checking-fn (->sym v) ofn ospec)
arglists (->> v meta :arglists (sort-by count) seq)
wrapped (maybe-wrap-kvs-emulation checked arglists)]
(alter-var-root v (constantly wrapped))
(swap! instrumented-vars assoc v {:raw to-wrap :wrapped wrapped})
(->sym v)))))
(defn- unstrument-1
[s]
(when-let [v (resolve s)]
(when-let [{:keys [raw wrapped]} (get @instrumented-vars v)]
(swap! instrumented-vars dissoc v)
(let [current @v]
(when (= wrapped current)
(alter-var-root v (constantly raw))
(->sym v))))))
(defn- opt-syms
"Returns set of symbols referenced by 'instrument' opts map"
[opts]
(reduce into #{} [(:stub opts) (keys (:replace opts)) (keys (:spec opts))]))
(defn- fn-spec-name?
[s]
(and (symbol? s)
(not (some-> (resolve s) meta :macro))))
(defn instrumentable-syms
"Given an opts map as per instrument, returns the set of syms
that can be instrumented."
([] (instrumentable-syms nil))
([opts]
(assert (every? ident? (keys (:gen opts))) "instrument :gen expects ident keys")
(reduce into #{} [(filter fn-spec-name? (keys (s/registry)))
(keys (:spec opts))
(:stub opts)
(keys (:replace opts))])))
(defn instrument
"Instruments the vars named by sym-or-syms, a symbol or collection
of symbols, or all instrumentable vars if sym-or-syms is not
specified.
If a var has an :args fn-spec, sets the var's root binding to a
fn that checks arg conformance (throwing an exception on failure)
before delegating to the original fn.
The opts map can be used to override registered specs, and/or to
replace fn implementations entirely. Opts for symbols not included
in sym-or-syms are ignored. This facilitates sharing a common
options map across many different calls to instrument.
The opts map may have the following keys:
:spec a map from var-name symbols to override specs
:stub a set of var-name symbols to be replaced by stubs
:gen a map from spec names to generator overrides
:replace a map from var-name symbols to replacement fns
:spec overrides registered fn-specs with specs your provide. Use
:spec overrides to provide specs for libraries that do not have
them, or to constrain your own use of a fn to a subset of its
spec'ed contract.
:stub replaces a fn with a stub that checks :args, then uses the
:ret spec to generate a return value.
:gen overrides are used only for :stub generation.
:replace replaces a fn with a fn that checks args conformance, then
invokes the fn you provide, enabling arbitrary stubbing and mocking.
:spec can be used in combination with :stub or :replace.
Returns a collection of syms naming the vars instrumented."
([] (instrument (instrumentable-syms)))
([sym-or-syms] (instrument sym-or-syms nil))
([sym-or-syms opts]
(locking instrumented-vars
(into
[]
(comp (filter (instrumentable-syms opts))
(distinct)
(map #(instrument-1 % opts))
(remove nil?))
(collectionize sym-or-syms)))))
(defn unstrument
"Undoes instrument on the vars named by sym-or-syms, specified
as in instrument. With no args, unstruments all instrumented vars.
Returns a collection of syms naming the vars unstrumented."
([] (unstrument (map ->sym (keys @instrumented-vars))))
([sym-or-syms]
(locking instrumented-vars
(into
[]
(comp (filter symbol?)
(map unstrument-1)
(remove nil?))
(collectionize sym-or-syms)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; testing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- explain-check
[args spec v role]
(ex-info
"Specification-based check failed"
(when-not (s/valid? spec v nil)
(assoc (s/explain-data* spec [role] [] [] v)
::args args
::val v
::s/failure :check-failed))))
(defn- check-call
"Returns true if call passes specs, otherwise *returns* an exception
with explain-data + ::s/failure."
[f specs args]
(let [cargs (when (:args specs) (s/conform (:args specs) args))]
(if (= cargs ::s/invalid)
(explain-check args (:args specs) args :args)
(let [ret (apply f args)
cret (when (:ret specs) (s/conform (:ret specs) ret))]
(if (= cret ::s/invalid)
(explain-check args (:ret specs) ret :ret)
(if (and (:args specs) (:ret specs) (:fn specs))
(if (s/valid? (:fn specs) {:args cargs :ret cret})
true
(explain-check args (:fn specs) {:args cargs :ret cret} :fn))
true))))))
(defn- quick-check
[f specs {gen :gen opts ::stc/opts}]
(let [{:keys [num-tests] :or {num-tests 1000}} opts
g (try (s/gen (:args specs) gen) (catch Throwable t t))]
(if (throwable? g)
{:result g}
(let [prop (gen/for-all* [g] #(check-call f specs %))]
(apply gen/quick-check num-tests prop (mapcat identity opts))))))
(defn- make-check-result
"Builds spec result map."
[check-sym spec test-check-ret]
(merge {:spec spec
::stc/ret test-check-ret}
(when check-sym
{:sym check-sym})
(when-let [result (-> test-check-ret :result)]
(when-not (true? result) {:failure result}))
(when-let [shrunk (-> test-check-ret :shrunk)]
{:failure (:result shrunk)})))
(defn- check-1
[{:keys [s f v spec]} opts]
(let [re-inst? (and v (seq (unstrument s)) true)
f (or f (when v @v))
specd (s/spec spec)]
(try
(cond
(or (nil? f) (some-> v meta :macro))
{:failure (ex-info "No fn to spec" {::s/failure :no-fn})
:sym s :spec spec}
(:args specd)
(let [tcret (quick-check f specd opts)]
(make-check-result s spec tcret))
:default
{:failure (ex-info "No :args spec" {::s/failure :no-args-spec})
:sym s :spec spec})
(finally
(when re-inst? (instrument s))))))
(defn- sym->check-map
[s]
(let [v (resolve s)]
{:s s
:v v
:spec (when v (s/get-spec v))}))
(defn- validate-check-opts
[opts]
(assert (every? ident? (keys (:gen opts))) "check :gen expects ident keys"))
(defn check-fn
"Runs generative tests for fn f using spec and opts. See
'check' for options and return."
([f spec] (check-fn f spec nil))
([f spec opts]
(validate-check-opts opts)
(check-1 {:f f :spec spec} opts)))
(defn checkable-syms
"Given an opts map as per check, returns the set of syms that
can be checked."
([] (checkable-syms nil))
([opts]
(validate-check-opts opts)
(reduce into #{} [(filter fn-spec-name? (keys (s/registry)))
(keys (:spec opts))])))
(defn check
"Run generative tests for spec conformance on vars named by
sym-or-syms, a symbol or collection of symbols. If sym-or-syms
is not specified, check all checkable vars.
The opts map includes the following optional keys, where stc
aliases clojure.spec.test.check:
::stc/opts opts to flow through test.check/quick-check
:gen map from spec names to generator overrides
The ::stc/opts include :num-tests in addition to the keys
documented by test.check. Generator overrides are passed to
spec/gen when generating function args.
Returns a lazy sequence of check result maps with the following
keys
:spec the spec tested
:sym optional symbol naming the var tested
:failure optional test failure
::stc/ret optional value returned by test.check/quick-check
The value for :failure can be any exception. Exceptions thrown by
spec itself will have an ::s/failure value in ex-data:
:check-failed at least one checked return did not conform
:no-args-spec no :args spec provided
:no-fn no fn provided
:no-fspec no fspec provided
:no-gen unable to generate :args
:instrument invalid args detected by instrument
"
([] (check (checkable-syms)))
([sym-or-syms] (check sym-or-syms nil))
([sym-or-syms opts]
(->> (collectionize sym-or-syms)
(filter (checkable-syms opts))
(pmap
#(check-1 (sym->check-map %) opts)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; check reporting ;;;;;;;;;;;;;;;;;;;;;;;;
(defn- failure-type
[x]
(::s/failure (ex-data x)))
(defn- unwrap-failure
[x]
(if (failure-type x)
(ex-data x)
x))
(defn- result-type
"Returns the type of the check result. This can be any of the
::s/failure keywords documented in 'check', or:
:check-passed all checked fn returns conformed
:check-threw checked fn threw an exception"
[ret]
(let [failure (:failure ret)]
(cond
(nil? failure) :check-passed
(failure-type failure) (failure-type failure)
:default :check-threw)))
(defn abbrev-result
"Given a check result, returns an abbreviated version
suitable for summary use."
[x]
(if (:failure x)
(-> (dissoc x ::stc/ret)
(update :spec s/describe)
(update :failure unwrap-failure))
(dissoc x :spec ::stc/ret)))
(defn summarize-results
"Given a collection of check-results, e.g. from 'check', pretty
prints the summary-result (default abbrev-result) of each.
Returns a map with :total, the total number of results, plus a
key with a count for each different :type of result."
([check-results] (summarize-results check-results abbrev-result))
([check-results summary-result]
(reduce
(fn [summary result]
(pp/pprint (summary-result result))
(-> summary
(update :total inc)
(update (result-type result) (fnil inc 0))))
{:total 0}
check-results)))

2
sci

@ -1 +1 @@
Subproject commit 34a9f8a99e497b16553505d63c6daf04ebbaf068
Subproject commit 92a071269f1a4e3f4fda262b33b47ec827be3d4e

View file

@ -11,11 +11,11 @@
(:require [babashka.deps :as deps]
[babashka.fs :as fs]
[babashka.tasks :refer [shell]]
[org.httpkit.client :as http]
[clojure.string :as str]
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.string :as str]
[clojure.tools.cli :as cli]
[clojure.edn :as edn]))
[org.httpkit.client :as http]))
(deps/add-deps '{:deps {org.clojure/tools.gitlibs {:mvn/version "2.4.172"}
borkdude/rewrite-edn {:mvn/version "0.1.0"}

View file

@ -7,24 +7,32 @@
(or (System/getenv "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH")
(System/getenv "APPVEYOR_REPO_BRANCH")
(System/getenv "CIRCLE_BRANCH")
(System/getenv "GITHUB_REF_NAME")
(System/getenv "CIRRUS_BRANCH")
(-> (sh "git" "rev-parse" "--abbrev-ref" "HEAD")
:out
str/trim)))
(defn release [& args]
(let [ght (System/getenv "GITHUB_TOKEN")
_ (println "Github token found")
file (first args)
_ (println "File" file)
branch (current-branch)
_ (println "On branch:" branch)
current-version
(-> (slurp "resources/BABASHKA_VERSION")
str/trim)]
(if (and ght (contains? #{"master" "main"} branch))
(do (assert file "File name must be provided")
(println "On main branch. Publishing asset.")
(ghr/overwrite-asset {:org "babashka"
:repo "babashka"
:file file
:tag (str "v" current-version)
:draft true})
:draft true
:overwrite (str/ends-with? current-version "SNAPSHOT")
:sha256 true})
(ghr/overwrite-asset {:org "babashka"
:repo "babashka-dev-builds"
:file file
@ -32,6 +40,8 @@
;; do not set, because we are posting to another repo
:target-commitish false
:draft false
:prerelease true}))
:prerelease true
:overwrite (str/ends-with? current-version "SNAPSHOT")
:sha256 true}))
(println "Skipping release artifact (no GITHUB_TOKEN or not on main branch)"))
nil))

15
script/built_in.clj Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bb
(ns built-in
(:require [babashka.fs :as fs]
[babashka.process :refer [shell]]))
;; copy clojure spec as built-in
(fs/with-temp-dir [tmp-dir {}]
(let [tmp-dir (fs/file tmp-dir)]
(shell {:dir tmp-dir} "git clone https://github.com/babashka/spec.alpha")
(let [spec-dir (fs/file tmp-dir "spec.alpha")]
(shell {:dir spec-dir} "git reset 1d9df099be4fbfd30b9b903642ad376373c16298 --hard")
(fs/copy-tree (fs/file spec-dir "src" "main" "clojure") (fs/file "resources" "src" "babashka")))))

View file

@ -43,7 +43,10 @@
".github/workflows/build.yml"
".circleci/config.yml"
"appveyor.yml"
"project.clj"])
"project.clj"
"script/bump_graal_version.clj"
".circleci/script/short_ci.clj"
".cirrus.yml"])
;; We might have to keep changing these from
;; time to time whenever the version is bumped
@ -51,10 +54,8 @@
;; OR
;;
;; We could have them as environment variables
(def current-graal-version "21.3.0")
(def current-graal-version "22.3.0")
(def current-java-version "java11")
(def valid-graal-bumps ["19.3.2" "20.1.0" "20.2.0" "20.3.0" "21.0.0" "21.1.0" "21.2.0" "21.3.0" "22.0.0.2"])
(def valid-java-bumps ["java8" "java11"])
(def cl-options
[["-g" "--graal VERSION" "graal version"]
@ -65,8 +66,8 @@
(:options (cli/parse-opts *command-line-args* cl-options)))
(defn is-valid-bump?
[version valid-bumps]
(some #(= % version) valid-bumps))
[_version _valid-bumps]
true)
(defn replace-current
[file current new]
@ -93,13 +94,13 @@
(let [new-graal-version (:graal args)
new-java-version (:java args)]
(when (not (nil? new-graal-version))
(if (is-valid-bump? new-graal-version valid-graal-bumps)
(if (is-valid-bump? new-graal-version nil)
(do
(println "Performing Graal bump...")
(bump-current current-graal-version new-graal-version))
(show-error new-graal-version)))
(when (not (nil? new-java-version))
(if (is-valid-bump? new-java-version valid-java-bumps)
(if (is-valid-bump? new-java-version nil)
(do
(println "Performing Java bump...")
(bump-current current-java-version new-java-version))

View file

@ -54,6 +54,7 @@ args=("-jar" "$BABASHKA_JAR"
"--verbose"
"--no-fallback"
"--native-image-info"
# --trace-class-initialization=jdk.internal.net.http.common.DebugLogger,jdk.internal.net.http.websocket.WebSocketImpl,jdk.internal.net.http.common.Utils
"$BABASHKA_XMX")
BABASHKA_STATIC=${BABASHKA_STATIC:-}
@ -77,6 +78,12 @@ if [ "$BABASHKA_FEATURE_HSQLDB" = "true" ]; then
args+=("-H:IncludeResources=org/hsqldb/.*\.properties" "-H:IncludeResources=org/hsqldb/.*\.sql")
fi
BABASHKA_FEATURE_POSTGRESQL=${BABASHKA_FEATURE_POSTGRESQL:-}
if [ "$BABASHKA_FEATURE_POSTGRESQL" = "true" ]; then
args+=("--initialize-at-build-time=org.postgresql.PGProperty")
fi
BABASHKA_FEATURE_SELMER=${BABASHKA_FEATURE_SELMER:-}
if [ "$BABASHKA_FEATURE_SELMER" = "true" ]; then
@ -91,7 +98,7 @@ then
export BABASHKA_FEATURE_XML="${BABASHKA_FEATURE_XML:-false}"
export BABASHKA_FEATURE_YAML="${BABASHKA_FEATURE_YAML:-false}"
export BABASHKA_FEATURE_CSV="${BABASHKA_FEATURE_CSV:-false}"
export BABAHSKA_FEATURE_TRANSIT="${BABAHSKA_FEATURE_TRANSIT:-false}"
export BABASHKA_FEATURE_TRANSIT="${BABASHKA_FEATURE_TRANSIT:-false}"
export BABASHKA_FEATURE_JAVA_TIME="${BABASHKA_FEATURE_JAVA_TIME:-false}"
export BABASHKA_FEATURE_JAVA_NET_HTTP="${BABASHKA_FEATURE_JAVA_NET_HTTP:-false}"
export BABASHKA_FEATURE_JAVA_NIO="${BABASHKA_FEATURE_JAVA_NIO:-false}"

View file

@ -2,7 +2,7 @@
set -euo pipefail
CLOJURE_TOOLS_VERSION="1.10.3.1040"
CLOJURE_TOOLS_VERSION="1.11.1.1200"
install_dir="${1:-/usr/local}"
mkdir -p "$install_dir"

View file

@ -9,7 +9,7 @@ else
fi
export BABASHKA_CLASSPATH
BABASHKA_CLASSPATH=$(clojure -A:lib-tests -Spath)
BABASHKA_CLASSPATH=$(clojure -Spath -A:lib-tests)
$BB_CMD -cp "$BABASHKA_CLASSPATH" \
-f "test-resources/lib_tests/babashka/run_all_libtests.clj" "$@"

View file

@ -19,12 +19,13 @@ fi
apt-get update -y && apt-get install musl-tools -y
ZLIB_VERSION="1.2.11"
ZLIB_VERSION="1.2.13"
ZLIB_SHA256="b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"
curl -O -sL "https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz"
# stable archive path
curl -O -sL --fail --show-error "https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz"
echo "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 zlib-${ZLIB_VERSION}.tar.gz" |
sha256sum --check
echo "${ZLIB_SHA256} zlib-${ZLIB_VERSION}.tar.gz" | sha256sum --check
tar xf "zlib-${ZLIB_VERSION}.tar.gz"
arch=${BABASHKA_ARCH:-"x86_64"}

View file

@ -16,7 +16,7 @@ then
export BABASHKA_FEATURE_XML="${BABASHKA_FEATURE_XML:-false}"
export BABASHKA_FEATURE_YAML="${BABASHKA_FEATURE_YAML:-false}"
export BABASHKA_FEATURE_CSV="${BABASHKA_FEATURE_CSV:-false}"
export BABAHSKA_FEATURE_TRANSIT="${BABAHSKA_FEATURE_TRANSIT:-false}"
export BABASHKA_FEATURE_TRANSIT="${BABASHKA_FEATURE_TRANSIT:-false}"
export BABASHKA_FEATURE_JAVA_TIME="${BABASHKA_FEATURE_JAVA_TIME:-false}"
export BABASHKA_FEATURE_JAVA_NET_HTTP="${BABASHKA_FEATURE_JAVA_NET_HTTP:-false}"
export BABASHKA_FEATURE_JAVA_NIO="${BABASHKA_FEATURE_JAVA_NIO:-false}"
@ -168,6 +168,13 @@ else
BABASHKA_LEIN_PROFILES+=",-feature/priority-map"
fi
if [ "$BABASHKA_FEATURE_RRB_VECTOR" = "true" ]
then
BABASHKA_LEIN_PROFILES+=",+feature/rrb-vector"
else
BABASHKA_LEIN_PROFILES+=",-feature/rrb-vector"
fi
cp deps.edn resources/META-INF/babashka/deps.edn
if [ -z "$BABASHKA_JAR" ]; then

View file

@ -130,6 +130,12 @@ set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/priority-map
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/priority-map
)
if not "%BABASHKA_FEATURE_RRB_VECTOR%"=="false" (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/rrb-vector
) else (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/rrb-vector
)
call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)"
call lein with-profiles %BABASHKA_LEIN_PROFILES%,+reflection,-uberjar do run

View file

@ -2,3 +2,29 @@
;; we need pprint loaded first, it patches pprint to not bloat the GraalVM binary
(:require [babashka.impl.patches.datafy]
[babashka.impl.pprint]))
;; Enable this for scanning requiring-resolve usage:
;; ---
;; (def old-requiring-resolve requiring-resolve)
;; (defmacro static-requiring-resolve [sym]
;; (prn :sym sym)
;; `(old-requiring-resolve ~sym))
;; (alter-var-root #'requiring-resolve (constantly @#'static-requiring-resolve))
;; (doto #'requiring-resolve (.setMacro))
;; ---
;; ((requiring-resolve 'clojure.pprint/pprint) (range 20))
;; Enable this for detecting literal usages of require
;; ---
;; (def old-require require)
;; (defmacro static-require [& syms]
;; (when (meta &form)
;; (prn :require &form ))
;; `(old-require ~@syms))
;; (alter-var-root #'require (constantly @#'static-require))
;; (doto #'require (.setMacro))
;; ---

View file

@ -1,5 +1,6 @@
(ns babashka.deps
(:require [babashka.process :as p]
(:require [babashka.impl.process :as pp]
[babashka.process :as p]
[borkdude.deps :as deps]
[sci.core :as sci]))
@ -26,10 +27,9 @@
(-> @(clojure) :exit) starts a clojure REPL, waits for it
to finish and returns the exit code from the process."
([] (clojure []))
([args] (clojure args nil))
([args opts]
(let [opts (merge {:in :inherit
[& args]
(let [{:keys [cmd opts prev]} (p/parse-args args)
opts (merge {:in :inherit
:out :inherit
:err :inherit
:shutdown p/destroy-tree}
@ -41,10 +41,14 @@
deps/*env* (:env opts)
deps/*extra-env* (:extra-env opts)
deps/*process-fn* (fn
([cmd] (p/process cmd opts))
([cmd _] (p/process cmd opts)))
([cmd] (pp/process* {:cmd cmd
:prev prev
:opts opts}))
([cmd _] (pp/process* {:cmd cmd
:prev prev
:opts opts})))
deps/*exit-fn* (fn
([_])
([_exit-code msg]
(throw (Exception. msg))))]
(apply deps/-main (map str args))))))
(apply deps/-main cmd))))

View file

@ -1,10 +1,10 @@
(ns babashka.impl.bencode
{:no-doc true}
(:require [bencode.core :as bencode]
[sci.impl.namespaces :refer [copy-var]]
[sci.impl.vars :as vars]))
(:require
[bencode.core :as bencode]
[sci.core :as sci :refer [copy-var]]))
(def tns (vars/->SciNamespace 'bencode.core nil))
(def tns (sci/create-ns 'bencode.core nil))
(def bencode-namespace
{'read-bencode (copy-var bencode/read-bencode tns)

View file

@ -1,10 +1,9 @@
(ns babashka.impl.cheshire
{:no-doc true}
(:require [cheshire.core :as json]
[sci.impl.namespaces :refer [copy-var]]
[sci.impl.vars :as vars]))
[sci.core :as sci :refer [copy-var]]))
(def tns (vars/->SciNamespace 'cheshire.core nil))
(def tns (sci/create-ns 'cheshire.core nil))
(def cheshire-core-namespace
{'encode (copy-var json/encode tns)

View file

@ -4,6 +4,8 @@
[babashka.impl.features :as features]
[babashka.impl.proxy :as proxy]
[cheshire.core :as json]
[clojure.core.async]
[sci.core :as sci]
[sci.impl.types :as t]))
(def base-custom-map
@ -78,11 +80,25 @@
;; this fixes clojure.lang.Reflector for Java 11
java.lang.reflect.AccessibleObject
{:methods [{:name "canAccess"}]}
java.lang.reflect.Method
java.lang.Package
{:methods [{:name "getName"}]}
java.lang.reflect.Member
{:methods [{:name "getModifiers"}]}
java.lang.reflect.Method
{:methods [{:name "getName"}
{:name "getModifiers"}
{:name "getParameterTypes"}
{:name "getReturnType"}]}
java.lang.reflect.Modifier
{:methods [{:name "isStatic"}]}
java.lang.reflect.Field
{:methods [{:name "getName"}
{:name "getModifiers"}]}
java.lang.reflect.Array
{:methods [{:name "newInstance"}
{:name "set"}]}
java.lang.Runnable
{:methods [{:name "run"}]}
java.net.Inet4Address
{:methods [{:name "getHostAddress"}]}
java.net.Inet6Address
@ -97,9 +113,34 @@
{:name "aset"}
{:name "aclone"}]}
clojure.lang.Compiler
{:fields [{:name "specials"}]}
{:fields [{:name "specials"}
{:name "CHAR_MAP"}]}
clojure.lang.PersistentHashMap
{:fields [{:name "EMPTY"}]}})
{:fields [{:name "EMPTY"}]}
clojure.lang.APersistentVector
{:methods [{:name "indexOf"}]}
clojure.lang.LazySeq
{:allPublicConstructors true,
:methods [{:name "indexOf"}]}
clojure.lang.ILookup
{:methods [{:name "valAt"}]}
clojure.lang.IPersistentMap
{:methods [{:name "without"}]}
clojure.lang.IPersistentSet
{:methods [{:name "disjoin"}]}
clojure.lang.Indexed
{:methods [{:name "nth"}]}
clojure.lang.Ratio
{:fields [{:name "numerator"}
{:name "denominator"}]}
clojure.lang.Agent
{:fields [{:name "pooledExecutor"}
{:name "soloExecutor"}]}
java.util.Iterator
{:methods [{:name "hasNext"}
{:name "next"}]}
java.util.TimeZone
{:methods [{:name "getTimeZone"}]}})
(def custom-map
(cond->
@ -110,7 +151,56 @@
:parameterTypes ["org.hsqldb.Database"]}]}
`java.util.ResourceBundle
{:methods [{:name "getBundle"
:parameterTypes ["java.lang.String","java.util.Locale","java.lang.ClassLoader"]}]})))
:parameterTypes ["java.lang.String","java.util.Locale",
"java.lang.ClassLoader"]}]})))
(def java-net-http-classes
"These classes must be initialized at run time since GraalVM 22.1"
'[java.net.Authenticator
java.net.CookieHandler
java.net.CookieManager
java.net.CookieStore
java.net.CookiePolicy
java.net.HttpCookie
java.net.PasswordAuthentication
java.net.ProxySelector
java.net.SocketTimeoutException
java.net.http.HttpClient
java.net.http.HttpClient$Builder
java.net.http.HttpClient$Redirect
java.net.http.HttpClient$Version
java.net.http.HttpHeaders
java.net.http.HttpRequest
java.net.http.HttpRequest$BodyPublisher
java.net.http.HttpRequest$BodyPublishers
java.net.http.HttpRequest$Builder
java.net.http.HttpResponse
java.net.http.HttpResponse$BodyHandler
java.net.http.HttpResponse$BodyHandlers
java.net.http.HttpTimeoutException
java.net.http.WebSocket
java.net.http.WebSocket$Builder
java.net.http.WebSocket$Listener
java.security.cert.X509Certificate
javax.crypto.Mac
javax.crypto.spec.SecretKeySpec
javax.net.ssl.HostnameVerifier ;; clj-http-lite
javax.net.ssl.HttpsURLConnection ;; clj-http-lite
javax.net.ssl.KeyManagerFactory
javax.net.ssl.SSLContext
javax.net.ssl.SSLException
javax.net.ssl.SSLParameters
javax.net.ssl.SSLSession ;; clj-http-lite
javax.net.ssl.TrustManager
javax.net.ssl.TrustManagerFactory
javax.net.ssl.X509TrustManager
jdk.internal.net.http.HttpClientBuilderImpl
jdk.internal.net.http.HttpClientFacade
jdk.internal.net.http.HttpRequestBuilderImpl
jdk.internal.net.http.HttpResponseImpl
jdk.internal.net.http.common.MinimalFuture
jdk.internal.net.http.websocket.BuilderImpl
jdk.internal.net.http.websocket.WebSocketImpl])
(def classes
`{:all [clojure.lang.ArityException
@ -165,6 +255,7 @@
java.lang.ClassNotFoundException
java.lang.Comparable
java.lang.Double
java.lang.Error
java.lang.Exception
java.lang.Float
java.lang.IllegalArgumentException
@ -193,10 +284,14 @@
java.lang.System
java.lang.Throwable
;; java.lang.UnsupportedOperationException
java.lang.ref.WeakReference
java.lang.ref.ReferenceQueue
java.lang.ref.Cleaner
java.math.BigDecimal
java.math.BigInteger
java.math.MathContext
java.math.RoundingMode
java.net.BindException
java.net.ConnectException
java.net.DatagramSocket
java.net.DatagramPacket
@ -208,54 +303,10 @@
java.net.SocketException
java.net.UnknownHostException
java.net.URI
;; java.net.URL, see below
;; java.net.URL, see custom map
java.net.URLConnection
java.net.URLEncoder
java.net.URLDecoder
;; java.net.http
~@(when features/java-net-http?
'[java.net.Authenticator
java.net.CookieHandler
java.net.CookieManager
java.net.CookieStore
java.net.CookiePolicy
java.net.HttpCookie
java.net.PasswordAuthentication
java.net.ProxySelector
java.net.http.HttpClient
java.net.http.HttpClient$Builder
java.net.http.HttpClient$Redirect
java.net.http.HttpClient$Version
java.net.http.HttpHeaders
java.net.http.HttpRequest
java.net.http.HttpRequest$BodyPublisher
java.net.http.HttpRequest$BodyPublishers
java.net.http.HttpRequest$Builder
java.net.http.HttpResponse
java.net.http.HttpResponse$BodyHandler
java.net.http.HttpResponse$BodyHandlers
java.net.http.HttpTimeoutException
java.net.http.WebSocket
java.net.http.WebSocket$Builder
java.net.http.WebSocket$Listener
java.security.cert.X509Certificate
javax.crypto.Mac
javax.crypto.spec.SecretKeySpec
javax.net.ssl.HostnameVerifier ;; clj-http-lite
javax.net.ssl.HttpsURLConnection ;; clj-http-lite
javax.net.ssl.KeyManagerFactory
javax.net.ssl.SSLContext
javax.net.ssl.SSLParameters
javax.net.ssl.SSLSession ;; clj-http-lite
javax.net.ssl.TrustManager
javax.net.ssl.TrustManagerFactory
javax.net.ssl.X509TrustManager
jdk.internal.net.http.HttpClientBuilderImpl
jdk.internal.net.http.HttpClientFacade
jdk.internal.net.http.HttpRequestBuilderImpl
jdk.internal.net.http.HttpResponseImpl
jdk.internal.net.http.common.MinimalFuture
jdk.internal.net.http.websocket.BuilderImpl
jdk.internal.net.http.websocket.WebSocketImpl])
~@(when features/java-nio?
'[java.nio.ByteBuffer
java.nio.ByteOrder
@ -319,6 +370,7 @@
java.time.Year
java.time.YearMonth
java.time.ZoneRegion
java.time.zone.ZoneRules
java.time.ZonedDateTime
java.time.ZoneId
java.time.ZoneOffset
@ -338,10 +390,26 @@
java.time.temporal.Temporal
java.time.temporal.TemporalAccessor
java.time.temporal.TemporalAdjuster])
java.util.concurrent.atomic.AtomicInteger
java.util.concurrent.atomic.AtomicLong
java.util.concurrent.atomic.AtomicReference
java.util.concurrent.CancellationException
java.util.concurrent.CompletionException
java.util.concurrent.ExecutionException
java.util.concurrent.Executor
java.util.concurrent.LinkedBlockingQueue
java.util.concurrent.ScheduledThreadPoolExecutor
java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ThreadPoolExecutor$AbortPolicy
java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy
java.util.concurrent.ThreadPoolExecutor$DiscardOldestPolicy
java.util.concurrent.ThreadPoolExecutor$DiscardPolicy
java.util.concurrent.ScheduledExecutorService
java.util.concurrent.Future
java.util.concurrent.FutureTask
java.util.concurrent.CompletableFuture
java.util.concurrent.Executors
java.util.concurrent.TimeUnit
java.util.jar.Attributes$Name
java.util.jar.JarFile
java.util.jar.JarEntry
@ -362,19 +430,26 @@
java.util.Base64$Decoder
java.util.Base64$Encoder
java.util.Date
java.util.HashMap
java.util.IdentityHashMap
java.util.InputMismatchException
java.util.List
java.util.Locale
java.util.Map
java.util.MissingResourceException
java.util.NoSuchElementException
java.util.Optional
java.util.Properties
java.util.Scanner
java.util.Set
java.util.StringTokenizer
java.util.WeakHashMap
java.util.UUID
java.util.concurrent.CompletableFuture
java.util.concurrent.Executors
java.util.concurrent.TimeUnit
java.util.function.Consumer
java.util.function.Function
java.util.function.BiConsumer
java.util.function.BiFunction
java.util.function.Predicate
java.util.function.Supplier
java.util.zip.Inflater
java.util.zip.InflaterInputStream
@ -388,6 +463,8 @@
java.util.zip.ZipEntry
java.util.zip.ZipException
java.util.zip.ZipFile
sun.misc.Signal
sun.misc.SignalHandler
~(symbol "[B")
~(symbol "[I")
~(symbol "[Ljava.lang.Object;")
@ -417,6 +494,7 @@
;; list above and then everything reachable via the public class will be
;; visible in the native image.
:instance-checks [clojure.lang.AFn
clojure.lang.AFunction
clojure.lang.AMapEntry ;; for proxy
clojure.lang.APersistentMap ;; for proxy
clojure.lang.APersistentSet
@ -434,12 +512,8 @@
clojure.lang.IEditableCollection
clojure.lang.IMapEntry
clojure.lang.IMeta
clojure.lang.ILookup
clojure.lang.IPersistentCollection
clojure.lang.IPersistentMap
clojure.lang.IPersistentSet
clojure.lang.IPersistentStack
clojure.lang.IPersistentVector
clojure.lang.IPersistentList
clojure.lang.IRecord
clojure.lang.IReduce
@ -447,10 +521,9 @@
clojure.lang.IKVReduce
clojure.lang.IRef
clojure.lang.ISeq
clojure.lang.IPersistentVector
clojure.lang.ITransientVector
clojure.lang.Indexed
clojure.lang.Iterate
clojure.lang.LazySeq
clojure.lang.LispReader$Resolver
clojure.lang.Named
clojure.lang.Keyword
@ -471,11 +544,18 @@
clojure.lang.Sequential
clojure.lang.Seqable
clojure.lang.Volatile
java.util.concurrent.atomic.AtomicInteger
java.util.concurrent.atomic.AtomicLong
;; the only way to check if something is a channel is to
;; call instance? on this...
clojure.core.async.impl.channels.ManyToManyChannel
java.lang.AbstractMethodError
java.lang.ExceptionInInitializerError
java.lang.LinkageError
java.lang.ThreadDeath
java.lang.VirtualMachineError
java.net.URLClassLoader
java.sql.Timestamp
java.util.concurrent.TimeoutException
java.util.Collection
java.util.List
java.util.Iterator
java.util.Map$Entry
~@(when features/xml? ['clojure.data.xml.node.Element])]
:custom ~custom-map})
@ -490,9 +570,11 @@
m (apply hash-map
(for [c classes
c [(list 'quote c) c]]
c))]
(assoc m :public-class
c))
m (assoc m :public-class
(fn [v]
;; NOTE: a series of instance check, so far, is still cheaper
;; than piggybacking on defmulti or defprotocol
(cond (instance? java.lang.Process v)
java.lang.Process
(instance? java.lang.ProcessHandle v)
@ -543,13 +625,34 @@
java.io.Closeable
(instance? java.nio.file.attribute.BasicFileAttributes v)
java.nio.file.attribute.BasicFileAttributes
(instance? java.util.concurrent.Future v)
java.util.concurrent.Future
(instance? java.util.concurrent.ScheduledExecutorService v)
java.util.concurrent.ScheduledExecutorService
(instance? java.util.Iterator v)
java.util.Iterator
;; keep commas for merge friendliness
,,,)))))
,,,)))
m (assoc m (list 'quote 'clojure.lang.Var) 'sci.lang.Var)
m (assoc m (list 'quote 'clojure.lang.Namespace) 'sci.lang.Namespace)]
m))
(def class-map (gen-class-map))
(def class-map*
"This contains mapping of symbol to class of all classes that are
allowed to be initialized at build time."
(gen-class-map))
(def class-map
"A delay to delay initialization of java-net-http classes to run time, since GraalVM 22.1"
(delay (persistent! (reduce (fn [acc c]
(assoc! acc c (Class/forName (str c))))
(transient class-map*) (when features/java-net-http?
java-net-http-classes)))))
(def imports
'{Appendable java.lang.Appendable
'{AbstractMethodError java.lang.AbstractMethodError
Appendable java.lang.Appendable
ArithmeticException java.lang.ArithmeticException
AssertionError java.lang.AssertionError
BigDecimal java.math.BigDecimal
@ -563,7 +666,9 @@
ClassNotFoundException java.lang.ClassNotFoundException
Comparable java.lang.Comparable
Double java.lang.Double
Error java.lang.Error
Exception java.lang.Exception
ExceptionInInitializerError java.lang.ExceptionInInitializerError
IndexOutOfBoundsException java.lang.IndexOutOfBoundsException
IllegalArgumentException java.lang.IllegalArgumentException
IllegalStateException java.lang.IllegalStateException
@ -573,6 +678,7 @@
File java.io.File
Float java.lang.Float
Long java.lang.Long
LinkageError java.lang.LinkageError
Math java.lang.Math
NullPointerException java.lang.NullPointerException
Number java.lang.Number
@ -589,11 +695,15 @@
System java.lang.System
Thread java.lang.Thread
Throwable java.lang.Throwable
VirtualMachineError java.lang.VirtualMachineError
ThreadDeath java.lang.ThreadDeath
;; UnsupportedOperationException java.lang.UnsupportedOperationException
})
(defn reflection-file-entries []
(let [entries (vec (for [c (sort (:all classes))
(let [entries (vec (for [c (sort (concat (:all classes)
(when features/java-net-http?
java-net-http-classes)))
:let [class-name (str c)]]
{:name class-name
:allPublicMethods true
@ -627,7 +737,8 @@
(let [all-entries (reflection-file-entries)]
(spit (or
(first args)
"resources/META-INF/native-image/babashka/babashka/reflect-config.json") (json/generate-string all-entries {:pretty true}))))
"resources/META-INF/native-image/babashka/babashka/reflect-config.json")
(json/generate-string all-entries {:pretty true}))))
(defn public-declared-method? [c m]
(and (= c (.getDeclaringClass m))
@ -643,18 +754,25 @@
(sort-by :name)
(vec)))
(defn all-methods []
(defn all-classes []
"Returns every java.lang.Class instance Babashka supports."
(->> (reflection-file-entries)
(map :name)
(map #(Class/forName %))
(mapcat public-declared-method-names)))
(map #(Class/forName %))))
(defn all-methods []
(mapcat public-declared-method-names (all-classes)))
(def cns (sci/create-ns 'babashka.classes nil))
(def classes-namespace
{:obj cns
'all-classes (sci/copy-var all-classes cns)})
(comment
(public-declared-method-names java.net.URL)
(public-declared-method-names java.util.Properties)
(->> (reflection-file-entries)
(map :name)
(map #(Class/forName %)))
(all-classes)
)

View file

@ -5,7 +5,8 @@
[clojure.java.io :as io]
[clojure.string :as str]
[sci.core :as sci])
(:import [java.util.jar JarFile Manifest]))
(:import [java.util.jar JarFile Manifest]
(java.net URL)))
(set! *warn-on-reflection* true)
@ -65,14 +66,18 @@
entries (keep part->entry parts)]
(Loader. entries)))
(defn source-for-namespace [loader namespace opts]
(defn resource-paths [namespace]
(let [ns-str (name namespace)
^String ns-str (munge ns-str)
^String ns-str (namespace-munge ns-str)
;; do NOT pick the platform specific file separator here, since that doesn't work for searching in .jar files
;; (io/file "foo" "bar/baz") does work on Windows, despite the forward slash
base-path (.replace ns-str "." "/")
resource-paths (mapv #(str base-path %) [".bb" ".clj" ".cljc"])]
(getResource loader resource-paths opts)))
resource-paths))
(defn source-for-namespace [loader namespace opts]
(let [rps (resource-paths namespace)]
(getResource loader rps opts)))
(defn main-ns [manifest-resource]
(with-open [is (io/input-stream manifest-resource)]
@ -106,11 +111,11 @@
[]
(:cp @cp-state))
(defn resource [path]
(when-let [st @cp-state]
(let [loader (:loader st)]
(defn resource
(^URL [path] (when-let [st @cp-state] (resource (:loader st) path)))
(^URL [loader path]
(if (str/starts-with? path "/") nil ;; non-relative paths always return nil
(getResource loader [path] true)))))
(getResource loader [path] true))))
(def cns (sci/create-ns 'babashka.classpath nil))
@ -126,5 +131,5 @@
(def cp "src:feature-xml:feature-core-async:feature-yaml:feature-csv:feature-transit:feature-java-time:feature-java-nio:sci/src:babashka.curl/src:babashka.pods/src:resources:sci/resources:/Users/borkdude/.m2/repository/com/cognitect/transit-java/1.0.343/transit-java-1.0.343.jar:/Users/borkdude/.m2/repository/org/clojure/clojure/1.10.2-alpha1/clojure-1.10.2-alpha1.jar:/Users/borkdude/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/Users/borkdude/.m2/repository/org/clojure/tools.analyzer/1.0.0/tools.analyzer-1.0.0.jar:/Users/borkdude/.m2/repository/org/clojure/tools.logging/0.6.0/tools.logging-0.6.0.jar:/Users/borkdude/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:/Users/borkdude/.m2/repository/org/clojure/spec.alpha/0.2.187/spec.alpha-0.2.187.jar:/Users/borkdude/.m2/repository/org/clojure/tools.cli/1.0.194/tools.cli-1.0.194.jar:/Users/borkdude/.m2/repository/org/clojure/tools.analyzer.jvm/1.0.0/tools.analyzer.jvm-1.0.0.jar:/Users/borkdude/.m2/repository/borkdude/graal.locking/0.0.2/graal.locking-0.0.2.jar:/Users/borkdude/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.10.2/jackson-dataformat-cbor-2.10.2.jar:/Users/borkdude/.m2/repository/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar:/Users/borkdude/.m2/repository/org/flatland/ordered/1.5.9/ordered-1.5.9.jar:/Users/borkdude/.m2/repository/org/postgresql/postgresql/42.2.12/postgresql-42.2.12.jar:/Users/borkdude/.m2/repository/fipp/fipp/0.6.22/fipp-0.6.22.jar:/Users/borkdude/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.10.2/jackson-core-2.10.2.jar:/Users/borkdude/.m2/repository/org/yaml/snakeyaml/1.25/snakeyaml-1.25.jar:/Users/borkdude/.m2/repository/org/ow2/asm/asm/5.2/asm-5.2.jar:/Users/borkdude/.gitlibs/libs/clj-commons/conch/9aa7724e925cb8bf163e0b62486dd420b84e5f0b/src:/Users/borkdude/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar:/Users/borkdude/.m2/repository/seancorfield/next.jdbc/1.0.424/next.jdbc-1.0.424.jar:/Users/borkdude/.m2/repository/org/clojure/data.xml/0.2.0-alpha6/data.xml-0.2.0-alpha6.jar:/Users/borkdude/.m2/repository/org/msgpack/msgpack/0.6.12/msgpack-0.6.12.jar:/Users/borkdude/.m2/repository/borkdude/edamame/0.0.11-alpha.9/edamame-0.0.11-alpha.9.jar:/Users/borkdude/.m2/repository/org/clojure/data.csv/1.0.0/data.csv-1.0.0.jar:/Users/borkdude/.m2/repository/com/cognitect/transit-clj/1.0.324/transit-clj-1.0.324.jar:/Users/borkdude/.m2/repository/clj-commons/clj-yaml/0.7.1/clj-yaml-0.7.1.jar:/Users/borkdude/.m2/repository/org/clojure/core.rrb-vector/0.1.1/core.rrb-vector-0.1.1.jar:/Users/borkdude/.m2/repository/persistent-sorted-set/persistent-sorted-set/0.1.2/persistent-sorted-set-0.1.2.jar:/Users/borkdude/.m2/repository/cheshire/cheshire/5.10.0/cheshire-5.10.0.jar:/Users/borkdude/.m2/repository/tigris/tigris/0.1.2/tigris-0.1.2.jar:/Users/borkdude/.m2/repository/org/clojure/tools.reader/1.3.2/tools.reader-1.3.2.jar:/Users/borkdude/.m2/repository/datascript/datascript/0.18.11/datascript-0.18.11.jar:/Users/borkdude/.m2/repository/org/hsqldb/hsqldb/2.4.0/hsqldb-2.4.0.jar:/Users/borkdude/.m2/repository/org/clojure/core.memoize/0.8.2/core.memoize-0.8.2.jar:/Users/borkdude/.m2/repository/org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.jar:/Users/borkdude/.m2/repository/org/clojure/java.data/1.0.64/java.data-1.0.64.jar:/Users/borkdude/.m2/repository/borkdude/sci.impl.reflector/0.0.1/sci.impl.reflector-0.0.1.jar:/Users/borkdude/.m2/repository/nrepl/bencode/1.1.0/bencode-1.1.0.jar:/Users/borkdude/.m2/repository/org/clojure/core.cache/0.8.2/core.cache-0.8.2.jar:/Users/borkdude/.m2/repository/org/clojure/core.async/1.1.587/core.async-1.1.587.jar:/Users/borkdude/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.10.2/jackson-dataformat-smile-2.10.2.jar:/Users/borkdude/.m2/repository/org/clojure/data.codec/0.1.0/data.codec-0.1.0.jar:/Users/borkdude/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar")
(def l (loader cp))
(source-for-namespace l 'babashka.impl.cheshire nil)
(time (:file (source-for-namespace l 'cheshire.core nil))) ;; 20ms -> 2.25ms
)
(time (:file (source-for-namespace l 'cheshire.core nil)))) ;; 20ms -> 2.25ms

37
src/babashka/impl/cli.clj Normal file
View file

@ -0,0 +1,37 @@
(ns babashka.impl.cli
(:require
[babashka.cli]
[sci.core :as sci]))
(def cns (sci/create-ns 'babashka.cli))
(def cli-namespace
(sci/copy-ns babashka.cli cns))
(defn exec-fn-snippet
([sym] (exec-fn-snippet sym nil))
([sym extra-opts]
(format "
(ns exec-%s
(:require [babashka.cli :as cli]))
(let [extra-opts '%s
sym `%s
the-var (requiring-resolve sym)
the-var-meta (meta the-var)
ns (:ns (meta the-var))
ns-meta (meta ns)
ct (babashka.tasks/current-task)
cli-opts (babashka.cli/merge-opts (:org.babashka/cli ns-meta)
(:org.babashka/cli the-var-meta)
(:org.babashka/cli ct)
extra-opts)
task-exec-args (:exec-args ct)
cli-exec-args (:exec-args cli-opts)
exec-args {:exec-args (babashka.cli/merge-opts cli-exec-args task-exec-args)}
cli-opts (babashka.cli/merge-opts exec-args cli-opts)
opts (babashka.cli/parse-opts *command-line-args* cli-opts)]
(the-var opts))"
(random-uuid)
(pr-str extra-opts)
sym
)))

View file

@ -7,9 +7,10 @@
[clojure.core :as c]
[clojure.string :as str]
[sci.core :as sci]
[sci.impl.namespaces :refer [copy-core-var core-var macrofy]]
[sci.impl.copy-vars :refer [copy-core-var new-var macrofy]]
[sci.impl.parser :as parser]
[sci.impl.vars :as vars :refer [clojure-core-ns]]))
[sci.impl.utils :refer [clojure-core-ns]]
[sci.impl.vars :as vars]))
(defn locking* [form bindings v f & args]
(apply @#'locking/locking form bindings v f args))
@ -31,6 +32,7 @@
(def command-line-args (core-dynamic-var '*command-line-args*))
(def warn-on-reflection (core-dynamic-var '*warn-on-reflection* false))
(def compile-files (core-dynamic-var '*compile-files* false))
(def unchecked-math (core-dynamic-var '*unchecked-math* false))
(def math-context (core-dynamic-var '*math-context*))
(defn read+string
@ -164,11 +166,12 @@
'*data-readers* data-readers
'default-data-readers (copy-core-var default-data-readers)
'xml-seq (copy-core-var xml-seq)
'read+string (core-var 'read+string (fn [& args]
(apply read+string @common/ctx args)))
'read+string (new-var 'read+string (fn [& args]
(apply read+string (common/ctx) args)))
'*command-line-args* command-line-args
'*warn-on-reflection* warn-on-reflection
'*compile-files* compile-files
'*unchecked-math* unchecked-math
'*math-context* math-context
'with-precision (sci/copy-var with-precision clojure-core-ns)
'-with-precision (sci/copy-var -with-precision clojure-core-ns)
@ -192,6 +195,8 @@
'iteration (sci/copy-var iteration clojure-core-ns)
'abs (sci/copy-var abs clojure-core-ns)
'StackTraceElement->vec (sci/copy-var StackTraceElement->vec clojure-core-ns)
'memfn (sci/copy-var memfn clojure-core-ns)
'into-array (sci/copy-var into-array clojure-core-ns)}
'into-array (sci/copy-var into-array clojure-core-ns)
'print-method (sci/copy-var print-method clojure-core-ns)
'print-dup (sci/copy-var print-dup clojure-core-ns)
'PrintWriter-on (sci/copy-var PrintWriter-on clojure-core-ns)}
)

View file

@ -2,7 +2,8 @@
{:no-doc true}
(:require [clojure.core.async :as async]
[clojure.core.async.impl.protocols :as protocols]
[sci.impl.namespaces :refer [copy-var macrofy]]
[sci.core :as sci :refer [copy-var]]
[sci.impl.copy-vars :refer [macrofy]]
[sci.impl.vars :as vars]))
(def ^java.util.concurrent.Executor executor @#'async/thread-macro-executor)
@ -39,14 +40,13 @@
[_ _ bindings & body]
(list 'clojure.core.async/thread (list* 'loop bindings body)))
(def core-async-namespace (vars/->SciNamespace 'clojure.core.async nil))
(def core-async-namespace (sci/create-ns 'clojure.core.async nil))
(def async-namespace
{:obj core-async-namespace
'<!! (copy-var async/<!! core-async-namespace)
'>!! (copy-var async/>!! core-async-namespace)
'admix (copy-var async/admix core-async-namespace)
'alts! (copy-var async/alts! core-async-namespace)
'alts!! (copy-var async/alts!! core-async-namespace)
'alt!! (macrofy 'alt!! alt!! core-async-namespace)
'buffer (copy-var async/buffer core-async-namespace)
@ -68,6 +68,8 @@
'mult (copy-var async/mult core-async-namespace)
'offer! (copy-var async/offer! core-async-namespace)
'onto-chan (copy-var async/onto-chan core-async-namespace)
'onto-chan! (copy-var async/onto-chan! core-async-namespace)
'onto-chan!! (copy-var async/onto-chan!! core-async-namespace)
'partition (copy-var async/partition core-async-namespace)
'partition-by (copy-var async/partition-by core-async-namespace)
'pipe (copy-var async/pipe core-async-namespace)
@ -92,6 +94,8 @@
'thread-call (copy-var thread-call core-async-namespace)
'timeout (copy-var async/timeout core-async-namespace)
'to-chan (copy-var async/to-chan core-async-namespace)
'to-chan! (copy-var async/to-chan! core-async-namespace)
'to-chan!! (copy-var async/to-chan!! core-async-namespace)
'toggle (copy-var async/toggle core-async-namespace)
'transduce (copy-var async/transduce core-async-namespace)
'unblocking-buffer? (copy-var async/unblocking-buffer? core-async-namespace)
@ -104,12 +108,13 @@
'untap-all (copy-var async/untap-all core-async-namespace)
;; polyfill
'go (macrofy 'go thread core-async-namespace)
'<! (copy-var async/<!! core-async-namespace)
'>! (copy-var async/>!! core-async-namespace)
'<! (copy-var async/<!! core-async-namespace {:name '<!})
'>! (copy-var async/>!! core-async-namespace {:name '>!})
'alt! (macrofy 'alt! alt!! core-async-namespace)
'alts! (copy-var async/alts!! core-async-namespace {:name 'alts!})
'go-loop (macrofy 'go-loop go-loop core-async-namespace)})
(def async-protocols-ns (vars/->SciNamespace 'clojure.core.async.impl.protocols nil))
(def async-protocols-ns (sci/create-ns 'clojure.core.async.impl.protocols nil))
(def async-protocols-namespace
{:obj async-protocols-ns

View file

@ -18,7 +18,7 @@
[babashka.impl.common :refer [debug]]
[sci.core :as sci]
[sci.impl.parser :as p]
[sci.impl.vars :as vars])
[sci.impl.utils :as utils])
(:import
[clojure.lang LineNumberingPushbackReader]
[java.io BufferedWriter InputStreamReader OutputStreamWriter]
@ -214,12 +214,11 @@
:val (if (instance? Throwable ret)
(Throwable->map ret)
ret)
:ns (str (vars/current-ns-name))
:ns (str (utils/current-ns-name))
:ms ms
:form s})
true)))
(catch Throwable ex
(prn (ex-message ex))
(set! *e ex)
(out-fn {:tag :ret :val (ex->data ex (or (-> ex ex-data :clojure.error/phase) :execution))
:ns (str (.name *ns*)) :form s

View file

@ -232,13 +232,13 @@
For additional event types, see the examples in the code.
"}
babashka.impl.clojure.test
(:require [babashka.impl.common :refer [ctx]]
(:require
[babashka.impl.common :refer [ctx]]
[clojure.stacktrace :as stack]
[clojure.template :as temp]
[sci.core :as sci]
[sci.impl.namespaces :as sci-namespaces]
[sci.impl.resolve :as resolve]
[sci.impl.vars :as vars]))
[sci.impl.resolve :as resolve]))
;; Nothing is marked "private" here, so you can rebind things to plug
;; in your own testing or reporting frameworks.
@ -297,7 +297,7 @@
current assertion."
{:added "1.1"}
[m]
(let [{:keys [:file :line]} (meta (first @testing-vars))]
(let [{:keys [:file :line]} (merge m (meta (first @testing-vars)))]
(str
;; Uncomment to include namespace in failure report:
;;(ns-name (:ns (meta (first *testing-vars*)))) "/ "
@ -332,7 +332,7 @@
:added "1.1"}
report-impl :type)
(def report (sci/copy-var report-impl tns))
(def report (sci/copy-var report-impl tns {:name 'report}))
(defn do-report
"Add file and line information to a test result and call report.
@ -408,8 +408,8 @@
{:added "1.1"}
[x]
(if (symbol? x)
(when-let [v (second (resolve/lookup @ctx x false))]
(when-let [value (if (vars/var? v)
(when-let [v (second (resolve/lookup (ctx) x false))]
(when-let [value (if (instance? sci.lang.Var v)
(get-possibly-unbound-var v)
v)]
(and (fn? value)
@ -667,7 +667,7 @@
value of key."
{:added "1.1"}
[key coll]
(swap! ns->fixtures assoc-in [(sci-namespaces/sci-ns-name @vars/current-ns) key] coll))
(swap! ns->fixtures assoc-in [(sci-namespaces/sci-ns-name @sci/ns) key] coll))
(defmulti use-fixtures
"Wrap test runs in a fixture function to perform setup and
@ -722,7 +722,7 @@
:expected nil, :actual e})))
(do-report {:type :end-test-var, :var v}))))
(def test-var (sci/copy-var test-var-impl tns))
(def test-var (sci/copy-var test-var-impl tns {:name 'test-var}))
(defn test-vars
"Groups vars by their namespace and runs test-vars on them with
@ -779,7 +779,7 @@
Defaults to current namespace if none given. Returns a map
summarizing test results."
{:added "1.1"}
([ctx] (run-tests ctx @vars/current-ns))
([ctx] (run-tests ctx @sci/ns))
([ctx & namespaces]
(let [summary (assoc (apply merge-with + (map #(test-ns ctx %) namespaces))
:type :summary)]
@ -804,3 +804,39 @@
[summary]
(and (zero? (:fail summary 0))
(zero? (:error summary 0))))
(defn run-test-var
"Runs the tests for a single Var, with fixtures executed around the test, and summary output after."
{:added "1.11"}
[v]
(sci/binding [report-counters (atom @initial-report-counters)]
(let [ns-obj (-> v meta :ns)
summary (do
(do-report {:type :begin-test-ns
:ns ns-obj})
(test-vars [v])
(do-report {:type :end-test-ns
:ns ns-obj})
(assoc @@report-counters :type :summary))]
(do-report summary)
summary)))
(defmacro run-test
"Runs a single test.
Because the intent is to run a single test, there is no check for the namespace test-ns-hook."
{:added "1.11"}
[test-symbol]
(let [test-var (sci/resolve (ctx) test-symbol)]
(cond
(nil? test-var)
(sci/binding [sci/out sci/err]
(binding [*out* sci/out]
(println "Unable to resolve" test-symbol "to a test function.")))
(not (-> test-var meta :test))
(sci/binding [sci/out sci/err]
(binding [*out* sci/out]
(println test-symbol "is not a test.")))
:else
`(clojure.test/run-test-var ~test-var))))

View file

@ -0,0 +1,56 @@
(ns babashka.impl.clojure.tools.reader
(:refer-clojure :exclude [read])
(:require
[edamame.core :as e]
[sci.core :as sci]
[clojure.tools.reader.reader-types :as rt]))
(def rns (sci/create-ns 'clojure.tools.reader))
(def default-opts
(e/normalize-opts
{:all true
:row-key :line
:col-key :column
:location? seq?
:end-location false}))
;; Added for compatibility with tools.namespace
(defn read
"Reads the first object from an IPushbackReader or a java.io.PushbackReader.
Returns the object read. If EOF, throws if eof-error? is true.
Otherwise returns sentinel. If no stream is provided, *in* will be used.
Opts is a persistent map with valid keys:
:read-cond - :allow to process reader conditionals, or
:preserve to keep all branches
:features - persistent set of feature keywords for reader conditionals
:eof - on eof, return value unless :eofthrow, then throw.
if not specified, will throw
***WARNING***
Note that read can execute code (controlled by *read-eval*),
and as such should be used only with trusted sources.
To read data structures only, use clojure.tools.reader.edn/read
Note that the function signature of clojure.tools.reader/read and
clojure.tools.reader.edn/read is not the same for eof-handling"
{:arglists '([] [reader] [opts reader] [reader eof-error? eof-value])}
([] (read @sci/in true nil))
([reader] (read reader true nil))
([{eof :eof :as opts :or {eof :eofthrow}} reader]
(let [opts (assoc default-opts
:read-cond (:read-cond opts)
:features (:features opts))
v (e/parse-next reader opts)]
(if (identical? ::e/eof v)
(if (identical? :eofthrow eof)
(throw (java.io.EOFException.))
eof)
v)))
([reader eof-error? sentinel]
(let [v (e/parse-next reader default-opts)]
(if (identical? ::e/eof v)
(if eof-error?
(throw (java.io.EOFException.))
sentinel)
v))))
(def reader-namespace {'read (sci/copy-var read rns)})

View file

@ -13,4 +13,5 @@
'peek-char (sci/copy-var rt/peek-char rtns)
'read-char (sci/copy-var rt/read-char rtns)
'unread (sci/copy-var rt/unread rtns)
'source-logging-push-back-reader (sci/copy-var rt/source-logging-push-back-reader rtns)})
'source-logging-push-back-reader (sci/copy-var rt/source-logging-push-back-reader rtns)
'source-logging-reader? (sci/copy-var rt/source-logging-reader? rtns)})

View file

@ -1,10 +1,9 @@
(ns babashka.impl.clojure.zip
{:no-doc true}
(:require [clojure.zip :as zip]
[sci.impl.namespaces :refer [copy-var]]
[sci.impl.vars :as vars]))
[sci.core :as sci :refer [copy-var]]))
(def zip-ns (vars/->SciNamespace 'clojure.zip nil))
(def zip-ns (sci/create-ns 'clojure.zip nil))
(def zip-namespace
{'zipper (copy-var zip/zipper zip-ns)

View file

@ -1,6 +1,11 @@
(ns babashka.impl.common)
(ns babashka.impl.common
(:require
[clojure.java.io :as io]
[clojure.string :as str]
[sci.ctx-store :as ctx-store]))
;; placeholder for ctx
(def ctx (volatile! nil))
(defn ctx [] (ctx-store/get-ctx))
(def bb-edn (volatile! nil))
(def debug (volatile! false))
(def version (str/trim (slurp (io/resource "BABASHKA_VERSION"))))

View file

@ -1,10 +1,10 @@
(ns babashka.impl.curl
{:no-doc true}
(:require [babashka.curl :as curl]
[sci.impl.namespaces :refer [copy-var]]
[sci.impl.vars :as vars]))
(:require
[babashka.curl :as curl]
[sci.core :as sci :refer [copy-var]]))
(def tns (vars/->SciNamespace 'babashka.curl nil))
(def tns (sci/create-ns 'babashka.curl nil))
(def curl-namespace
{'request (copy-var curl/request tns)

View file

@ -1,10 +1,11 @@
(ns babashka.impl.data
{:no-doc true}
(:require [babashka.impl.clojure.data :as data]
[sci.impl.namespaces :refer [copy-var]]
[sci.impl.vars :as vars]))
(:require
[babashka.impl.clojure.data :as data]
[sci.core :as sci :refer [copy-var]]))
(def data-ns (vars/->SciNamespace 'clojure.data nil))
(def data-ns (sci/create-ns 'clojure.data nil))
(def data-namespace
{'diff (copy-var data/diff data-ns)})
{'diff (copy-var data/diff data-ns)
'equality-partition (copy-var data/equality-partition data-ns)})

View file

@ -3,8 +3,7 @@
(:refer-clojure :exclude [create-ns])
(:require
[babashka.impl.protocols :as protocols]
[sci.core :as sci :refer [copy-var]]
[sci.impl.vars]))
[sci.core :as sci :refer [copy-var]]))
(def datafy-ns (sci/create-ns 'clojure.datafy nil))

View file

@ -66,7 +66,7 @@
paths)
paths)]
(cp/add-classpath (str/join cp/path-sep paths))))
(let [need-deps? (or (:deps deps-map)
(let [need-deps? (or (seq (:deps deps-map))
(and (:aliases deps-map)
aliases))]
(when need-deps?
@ -101,4 +101,4 @@
'clojure (sci/copy-var bdeps/clojure dns)
'merge-deps (sci/copy-var merge-deps dns)
;; undocumented
'merge-defaults (sci/copy-var merge-default-deps dns)})
'merge-defaults (sci/copy-var merge-default-deps dns {:name 'merge-defaults})})

View file

@ -0,0 +1,7 @@
(ns babashka.impl.edamame
(:require [edamame.core]
[sci.core :as sci]))
(def ens (sci/create-ns 'edamame.core))
(def edamame-namespace (sci/copy-ns edamame.core ens))

View file

@ -108,7 +108,7 @@
stacktrace (dedupe
(concat (sequence (comp (map StackTraceElement->vec)
(take-while #(not (str/starts-with? (first %) "sci.impl.")))
(map render-native-stacktrace-elem))
(keep render-native-stacktrace-elem))
(.getStackTrace (or (ex-cause e) e)))
(sci/stacktrace e)))]
(if exit-code

View file

@ -27,6 +27,7 @@
(def datascript? (= "true" (System/getenv "BABASHKA_FEATURE_DATASCRIPT")))
(def lanterna? (= "true" (System/getenv "BABASHKA_FEATURE_LANTERNA")))
(def spec-alpha? (= "true" (System/getenv "BABASHKA_FEATURE_SPEC_ALPHA")))
(def rrb-vector? (= "true" (System/getenv "BABASHKA_FEATURE_RRB_VECTOR")))
(when xml?
(require '[babashka.impl.xml]))
@ -76,3 +77,6 @@
(when priority-map?
(require '[babashka.impl.priority-map]))
(when rrb-vector?
(require '[babashka.impl.rrb-vector]))

Some files were not shown because too many files have changed in this diff Show more