summaryrefslogtreecommitdiff
path: root/packages/komodo/qaterial.scm
blob: 91a8b6815152b0004a4e647ee8038e88fcacdc95 (about) (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
(define-module (packages komodo qaterial)
  #:use-module (gnu packages qt)
  #:use-module (packages komodo googlefontcmake)
  #:use-module (guix build utils)
  #:use-module (guix build-system copy)
  #:use-module (guix build-system cmake)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module ((guix licenses)
		#:prefix license:)
  #:use-module (guix packages)
  #:use-module (packages komodo qolm)
  #:use-module (packages komodo qtgeneratorcmake))

;; DATA LAYER

(define cmake-fetchgooglefontcmake
  "cmake/FetchGoogleFontCMake.cmake")

(define cmakelists-fonts
  "qml/Qaterial/Fonts/CMakeLists.txt")

(define cmakelists-icons
  "qml/Qaterial/Icons/CMakeLists.txt")

(define cmakelists-root
  "CMakeLists.txt")

(define description
  "A collection of Material Components to build faster UI using Qml.")

(define disable-icons
  "set(QATERIAL_ENABLE_ICONS OFF")

(define disable-lato
  "set(QATERIAL_ENABLE_LATO OFF")

(define disable-roboto
  "set(QATERIAL_ENABLE_ROBOTO OFF")

(define disable-robotomono
  "set(QATERIAL_ENABLE_ROBOTOMONO OFF")

(define enable-build-shared
  "set(QATERIAL_BUILD_SHARED ON")

(define fetcher-fonts
  "include\\(\\$\\{PROJECT_SOURCE_DIR\\}\\/cmake\\/FetchGoogleFontCMake.cmake\\)")

(define fetcher-qolm
  "include\\(cmake\\/FetchQOlm.cmake\\)")

(define file-generateqrc
  "cmake/GenerateQrc.cmake")

(define fetcher-qtgeneratorcmake
  "include\\(cmake\\/FetchQtGeneratorCMake.cmake\\)")

(define hash
  (base32 "19xvgk4h908x0zgxy63fqmrsb5df613vhr5h7cpsgg7nllglypss"))

(define hook-enable-icons
  "set\\(QATERIAL_ENABLE_ICONS ON")

(define hook-qaterial-generate-icons-class
  "qaterial_generate_icons_class\\(\\$\\{QATERIAL_ICONS_CLASS_FILE\\} \\$\\{QATERIAL_ICONS_SRC_FILE\\}\\)")

(define head-hook
  "include\\(cmake\\/Version.cmake\\)")

(define home-page
  "https://olivierldff.github.io/Qaterial")

(define hook-icons
  "include\\(\\$\\{PROJECT_SOURCE_DIR\\}\\/cmake\\/FetchMaterialDesignIcons.cmake\\)")

(define name
  "qaterial")

(define null-string
  "")

(define setter-build-shared
  "set\\(QATERIAL_BUILD_SHARED OFF")

(define setter-lato
  "set\\(QATERIAL_ENABLE_LATO ON")

(define setter-roboto
  "set\\(QATERIAL_ENABLE_ROBOTO ON")

(define setter-robotomono
  "set\\(QATERIAL_ENABLE_ROBOTOMONO ON")

(define synopsis
  "🧩 Collection of Material Components based on QtQuickControls2.")

(define url
  "https://github.com/OlivierLDff/Qaterial.git")

(define version
  "v1.4.9")

;; ABSTRACTION LAYER -4

(define link-qtgeneratorcmake
  '(string-append "include(cmake/Version.cmake)\n"
		  "include("
		  path-qtgeneratorcmake
		  "/cmake/GenerateQrc.cmake"
		  ")\n"
		  "include("
		  path-qtgeneratorcmake
		  "/cmake/GenerateQmldir.cmake"
		  ")\n"
		  "include("
		  path-qtgeneratorcmake
		  "/cmake/GenerateQrcAliasQtObject.cmake"
		  ")\n"))

;; ABSTRACTION LAYER -3

(define clause-delete-fetchers
  `(lambda _
     (substitute* ,cmakelists-root
		  ((,fetcher-qolm)
		   ,null-string))
     (substitute* ,cmakelists-root
		  ((,fetcher-qtgeneratorcmake)
		   ,null-string))
     (substitute* ,cmakelists-root
		  ((,setter-roboto)
		   ,disable-roboto))
     (substitute* ,cmakelists-root
		  ((,setter-robotomono)
		   ,disable-robotomono))
     (substitute* ,cmakelists-root
		  ((,setter-lato)
		   ,disable-lato))
     (substitute* ,cmakelists-fonts
		  ((,fetcher-fonts)
		   ,null-string))
     (substitute* ,cmakelists-icons
		  ((,hook-icons)
		   ,null-string))
     (substitute* ,cmakelists-root
		  ((,hook-enable-icons)
		   ,disable-icons))
     (substitute* ,cmakelists-root
		  (("\\# ───── QATERIAL TARGET ─────")
		   "find_package(QOlm)"))))

;; (define clause-hack-icon-generator
;;   `(lambda _
;;      (invoke "echo" ,qaterial-fix ">" "cmake/QaterialGenerateIcons.cmake")))

(define clause-link-qtgenerator
  `(lambda* (#:key inputs #:allow-other-keys)
     (let ((path-qtgeneratorcmake (assoc-ref inputs "qtgeneratorcmake")))
       (substitute* ,cmakelists-root
		    ((,head-hook)
		     ,link-qtgeneratorcmake)))))

(define clause-set-build-shared
  `(lambda _
     (substitute* ,cmakelists-root
		  ((,setter-build-shared)
		   ,enable-build-shared))))

;; ABSTRACTION LAYER -2

(define phase-delete-fetchers
  `(add-before 'configure
	       'delete-fetchers
	       ,clause-delete-fetchers))

;; (define phase-hack-icon-generator
;;   `(add-before 'configure
;; 	       'hack-icon-generator
;; 	       ,clause-hack-icon-generator))

(define phase-link-qtgenerator
  `(add-before 'configure
	       'link-qtgenerator
	       ,clause-link-qtgenerator))

(define phase-set-build-shared
  `(add-before 'configure
	       'set-build-shared
	       ,clause-set-build-shared))

;; ABSTRACTION LAYER -1

(define phases
  `(modify-phases %standard-phases
		  ,phase-delete-fetchers
		  ,phase-set-build-shared
		  ,phase-link-qtgenerator
		  (add-after 'unpack
			     'kill-registericons
			     (lambda _
			       (substitute* "src/Qaterial/Details/Utils.cpp"
					    (("  __Qaterial_registerIconsSingleton\\(\\)")
					     ,null-string))))
		  ))

(define uri
  (git-reference (url url)
		 (commit version)))

;; ABSTRACTION LAYER -0

(define arguments
  (list #:phases phases
	#:tests? #f))

(define inputs
  (list googlefontcmake qolm qtbase-5 qtdeclarative-5
	qtgeneratorcmake qtquickcontrols2-5 qtsvg-5))

(define source
  (origin (uri uri)
	  (method git-fetch)
	  (sha256 hash)
	  (patches (list (local-file "Qaterial.patch")))))

;; SURFACE LAYER

(define-public qaterial
  (package (name name)
	   (version version)
	   (source source)
	   (build-system cmake-build-system)
	   (arguments arguments)
	   (inputs inputs)
	   (synopsis synopsis)
	   (description description)
	   (license license:expat)
	   (home-page home-page)))