diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,4 +252,7 @@ install(TARGETS clazy-standalone DESTINATION bin PERMISSIONS OWNER_WRITE OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE) endif() +file(READ checks.json SUPPORTED_CHECKS_JSON_STR) +configure_file(checks.json.h.in checks.json.h) + install(FILES org.kde.clazy.metainfo.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo) diff --git a/checks.json.h.in b/checks.json.h.in new file mode 100644 --- /dev/null +++ b/checks.json.h.in @@ -0,0 +1,28 @@ +/* + This file is part of the clazy static checker. + + Copyright (C) 2019 Nikolai Kosjar + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef CHECKS_JSON_H +#define CHECKS_JSON_H + +const char SUPPORTED_CHECKS_JSON_STR[] = R"meta(${SUPPORTED_CHECKS_JSON_STR})meta"; + +#endif // CHECKS_JSON_H + diff --git a/src/ClazyStandaloneMain.cpp b/src/ClazyStandaloneMain.cpp --- a/src/ClazyStandaloneMain.cpp +++ b/src/ClazyStandaloneMain.cpp @@ -24,12 +24,15 @@ #include "Clazy.h" #include "ClazyContext.h" +#include "checks.json.h" + #include #include #include #include #include +#include #include namespace clang { @@ -72,6 +75,9 @@ directories for which diagnostics should never be emitted. Useful for ignoring 3rdparty code.)"), cl::init(""), cl::cat(s_clazyCategory)); +static cl::opt s_supportedChecks("supported-checks-json", cl::desc("Dump meta information about supported checks in JSON format."), + cl::init(false), cl::cat(s_clazyCategory)); + static cl::extrahelp s_commonHelp(CommonOptionsParser::HelpMessage); class ClazyToolActionFactory @@ -116,7 +122,13 @@ int main(int argc, const char **argv) { - CommonOptionsParser optionsParser(argc, argv, s_clazyCategory); + CommonOptionsParser optionsParser(argc, argv, s_clazyCategory, cl::ZeroOrMore); + + if (s_supportedChecks.getValue()) { + std::cout << SUPPORTED_CHECKS_JSON_STR; + return 0; + } + ClangTool tool(optionsParser.getCompilations(), optionsParser.getSourcePathList()); return tool.run(new ClazyToolActionFactory(optionsParser.getSourcePathList()));