1 Running mzc
2 Compiling Modified Modules to Bytecode
3 Creating and Distributing Stand-Alone Executables
4 Packaging Library Collections
5 Compiling and Linking C Extensions
6 Embedding Scheme Modules via C
7 Compiling to Raw Bytecode
8 Compiling to Native Code via C
9 Scheme API for Compilation
Index
On this page:
3.2.1 Scheme API for Distributing Executables
assemble-distribution
3.2.2 Scheme API for Bundling Distributions
bundle-directory
bundle-put-file-extension+ style+ filters
Version: 4.0.2

 

3.2 Distributing Stand-Alone Executables

The command-line flag --exe-dir directs mzc to combine a stand-alone executable (created via --exe or --gui-exe) with all of the shared libraries that are needed to run it, along with any run-time files declared via define-runtime-path. The resulting package can be moved to other machines that run the same operating system.

After the --exe-dir flag, supply a directory to contain the combined files for a distribution. Each command-line argument is an executable to include in the distribution, so multiple executables can be packaged together. For example, under Windows,

  mzc --exe-dir geetings hello.exe goodbye.exe

creates a directory "greetings" (if the directory doesn’t exist already), and it copies the executables "hello.exe" and "goodbye.exe" into "greetings". It also creates a "lib" sub-directory in "greetings" to contain DLLs, and it adjusts the copied "hello.exe" and "goodbye.exe" to use the DLLs in "lib".

The layout of files within a distribution directory is platform-specific:

A distribution also has a "collects" directory that is used as the main library collection directory for the packaged executables. By default, the directory is empty. Use mzc’s ++copy-collects flag to supply a directory whose content is copied into the distribution’s "collects" directory. The ++copy-collects flag can be used multiple times to supply multiple directories.

When multiple executables are disrtibuted together, then separately creating the executables with --exe and --gui-exe can generate multiple copies of collection-based libraries that are used by multiple executables. To share the library code, instead, specify a target directory for library copies using the --collects-dest flag with --exe and --gui-exe, and specify the same directory for each executable (so that the set of libraries used by all executables are pooled together). Finally, when packaging the distribution with --exe-dir, use the ++copy-collects flag to include the copied libraries in the distribution.

3.2.1 Scheme API for Distributing Executables

 (require compiler/distribute)

The compiler/distribute library provides a function to perform the same work as mzc --exe or mzc --gui-exe.

(assemble-distribution

 

dest-dir

 

 

 

 

 

 

exec-files

 

 

 

 

 

 [

#:collects-path path

 

 

 

 

 

 

#:copy-collects dirs])

 

 

void?

  dest-dir : path-string?

  exec-files : (listof path-string?)

  path : (or/c false/c (and/c path-string? relative-path?)) = #f

  dirs : (listof path-string?) = null

Copies the executables in exec-files to the directory dest-dir, along with DLLs, frameworks, and/or shared libraries that the executables need to run a different machine.

The arrangement of the executables and support files in dest-dir depends on the platform. In general assemble-distribution tries to do the Right Thing.

If a #:collects-path argument is given, it overrides the default location of the main "collects" directory for the packaged executables. It should be relative to the dest-dir directory (typically inside it).

The content of each directory in the #:copy-collects argument is copied into the main "collects" directory for the packaged executables.

3.2.2 Scheme API for Bundling Distributions

 (require compiler/bundle-dist)

The compiler/bundle-dist library provides a function to pack a directory (usually assembled by assemble-distribution) into a distribution file. Under Windows, the result is a ".zip" archive; under Mac OS X, it’s a ".dmg" disk image; under Unix, it’s a ".tgz" archive.

(bundle-directory dist-file dir [for-exe?])  void?

  dist-file : file-path?

  dir : file-path?

  for-exe? : any/c = #f

Packages dir into dist-file. If dist-file has no extension, a file extension is added automatcially (using the first result of bundle-put-file-extension+style+filters).

The created archive contains a directory with the same name as dir – except under Mac OS X when for-exe? is true and dir contains a single a single file or directory, in which case the created disk image contains just the file or directory. The default for for-exe? is #f.

Archive creation fails if dist-file exists.

(bundle-put-file-extension+style+filters)

 

 

(or/c string? false/c)

(listof (one-of/c 'packages 'enter-packages))

(listof (list/c string? string?))

Returns three values suitable for use as the extension, style, and filters arguments to put-file, respectively to select a distribution-file name.