move compile-file' to
compiler/compile-file'
The `mzlib/compile' module re-exports the moved function. Also, fix `make-directory*' so that it never fails on an existing directory. Remove `unstable/file', since it was just the same clean-up of `make-directory*'.
This commit is contained in:
parent
72c9162989
commit
8d3c09b38b
|
@ -1,34 +1,7 @@
|
|||
#lang scribble/doc
|
||||
@(require "common.rkt"
|
||||
(for-label mzlib/compile
|
||||
compiler/compiler
|
||||
compiler/cm))
|
||||
(for-label compiler/compile-file))
|
||||
|
||||
@mzlib[#:mode title compile]
|
||||
|
||||
@defproc[(compile-file [src path-string?]
|
||||
[dest path-string? (let-values ([(base name dir?) (split-path src)])
|
||||
(build-path base "compiled"
|
||||
(path-add-suffix name #".zo")))]
|
||||
[filter (any/c . -> . any/c) values])
|
||||
path?]{
|
||||
|
||||
Compiles the Scheme file @racket[src] and saves the compiled code to
|
||||
@racket[dest]. If @racket[dest] is not provided and the
|
||||
@filepath{compiled} subdirectory does not already exist, the
|
||||
subdirectory is created. The result of @racket[compile-file] is the
|
||||
destination file's path.
|
||||
|
||||
If the @racket[filter] procedure is provided, it is applied to each
|
||||
source expression, and the result is compiled.
|
||||
|
||||
The @racket[compile-file] procedure is designed for compiling modules
|
||||
files, in that each expression in @racket[src] is compiled
|
||||
independently. If @racket[src] does not contain a single
|
||||
@racket[module] expression, then earlier expressions can affect the
|
||||
compilation of later expressions when @racket[src] is loaded
|
||||
directly. An appropriate @racket[filter] can make compilation behave
|
||||
like evaluation, but the problem is also solved (as much as possible)
|
||||
by the @racket[compile-zos] procedure.
|
||||
|
||||
See also @racket[managed-compile-zo].}
|
||||
Re-exports @racket[compile-file] from @racketmodname[compiler/compile-file].
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#lang racket/base
|
||||
(require compiler/compile-file)
|
||||
|
||||
(provide compile-file)
|
|
@ -516,6 +516,8 @@ datastructure containing an in-memory tree representation of the collects
|
|||
directory.
|
||||
}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section{Compilation Manager Hook for Syntax Transformers}
|
||||
|
||||
@defmodule[compiler/cm-accomplice]
|
||||
|
@ -549,6 +551,39 @@ recognizes the message to register a dependency on a
|
|||
module (which implies a dependency on all of that module's
|
||||
dependencies, etc.).}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@section{API for Simple Bytecode Creation}
|
||||
|
||||
@defmodule[compiler/compile-file]
|
||||
|
||||
@defproc[(compile-file [src path-string?]
|
||||
[dest path-string? (let-values ([(base name dir?) (split-path src)])
|
||||
(build-path base "compiled"
|
||||
(path-add-suffix name #".zo")))]
|
||||
[filter (any/c . -> . any/c) values])
|
||||
path?]{
|
||||
|
||||
Compiles the Racket file @racket[src] and saves the compiled code to
|
||||
@racket[dest]. If @racket[dest] is not provided and the
|
||||
@filepath{compiled} subdirectory does not already exist, the
|
||||
subdirectory is created. The result of @racket[compile-file] is the
|
||||
destination file's path.
|
||||
|
||||
If the @racket[filter] procedure is provided, it is applied to each
|
||||
source expression, and the result is compiled.
|
||||
|
||||
The @racket[compile-file] procedure is designed for compiling modules
|
||||
files, in that each expression in @racket[src] is compiled
|
||||
independently. If @racket[src] does not contain a single
|
||||
@racket[module] expression, then earlier expressions can affect the
|
||||
compilation of later expressions when @racket[src] is loaded
|
||||
directly. An appropriate @racket[filter] can make compilation behave
|
||||
like evaluation, but the problem is also solved (as much as possible)
|
||||
by the @racket[compile-zos] procedure.
|
||||
|
||||
See also @racket[managed-compile-zo].}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section[#:tag "zo"]{Compiling to Raw Bytecode}
|
||||
|
|
|
@ -996,7 +996,8 @@ paths disappear during the scan, then an exception is raised.}
|
|||
@defproc[(make-directory* [path path-string?]) void?]{
|
||||
|
||||
Creates directory specified by @racket[path], creating intermediate
|
||||
directories as necessary.}
|
||||
directories as necessary, and never failing if @racket[path] exists
|
||||
already.}
|
||||
|
||||
|
||||
@defproc[(make-temporary-file [template string? "rkttmp~a"]
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
scribble/private/run-pdflatex
|
||||
setup/xref
|
||||
scribble/xref
|
||||
unstable/file
|
||||
racket/place
|
||||
pkg/lib
|
||||
pkg/strip
|
||||
|
@ -1103,7 +1102,7 @@
|
|||
(unless latex-dest
|
||||
(let ([dir (doc-dest-dir doc)])
|
||||
(if (not (directory-exists? dir))
|
||||
(make-directory*/ignore-exists-exn dir)
|
||||
(make-directory* dir)
|
||||
(for ([f (directory-list dir)]
|
||||
#:when
|
||||
(and (file-exists? f)
|
||||
|
@ -1225,7 +1224,7 @@
|
|||
(let* ([filename (sxref-path latex-dest doc name)])
|
||||
(prep! filename)
|
||||
(when (verbose) (printf " [Caching to disk ~a]\n" filename))
|
||||
(make-directory*/ignore-exists-exn (doc-dest-dir doc))
|
||||
(make-directory* (doc-dest-dir doc))
|
||||
(with-compile-output
|
||||
filename
|
||||
(lambda (out tmp-filename)
|
||||
|
@ -1242,7 +1241,7 @@
|
|||
(when (and (doc-pkg? doc)
|
||||
(not (doc-under-main? doc))
|
||||
(not latex-dest))
|
||||
(make-directory*/ignore-exists-exn (doc-dest-dir doc))
|
||||
(make-directory* (doc-dest-dir doc))
|
||||
(with-compile-output
|
||||
(sxref-path latex-dest doc "provides.sxref")
|
||||
(lambda (out tmp-filename)
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#lang scribble/doc
|
||||
@(require scribble/base
|
||||
scribble/manual
|
||||
"utils.rkt"
|
||||
(for-label unstable/file
|
||||
racket/file
|
||||
racket/contract
|
||||
racket/base))
|
||||
|
||||
@title[#:tag "file"]{Filesystem}
|
||||
@unstable[@author+email["Jay McCarthy" "jay@racket-lang.org"]]
|
||||
|
||||
@defmodule[unstable/file]
|
||||
|
||||
@defproc[(make-directory*/ignore-exists-exn [pth path-string?])
|
||||
void]{
|
||||
Like @racket[make-directory*], except it ignores errors when the path already exists. Useful to deal with race conditions on processes that create directories.
|
||||
}
|
|
@ -81,7 +81,6 @@ Keep documentation and tests up to date.
|
|||
@include-section["debug.scrbl"]
|
||||
@include-section["define.scrbl"]
|
||||
@include-section["error.scrbl"]
|
||||
@include-section["file.scrbl"]
|
||||
@include-section["find.scrbl"]
|
||||
@include-section["flonum.scrbl"]
|
||||
@include-section["future.scrbl"]
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
syntax/modresolve
|
||||
syntax/modread
|
||||
setup/dirs
|
||||
unstable/file
|
||||
racket/file
|
||||
racket/list
|
||||
racket/path
|
||||
|
@ -426,7 +425,7 @@
|
|||
|
||||
;; Write the code and dependencies:
|
||||
(when code
|
||||
(with-compiler-security-guard (make-directory*/ignore-exists-exn code-dir))
|
||||
(with-compiler-security-guard (make-directory* code-dir))
|
||||
(with-compile-output zo-name
|
||||
(lambda (out tmp-name)
|
||||
(with-handlers ([exn:fail?
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
#lang racket/base
|
||||
(require racket/function
|
||||
racket/path
|
||||
racket/file
|
||||
unstable/file)
|
||||
racket/file)
|
||||
(provide compile-file)
|
||||
|
||||
(define compile-file
|
||||
(case-lambda
|
||||
[(src)
|
||||
(define cdir (build-path (path-only src) "compiled"))
|
||||
(make-directory*/ignore-exists-exn cdir)
|
||||
(make-directory* cdir)
|
||||
(compile-file src (build-path cdir (path-add-suffix (file-name-from-path src) #".zo")))]
|
||||
[(src dest)
|
||||
(compile-file src dest values)]
|
|
@ -18,7 +18,7 @@
|
|||
syntax/moddep
|
||||
|
||||
scheme/file
|
||||
mzlib/compile ; gets compile-file
|
||||
compiler/compile-file
|
||||
compiler/cm
|
||||
setup/getinfo
|
||||
setup/main-collects
|
||||
|
|
|
@ -2,6 +2,7 @@ Version 5.3.900.6
|
|||
Added identifier-binding-symbol
|
||||
Changed ".plt" file unpacking to require certain literal S-expression
|
||||
patterns, instead of evaluating S-expressions from the archive
|
||||
racket/file: make-directory* never fails on existing directories
|
||||
|
||||
Version 5.3.900.5
|
||||
Added call-with-default-reading-parameterization
|
||||
|
|
|
@ -94,7 +94,8 @@
|
|||
(not (directory-exists? base)))
|
||||
(make-directory* base))
|
||||
(unless (directory-exists? dir)
|
||||
(make-directory dir))))
|
||||
(with-handlers ([exn:fail:filesystem:exists? void])
|
||||
(make-directory dir)))))
|
||||
|
||||
(define-syntax (make-temporary-file stx)
|
||||
(with-syntax ([app (datum->syntax stx #'#%app stx)])
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#lang racket/base
|
||||
; Responsible: Jay McCarthy
|
||||
(require racket/contract/base)
|
||||
|
||||
(define (exn:fail:filesystem:exists? x)
|
||||
(and (exn:fail:filesystem? x)
|
||||
(regexp-match #rx"exists" (exn-message x))))
|
||||
|
||||
(define (make-directory*/ignore-exists-exn dir)
|
||||
(let-values ([(base name dir?) (split-path dir)])
|
||||
(when (and (path? base)
|
||||
(not (directory-exists? base)))
|
||||
(make-directory*/ignore-exists-exn base))
|
||||
(unless (directory-exists? dir)
|
||||
(with-handlers ([exn:fail:filesystem:exists? void])
|
||||
(make-directory dir)))))
|
||||
|
||||
(provide/contract
|
||||
[make-directory*/ignore-exists-exn (path-string? . -> . void?)])
|
Loading…
Reference in New Issue
Block a user