XTC implements the XT component model and provides support for creating compositions of XT components. The xtc tool is used to register components in an XTC repository. For example the command:
> xtc -r /usr/share/StrategoXT/XTC register -t sglr -l /bin -V 3.8
registers version 3.8 of sglr which is installed in /bin in the XTC repository located in /usr/share/StrategoXT. The generic Makefile.xt provided by AutoXT automatically registers all installed tools with the package repository.
XTC repositories can be used to find the installation location of a tool without needing to know all the installation paths. For example, the following query can be used to find out where sglr is installed:
> xtc -r /usr/share/StrategoXT/XTC query -t sglr sglr (3.8) : /bin/sglr
An existing repository can be inherited by importing it
> xtc -r /home/user/share/tiger/XTC import /usr/share/StrategoXT/XTC
In addition to the command-line tool for registration and querying of repositories, XTC also provides a Stratego API for approaching XTC repositories. All that is required to use this API is importing the xtc-lib module. To use XTC add the following to your Makefile.am:
------------------------------------------------ bin_PROGRAMS = term-to-dot SCFLAGS = --main $* STRINCLUDES = -I $(XTC)/share/xtc ------------------------------------------------
The XTC API supports easy calling of external Stratego components and mixing them with internally defined transformations. Here is an example:
------------------------------------------------ module term-to-dot imports xtc-lib lib term-to-adot strategies term-to-dot = xtc-io-wrap(term-to-adot-options, xtc-io-transform(to-adot) ; xtc-transform(!"ast2abox", !["-p", <xtc-find> "Dot-pretty.pp"]) ; xtc-transform(!"abox2text") ) ------------------------------------------------
Note that no code is needed to load the repository. Whenever a query is done (e.g., by xtc-transform to find "ast2abox"), and no repository is loaded the XTC repository is loaded.
AutoXT provides support for XTC by means of a package switch --with-repository that can be used to indicate the repository in which to register tools. The default is $prefix/share/$PACKAGE/XTC, i.e., the XTC file in the package data directory. In the StrategoXT distribution the sub-packages inherit the repository location from the super-package, i.e., all StrategoXT tools are registered in $prefix/share/StrategoXT/XTC.
Makefile.xt implements an automake install hook to install all programs, scripts, and data. Thus it is not necessary to include make rules for this purpose. The Makefile example above is sufficient to register tools and data.
-- EelcoVisser - 13 Dec 2002