► |  | raco: Racket Command-Line Tools

1 | raco make: Compiling Source to Bytecode
2 | raco exe: Creating Stand-Alone Executables
3 | raco distribute: Sharing Stand-Alone Executables
4 | raco planet: Automatic Package Distribution
5 | raco pkg: Package Management
6 | raco setup: Installation Management
7 | raco decompile: Decompiling Bytecode
8 | raco demod: Demodularizing Programs
9 | raco link: Library Collection Links
10 | raco pack: Packing Library Collections
11 | raco unpack: Unpacking Library Collections
12 | raco ctool: Working with C Code
13 | raco test: Run tests
14 | raco docs: Documentation Search
15 | raco expand: Macro Expansion
16 | raco read: Reading and Pretty-Printing
17 | raco scribble: Building Documentation
18 | Adding a raco Command
19 | Installation Configuration and Search Paths

▼ | 1 | raco make: Compiling Source to Bytecode

1.1 | Running raco make
1.2 | Bytecode Files
1.3 | Dependency Files
1.4 | API for Making Bytecode
1.5 | API for Parallel Builds
1.6 | Compilation Manager Hook for Syntax Transformers
1.7 | API for Simple Bytecode Creation
1.8 | API for Bytecode Paths
1.9 | Compiling to Raw Bytecode
1.10 | API for Raw Compilation
1.11 | API for Reading Compilation Dependencies

On this page:

compile-file

top ← prev up next →

#### 1.7`` API for Simple Bytecode Creation

(require compiler/compile-file) | package: base

> > procedure

> > (compile-file src [dest filter]) → path?

> 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

Compiles the Racket file src and saves the compiled code to dest. If dest is not provided and the "compiled" subdirectory does not already exist, the subdirectory is created. The result of compile-file is the destination file’s path.

If the filter procedure is provided, it is applied to each source expression, and the result is compiled.

Beware that compile-file uses the current reader parameterization to read src. Typically, compile-file should be called from a thunk passed to with-module-reading-parameterization so that the source program is parsed in a consistent way and allowing #lang.

Each expression in src is compiled independently. If src does not contain a single module expression, then earlier expressions can affect the compilation of later expressions when src is loaded directly. An appropriate filter can make compilation behave like evaluation, but the problem is also solved (as much as possible) by the compile-zos procedure.

See also managed-compile-zo.

top ← prev up next →