Interface Toolchain


public interface Toolchain
A toolchain provides access to a set of tools which are used to translate an input file into a source format that can be executed. Its purpose is to support build systems that are executed by users, for example to compile and install additional libraries.

Example:

LanguageInfo llvmInfo = env.getInternalLanguages().get("llvm");
Toolchain toolchain = env.lookup(llvmInfo, Toolchain.class);
String id = toolchain.getIdentifier();
TruffleFile cc = toolchain.getToolPath("CC");
TruffleFile cl = toolchain.getToolPath("CL");
TruffleFile cxx = toolchain.getToolPath("CXX");
TruffleFile ld = toolchain.getToolPath("LD");

String[] args = {"make", "CC=" + cc, "CL=" + cl, "CXX=" + cxx,
                "LD=" + ld, "OUTPUT_DIR=" + id};
Process p = env.newProcessBuilder(args).start();
p.waitFor();
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an identifier for the toolchain.
    List<com.oracle.truffle.api.TruffleFile>
    getPaths(String pathName)
    Returns a list of directories for a given path name.
    com.oracle.truffle.api.TruffleFile
    Gets the path to the executable for a given tool.
  • Method Details

    • getToolPath

      com.oracle.truffle.api.TruffleFile getToolPath(String tool)
      Gets the path to the executable for a given tool. Every implementation is free to choose its own set of supported tools. The command line interface of the executable is specific to the tool. If a tool is not supported or not known, null must be returned. Known tools are:
      CC
      A C compiler with a clang-like command line interface.
      CL
      A C/C++ compiler with a cl-like command line interface.
      CXX
      A C++ compiler with a clang++-like command line interface.
      LD
      A linker that can deal with object files and bitcode files.
      AR
      Archiver
      NM
      Symbol table lister
      OBJCOPY
      Object copying and editing tool
      OBJDUMP
      Object file dumper
      RANLIB
      Archive index generator
      READELF
      GNU-style object reader
      READOBJ
      Object reader
      STRIP
      Object stripping tool
      Note that not all toolchains support all tools.
    • getPaths

      List<com.oracle.truffle.api.TruffleFile> getPaths(String pathName)
      Returns a list of directories for a given path name. Every implementation is free to choose its own set of supported path names. If a path name is not supported or not known, null must be returned. Note that the directories returned by this method do not need to exist.

      Known path names are:

      PATH
      Directories where the toolchain executables are located.
      LD_LIBRARY_PATH
      (Additional) directories to look up shared libraries.
    • getIdentifier

      String getIdentifier()
      Returns an identifier for the toolchain. It can be used to distinguish results produced by different toolchains. Since the identifier may be used as a path suffix to place results in distinct locations, it should not contain special characters like slashes / or \.