This file contains instructions on how to build and run the srcfacts program.
This project does not support an in-source build. The instructions are based on a build subdirectory. You can also use a sibling directory of the source.
The commands are given in terms of make
. If you setup cmake with ninja
as your build tool (highly recommended), then just replace make
with ninja
in those commands.
Create a build directory and move into it:
mkdir build
cd build
Once in your build directory run cmake with a path to the (parent) source directory:
cmake ..
Running cmake with the path to the source directory is only needed the first time. From then on, you can directly run cmake in the build directory:
cmake .
You can then perform the build:
make
An example input file is provided. To run with make:
make run
To run on the command line:
./srcfacts < data/demo.xml
You can also time it:
time ./srcfacts < data/demo.xml
Tracing shows each parsing event on a separate output line. Trace is off by default. To turn tracing on:
cmake .. -DTRACE=ON
To turn tracing back off:
cmake .. -DTRACE=OFF
The included demo file is quite small. In order to check scalability, a much larger example can be used. This larger example is the srcML file for linux-6.0 and consists of 55,174 linux source-code files. The zip archive download is not that big (over 280 MB), but the unzipped file is extremely large at over 4 GB.
To download the linux kernel example, use the following cmake option:
cmake . -DDOWNLOAD_BIGDATA=ON
This option does not directly download the file, but provides instructions and a warning about the resulting file size. To confirm the download, use the following cmake option:
cmake . -DDOWNLOAD_BIGDATA_CONFIRM=ON
The resulting file, linux-6.0.xml, is placed in the data subdirectory of your build.
To run this linux kernel example with your program, use the following make command:
make run_bigdata
To run on the command line:
./srcfacts < data/linux-6.0.xml
You can also time it:
time ./srcfacts < data/linux-6.0.xml
By default, the build also builds the application xmlstats.
To build only the xmlstats application:
make xmlstats
To run xmlstats with the demo file using make:
make run_xmlstats
To run xml stats with the demo file on the command line:
./xmlstats < data/demo.xml
By default, the build also builds the application identity.
To build only the identity application:
make identity
To run identity with the demo file using make:
make run_identity
The target runidentity does not output to standard output, but is redirected to the file democopy.xml. It is equivalent to next command.
To run xml stats with the demo file on the command line:
./identity < data/demo.xml > democopy.xml
If you want to compare the output to the input for identity, you can use the following command:
make run_identity_check
This is equivalent to:
make run_identity
diff data/demo.xml democopy.xml
This runs a diff between the input file and the output file. Note that the output can be very large.