2.2. Running srctools

The srctools programs operate on srcML data that has been previously produced by the src2srcml translator. This means that you /must/ run the srcML translator and you /must/ run it with a special set of options. When run, you must supply the following options:


--xmlns:lit=http://www.sdml.info/srcML/literal
--xmlns:op=http://www.sdml.info/srcML/operator
--xmlns:mod=http://www.sdml.info/srcML/modifier'''

This is somewhat verbose. Unfortunately, src2srcml does not (to my knowledge) provide a means of automatically specifying options via the environment. My solutions is to use your shell to define an alias that runs `src2srcml` with these options. For example, this is in my `~/.bashrc` file:


SRCML_LIT="--xmlns:lit=http://www.sdml.info/srcML/literal"
SRCML_OP="--xmlns:op=http://www.sdml.info/srcML/operator"
SRCML_MOD="--xmlns:mod=http://www.sdml.info/srcML/modifier"
export SRCML_FLAGS="$SRCML_LIT $SRCML_OP $SRCML_MOD"
alias srcml="src2srcml $SRCML_FLAGS"

This adds an alias srcml that will execute the src2srcml program with those options. This program is best used when it is run on a single file at a time. Running on multiple files is best programmed using the find or xargs command. Unfortunately, find won't use the shell alias to run the program, so the program and arguments must be given explcilitly. For example, I typically use run src2srcml using:


$ find . -name '*.?pp' -exec src2srcml $SRCM_FLAGS {} {}.xml \;

This recursively finds every file of the form `.cpp` or `.hpp` and executes the srcml translator on it, generating a new file with the `.cpp.xml` or `.hpp.xml` extension. Now, I can run my `srctools` programs over the `.xml` files in the Boost libraries.

See the "man" page for each tool to see how it is run and what inputs it requires.