
The ciao command implements most bundle management operations. The most important commands are:
$ ciao list # List bundles in current workspaces $ ciao build [<tgts>] # Build $ ciao build -r [<tgts>] # Build, including dependencies $ ciao fetch [<tgts>] # Fetch all dependencies of a bundle $ ciao get [<tgts>] # Fetch, build, and install a bundle $ ciao rm [<tgts>] # Remove a bundle $ ciao install [<tgts>] # Make bundles available (see below) $ ciao update # Update the downloaded bundles
Most commands accept one ore more targets (workspace paths, bundle directories, bundle names, or bundle aliases for location on the network). For example, valid targets are:
Execute ciao help to obtain a detailed list of commands.
(See Bundles and workspaces for what bundles and workspaces are, and how bundles are found in a workspace.)
Ciao locates bundles by looking at one or more workspaces, given by the following (optional) environment variables:
Workspaces from CIAOPATH are consulted from left to right. If CIAOPATH is undefined, a default value of ~/.ciao will be used. The first encountered workspace directory is denoted as the top workspace. The variable CIAOROOT is not needed: the Ciao executables find the root from their own location (the variable overrides it).
As mentioned in Installing Ciao, setting up the environment uses the ciao-env tool, which updates the PATH and other environment variables to make commands and documentation (man, info) accessible by default.
Configuring workspaces: The directory ~/ciao can be added permanently as a workspace as follows. Include the following at the ~/.emacs file:
(setenv "CIAOPATH" (expand-file-name "~/ciao"))
Then add these lines to the ~/.bashrc file:
export CIAOPATH=~/ciao
It is possible to change CIAOPATH temporarily from emacs (M-x setenv) or a shell in a terminal (executing export CIAOPATH=<path>)
Creating new bundles: For creating new bundles it is recommended to define a workspace directory (e.g., ~/ciao) and set the CIAOPATH environment variable to that directory.
Bundles can be created from scratch or cloned from repositories, e.g.:
$ cd ~/ciao $ git clone https://github.com/jfmc/chat80
At that point bundles can be managed with the ciao command. The ciao list should display chat80 as a recognized bundle, and it should be possible to configure, build, or install it (e.g., ciao build at chat80 directory or ciao build chat80 anywhere). Most commands will rescan the bundles at the workspace, but it can be done manually with:
$ ciao rescan-bundlesNote that existing toplevels may need to be restarted to recognize modules at the new bundles.
Network installation: It is possible to download, configure, build, and install automatically bundles from the network. For example:
ciao get github.com/jfmc/chat80will fetch and install chat80 under the top workspace (~/.ciao if CIAOPATH is unset) (see bundle_fetch). The bundle name will be chat80, while the rest of the bundle alias is used to locate the location on the network. The command:
ciao rm chat80removes the bundle (to prevent accidental data losses, only iff it has been marked as downloaded).
A built system is made available with ciao install:
ciao uninstall (with the same --prefix) undoes it. The downloaded bundles are updated with ciao update, and Ciao itself (a git clone) with ./ciao-boot.sh update (optionally to a branch, snapshot or release: ./ciao-boot.sh update REF). The ciao_builder manual describes the details: Configuration, Build, Installation, and Updating.
In the context of calls to <srcdir>/ciao-boot.sh, CIAOROOT is implicitly set to the directory where ciao-boot.sh is located (<srcdir>) and CIAOPATH is unset. Thus only bundles at <srcdir> (including bundle catalog directories) are considered.
This is useful to:
Example: the following command will bootstrap Ciao from source, as well as fetch and install the full development environment:
./ciao-boot.sh get devenv
The command ciaoc -S makes a standalone executable (with the engine) for the current platform. --po-embed says how it embeds the bytecode:
When the modules included in an executable that is not linked (in any other mode, or with --po-embed tail) have foreign libraries, they are copied into lib/ next to the executable (--foreign-libdir), with the shared libraries that they need (transitively, except those of the operating system), relocated, and loaded from there; so the directory of such an executable can be copied to another machine of the same platform (see nativelink__foreign).
Example:
ciaoc -S -o dist/YOURMAINEXEC src/YOURMAINEXEC cp src/SOMEASSET dist/
This creates a platform specific binary dist/YOURMAINEXEC (with --po-embed tail, also dist/lib/ with the shared libraries of its dependencies).
Only our own libraries are copied or linked in (built by Ciao: the foreign dependencies built in third-party/, and the foreign code of bundles). A library of the system (e.g., from Homebrew, or of a Linux distribution) is referred to where it is, and ciaoc lists the ones the executable needs: it must exist where the executable runs. To carry it, build the dependency here (ciao configure --builder:foreign_origin=only_own), or, with --po-embed tail, copy it with ciaoc --system-libs copy.
ciaoc --lib archive (a .a) and ciaoc --lib shared (a .so or .dylib) make a library instead of an executable, with the bytecode of the program inside, its foreign code linked in (from the .a of its modules and of the libraries they need), and with -S the engine too; without -S the host links the engine (libciaoengine), and in the default mode the library modules are loaded from the Ciao that built the library (unless CIAOROOT is set). Next to it, libNAME.h declares ciao_ctx NAME_open(int argc, char **argv), which initializes Ciao, loads the program and runs the initialization of its modules, and void NAME_close(ciao_ctx ctx); the host then calls the program with the API of ciao_prolog.h (e.g., ciao_commit_call()). With -S that API is inlined in libNAME.h, since it is the API of the engine inside the library; otherwise libNAME.h includes the ciao_prolog.h of the Ciao whose engine the host links. libNAME.pc gives the flags to compile and link the host, relative to its own directory (${pcfiledir}): with pkg-config, or with ciao-config --pc, which needs no pkg-config (it is not part of the macOS command line tools). The same flags are written in a comment at the start of libNAME.h, and printed by ciaoc.
Example:
ciaoc -S --lib archive -o out/libmyprog.a src/myprog cc $(ciao-config --pc out/libmyprog.pc --cflags) host.c -o host $(ciao-config --pc out/libmyprog.pc --libs)
The directory of a library made with -S (only libNAME.a or the shared library, libNAME.h and libNAME.pc) can be distributed as it is: a host is compiled with -I<dir> and linked with -L<dir> -lNAME (and, for an archive, the libraries of the system given in libNAME.h), with no Ciao installed. Without -S the host needs the engine of an installed Ciao (and, in the default mode, its libraries).
A shared library exports only NAME_open, NAME_close and the ciao_* API. A library made with -S contains its own engine: use one of them per process; several programs in one process share one engine with -s libraries (if they do not share modules) or the default mode.
The bundle_path/3 predicate (at bundle/bundle_paths) can be used to obtain the absolute path name of a bundle or a relative path in a bundle.
Example:
:- use_module(library(system), [file_exists/1]).
:- use_module(library(pathnames), [path_concat/3]).
:- use_module(library(bundle/bundle_paths), [bundle_path/3]).
% Find file X in the same directory as the executable
% or in the sources.
find_asset(Name, Path) :-
( current_executable(ExecPath),
path_split(ExecPath, Dir, _)
; bundle_path(<SomeBundle>, 'images', Dir)
),
path_concat(Dir, Name, Path0),
file_exists(Path0),
!,
Path = Path0. The example predicate find_assert/2 above will look for arbitrary files in either the images/ directory or the directory of the current executable.
find_asset('spaceship.png', Sprite) Q: Moving a Ciao tree, a workspace, or a bundle.
A: A built Ciao tree or workspace can be moved or copied anywhere: it keeps working with no rebuild. If it was registered (see ciao install), register it again from its new location (ciao register), so that the startup files point to it. A bundle moved to another workspace has to be found, configured, and built again there (its registry, configuration, and compiled files stay in the build/ of the old workspace); go to the new workspace and type:
ciao rescan-bundles ciao configure [<configuration-options>] ciao build
Q: Compilation of some module complains about missing dependencies (to seemingly auto-generated code and third-party libraries).
A: Make sure that the bundle and its dependencies are properly configured and build (e.g., calling ciao build for each of them or with ciao build -r). Some bundles (e.g., interfaces to external solvers) require pre-build steps to download and compile third-party code. This part of the compilation is not currently handled by the Ciao compiler.
Q: Alias paths configured at .ciaorc are not visible in executables.
A: The .ciaorc file is read only by the Ciao toplevel (not arbitrary Ciao executables). Configure alias paths through manifest files instead.