Hi, if someone is looking for a mock generator based on libclang, which could be used in huge projects and be easily integrated with the build system, I have recently written one:
its written in python (tested with 2.7 and 3.2) using libclang and python bindings (tested with 3.2)
features:
* its reliable, since its using clang compiler
* its fast (tested on project ~200 kloc -> generation of mocs took 3-5 seconds on common laptop)
* output file might be easily adopted to the project via configuration file
* easy integration with the project build system -> generate mocks files for each interface, limited to the project (for example via project namespace), from given files
* generate pretty output (one mock per file)
* handle c++ operators:
virtual int operator()(int, double);
...
virtual int operator()(int arg0, double arg1) { return function_call_or_cast_operator(arg0, arg1);
MOCK_METHOD2(function_call_or_cast_operator, int(int, double));
* easy to extend (~200 lines of code)
usage:
./gmock.py <config_file> <dir_for_generated_mocks> <limit_to_interfaces_within_decl> files...
integration with build system:
find project -iname "*.h" -or -iname "*.hpp" | xargs gmock.py "project/conf/gmock.conf" "project/generated/mocks" "Project"
example output:
project/generated/mocks/I1Mock.hpp
project/generated/mocks/I2Mock.hpp
...
hopefully, it will be useful for you as well,
Chris