| Did you know ... | Search Documentation: |
| tools.pl -- Utilities for building foreign resources |
This module implements the build system that is used by pack_install/1 and pack_rebuild/1. The build system is a plugin based system where each plugin knows about a specific build toolchain. The plugins recognise whether they are applicable based on the existence of files that are unique to the toolchain. Currently it supports
automake and autoconf
for configuration and building
build_steps(+Steps:list, SrcDir:atom, +Options) is detdistclean or clean. [test] may be
omited if --no-test is effective.
[[dependencies], [configure], build, [test], install]
Each step finds an applicable toolchain based on known unique files and calls the matching plugin to perform the step. A step may fail, which causes the system to try an alternative. A step that wants to abort the build process must throw an exception.
If a step fails, a warning message is printed. The message can be
suppressed by enclosing the step in square brackets. Thus, in the
above example of Steps, only failure by the build and install
steps result in warning messages; failure of the other steps is
silent.
The failure of a step can be made into an error by enclosing it
in curly brackets, e.g. [[dependencies], [configure], {build}, [test], {install}]
would throw an exception if either the build or install step failed.
Options are:
@tbd If no tool is willing to execute some step, the step is
skipped. This is ok for some steps such as dependencies or test.
Possibly we should force the install step to succeed?
post_step(+Step, +State) is det[private]
ensure_build_dir(+Dir, +State0, -State) is detbuild to create a build subdir.
build_environment(-Env, +Options) is det[private]
Assemble a clean build environment for creating extensions to
SWI-Prolog. Env is a list of Var=Value pairs. The variable names
depend on the pack_version(Version) term from pack.pl. When
absent or 1, the old names are used. These names are confusing and
conflict with some build environments. Using 2 (or later), the new
names are used. The list below first names the new name and than
between parenthesis, the old name. Provided variables are:
PATHswipl is always present and
runs the same SWI-Prolog instance as the current Prolog process.SWIPLSWIPL_PACK_VERSIONSWIPL_VERSION (SWIPLVERSION)SWIPL_HOME_DIR (SWIHOME)SWIPL_ARCH (SWIARCH)SWIPL_MODULE_DIR (PACKSODIR)lib/$SWIARCH.SWIPL_MODULE_LIB (SWISOLIB)SWIPL_LIB (SWILIB)-lswipl).SWIPL_INCLUDE_DIRSSWI-Prolog.h, SWI-Stream.h and SWI-cpp.h.SWIPL_LIBRARIES_DIRlibswiplSWIPL_CC (CC)SWIPL_CXX (CXX)SWIPL_LD (LD)SWIPL_CFLAGS (CFLAGS)-ISWIPL-INCLUDE-DIR.SWIPL_MODULE_LDFLAGS (LDSOFLAGS)SWIPL_MODULE_EXT (SOEXT)so or dll)SWIPL_PREFIX (PREFIX)
prolog:build_environment('USER', User) :-
getenv('USER', User).
def_environment(-Name, -Value, +Options) is nondet[private]
prolog_library_dir(-Dir) is det[private]libswipl.$SOEXT
default_c_compiler(-CC) is semidet[private]
save_build_environment(+State:dict) is det[private]buildenv.sh that contains the build
environment. This may be sourced in the build directory to run the
build steps outside Prolog. It may also be useful for debugging
purposes.
prolog_install_prefix(-Prefix) is semidetconfigure or cmake
to install executables and other related resources in a similar
location as SWI-Prolog itself. Tries these rules:
pack_prefix at a writable directory, use
this.~/bin directory, use ~.
run_process(+Executable, +Argv, +Options) is detinformational.output(Out), but messages are printed at level error.
If Executable is path(Program) and we have an environment we make
sure to use the PATH from this environment for searching
Program.
has_program(+Spec) is semidet[private]
has_program(+Spec, -Path) is semidet[private]
has_program(+Spec, -Path, +Env:list) is semidet[private]has_program(path(cmake), CMakeExe).
The second allows passing in an environment as Name=Value pairs. If
this contains a value for PATH, this is used rather than the
current path variable.
setup_path(+Programs) is det[private]$PATH such that we can find the tools. Currently deals with
MinGW on Windows to provide make and gcc.
mingw_extend_path is semidet[private]%PATH% and if not, try to extend the
search path.
process_output(+Codes)//[private]The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
has_program(+Spec) is semidet
has_program(+Spec, -Path) is semidet
has_program(+Spec, -Path, +Env:list) is semidethas_program(path(cmake), CMakeExe).
The second allows passing in an environment as Name=Value pairs. If
this contains a value for PATH, this is used rather than the
current path variable.