diff options
author | Case Duckworth | 2024-05-29 12:41:22 -0500 |
---|---|---|
committer | Case Duckworth | 2024-05-29 12:41:22 -0500 |
commit | caee1cfe808ddd184aff7138b43d9a4dc907e059 (patch) | |
tree | b19b0dfd04b3b5fc2789188748000e089dcb79ed | |
parent | Add README, LICENSE (diff) | |
download | scramble-caee1cfe808ddd184aff7138b43d9a4dc907e059.tar.gz scramble-caee1cfe808ddd184aff7138b43d9a4dc907e059.zip |
Relativize file names
-rw-r--r-- | scramble.scm | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/scramble.scm b/scramble.scm index 591ebad..7af5282 100644 --- a/scramble.scm +++ b/scramble.scm | |||
@@ -6,7 +6,8 @@ | |||
6 | (chicken process) | 6 | (chicken process) |
7 | (chicken process-context) | 7 | (chicken process-context) |
8 | (chicken string) | 8 | (chicken string) |
9 | (srfi 1)) | 9 | (srfi 1) |
10 | utf8-srfi-13) | ||
10 | 11 | ||
11 | (define egg (make-parameter #f)) | 12 | (define egg (make-parameter #f)) |
12 | (define build-dir (make-parameter "build")) | 13 | (define build-dir (make-parameter "build")) |
@@ -105,9 +106,6 @@ | |||
105 | ((list? (cdr kv)) | 106 | ((list? (cdr kv)) |
106 | (apply alist-walk (cdr kv) (cdr keys))))))) | 107 | (apply alist-walk (cdr kv) (cdr keys))))))) |
107 | 108 | ||
108 | (define (string-join ss) | ||
109 | (string-intersperse ss " ")) | ||
110 | |||
111 | (define (find-executable name) | 109 | (define (find-executable name) |
112 | (let loop ((path (string-split (get-environment-variable "PATH") ":"))) | 110 | (let loop ((path (string-split (get-environment-variable "PATH") ":"))) |
113 | (cond | 111 | (cond |
@@ -122,9 +120,9 @@ | |||
122 | (define (rule c) | 120 | (define (rule c) |
123 | (let ((deps (alist-ref c (dependency-graph)))) | 121 | (let ((deps (alist-ref c (dependency-graph)))) |
124 | (sprintf "~a: ~a $(BUILD)\n\t~a\n\t~a" | 122 | (sprintf "~a: ~a $(BUILD)\n\t~a\n\t~a" |
125 | (output-of c) | 123 | (relativize (output-of c)) |
126 | (string-join (cons (source-of (car deps)) | 124 | (string-join (cons (relativize (source-of (car deps))) |
127 | (map output-of (cdr deps)))) | 125 | (map (o relativize output-of) (cdr deps)))) |
128 | (string-append "$(CSC) $(CSC_OPTIONS)" | 126 | (string-append "$(CSC) $(CSC_OPTIONS)" |
129 | (if (eq? (car (find-component c)) 'extension) | 127 | (if (eq? (car (find-component c)) 'extension) |
130 | " $(CSC_LIB_OPTIONS)" "") | 128 | " $(CSC_LIB_OPTIONS)" "") |
@@ -134,6 +132,16 @@ | |||
134 | "echo mv " (->string c) ".import.scm $(BUILD)/;" | 132 | "echo mv " (->string c) ".import.scm $(BUILD)/;" |
135 | " fi")))) | 133 | " fi")))) |
136 | 134 | ||
135 | (define (relativize pn) | ||
136 | (let ((ed (string-append | ||
137 | (if (pair? (egg-directory)) | ||
138 | (car (egg-directory)) | ||
139 | (egg-directory)) | ||
140 | "/"))) | ||
141 | (if (string-prefix? ed pn) | ||
142 | (substring pn (string-length ed)) | ||
143 | pn))) | ||
144 | |||
137 | (define (emit-makefile egg-file) | 145 | (define (emit-makefile egg-file) |
138 | (parameterize ((egg (read-egg egg-file))) | 146 | (parameterize ((egg (read-egg egg-file))) |
139 | (print "# Automatically generated by scramble") (newline) | 147 | (print "# Automatically generated by scramble") (newline) |
@@ -148,7 +156,8 @@ | |||
148 | (print "TEST_ENV = env BUILD=$(BUILD) TESTS=$(TESTS)") | 156 | (print "TEST_ENV = env BUILD=$(BUILD) TESTS=$(TESTS)") |
149 | (newline) | 157 | (newline) |
150 | (print ".PHONY: all test clean install uninstall") | 158 | (print ".PHONY: all test clean install uninstall") |
151 | (print "all: " (string-join (map (o output-of car) (dependency-graph)))) | 159 | (print "all: " (string-join (map (o relativize output-of car) |
160 | (dependency-graph)))) | ||
152 | (print "test: $(BUILD)" | 161 | (print "test: $(BUILD)" |
153 | "\n\t" "cd $(BUILD) && " | 162 | "\n\t" "cd $(BUILD) && " |
154 | "$(TEST_ENV) $(CSI) -setup-mode -s $(TESTS)/run.scm $(NAME)") | 163 | "$(TEST_ENV) $(CSI) -setup-mode -s $(TESTS)/run.scm $(NAME)") |