Compare commits
3 Commits
v1.1
...
5c93f4e570
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c93f4e570 | |||
| dfc3d4e579 | |||
| e7b2683d2c |
5
deps.edn
5
deps.edn
@@ -11,7 +11,10 @@
|
|||||||
;; Native image (GraalVM)
|
;; Native image (GraalVM)
|
||||||
com.github.clj-easy/graal-build-time {:mvn/version "1.0.5"};; Tutorial: https://shagunagrawal.me/posts/setup-clojure-with-graalvm-for-native-image/
|
com.github.clj-easy/graal-build-time {:mvn/version "1.0.5"};; Tutorial: https://shagunagrawal.me/posts/setup-clojure-with-graalvm-for-native-image/
|
||||||
;; Protobuf for java
|
;; Protobuf for java
|
||||||
com.google.protobuf/protobuf-java {:mvn/version "3.25.8"}}
|
com.google.protobuf/protobuf-java {:mvn/version "3.25.8"}
|
||||||
|
;; Progress bar
|
||||||
|
com.github.pmonks/spinner {:mvn/version "2.0.284"}
|
||||||
|
}
|
||||||
|
|
||||||
:aliases {;; Execute the app
|
:aliases {;; Execute the app
|
||||||
:run {:main-opts ["-m" "totp.app"]}
|
:run {:main-opts ["-m" "totp.app"]}
|
||||||
|
|||||||
33
native.cmd
Normal file
33
native.cmd
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
REM YOUR LOCAL GRAAL VM INSTALLATION
|
||||||
|
set JAVA_HOME=D:\programas\graalvm-jdk-21.0.7+8.1
|
||||||
|
REM generated file
|
||||||
|
set BIN_FILE=totp
|
||||||
|
|
||||||
|
set DEST_DIR=C:\Users\rubencj\util
|
||||||
|
|
||||||
|
set PATH=%JAVA_HOME%\bin;%CLOJURE_HOME%;%PATH%
|
||||||
|
set NATIVE=%JAVA_HOME%\bin\native-image.cmd
|
||||||
|
|
||||||
|
|
||||||
|
echo Using GraalVM native compiler: %NATIVE%
|
||||||
|
|
||||||
|
echo Creating uberjar
|
||||||
|
clojure -T:build uber
|
||||||
|
|
||||||
|
set UBERJAR=
|
||||||
|
for /f "delims=" %%a in ('dir /b /s target\clj-totp-*-standalone.jar') do @set UBERJAR=%%a
|
||||||
|
echo Created uberjar: %UBERJAR%
|
||||||
|
|
||||||
|
echo "Creating native image"
|
||||||
|
cmd /c %NATIVE% -jar %UBERJAR% -o target\%BIN_FILE% -H:+ReportExceptionStackTraces --features=clj_easy.graal_build_time.InitClojureClasses --report-unsupported-elements-at-runtime --verbose --no-fallback -H:ReflectionConfigurationFiles=reflect_config.json -H:-CheckToolchain
|
||||||
|
|
||||||
|
|
||||||
|
echo Executable created: target\%BIN_FILE%.exe
|
||||||
|
|
||||||
|
copy target\%BIN_FILE%.exe %DEST_DIR%
|
||||||
|
echo Native image copied to %DEST_DIR%\%BIN_FILE%.exe
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
[totp.data :refer :all]
|
[totp.data :refer :all]
|
||||||
[cli-matic.core :refer [run-cmd]]
|
[cli-matic.core :refer [run-cmd]]
|
||||||
[clojure.pprint :as pp]
|
[clojure.pprint :as pp]
|
||||||
[clojure.string :as str])
|
[clojure.string :as str]
|
||||||
|
[progress.determinate :as pd])
|
||||||
(:import [java.util TimerTask Timer])
|
(:import [java.util TimerTask Timer])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
@@ -17,12 +18,27 @@
|
|||||||
delay (int (- step-millis (rem now step-millis)))
|
delay (int (- step-millis (rem now step-millis)))
|
||||||
fn-show (fn [s] (println (format "[%d] %s" (System/currentTimeMillis) (get-otp s algorithm digits period))))
|
fn-show (fn [s] (println (format "[%d] %s" (System/currentTimeMillis) (get-otp s algorithm digits period))))
|
||||||
task (proxy [TimerTask] []
|
task (proxy [TimerTask] []
|
||||||
(run [] (fn-show secret)))]
|
(run [] (fn-show secret)))
|
||||||
|
a (atom (int (- period (/ delay 1000))))
|
||||||
|
up-task (proxy [TimerTask] []
|
||||||
|
(run [] (pd/animate! a :opts {:total period
|
||||||
|
:style (:coloured-ascii-boxes pd/styles)
|
||||||
|
:label "Next TOTP"
|
||||||
|
:redraw-rate 1
|
||||||
|
;:line 1
|
||||||
|
}
|
||||||
|
;(println "inc" @a)
|
||||||
|
(if (< @a period)
|
||||||
|
(swap! a inc)
|
||||||
|
(reset! a 0)
|
||||||
|
))))]
|
||||||
(println "\n <Generating continuosly, press enter to stop>\n")
|
(println "\n <Generating continuosly, press enter to stop>\n")
|
||||||
;; (println "Now:" now ", Delay:" delay ", Next execution: " (+ now delay))
|
;; (println "Now:" now ", Delay:" delay ", Next execution: " (+ now delay))
|
||||||
(println "Refresing in" (int (/ delay 1000)) "seconds")
|
(println "Refresing in" (int (/ delay 1000)) "seconds")
|
||||||
(fn-show secret)
|
(fn-show secret)
|
||||||
(. (new Timer) (scheduleAtFixedRate task delay step-millis)))
|
(. (new Timer) (scheduleAtFixedRate up-task 0 1000))
|
||||||
|
(. (new Timer) (scheduleAtFixedRate task delay step-millis))
|
||||||
|
)
|
||||||
(read-line))) ;; Waits for a key press
|
(read-line))) ;; Waits for a key press
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user