forked from atlas-engineer/nyxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnyxt.asd
641 lines (596 loc) · 24 KB
/
nyxt.asd
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause
#+sbcl
(progn
(sb-ext:assert-version->= 2 0 0)
(require 'sb-bsd-sockets))
(defvar *prefix* (format nil "~a/~a"
(or (uiop:getenv "DESTDIR") "")
(or (uiop:getenv "PREFIX")
"/usr/local")))
(defvar *datadir* (or (uiop:getenv "DATADIR")
(format nil "~a/share" *prefix*)))
(defvar *bindir* (or (uiop:getenv "BINDIR")
(format nil "~a/bin" *prefix*)))
(defvar *nyxt-renderer* (or (uiop:getenv "NYXT_RENDERER")
"gi-gtk"))
(defvar *submodules-dir* (or (uiop:getenv "NYXT_SUBMODULES_DIR")
"_build"))
(defvar *submodules-jobs* (or (uiop:getenv "NYXT_SUBMODULES_JOBS")
4)
"Number of parallel 'git clone' jobs to fetch the Git submodules.
A naive benchmark on a 16 Mpbs bandwidth gives us
1 job: 5m17s
2 jobs: 3m38s
4 jobs: 2m51s
8 jobs: 2m21s")
(defsystem "nyxt"
:version "2.2.4"
:author "Atlas Engineer LLC"
:homepage "https://nyxt.atlas.engineer"
:description "Extensible web-browser in Common Lisp"
:license "BSD 3-Clause"
:depends-on (alexandria
bordeaux-threads
calispel
cl-base64
cl-css
cl-gopher
cl-html-diff
cl-json
cl-ppcre
cl-ppcre-unicode
cl-prevalence
cl-qrencode
cl-tld
closer-mop
cl-containers
moptilities
dexador
enchant
flexi-streams
iolib
iolib/os
local-time
lparallel
log4cl
#-sbcl
osicat
parenscript
quri
serapeum
nhooks
str
phos
plump
clss
spinneret
swank
trivia
trivial-clipboard
trivial-features
trivial-garbage
trivial-package-local-nicknames
trivial-types
unix-opts
;; Local systems:
nyxt/user-interface
nyxt/text-buffer
nyxt/analysis
nyxt/download-manager
nyxt/history-tree
nyxt/password-manager
nyxt/keymap
nyxt/class-star
nyxt/ospm
nyxt/prompter
nyxt/theme)
:pathname "source/"
:components ((:file "package")
(:module "Utilities"
:pathname ""
:depends-on ("package")
:components
((:file "time")
(:file "types")
(:file "conditions")
(:file "debug")
(:file "user-interface")))
(:module "Core"
:pathname ""
:serial t
:depends-on ("Utilities")
:components
((:file "global")
(:file "concurrency")
(:file "data-storage")
(:file "configuration")
(:file "message")
(:file "command")
(:file "urls")
(:file "parenscript-macro")
(:file "renderer-script")
(:file "dom")
(:file "buffer")
(:file "window")
(:file "mode")
(:file "search-engine")
(:file "browser")
(:file "clipboard")
(:file "input")
(:file "prompt-buffer")
(:file "command-commands")
(:file "recent-buffers")
(:file "annotate")
(:file "history")
(:file "autofill")
(:file "external-editor")
#+quicklisp
(:file "lisp-system")))
(:module "Core modes"
:pathname "mode"
:depends-on ("Core")
:components
((:file "auto")
(:file "input-edit")
(:file "prompt-buffer" :depends-on ("input-edit"))
(:file "file-manager")
(:file "buffer-listing")
(:file "base" :depends-on ("buffer-listing" "file-manager"))
(:file "help")
(:file "message")
(:file "passthrough")
(:file "history-tree")
(:file "list-history")
(:file "web" :depends-on ("history-tree" "list-history"))
(:file "style")
(:file "certificate-exception")
(:file "emacs")
(:file "vi")
(:file "blocker")
(:file "proxy")
(:file "download")
(:file "process")))
(:module "file-manager-mode deps"
:pathname ""
:depends-on ("Core modes")
:components
((:file "password")
(:file "bookmark")
(:file "mode/bookmark-frequent-visits" :depends-on ("bookmark"))
(:file "mode/bookmark" :depends-on ("bookmark"))))
(:module "web-mode commands"
:pathname "mode"
:depends-on ("Core modes" "file-manager-mode deps")
:components
((:file "bookmarklets")
(:file "element-hint" :depends-on ("search-buffer"))
(:file "element-frame")
(:file "jump-heading")
(:file "summarize")
(:file "scroll")
(:file "search-buffer")
(:file "spell-check")
(:file "zoom")))
(:file "status" :depends-on ("Core"))
(:file "start" :depends-on ("Core"))
(:module "Editor modes"
:pathname "mode"
:depends-on ("Core modes")
:components
((:file "editor")
(:file "plaintext-editor")))
(:module "Help"
:pathname ""
:depends-on ("Core modes" "Modes")
:components
((:file "help")
(:file "about")
(:file "tutorial")
(:file "changelog")
(:file "manual")))
(:module "Modes"
:pathname "mode"
:depends-on ("Core modes")
:components
((:file "repl")
(:file "small-web")
(:file "reading-line")
(:file "no-image")
(:file "no-sound")
(:file "no-script")
(:file "no-webgl")
(:file "reduce-bandwidth")
(:file "force-https")
(:file "reduce-tracking")
(:file "os-package-manager")
(:file "visual")
(:file "repeat")
(:file "cruise-control")
(:file "watch")
(:file "preview")
(:file "diff")
(:file "expedition")
(:file "tts")
(:file "record-input-field")
(:file "macro-edit"))))
:in-order-to ((test-op (test-op "nyxt/tests")
(test-op "nyxt/download-manager/tests")
(test-op "nyxt/history-tree/tests")
(test-op "nyxt/keymap/tests")
(test-op "nyxt/class-star/tests")
(test-op "nyxt/ospm/tests")
(test-op "nyxt/prompter/tests"))))
(defun register-submodules (component)
;; Ideally we should avoid writing global, stateful files to the user file
;; system. So instead of writing to the ASDF config file, we register the
;; sudmodule directory with CL_SOURCE_REGISTRY. This locally overrides
;; CL_SOURCE_REGISTRY, but it's fine since submodules are only meant for
;; non-developers (who probably don't set CL_SOURCE_REGISTRY).
;;
;; We must set this globally because the information would be lost within a
;; Lisp compiler subprocess (e.g. as used by linux-packaging).
(flet ((ensure-absolute-path (path component)
(if (uiop:absolute-pathname-p path)
path
(system-relative-pathname component path))))
(setf (uiop:getenv "CL_SOURCE_REGISTRY")
(uiop:strcat
(namestring
(uiop:truenamize
(uiop:ensure-directory-pathname
(ensure-absolute-path *submodules-dir* component))))
;; Double-slash tells ASDF to traverse the tree recursively.
"/"
;; Register this directory so that nyxt.asd is included, just in case.
(uiop:inter-directory-separator)
(namestring (uiop:truenamize (uiop:pathname-directory-pathname
(asdf:system-source-file component))))
(if (uiop:getenv "CL_SOURCE_REGISTRY")
(uiop:strcat (uiop:inter-directory-separator) (uiop:getenv "CL_SOURCE_REGISTRY"))
;; End with an empty string to tell ASDF to inherit configuration.
(uiop:inter-directory-separator)))))
(asdf:clear-configuration)
(format t "; CL_SOURCE_REGISTRY: ~s~%" (uiop:getenv "CL_SOURCE_REGISTRY")))
(defsystem "nyxt/submodules"
:perform (compile-op (o c)
(uiop:run-program `("git"
"-C" ,(namestring (system-relative-pathname c ""))
"submodule" "update" "--init" "--force"
"--jobs" ,(write-to-string *submodules-jobs*))
:ignore-error-status t
:output t)
(register-submodules c)))
(defun nyxt-run-test (c path &key network-needed-p)
(and (or (not network-needed-p)
(not (uiop:getenv "NYXT_TESTS_NO_NETWORK")))
(not (funcall (read-from-string "prove:run")
(system-relative-pathname c path)))
(uiop:getenv "NYXT_TESTS_ERROR_ON_FAIL")
(uiop:quit 18)))
;; TODO: Test that Nyxt starts and that --help, --version work.
(defsystem "nyxt/tests"
:depends-on (nyxt prove)
:components ((:file "tests/package"))
:perform (test-op (op c)
(nyxt-run-test c "tests/offline/")
(nyxt-run-test c "tests/online/" :network-needed-p t)))
(defun print-benchmark (benchmark-results)
(labels ((rat->float (num)
(if (integerp num) num (float num)))
(print-times (entry)
(let ((title (first entry))
(attr (rest entry)))
(unless (or (member (symbol-name title) '("RUN-TIME" "SYSTEM-RUN-TIME")) ; Not so interesting.
(and (member (symbol-name title) '("PAGE-FAULTS" "EVAL-CALLS")
:test #'string=)
(zerop (getf attr :average))))
(format t " ~a: ~,9t~a" (string-downcase title) (rat->float (getf attr :average)))
(format t "~32,8t[~a, ~a]"
(rat->float (getf attr :minimum))
(rat->float (getf attr :maximum)))
(format t "~56,8t(median ~a, deviation ~a, total ~a)"
(rat->float (getf attr :median))
(rat->float (getf attr :deviation))
(rat->float (getf attr :total)))
(format t "~%")))))
(dolist (mark benchmark-results)
(format t "~a (~a sample~:p):~%" (first mark)
(getf (rest (second mark)) :samples))
(mapc #'print-times (rest mark)))))
(defsystem "nyxt/benchmark"
:depends-on (alexandria
nyxt
trivial-benchmark)
:pathname "tests/benchmarks"
:components ((:file "../benchmark-package")
(:file "prompter"))
:perform (test-op (op c)
(let ((results
(funcall (read-from-string "alexandria:hash-table-alist")
(funcall (read-from-string "benchmark:run-package-benchmarks")
:package :nyxt/benchmark
:verbose t))))
(print-benchmark results))))
(defsystem "nyxt/clean-fasls"
:depends-on (swank)
:perform (compile-op (o c)
(load (merge-pathnames
"contrib/swank-asdf.lisp"
(symbol-value
(read-from-string "swank-loader:*source-directory*"))))
(funcall (read-from-string "swank:delete-system-fasls") "nyxt")))
;; We use a temporary "version" file to generate the final nyxt.desktop with the
;; right version number. Since "version" is a file target, third-party
;; packaging systems can choose to generate "version" in advance before calling
;; "make install-assets", so that they won't need to rely on submodules.
(defsystem "nyxt/version"
:depends-on (nyxt)
:output-files (compile-op (o c)
(values (list (system-relative-pathname c "version"))
t))
:perform (compile-op (o c)
(with-open-file (out (output-file o c)
:direction :output
:if-exists :supersede)
(princ (symbol-value (read-from-string "nyxt:+version+"))
out))))
(defsystem "nyxt/documentation" ; TODO: Only rebuild if input changed.
:depends-on (nyxt)
:output-files (compile-op (o c)
(values (list (system-relative-pathname c "manual.html"))
t))
:perform (compile-op (o c)
(with-open-file (out (output-file o c)
:direction :output
:if-exists :supersede)
(write-string (funcall (read-from-string "nyxt::manual-content"
(find-package 'nyxt)))
out))
(format *error-output* "Manual dumped to ~s.~&" (output-file o c))))
(defsystem "nyxt/gtk"
:depends-on (nyxt
cl-cffi-gtk
cl-webkit2)
:pathname "source/"
:serial t
:components ((:file "web-extensions")
(:file "web-extensions-callbacks")
(:file "renderer/gtk-clipboard")
(:file "renderer/gtk")))
(defsystem "nyxt/gi-gtk"
:depends-on (nyxt/gtk
cl-gobject-introspection
bordeaux-threads)
:pathname "source/"
:components ((:file "renderer/gi-gtk")))
(defsystem "nyxt/qt"
:depends-on (nyxt
cl-webengine
trivial-main-thread)
:pathname "source/"
:components ((:file "renderer/qt")))
;; We should not set the build-pathname in systems that have a component.
;; Indeed, when an external program (like Guix) builds components, it needs to
;; know the name of the output. But ASDF/SYSTEM::COMPONENT-BUILD-PATHNAME is
;; non-exported so the only reliable way to know the build pathname is to use
;; the default.
;;
;; The workaround is to set a new dummy system of which the sole purpose is to
;; produce the desired binary.
(defsystem "nyxt/gtk-application"
:depends-on (nyxt/gtk)
:build-operation "program-op"
:build-pathname "nyxt"
:entry-point "nyxt:entry-point")
(defsystem "nyxt/gi-gtk-application"
:depends-on (nyxt/gi-gtk)
:build-operation "program-op"
:build-pathname "nyxt"
:entry-point "nyxt:entry-point")
(defsystem "nyxt/qt-application"
:depends-on (nyxt/qt)
:build-operation "program-op"
:build-pathname "nyxt-qt"
:entry-point "nyxt:entry-point")
#+sb-core-compression
(handler-bind ((warning #'muffle-warning))
(defmethod perform ((o image-op) (c system))
(uiop:dump-image (output-file o c)
:executable t
:compression (when (uiop:getenv "NYXT_COMPRESS")
(parse-integer (uiop:getenv "NYXT_COMPRESS"))))))
(defmethod perform :before ((o image-op) (c system))
"Register immutable systems to prevent compiled images of Nyxt from
trying to recompile dependencies.
See `asdf::*immutable-systems*'."
(map () 'asdf:register-immutable-system (asdf:already-loaded-systems)))
(defsystem "nyxt/install"
:depends-on (alexandria
str
#.(format nil "nyxt/~a-application" *nyxt-renderer*)
nyxt/version)
:perform (compile-op
(o c)
(flet ((ensure-parent-exists (file)
(uiop:ensure-all-directories-exist
(list (directory-namestring file)))))
(let ((desktop-file (format nil "~a/applications/nyxt.desktop" *datadir*)))
(ensure-parent-exists desktop-file)
(uiop:copy-file (system-relative-pathname c "assets/nyxt.desktop")
(format nil "~a/applications/nyxt.desktop" *datadir*)))
(mapc (lambda (icon-size)
(let ((icon-file (format nil "~a/icons/hicolor/~ax~a/apps/nyxt.png"
*datadir* icon-size icon-size)))
(ensure-parent-exists icon-file)
(uiop:copy-file (system-relative-pathname
c
(format nil "assets/nyxt_~ax~a.png"
icon-size icon-size))
icon-file)))
'(16 32 128 256 512))
(let ((binary-file (format nil "~a/nyxt" *bindir*)))
(ensure-parent-exists binary-file)
(uiop:copy-file (system-relative-pathname c "nyxt") binary-file)
;; TODO: Use iolib/os:file-permissions instead of chmod? Too verbose?
(uiop:run-program (list "chmod" "+x" binary-file))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Library subsystems:
(defsystem "nyxt/download-manager"
:depends-on (calispel
cl-ppcre
dexador
log4cl
quri
str)
:pathname "libraries/download-manager/"
:components ((:file "package")
(:file "engine")
(:file "native"))
:in-order-to ((test-op (test-op "nyxt/download-manager/tests"))))
(defsystem "nyxt/download-manager/tests"
:depends-on (nyxt/download-manager prove)
:perform (test-op (op c)
(nyxt-run-test c "libraries/download-manager/tests/"
:network-needed-p t)))
(defsystem "nyxt/analysis"
:depends-on (str
serapeum
alexandria
cl-ppcre)
:pathname "libraries/analysis/"
:components ((:file "package")
(:file "data")
(:file "stem")
(:file "tokenize")
(:file "analysis")
(:file "document-vector")
(:file "text-rank")
(:file "dbscan")
(:file "section")))
(defsystem "nyxt/user-interface"
:depends-on (spinneret)
:pathname "libraries/user-interface/"
:components ((:file "package")
(:file "user-interface")))
(defsystem "nyxt/text-buffer"
:depends-on (cluffer)
:pathname "libraries/text-buffer/"
:components ((:file "package")
(:file "text-buffer")))
(defsystem "nyxt/history-tree"
:depends-on (alexandria
cl-custom-hash-table
local-time
nyxt/class-star
trivial-package-local-nicknames)
:pathname "libraries/history-tree/"
:components ((:file "package")
(:file "history-tree"))
:in-order-to ((test-op (test-op "nyxt/history-tree/tests"))))
(defsystem "nyxt/history-tree/tests"
:depends-on (nyxt/history-tree prove str)
:perform (test-op (op c)
(nyxt-run-test c "libraries/history-tree/tests/")))
(defsystem "nyxt/password-manager"
:depends-on (bordeaux-threads
cl-ppcre
str
trivial-clipboard
uiop
nyxt/class-star
serapeum)
:pathname "libraries/password-manager/"
:components ((:file "package")
(:file "password")
(:file "password-keepassxc")
(:file "password-security")
;; Keep password-store last so that it has higher priority.
(:file "password-pass")))
(defsystem "nyxt/keymap"
:depends-on (alexandria fset str)
:pathname "libraries/keymap/"
:components ((:file "package")
(:file "types")
(:file "conditions")
(:file "keymap")
(:file "scheme")
(:file "scheme-names"))
:in-order-to ((test-op (test-op "nyxt/keymap/tests"))))
(defsystem "nyxt/keymap/tests"
:depends-on (alexandria fset nyxt/keymap prove)
:components ((:file "libraries/keymap/test-package"))
:perform (test-op (op c)
(nyxt-run-test c "libraries/keymap/tests/")))
(defsystem "nyxt/class-star"
:depends-on (hu.dwim.defclass-star moptilities alexandria)
:pathname "libraries/class-star/"
:components ((:file "package")
(:file "patch")
(:file "class-star"))
:in-order-to ((test-op (test-op "nyxt/class-star/tests"))))
(defsystem "nyxt/class-star/tests"
:depends-on (nyxt/class-star prove)
:perform (test-op (op c)
(nyxt-run-test c "libraries/class-star/tests/")))
(defsystem "nyxt/ospm"
:depends-on (alexandria
calispel
cl-ppcre
local-time
named-readtables
#-sbcl
osicat
serapeum
str
trivia
nyxt/class-star)
:pathname "libraries/ospm/"
:components ((:file "package")
(:file "scheme-syntax")
(:file "guix-backend")
(:file "ospm")
(:file "ospm-guix"))
:in-order-to ((test-op (test-op "nyxt/ospm/tests"))))
(defsystem "nyxt/ospm/tests"
:depends-on (nyxt/ospm prove)
:components ((:file "libraries/ospm/test-package"))
:perform (test-op (op c)
(nyxt-run-test c "libraries/ospm/tests/tests.lisp")))
(defsystem "nyxt/prompter"
:depends-on (alexandria
calispel
cl-containers
closer-mop
lparallel
moptilities
serapeum
str
trivial-package-local-nicknames
nyxt/class-star)
:pathname "libraries/prompter/"
:components ((:file "package")
(:file "filter-preprocessor")
(:file "filter")
(:file "prompter-source")
(:file "prompter"))
:in-order-to ((test-op (test-op "nyxt/prompter/tests"))))
(defsystem "nyxt/prompter/tests"
:depends-on (nyxt/prompter prove)
:components ((:file "libraries/prompter/test-package"))
:perform (test-op (op c)
(nyxt-run-test c "libraries/prompter/tests/")))
(defsystem "nyxt/theme"
:depends-on (alexandria
serapeum
nyxt/class-star
cl-css)
:pathname "libraries/theme/"
:components ((:file "package")
(:file "theme"))
:in-order-to ((test-op (test-op "nyxt/theme/tests"))))
(defsystem "nyxt/theme/tests"
:depends-on (nyxt/theme prove)
:components ((:file "libraries/theme/test-package"))
:perform (test-op (op c)
(nyxt-run-test c "libraries/theme/tests/")))