sprite-make

sprite-make runs the compilation pipeline on a module up to the requested product: ICurry (--icy), a module image (--image), C++ (--cxx) or an object (--so). make stage uses it to compile the Curry library into the installation. It also writes intermediate forms for inspection.

sprite-make -h prints the usage and sprite-make --man the manual; both follow.

sprite-make Manual

usage: sprite-make [-h] [--curry2icurry TOOL] [--cxx] [--so] [-g GOAL] [-i]
                   [--jobs N] [-k] [-M] [-o OUTPUT] [-q] [--rewrite-flat] [-S]
                   [-t] [--image] [--stage-library]
                   [names ...]

Compile Curry modules to ICurry, images, C++ or shared objects.

positional arguments:
  names                Curry modules or source files to process

options:
  -h, --help           show this help message and exit
  --curry2icurry TOOL  the route from Curry to ICurry: frontend (the Curry
                       front end and the built-in translation) or icurry (the
                       icurry program)
  --cxx                make C++ files
  --so                 make shared objects for the C++ backend (implies --cxx)
  -g, --goal GOAL      specifies the goal of a generated program
  -i, --icy            make ICY files
  --jobs N             make up to N modules at once, each in a child process
                       (auto: one per processor); the imports of a module are
                       made first
  -k, --keep-going     keep working after an error
  -M, --man            show detailed usage
  -o, --output OUTPUT  specify the output file
  -q, --quiet          work quietly
  --rewrite-flat       run the step from Curry to ICurry again, current or
                       not: the front end, the rewrite of the FlatCurry file
                       by the binding optimization and the set0 lift, and the
                       translation (implies --icy; needs the source; --jobs 1)
  -S, --subdir         print the subdirectory to which output files are
                       written then exit
  -t, --tidy           remove intermediate files generated by this program
  --image              make runtime module images
  --stage-library      build the installed library in place, including
                       compiler imports

Executes the toolchain to compile Curry code.

This program uses timestamps and prerequisites to lazily update targets. Each positional argument can be a Curry module name, a Curry source file, or an ICurry file (extension: .icy). Modules are located by searching the CURRYPATH environment variable; the imports of a program given as a source file are searched in the directory of the file first, as PAKCS searches, so a program and the modules beside it need no CURRYPATH. An ICurry file can be translated to a module image beside it.

The targets are --icy (the translation record), --image (the runtime module image), --cxx (generated C++) and --so (a shared object, with extension .dll on Windows). Each target implies its prerequisites. With no target option, the default is --image. Output lives under <dir>/.curry/sprite-pakcs-3.10.0; --output copies the final product to the requested path. --tidy removes newly generated intermediates, retaining the ICurry text required by inspection and save.

The --curry2icurry option names the route from Curry to ICurry. frontend runs the Curry front end and then the built-in translation from FlatCurry; icurry runs the icurry program. The default is the value of SPRITE_CURRY2ICURRY, else the choice made by CMake (CURRY2ICURRY_TOOL), else whichever tool is installed.

The --rewrite-flat option runs the step from Curry to ICurry of every named module again, whether or not its files are current, without the ICurry cache: the front end (which leaves a current FlatCurry file as it is), the rewrite step, which rewrites the FlatCurry file in place when the binding optimization replaces an equality or the set0 lift lifts a call (curry.toolchain.flat2icurry.rewrite_file), and the translation. The option implies --icy, so it stands alone; the later steps of another target follow as usual from the new ICurry file. Use it on a module whose products were made before the FlatCurry file was rewritten, so that the file on disk and the products agree; the module must have its source. The option runs the modules in this process (--jobs 1).

The --jobs N option makes up to N modules at once. Each module is made by a child process that runs this program on that module alone; auto is one child per processor. The imports of a module are made before the module, so no two children write the files that this program makes for one module (the ICurry, image, C++ and shared-object files). A module whose files are current gets no child. The order does not cover the interface files of the Curry front end (.fint, .fcy): the front end writes those of an import on its own when they are missing, so two children whose modules import one module without them write them at once. Run the front-end step of such a tree (products copied without their interface files) with --jobs 1. Before the children start, this process builds the precompiled header of the C++ backend when it is missing, so the children find it. The option covers the modules named on the command line and the modules they import. The installation procedure passes the job count of make.

The product cache. The C++ backend keeps a copy of each shared object it compiles, with the generated C++ and the ABI stamp, in a cache directory outside the tree when SPRITE_PRODUCT_CACHE names a directory. An entry is found by content: the digest of the ABI stamp, the text of the module and of the modules it imports, and the facts that shape the generated code. A module whose entry is in the cache is neither generated nor compiled; its files are placed beside the source with a stamp for this installation. A module in the temporary directory of the system is not cached. At the end of a run that restored or stored a product this program prints one line with the two counts, sprite-make: product cache: N restored, M stored, unless -q was given; under --jobs the counts of the children are summed. See the page on environment variables.

Products made before the rewrite. An ICurry file translated before the rewrite step existed is stale: the FlatCurry file beside the source holds a Boolean equality that the binding optimization replaces, or a set0 call that the set0 lift lifts, and the ICurry file lacks the result (a pair from an older tree or from the overlay archive of the tests). The step from Curry to ICurry runs again for such a module, as for a changed source. At the end of a run that made such a module again this program prints sprite-make: pre-rewrite pairs: N translated again, unless -q was given; under --jobs the counts of the children are summed. When the ICurry cache held the entry of the module (the test drivers keep one), the cache writes the ICurry file and the rewrite step runs over the FlatCurry file; the line then ends in , M from the ICurry cache. The modules of the Curry library are not judged; their ICurry is committed. A FlatCurry file larger than 256 KB, or one that cannot be written again, is not judged either, with a warning.

Environment Variables

CURRYPATH

a colon-separated list of paths to search for Curry modules. The directory of a program given as a source file is searched first.

SPRITE_PRODUCT_CACHE

the directory of the product cache; the empty string turns the cache off.

SPRITE_CURRY2ICURRY

names the route from Curry to ICurry: frontend or icurry.

SPRITE_LOG_LEVEL

adjusts logging output. Values are CRITICAL, ERROR, WARNING (default), INFO, and DEBUG.

SPRITE_FRONTEND_WARNINGS

set to 0 silences the warnings of the Curry front end (overlapping rules), which a run otherwise reports once per module through the log at the WARNING level. -q silences them too.

Examples

The following converts Peano.curry to the ICurry file Peano.icy. Module Peano is found by searching CURRYPATH. The output is placed at <dir>/.curry/sprite-pakcs-3.10.0/Peano.icy, where <dir> is the directory containing Peano.curry:

sprite-make --icy Peano.curry

The following creates a runtime module image:

sprite-make --image Peano.curry

Generating ICurry

--icy writes the ICurry of a module. From examples/:

sprite-make --icy Peano.curry

The file goes to the subdirectory of intermediate products beside the source; print its name with:

sprite-make --subdir

-o names another output file:

sprite-make --icy Peano.curry -o Peano.icy

Generating module images

To generate a runtime module image, supply --image:

sprite-make --image Peano.curry -o Peano.img

This is also the default target. It implies --icy; --cxx and --so imply --image. The translation record stays beside the image for inspection and saving, including with --tidy.

Compiling ahead of time

--so compiles a module ahead of time into a shared object that the runtime loads. It implies --cxx and needs a C++ compiler. A staged installation uses tools/cxx; a wheel uses CXX or g++ on PATH:

sprite-make --so Peano.curry

The object is written to .curry/sprite-pakcs-<ver>/Peano.so beside its ABI stamp and loads whenever the module is imported. It is compiled again when the runtime, the compiler or an imported module changed. The product cache keeps a copy (SPRITE_PRODUCT_CACHE, Development Variables).