{"id":13745987,"url":"https://github.com/joakim-brannstrom/dextool","last_synced_at":"2025-05-09T06:31:20.883Z","repository":{"id":37412799,"uuid":"43734144","full_name":"joakim-brannstrom/dextool","owner":"joakim-brannstrom","description":"Suite of C/C++ tooling built on LLVM/Clang","archived":false,"fork":false,"pushed_at":"2024-11-04T07:15:38.000Z","size":15439,"stargazers_count":101,"open_issues_count":15,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-19T17:18:23.574Z","etag":null,"topics":["clang","cpp","d","googletest","mccabe","mock","mutation-testing","staticcodeanalysis","test","test-double","testdouble"],"latest_commit_sha":null,"homepage":"http://joakim-brannstrom.github.io/dextool/","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joakim-brannstrom.png","metadata":{"files":{"readme":"README.md","changelog":"news.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-06T06:41:19.000Z","updated_at":"2024-11-01T21:04:32.000Z","dependencies_parsed_at":"2023-10-16T09:13:27.650Z","dependency_job_id":"4a64402c-11e0-42a4-bc60-7774acd641d7","html_url":"https://github.com/joakim-brannstrom/dextool","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakim-brannstrom%2Fdextool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakim-brannstrom%2Fdextool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakim-brannstrom%2Fdextool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakim-brannstrom%2Fdextool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joakim-brannstrom","download_url":"https://codeload.github.com/joakim-brannstrom/dextool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253206067,"owners_count":21871158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","cpp","d","googletest","mccabe","mock","mutation-testing","staticcodeanalysis","test","test-double","testdouble"],"created_at":"2024-08-03T06:00:42.233Z","updated_at":"2025-05-09T06:31:15.846Z","avatar_url":"https://github.com/joakim-brannstrom.png","language":"D","funding_links":[],"categories":["Mutation Testing"],"sub_categories":[],"readme":"# dextool [![Build Status](https://dev.azure.com/wikodes/wikodes/_apis/build/status/joakim-brannstrom.dextool?branchName=master)](https://dev.azure.com/wikodes/wikodes/_build/latest?definitionId=1\u0026branchName=master)\n\n**Dextool** is a framework for writing plugins using libclang. The main focus\nis tools for testing and static analysis.\n\nThe plugins in a standard installation of Dextool are:\n - Analyze. Analyze C/C++ code to generate complexity numbers such as McCabe.\n - C TestDouble. Analyze C code to generate a test double implementation.\n - C++ TestDouble. Analyze C++ code to generate a test double implementation.\n - Mutate. Mutation testing tool for C/C++.\n - UML. Analyze C/C++ code to generate PlantUML diagrams.\n\n## Plugin Status\n\n * **Analyze**: production ready.\n * **C TestDouble**: production ready. The API of the generated code and how it behaves is stable.\n * **C++ TestDouble**: production ready. The API of the generated code and how it behaves is stable.\n * [**Mutate**](plugin/mutate/README.md): production ready.\n * **UML**: beta.\n\n## Installation\n\n### Dependencies\n\nTo build and run dextool, you will need the following packages:\n\n * [llvm](http://releases.llvm.org/download.html) \u003e= 14.0\n   Tested versions are 14.0, 15.0, 16.0., 17.0, 18.0\n   Note that these are the versions that are tested or have been tested.\n   Dextool usually am able to work with never versions so if you version isn't\n   in this list then please just try it. Otherwise leave an issue on github.\n * llvm-xyz-dev \u003e= 14.0\n * libclang-xyz-dev \u003e= 14.0\n * [cmake](https://cmake.org/download) \u003e= 3.5\n * [sqlite3](https://sqlite.org/download.html) \u003e= 3.24.0\n * [D compiler](https://dlang.org/download.html). See the following files for\n   the tested versions. They are guaranteed to work.\n   * [dmd minimal version](Docker/partial/dmd_min_version)\n   * [dmd max version](Docker/partial/dmd_latest_version)\n   * [ldc minimal version](Docker/partial/ldc_min_version)\n   * [ldc max version](Docker/partial/ldc_latest_version)\n\n**NOTE** only ldc is able to build a release build of dextool. dmd is for debug\nbuild. Which mean that for a *normal* user it is ldc that you should use.\n\nMost of them can be installed using your package manager.\n\nInstallation instructions for Ubuntu is available [here](doc/install).\nDockerfile are another alternative (they MAY be outdated until the CI is fixed\nto check them so if they fail for you ping me on github):\n\n* [Ubuntu](Docker/dextool-ubuntu-focal)\n* [Fedora](Docker/dextool-fedora-34)\n\n### Build and Install\n\nThe easiest way to build and run dextool is to do it via `dub`:\n```sh\ndub run dextool -- -h\n```\n\nBut if you want to, these are the steps to build it using CMake:\n\n```sh\ngit clone https://github.com/joakim-brannstrom/dextool.git\ncd dextool\nmkdir build\ncd build\ncmake -DCMAKE_INSTALL_PREFIX=/path/to/where/to/install/dextool/binaries ..\nmake install\n```\n\nDone! Have fun.\nDon't be shy to report any issue that you find.\n\n### Common Build Errors\n\n#### ldc is killed\n\nTo build dextool comfortably you need ~16Gbyte of RAM. Compiling\n`dextool-mutate.o` consume ~9Gbyte.\n\nYou probably ran out of memory when compiling `dextool-mutate.o`. Run cmake\nwith `-DLOW_MEM=ON` and single threaded.\n\n#### `dub` run dextool fail\n\nThis method of running dextool assume that the `llvm-config` commands found in\n`$PATH` is named and behave as the ones on Ubuntu. Such that `llvm-config-12`\nreturns the flags for llvm-12 and clang-12. There are also some assumptions of\nwhat the libraries that are installed are named. On Fedora for example the\nclang-libraries are `clang-cpp` and `clang`. So if this method of running\ndextool fail and you are on ubuntu then you need to install the necessary\ndependencies otherwise use the other installation method together with the more\ncomplex flags for specifying the llvm/clang versions.\n\n#### component_tests Fail\n\nThe most common reason for why `component_tests` fail is that clang++ try to\nuse the latest GCC that is installed, but the c++ standard library is not\ninstalled for that compiler.\n\nTry to compile the following code with clang++:\n```c++\n#include \u003cstring\u003e\n\nint main(int argc, char **argv) {\n    return 0;\n}\n```\n\n```sh\nclang++ -v test.cpp\n```\n\nIf it fails with something like this:\n```sh\ntest.cpp:1:10: fatal error: 'string' file not found\n```\n\nit means that you need to install the c++ standard library for your compiler.\n\nIn the output look for this line:\n```sh\n /usr/bin/../lib/gcc/x86_64-linux-gnu/XYZ/../../../../include/c++\n```\n\nFrom that line we can deduce that the package to install in Ubuntu is:\n```sh\nsudo apt install libstdc++-XYZ-dev\n```\n\n#### Mismatch Clang and LLVM\n\nTo build dextool, the dev packages are required. Dextool is optimistic and\nassume that the latest and greatest version of llvm+libclang should be used.\nBut this also requires that the dev packages are installed.\n\nIf you get this error:\n```sh\nlibclang_interop.hpp:13:10: fatal error: clang/Analysis/CFG.h: No such file or directory\n #include \u003cclang/Analysis/CFG.h\u003e\n```\n\nIt means that you need to install `llvm-x.y-dev` and `libclang-x.y-dev` for the\nversion that Dextool detected.\n\n### Bypass llvm-config\n\n`cmake/introspect_llvm_.d` try to derive the version of llvm/clang from\n`llvm-config`. If this fail or you want to force a specific version of\nllvm/clang you do it with these flags:\n\nThe following variables are defined:\n* LIBCLANG_LDFLAGS          - flags to use when linking with libclang\n* LIBLLVM_VERSION           - libLLVM full version (e.g. 8_0_1)\n* LIBLLVM_MAJOR_VERSION     - libLLVM major version (e.g. 8)\n* LIBLLVM_LDFLAGS           - flags to use when linking with libllvm\n* LIBLLVM_CXX_FLAGS         - the required flags to build C++ code using LLVM\n* LIBLLVM_CXX_EXTRA_FLAGS   - extra flags to use when build C++ code using LLVM\n* LIBLLVM_FLAGS             - the required flags by llvm-d such as version\n* LIBLLVM_LIBS              - the required libraries for linking LLVM\n* LIBCLANG_INC              - the libclang-c headers such as Index.h\n\nLets say you have version `8.0.1` of LLVM installed but llvm-config returns\n`0.0.0`. `introspect_llvm.d` will in this case fail to detect the version of\nLLVM thus what version of the bindings is unknown, which will default to the\nlatest known by `introspect_llvm.d`. This is probably not the version you have.\nTo tell cmake what version it is you can do the following:\n\n```sh\n# llvm-config --version\ncmake -DLIBLLVM_VERSION=\"LLVM_8_0_1\" \\\n-DLIBLLVM_MAJOR_VERSION=\"8\"\n```\n\nIf you also need to provide the includes and libs you would need to add the\nrest of the flags, otherwise they are derived from whatever `llvm-config` that\nis in `$PATH`.\n\n```sh\n# uses llvm-config --libdir to find where libclang.so is installed. Some\n# additional flags are added but these are optional.\n-DLIBLCANG_LDFLAGS=\"-Wl,--enable-new-dtags -Wl,--no-as-needed -L/foo/bar/libs -Wl,-rpath,/foo/bar/libs -l:libclang.so.8\"\n# llvm-config --libdir is searched for these libraries.\n-DLIBCLANG_LIBS=\"-lclangFrontendTool -lclangRewriteFrontend -lclangDynamicASTMatchers -lclangFrontend -lclangASTMatchers -lclangParse -lclangSerialization -lclangRewrite -lclangSema -lclangEdit -lclangAnalysis -lclangAST -lclangLex -lclangBasic -l:libclang.so\"\n# llvm-config --cxxflags\n-DLIBLLVM_CXX_FLAGS=\"-I/foo/bar/llvm-include -std=c++11 -fno-exceptions -fno-rtti\"\n# llvm-config --ldflags\n-DLIBLLVM_LDFLAGS=\"-L/foo/smurf/libs -Wl,-rpath,/foo/smurf/libs\"\n# use llvm-config --libs and llvm-config --system-libs to find all libraries to link with.\n# all those that are prefixed with libLLVM.\n-DLIBLLVM_LIBS=\"-lLLVMXRay -lLLVMTextApi /*and maaaany more or just one depending on how you have installed LLVM*/\"\n# where the libclang-c headers are located\n-DLIBCLANG_INC=\"\"\n```\n\n#### SQLite link or missing\n\nThe sqlite3 library source code with a CMake build file in the vendor's\ndirectory. It is intended for those old OSs that have too old versions of\nSQLite.\n\nTo use it do something like this.\n```sh\nmkdir sqlite3\ncd sqlite3 \u0026\u0026 cmake ../vendor/sqlite \u0026\u0026 make \u0026\u0026 cd ..\n# setup dextool build to use it\nmkdir build\ncd build \u0026\u0026 cmake .. -DSQLITE3_LIB=\"-L/opt/sqlite -lsqlite3\"\n```\n\n#### Cmake is unable to find the D compiler\n\nIf you have a D compiler installed in such a way that it isn't available in\nyour `$PATH` you can specify it manually.\n\n```sh\ncmake .. -DD_COMPILER=/foo/bar/dmd/2.088/linux64/bin/dmd\n```\n\n#### My version of LLVM is not offically supported / do not work\n\nFirst of all just test and see if dextool do build with your version of llvm.\nThe tool `introspect_llvm.d` reuse the latest bindings if a new version is\ndetected but no bindings exists. The C API rarely change so it normally just\nworks.\n\nIf it doesn't then follow these steps:\n\n * Follow the instructions in `libs/libclang/README.md` to generate the new bindings.\n * Open the file `cmake/introspect_llvm.d`.\n * Update the array of search paths in the function `llvmSearchPaths` with the new location.\n\n## Usage\n\nSee the usage examples in respective plugin directory.\n\n# Credit\n\nJacob Carlborg for his excellent DStep. It was used as a huge inspiration for\nthis code base. Without DStep, Dextool wouldn't exist.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakim-brannstrom%2Fdextool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoakim-brannstrom%2Fdextool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakim-brannstrom%2Fdextool/lists"}