nandi/frqpublic Fork 0
5c7976e0e9f36027ad2071454d8fbf3e317535bd
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Write the build in babashka, and pin the babashka 34832a8 · on 5c7976e0e9f36027ad2071454d8fbf3e317535bd · nandi · 18d ago
apk.bb · 41 lines · 1.5 KBBlitzBasic Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
#_(
exec "$(dirname "$0")/bb" "$0" "$@"
)

;; The APK, built as a graph.
;;
;;   apk.bb [build|install|run|log]
;;
;; The build itself is android/BUCK; this only asks buck for the file and then
;; does what was asked with it. android/build-apk.bb is the same APK built step
;; by step instead, for when the graph is what is being doubted.
(require '[babashka.classpath :as cp])
(cp/add-classpath (str (babashka.fs/parent *file*)))
(require '[frq.paths :as paths]
         '[babashka.fs :as fs]
         '[babashka.process :as p]
         '[clojure.string :as str])

(def root (str (fs/canonicalize (fs/path (fs/parent *file*) ".."))))
(def action (or (first *command-line-args*) "build"))
(def adb (paths/env "ADB" (str (fs/path (fs/home) ".local" "share" "android-sdk"
                                        "platform-tools" "adb"))))
(def package "uk.nandi.frq")

(defn apk []
  (->> (paths/out (str (fs/path root "scripts" "buck.bb"))
                  "build" "--show-output" "//:apk")
       str/split-lines
       (some #(when (str/includes? % "frq.apk") (second (str/split % #"\s+"))))
       (str root "/")))

(case action
  "build" (println (apk))
  "install" (p/shell adb "install" "-r" (apk))
  "run" (let [file (apk)]
          (p/shell adb "install" "-r" file)
          (p/shell adb "shell" "am" "force-stop" package)
          (p/shell adb "shell" "am" "start" "-n" (str package "/.FrqActivity")))
  "log" (p/shell adb "logcat" "-s" "VidyaJolt" "Vidya")
  (paths/die "usage: apk.bb [build|install|run|log]"))