-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanifest.rkt
55 lines (49 loc) · 2.06 KB
/
manifest.rkt
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
#lang racket/base
;; Defines a #lang for declaraing files/directories to benchmark
(provide
(rename-out [-#%module-begin #%module-begin]))
(require
(for-syntax
gtp-measure/private/parse
racket/base
syntax/parse))
;; =============================================================================
(define-syntax (-#%module-begin stx)
(syntax-parse stx
[(_ (~optional (~seq #:config cfg) #:defaults ((cfg #'#hash())))
tgt*:gtp-measure-target ...)
#`(#%module-begin
(provide #,GTP-MEASURE-TARGETS-ID #,GTP-MEASURE-CONFIG-ID)
(require
(only-in racket/path normalize-path path-only)
(only-in racket/contract define/contract)
(only-in gtp-measure/private/configure gtp-measure-config/c)
(only-in gtp-measure/private/parse valid-target? valid-target?/kind check-target/kind))
(define CWD
(let ([p (variable-reference->module-source (#%variable-reference))])
(if (path? p)
(path-only p)
(error 'gtp-measure/manifest "cannot find module source"))))
(define/contract #,GTP-MEASURE-CONFIG-ID
gtp-measure-config/c
'cfg)
(define #,GTP-MEASURE-TARGETS-ID
(for/list ([pre-path (in-list '(tgt*.string ...))]
[pre-kind (in-list '(tgt*.kind ...))])
(define p (normalize-path pre-path CWD))
(if pre-kind
(if (valid-target?/kind p pre-kind)
(cons (path->string p) pre-kind)
(raise-arguments-error 'gtp-measure/manifest "invalid target"
"target" pre-path
"kind" pre-kind
"reason" (check-target/kind pre-path pre-kind)))
(let ([kind (valid-target? p)])
(if kind
(cons (path->string p) kind)
(raise-arguments-error 'gtp-measure/manifest "invalid target"
"target" pre-path)))))))]))
(module* reader syntax/module-reader
gtp-measure/manifest
#:read read
#:read-syntax read-syntax)