-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.clj
More file actions
70 lines (61 loc) · 2.54 KB
/
Copy pathbuild.clj
File metadata and controls
70 lines (61 loc) · 2.54 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(ns build
(:require [clojure.tools.build.api :as b]
[clojure.data.json :as json]
[clojure.java.io :as io]
[clojure.string :as str]))
(def lib 'com.phronemophobic/grease)
(def version "0.1")
(def class-dir "target/classes")
(def basis* (delay
(b/create-basis {:project "deps.edn"
:aliases [:native-image
:membrane]})))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def uber-file (format "target/%s-uber.jar" (name lib)))
(def src-pom "./pom-template.xml")
(defn clean [_]
(b/delete {:path "target"}))
(defn compile-native-image [_]
(b/compile-clj {:class-dir class-dir
:basis @basis*
:java-opts ["-Dtech.v3.datatype.graal-native=true"
"-Dclojure.compiler.direct-linking=true"
"-Dmembrane.ios=true"
"-Dclojure.spec.skip-macros=true"]
:ns-compile '[com.phronemophobic.grease.ios]}))
(defn uberjar-native-image [opts]
#_(clean nil)
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(compile-native-image opts)
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis @basis*
:main 'com.phronemophobic.grease.ios})
)
(defn uberjar-native-image-shared [opts]
(let [shared-basis (b/create-basis {:project "deps.edn"
:aliases [:native-image]})]
(clean nil)
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/compile-clj {:class-dir class-dir
:basis shared-basis
:java-opts ["-Dtech.v3.datatype.graal-native=true"
"-Dclojure.compiler.direct-linking=true"
"-Dclojure.spec.skip-macros=true"]
:ns-compile '[com.phronemophobic.grease]})
(b/uber {:class-dir class-dir
:uber-file "target/bb.jar"
:basis shared-basis
:main 'com.phronemophobic.grease})))
(defn fix-reflect-config [f]
(let [config (with-open [rdr (io/reader f)]
(json/read rdr))
new-config (->> config
(remove (fn [{:strs [name]}]
(str/ends-with? name "__init"))))]
(with-open [w (io/writer f)]
(json/write new-config w))))
(defn fix-config [_]
(fix-reflect-config (io/file "native-image" "config" "reflect-config.json")))