-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsalmonella-5.scm
101 lines (91 loc) · 4.41 KB
/
salmonella-5.scm
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
;; Although the name of this file contains 5, which would indicate it
;; is the salmonella code for CHICKEN 5, it also provides support for
;; CHICKEN 6, as when it comes to CHICKEN behavior required by
;; salmonella, CHICKEN 5 and CHICKEN 6 at this point are pretty much
;; the same.
(import (chicken base)
(chicken condition)
(chicken pathname))
(define (make-salmonella tmp-dir
#!key chicken-installation-prefix
chicken-install-args
eggs-doc-dir
clear-chicken-home?
this-egg?
csi
csc
chicken-install)
(let* ((env (salmonella-env tmp-dir
chicken-installation-prefix
chicken-install-args
this-egg?
clear-chicken-home?
csi
csc
chicken-install))
(glob-units (lambda (pattern)
(glob (make-pathname (env 'host-repository-path)
(string-append
pattern
(if (eq? (software-type) 'windows)
"dll"
"so"))))))
(chicken-import-libraries
;; List of chicken import libraries. This is a bit broken,
;; as if an egg installs a library called chicken*.import or
;; scheme.*.import this code is going to copy the egg
;; library as if it was a core library.
(cons
"srfi-4"
(map (lambda (unit)
(string-chomp (pathname-strip-directory unit)
".import.so"))
(append
(glob-units "chicken*.import.")
(if (= (env 'major-version) 6)
(glob-units "scheme.*.import.")
'()))))))
(check-chicken-executables env)
(define (init-repo!)
;; Create repository-path into the test directory
(create-directory (env 'tmp-repo-lib-dir) 'recursively)
;; Copy CHICKEN executables
(init-tmp-repo-bin-dir! env)
;; Copy CHICKEN core units
(for-each (lambda (unit)
(copy-file (make-pathname (env 'host-repository-path) unit "import.so")
(make-pathname (env 'tmp-repo-lib-dir) unit "import.so")
'clobber))
chicken-import-libraries)
;; Copy types.db
(copy-file (make-pathname (env 'host-repository-path) "types.db")
(make-pathname (env 'tmp-repo-lib-dir) "types.db")
'clobber)
;; Set environment variables (CHICKEN_REPOSITORY_PATH must be
;; set after initializing the repository)
(set-environment-variable! "SALMONELLA_RUNNING" "1")
(set-environment-variable! "CHICKEN_INCLUDE_PATH" (env 'tmp-repo-share-dir))
(set-environment-variable! "CHICKEN_C_INCLUDE_PATH"
(make-pathname (env 'tmp-repo-dir) "include/chicken"))
(set-environment-variable! "PATH" (salmonella-system-path env))
(set-environment-variable! "CHICKEN_EGG_CACHE" (env 'cache-dir))
(set-environment-variable! "CHICKEN_INSTALL_REPOSITORY" (env 'tmp-repo-lib-dir))
(set-environment-variable! "CHICKEN_INSTALL_PREFIX" (env 'tmp-repo-dir))
(set-environment-variable! "CHICKEN_REPOSITORY_PATH" (env 'tmp-repo-lib-dir)))
(lambda (action #!optional egg #!rest more-args)
(case action
((clear-repo!) (clear-repo! egg env))
((clear-chicken-home!) (clear-chicken-home! env))
((init-repo!) (init-repo!))
((fetch) (fetch-egg egg env))
((install) (install-egg egg env))
((test) (test-egg egg env))
((check-version) (check-version egg env))
((env-info) (env-info env))
((meta-data) (meta-data egg env))
((check-dependencies) (check-dependencies egg (car more-args) (env 'major-version)))
((check-category) (check-category egg (car more-args)))
((check-doc) (check-egg-doc egg eggs-doc-dir (env 'major-version)))
((check-license) (check-license egg (car more-args)))
((check-author) (check-author egg (car more-args)))
(else (error 'salmonella "Invalid action" action))))))