babashka.os
This commit is contained in:
parent
cf20734557
commit
a089394221
5 changed files with 37 additions and 47 deletions
|
|
@ -20,7 +20,10 @@
|
||||||
[cheshire "5.10.0"]
|
[cheshire "5.10.0"]
|
||||||
[nrepl/bencode "1.1.0"]
|
[nrepl/bencode "1.1.0"]
|
||||||
[borkdude/sci.impl.reflector "0.0.1"]
|
[borkdude/sci.impl.reflector "0.0.1"]
|
||||||
[org.clojure/test.check "1.1.0"]]
|
[org.clojure/test.check "1.1.0"]
|
||||||
|
;; core async was moved from the core async feature to here,
|
||||||
|
;; because it is used in tasks
|
||||||
|
[org.clojure/core.async "1.3.610"]]
|
||||||
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
||||||
:dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]}
|
:dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]}
|
||||||
:feature/yaml {:source-paths ["feature-yaml"]
|
:feature/yaml {:source-paths ["feature-yaml"]
|
||||||
|
|
@ -31,8 +34,7 @@
|
||||||
;:feature/oracledb [:feature/jdbc {:dependencies [[com.oracle.database.jdbc/ojdbc8 "19.8.0.0"]]}]
|
;:feature/oracledb [:feature/jdbc {:dependencies [[com.oracle.database.jdbc/ojdbc8 "19.8.0.0"]]}]
|
||||||
:feature/oracledb [:feature/jdbc {:dependencies [[io.helidon.integrations.db/ojdbc "2.1.0"]]}] ; ojdbc10 + GraalVM config, by Oracle
|
:feature/oracledb [:feature/jdbc {:dependencies [[io.helidon.integrations.db/ojdbc "2.1.0"]]}] ; ojdbc10 + GraalVM config, by Oracle
|
||||||
:feature/hsqldb [:feature/jdbc {:dependencies [[org.hsqldb/hsqldb "2.5.1"]]}]
|
:feature/hsqldb [:feature/jdbc {:dependencies [[org.hsqldb/hsqldb "2.5.1"]]}]
|
||||||
:feature/core-async {:source-paths ["feature-core-async"]
|
:feature/core-async {:source-paths ["feature-core-async"]}
|
||||||
:dependencies [[org.clojure/core.async "1.3.610"]]}
|
|
||||||
:feature/csv {:source-paths ["feature-csv"]
|
:feature/csv {:source-paths ["feature-csv"]
|
||||||
:dependencies [[org.clojure/data.csv "1.0.0"]]}
|
:dependencies [[org.clojure/data.csv "1.0.0"]]}
|
||||||
:feature/transit {:source-paths ["feature-transit"]
|
:feature/transit {:source-paths ["feature-transit"]
|
||||||
|
|
|
||||||
|
|
@ -25,22 +25,36 @@ public class Graal {
|
||||||
@CFunction
|
@CFunction
|
||||||
private static native int setenv(CCharPointer name, CCharPointer value, int overwrite);
|
private static native int setenv(CCharPointer name, CCharPointer value, int overwrite);
|
||||||
|
|
||||||
// API
|
@CFunction
|
||||||
public static int setEnv(String name, String value) {
|
private static native CCharPointer getenv(CCharPointer name);
|
||||||
int ret = 0;
|
|
||||||
System.out.println("setenv" + " " + name + " " + value);
|
// Public API
|
||||||
try (CCharPointerHolder nameHolder = CTypeConversion.toCString(name);
|
|
||||||
CCharPointerHolder valueHolder = CTypeConversion.toCString(value)) {
|
public static boolean setEnv(String name, String value) {
|
||||||
ret = setenv(nameHolder.get(), valueHolder.get(), 1);
|
return setEnv(name, value, true);
|
||||||
System.out.println(System.getenv(name));
|
|
||||||
}
|
|
||||||
System.out.println(System.getenv(name));
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
public static boolean setEnv(String name, String value, boolean overwrite) {
|
||||||
// setEnv(args[0], args[1]);
|
boolean ret = false;
|
||||||
// System.out.println(System.getenv(args[0]));
|
try (CCharPointerHolder nameHolder = CTypeConversion.toCString(name)) {
|
||||||
// }
|
CCharPointerHolder valueHolder = CTypeConversion.toCString(value);
|
||||||
}
|
int w = (overwrite ? 1 : 0);
|
||||||
|
int cRet = setenv(nameHolder.get(), valueHolder.get(), w);
|
||||||
|
ret = (cRet == 0 ? true : false);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getEnv(String name) {
|
||||||
|
try (CCharPointerHolder nameHolder = CTypeConversion.toCString(name);) {
|
||||||
|
CCharPointer p = getenv(nameHolder.get());
|
||||||
|
String ret = CTypeConversion.toJavaString(p);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(setEnv(args[0], args[1]));
|
||||||
|
System.out.println(getEnv(args[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
(ns babashka.impl.utils
|
|
||||||
{:no-doc true}
|
|
||||||
(:require [babashka.utils :as utils]
|
|
||||||
[sci.core :as sci]))
|
|
||||||
|
|
||||||
(def uns (sci/create-ns 'babashka.utils nil))
|
|
||||||
|
|
||||||
(def utils-namespace
|
|
||||||
{'set-env (sci/copy-var utils/set-env uns)})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
[babashka.impl.error-handler :refer [error-handler]]
|
[babashka.impl.error-handler :refer [error-handler]]
|
||||||
[babashka.impl.features :as features]
|
[babashka.impl.features :as features]
|
||||||
[babashka.impl.fs :refer [fs-namespace]]
|
[babashka.impl.fs :refer [fs-namespace]]
|
||||||
|
[babashka.impl.os :refer [os-namespace]]
|
||||||
[babashka.impl.pods :as pods]
|
[babashka.impl.pods :as pods]
|
||||||
[babashka.impl.pprint :refer [pprint-namespace]]
|
[babashka.impl.pprint :refer [pprint-namespace]]
|
||||||
[babashka.impl.process :refer [process-namespace]]
|
[babashka.impl.process :refer [process-namespace]]
|
||||||
|
|
@ -34,7 +35,6 @@
|
||||||
[babashka.impl.tasks :as tasks :refer [tasks-namespace]]
|
[babashka.impl.tasks :as tasks :refer [tasks-namespace]]
|
||||||
[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]]
|
||||||
[babashka.impl.utils :refer [utils-namespace]]
|
|
||||||
[babashka.nrepl.server :as nrepl-server]
|
[babashka.nrepl.server :as nrepl-server]
|
||||||
[babashka.wait :as wait]
|
[babashka.wait :as wait]
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
|
|
@ -315,7 +315,7 @@ Use bb run --help to show this help output.
|
||||||
'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.utils utils-namespace
|
'babashka.os os-namespace
|
||||||
'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
|
||||||
'cheshire.core cheshire-core-namespace
|
'cheshire.core cheshire-core-namespace
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
(ns babashka.utils)
|
|
||||||
|
|
||||||
(defmacro if-graal [then else]
|
|
||||||
(if (resolve 'babashka.impl.Graal)
|
|
||||||
then
|
|
||||||
else))
|
|
||||||
|
|
||||||
(defn set-env [name value]
|
|
||||||
(if-graal
|
|
||||||
(do
|
|
||||||
(prn :setting name value)
|
|
||||||
(prn (babashka.impl.Graal/setEnv name value)))
|
|
||||||
(throw (UnsupportedOperationException. "set-env is only available in the native image."))))
|
|
||||||
Loading…
Reference in a new issue