shrink the dependencies from racket/runtime-path (remove mzscheme

and pull out the one things from mzlib/etc that it uses into a separate,
private file)

original commit: b0607f04a90713d88e314d0a534ac28440bc77b7
This commit is contained in:
Robby Findler 2012-06-10 13:50:15 -05:00
parent 0f2664cdd9
commit 3b0c11e22b
2 changed files with 4 additions and 47 deletions

View File

@ -10,6 +10,7 @@
build-list
build-vector
compose)
"private/this-expression-source-directory.rkt"
(rename racket/base base-else else))
(require-for-syntax syntax/name
@ -240,50 +241,6 @@
(not (eq? (namespace-variable-value n #t (lambda () ns-undefined))
ns-undefined)))
(define (extract-module-directory stx)
(let ([srcmod (let ([mpi (syntax-source-module stx)])
(if (module-path-index? mpi)
(module-path-index-resolve mpi)
mpi))])
(let* ([name (resolved-module-path-name srcmod)]
[name (if (pair? name) (car name) name)])
(and (path? name)
(let-values ([(base name dir?) (split-path name)])
(and (path? base)
base))))))
(define-syntax (this-expression-source-directory stx)
(syntax-case stx ()
[(_ sub)
(let ([stx (syntax sub)])
(let ([source-path
(let* ([source (syntax-source stx)]
[source (and (path? source) source)]
[local (or (current-load-relative-directory) (current-directory))]
[dir (path->main-collects-relative
(or (and source (file-exists? source)
(let-values ([(base file dir?)
(split-path source)])
(and (path? base)
(path->complete-path base local))))
local))])
(if (and (pair? dir) (eq? 'collects (car dir)))
(with-syntax ([d dir])
(syntax/loc stx (main-collects-relative->path 'd)))
(with-syntax ([d (if (bytes? dir) dir (path->bytes dir))])
(syntax/loc stx (bytes->path d)))))])
(let ([mpi (syntax-source-module stx)])
(if mpi
(quasisyntax/loc stx
(or (extract-module-directory (quote-syntax #,(datum->syntax-object
stx
'context
stx
stx)))
#,source-path))
source-path))))]
[(_) #`(this-expression-source-directory #,stx)]))
(define-syntax (this-expression-file-name stx)
(syntax-case stx ()
[(_ sub)

View File

@ -1,7 +1,7 @@
(module runtime-path racket/base
(require mzlib/etc
setup/dirs
(require "private/this-expression-source-directory.rkt"
racket/list
setup/dirs
(only-in "private/runtime-path-table.rkt" table)
(for-syntax racket/base))
@ -72,7 +72,7 @@
((length p) . > . 1)
(eq? 'lib (car p))
(andmap string? (cdr p)))
(let* ([strs (regexp-split #rx"/"
(let* ([strs (regexp-split #rx"/"
(let ([s (cadr p)])
(if (regexp-match? #rx"[./]" s)
s