4.6 Test for the Existence of Share Package Binaries

If an external binary is essential for the workings of a share package, the test function called from DeclarePackage should test whether the program has been compiled on the architecture (and inhibit package loading if this is not the case). This is especially important if the package is loaded automatically.

The easiest way to accomplish this is to use Filename (see Filename in the Reference Manual) for checking for the actual binaries in the path given by DirectoryPackagePrograms for the respective package. For example the ``example'' share package uses the following commands to test whether the binary hello has been compiled, it issues a warning if not and will only load if it is indeed available.

DeclarePackage("example","1.0",
  function()
  local path,file;
    # test for existence of the compiled binary
    path:=DirectoriesPackagePrograms("example");
    file:=Filename(path,"hello");
    if file=fail then
      Info(InfoWarning,1,
        "Package ``example'': The program `hello' is not compiled");
    fi;
    return file<>fail;
  end);

You might also have to cope with the situation that external binaries will only run under UNIX (and not, say on a Macintosh). See section Testing for the System Architecture in the reference manual for information on how to test for the architecture.

[Top] [Previous] [Up] [Next] [Index]

GAP 4 manual
February 2000