#lang s-exp "../lang/kernel.rkt"
(require (for-syntax racket/base
racket/path
syntax/parse
"munge-path.rkt"
"record.rkt"))
(provide define-resource)
(require "structs.rkt")
(define-syntax (define-resource stx)
(syntax-parse stx
[(_ name:id path:str)
(let* ([normal-path
(normalize-path (build-path
(or (current-load-relative-directory)
(current-directory))
(syntax-e #'path)))]
[munged-path (munge-path normal-path)])
(with-syntax ([normal-path normal-path]
[munged-path munged-path])
(syntax/loc stx
(begin
(begin-for-syntax
(let* ([this-module
(variable-reference->resolved-module-path
(#%variable-reference))]
[resolved-module-path (resolved-module-path-name this-module)])
(record-resource resolved-module-path normal-path munged-path)))
(define name (resource normal-path munged-path))))))]))