You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pollen/project.rkt

29 lines
1.2 KiB
Racket

#lang racket/base
(require "world.rkt" sugar/define sugar/coerce)
(define (paths? x) (and (list? x) (andmap path? x)))
11 years ago
(define/contract+provide (get-directory-require-files source-path) ; keep contract local to ensure coercion
(coerce/path? . -> . (or/c #f paths?))
(define possible-requires (list (simplify-path (build-path source-path 'up world:directory-require))))
(and (andmap file-exists? possible-requires) possible-requires))
11 years ago
(define+provide/contract (require+provide-directory-require-files here-path #:provide [provide #t])
11 years ago
(coerce/path? . -> . (or/c list? void?))
(define (put-file-in-require-form file)
`(file ,(path->string file)))
(define directory-require-files (get-directory-require-files here-path))
(if directory-require-files
(let ([files-in-require-form (map put-file-in-require-form directory-require-files)])
`(begin
(require ,@files-in-require-form)
11 years ago
,@(if provide
(list `(provide (all-from-out ,@files-in-require-form)))
'())))
11 years ago
'(begin)))
11 years ago
(define+provide (require-directory-require-files here-path)
(require+provide-directory-require-files here-path #:provide #f))