Merge windows branch to master

This commit is contained in:
Michiel Borkent 2020-04-28 15:32:34 +02:00 committed by GitHub
parent 4e42729663
commit 6c255a702e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 112 additions and 17 deletions

View file

@ -7,7 +7,8 @@ image: Visual Studio 2015
clone_folder: C:\projects\babashka clone_folder: C:\projects\babashka
environment: environment:
GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java8-19.3.0 GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java8-19.3.1
BABASHKA_XMX: "-J-Xmx5g"
cache: cache:
- C:\ProgramData\chocolatey\lib -> project.clj, appveyor.yml - C:\ProgramData\chocolatey\lib -> project.clj, appveyor.yml
@ -43,11 +44,13 @@ build_script:
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"
powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-19.3.0/graalvm-ce-java8-windows-amd64-19.3.0.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-19.3.1/graalvm-ce-java8-windows-amd64-19.3.1.zip', 'graalvm.zip') }"
powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }" powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }"
# call script/compile.bat call script/uberjar.bat
call script/compile.bat
# - cmd: >- # - cmd: >-
# lein clean # lein clean
@ -56,6 +59,6 @@ build_script:
# call script/test.bat # call script/test.bat
# artifacts: artifacts:
# - path: babashka-*-windows-amd64.zip - path: babashka-*-windows-amd64.zip
# name: babashka name: babashka

46
script/compile.bat Normal file
View file

@ -0,0 +1,46 @@
@echo off
Rem set GRAALVM_HOME=C:\Users\IEUser\Downloads\graalvm-ce-java8-19.3.1
Rem set PATH=%PATH%;C:\Users\IEUser\bin
if "%GRAALVM_HOME%"=="" (
echo Please set GRAALVM_HOME
exit /b
)
if "%BABASHKA_XMX%"=="" (
set BABASHKA_XMX="-J-Xmx4500m"
)
set JAVA_HOME=%GRAALVM_HOME%
set PATH=%PATH%;%GRAALVM_HOME%\bin
set /P BABASHKA_VERSION=< resources\BABASHKA_VERSION
echo Building Babashka %BABASHKA_VERSION%
Rem the --no-server option is not supported in GraalVM Windows.
Rem -H:EnableURLProtocols=jar,http,https is also not supported.
call %GRAALVM_HOME%\bin\native-image.cmd ^
"-jar" "target/babashka-%BABASHKA_VERSION%-standalone.jar" ^
"-H:Name=bb" ^
"-H:+ReportExceptionStackTraces" ^
"-J-Dclojure.spec.skip-macros=true" ^
"-J-Dclojure.compiler.direct-linking=true" ^
"-H:IncludeResources=BABASHKA_VERSION" ^
"-H:IncludeResources=SCI_VERSION" ^
"-H:ReflectionConfigurationFiles=reflection.json" ^
"--initialize-at-run-time=java.lang.Math$RandomNumberGeneratorHolder" ^
"--initialize-at-build-time" ^
"--initialize-at-run-time=org.postgresql.sspi.SSPIClient" ^
"-H:Log=registerResource:" ^
"--no-fallback" ^
"--verbose" ^
"%BABASHKA_XMX%"
if %errorlevel% neq 0 exit /b %errorlevel%
call bb "(+ 1 2 3)"
echo Creating zip archive
jar -cMf babashka-%BABASHKA_VERSION%-windows-amd64.zip bb.exe

29
script/uberjar.bat Executable file
View file

@ -0,0 +1,29 @@
@echo on
if "%GRAALVM_HOME%"=="" (
echo Please set GRAALVM_HOME
exit /b
)
set JAVA_HOME=%GRAALVM_HOME%
set PATH=%PATH%;%GRAALVM_HOME%\bin
if "%BABASHKA_FEATURE_HSQLDB%"=="true" (
set BABASHKA_LEIN_PROFILES=+feature/hsqldb
) else (
set BABASHKA_LEIN_PROFILES=-feature/hsqldb
)
if not "%BABASHKA_FEATURE_XML%"=="false" (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/xml
) else (
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/xml
)
call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)"
call lein with-profiles +reflection,%BABASHKA_LEIN_PROFILES% do run
if %errorlevel% neq 0 exit /b %errorlevel%
call lein with-profiles "%BABASHKA_LEIN_PROFILES%" do clean, uberjar
if %errorlevel% neq 0 exit /b %errorlevel%

View file

@ -18,9 +18,7 @@
[babashka.impl.features :as features] [babashka.impl.features :as features]
[babashka.impl.jdbc :as jdbc] [babashka.impl.jdbc :as jdbc]
[babashka.impl.nrepl-server :as nrepl-server] [babashka.impl.nrepl-server :as nrepl-server]
[babashka.impl.pipe-signal-handler :refer [handle-pipe! pipe-signal-received?]]
[babashka.impl.repl :as repl] [babashka.impl.repl :as repl]
[babashka.impl.sigint-handler :as sigint-handler]
[babashka.impl.socket-repl :as socket-repl] [babashka.impl.socket-repl :as socket-repl]
[babashka.impl.test :as t] [babashka.impl.test :as t]
[babashka.impl.tools.cli :refer [tools-cli-namespace]] [babashka.impl.tools.cli :refer [tools-cli-namespace]]
@ -39,6 +37,26 @@
[sci.impl.vars :as vars]) [sci.impl.vars :as vars])
(:gen-class)) (:gen-class))
(def windows?
(some-> (System/getProperty "os.name")
(str/lower-case)
(str/index-of "win")))
(if-not windows?
(do ;; see https://github.com/oracle/graal/issues/1784
(require 'babashka.impl.pipe-signal-handler)
(let [handle-pipe! (resolve 'babashka.impl.pipe-signal-handler/handle-pipe!)]
(def handle-pipe! @handle-pipe!))
(let [pipe-signal-received? (resolve 'babashka.impl.pipe-signal-handler/pipe-signal-received?)]
(def pipe-signal-received? @pipe-signal-received?))
;; JVM_FindSignal called: Unimplemented
(require 'babashka.impl.sigint-handler)
(def handle-sigint! @(resolve 'babashka.impl.sigint-handler/handle-sigint!)))
(do
(def handle-pipe! (constantly nil))
(def pipe-signal-received? (constantly false))
(def handle-sigint! (constantly nil))))
(when features/xml? (when features/xml?
(require '[babashka.impl.xml])) (require '[babashka.impl.xml]))
@ -283,7 +301,7 @@ Everything after that is bound to *command-line-args*."))
'clojure.java.shell shell-namespace 'clojure.java.shell shell-namespace
'babashka.wait {'wait-for-port wait/wait-for-port 'babashka.wait {'wait-for-port wait/wait-for-port
'wait-for-path wait/wait-for-path} 'wait-for-path wait/wait-for-path}
'babashka.signal {'pipe-signal-received? pipe-signal-received?} ;;'babashka.signal {'pipe-signal-received? pipe-signal-received?}
'clojure.java.io io-namespace 'clojure.java.io io-namespace
'clojure.core.async async-namespace 'clojure.core.async async-namespace
'clojure.core.async.impl.protocols async-protocols-namespace 'clojure.core.async.impl.protocols async-protocols-namespace
@ -323,9 +341,7 @@ Everything after that is bound to *command-line-args*."))
(defn main (defn main
[& args] [& args]
(handle-pipe!) (handle-pipe!)
(sigint-handler/handle-sigint!) (handle-sigint!)
#_(binding [*out* *err*]
(prn "M" (meta (get bindings 'future))))
(binding [*unrestricted* true] (binding [*unrestricted* true]
(sci/binding [reflection-var false (sci/binding [reflection-var false
sci/ns (vars/->SciNamespace 'user nil)] sci/ns (vars/->SciNamespace 'user nil)]

View file

@ -179,7 +179,7 @@
(is (true? (bb nil "(.exists (io/file \"README.md\"))"))) (is (true? (bb nil "(.exists (io/file \"README.md\"))")))
(is (true? (bb nil "(.canWrite (io/file \"README.md\"))")))) (is (true? (bb nil "(.canWrite (io/file \"README.md\"))"))))
(deftest pipe-test #_(deftest pipe-test
(when test-utils/native? (when test-utils/native?
(let [out (:out (sh "bash" "-c" "./bb -o '(range)' | (let [out (:out (sh "bash" "-c" "./bb -o '(range)' |
./bb --stream '(* *input* *input*)' | ./bb --stream '(* *input* *input*)' |

View file

@ -1,18 +1,19 @@
(ns babashka.shutdown-hook-test (ns babashka.shutdown-hook-test
{:no-doc true} {:no-doc true}
(:import [java.nio.charset Charset]) #_(:import [java.nio.charset Charset])
(:require [babashka.test-utils :as tu] #_(:require [babashka.test-utils :as tu]
[clojure.java.io :as io] [clojure.java.io :as io]
[clojure.test :refer [deftest is]])) [clojure.test :refer [deftest is]]))
(defn- stream-to-string #_(defn- stream-to-string
([in] (stream-to-string in (.name (Charset/defaultCharset)))) ([in] (stream-to-string in (.name (Charset/defaultCharset))))
([in enc] ([in enc]
(with-open [bout (java.io.StringWriter.)] (with-open [bout (java.io.StringWriter.)]
(io/copy in bout :encoding enc) (io/copy in bout :encoding enc)
(.toString bout)))) (.toString bout))))
(deftest shutdown-hook-test #_(deftest shutdown-hook-test
(let [script "(-> (Runtime/getRuntime) (.addShutdownHook (Thread. #(println \"bye\"))))" (let [script "(-> (Runtime/getRuntime) (.addShutdownHook (Thread. #(println \"bye\"))))"
pb (ProcessBuilder. (if tu/jvm? pb (ProcessBuilder. (if tu/jvm?
["lein" "bb" "-e" script] ["lein" "bb" "-e" script]