{"id":18546546,"url":"https://github.com/saveourtool/kompiledb","last_synced_at":"2025-07-01T15:10:11.001Z","repository":{"id":173640198,"uuid":"651012030","full_name":"saveourtool/kompiledb","owner":"saveourtool","description":"Kotlin bindings to JSON Compilation Database Format","archived":false,"fork":false,"pushed_at":"2024-08-26T11:41:07.000Z","size":962,"stargazers_count":8,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-26T13:58:41.015Z","etag":null,"topics":["clang","compilation-database"],"latest_commit_sha":null,"homepage":"https://saveourtool.github.io/kompiledb/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saveourtool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2023-06-08T09:46:33.000Z","updated_at":"2024-08-26T11:40:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"2509e842-3c39-4268-860a-a5edb52201e9","html_url":"https://github.com/saveourtool/kompiledb","commit_stats":null,"previous_names":["0x6675636b796f75676974687562/kompdb"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saveourtool%2Fkompiledb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saveourtool%2Fkompiledb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saveourtool%2Fkompiledb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saveourtool%2Fkompiledb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saveourtool","download_url":"https://codeload.github.com/saveourtool/kompiledb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107220,"owners_count":21048882,"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","compilation-database"],"created_at":"2024-11-06T20:25:52.989Z","updated_at":"2025-04-09T20:31:03.009Z","avatar_url":"https://github.com/saveourtool.png","language":"Kotlin","readme":"# kompiledb\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![GitHub release](https://img.shields.io/github/release/saveourtool/kompiledb.svg)](https://github.com/saveourtool/kompiledb/releases/)\n[![Maven Central](https://img.shields.io/maven-central/v/com.saveourtool.kompiledb/kompiledb-core.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.saveourtool.kompiledb%22)\n[![javadoc](https://javadoc.io/badge2/com.saveourtool.kompiledb/kompiledb-core/javadoc.svg)](https://javadoc.io/doc/com.saveourtool.kompiledb/kompiledb-core)\n[![Build](https://github.com/saveourtool/kompiledb/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/saveourtool/kompiledb/actions/workflows/build.yml?query=branch%3Amaster)\n[![Dependencies](https://github.com/saveourtool/kompiledb/actions/workflows/dependencies.yml/badge.svg?branch=master)](https://github.com/saveourtool/kompiledb/actions/workflows/dependencies.yml?query=branch%3Amaster)\n\n_Kotlin_ bindings to [_JSON Compilation Database_](http://clang.llvm.org/docs/JSONCompilationDatabase.html) Format.\n\nThis library is inspired by tools such as [nickdiego/compiledb](https://github.com/nickdiego/compiledb) and [rizsotto/Bear](https://github.com/rizsotto/Bear).\n\nSee the [project website](https://saveourtool.github.io/kompiledb/) for documentation and APIs.\n\n## Features\n\n - Compatible with Java 8.\n - Can read and write `compile_commands.json`.\n - No dependencies (except for [google/gson](https://github.com/google/gson)).\n   The core library is JSON engine agnostic, so it's easy to add support for a\n   different JSON back-end, such as [FasterXML/jackson](https://github.com/FasterXML/jackson)\n   or [Kotlin/kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization).\n - Support for pluggable path translation between the local and the build\n   environments (such as [_Cygwin_](https://www.cygwin.com) or\n   [_WSL_](https://github.com/Microsoft/WSL)).\n   Built-in path mapper for [_MSys_](https://www.msys2.org).\n - Command-line parser for _GCC_ and compatibles, such as _Clang_:\n   + [response file](https://gcc.gnu.org/wiki/Response_Files) expansion;\n   + support for 'single'- and \"double\"-quoted arguments (also within response files);\n   + include paths (`-I`, `-include`, `-isystem` and so on) recognized;\n   + defined (`-D`) and undefined (`-U`) preprocessor macros recognized;\n   + language (C, C++) and standard (`c++17`, `gnu++14`) recognized;\n   + `-nostdinc`, `-nostdinc++` and similar switches recognized.\n\n## Releases\n\nThe latest release is available from both _GitHub Packages_ and _Maven Central_.\nFor _GitHub Packages_, the repository can be added as follows.\n\nFor `build.gradle.kts`:\n\n```kotlin\nrepositories {\n    maven {\n        name = \"saveourtool/kompiledb\"\n        url = uri(\"https://maven.pkg.github.com/saveourtool/kompiledb\")\n        content {\n            includeGroup(\"com.saveourtool.kompiledb\")\n        }\n        credentials {\n            username = project.findProperty(\"gpr.user\") as String? ?: System.getenv(\"GITHUB_ACTOR\")\n            password = project.findProperty(\"gpr.key\") as String? ?: System.getenv(\"GITHUB_TOKEN\")\n        }\n    }\n}\n```\n\nFor `settings.gradle.kts`:\n\n```kotlin\ndependencyResolutionManagement {\n    repositories {\n        maven {\n            name = \"saveourtool/kompiledb\"\n            url = uri(\"https://maven.pkg.github.com/saveourtool/kompiledb\")\n            content {\n                includeGroup(\"com.saveourtool.kompiledb\")\n            }\n            credentials {\n                username = providers.gradleProperty(\"gpr.user\").orNull\n                    ?: System.getenv(\"GITHUB_ACTOR\")\n                password = providers.gradleProperty(\"gpr.key\").orNull\n                    ?: System.getenv(\"GITHUB_TOKEN\")\n            }\n        }\n    }\n}\n```\n\nThen add the dependency as usual:\n\n```kotlin\ndependencies {\n    implementation(\"com.saveourtool.kompiledb:kompiledb-gson:1.0.0\")\n}\n```\n\n## Other JSON formats\n\nIf your build system produces a JSON different from the compilation database\nformat, you can preprocess it with the [`jq`](https://github.com/jqlang/jq)\nutility.\n\nExample input:\n\n```json\n{\n    \"compiler_info\": [\n        {\n            \"compiler_name\": \"/usr/bin/gcc\",\n            \"environment\": [\n                \"PWD=/proc/self/cwd\",\n                \"LANG=C.UTF-8\",\n                \"JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8\",\n                \"SHELL=/bin/bash\",\n                \"SHLVL=9\",\n                \"HISTSIZE=10000\",\n                \"LD_PRELOAD=\",\n                \"GCC_COLORS=error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01\"\n            ],\n            \"uuid\": \"8a3117fde10aa7cdc517ffa313174af5\",\n            \"version\": \"4.2.1\",\n            \"machine\": \"x86_64-pc-linux-gnu\",\n            \"bits\": \"-m64\",\n            \"system_include\": [\n                \"/usr/include\"\n            ],\n            \"pre_define_macros\": [\n                \"-DDEBUG=1\",\n                \"-D__GNUC_MINOR__=2\",\n                \"-D__GNUC_PATCHLEVEL__=1\",\n                \"-D__GNUC_STDC_INLINE__=1\",\n                \"-D__GNUC__=4\"\n            ]\n        },\n        {\n            \"compiler_name\": \"/usr/bin/clang\",\n            \"environment\": [\n                \"PWD=/proc/self/cwd\",\n                \"LANG=C.UTF-8\",\n                \"JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8\",\n                \"SHELL=/bin/bash\",\n                \"SHLVL=9\",\n                \"HISTSIZE=10000\",\n                \"LD_PRELOAD=\",\n                \"GCC_COLORS=error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01\"\n            ],\n            \"uuid\": \"cfc0dbb9c58d9ee084ee0bec7cf69c25\",\n            \"version\": \"4.2.1\",\n            \"machine\": \"x86_64-redhat-linux-gnu\",\n            \"bits\": \"-m32\",\n            \"system_include\": [\n                \"/usr/include\"\n            ],\n            \"pre_define_macros\": [\n                \"-DDEBUG=1\",\n                \"-D__GNUC_MINOR__=2\",\n                \"-D__GNUC_PATCHLEVEL__=1\",\n                \"-D__GNUC_STDC_INLINE__=1\",\n                \"-D__GNUC__=4\"\n            ]\n        }\n    ],\n    \"compilation_unit\": [\n        {\n            \"arguments\": [\n                \"gcc\",\n                \"-c\",\n                \"file1.c\"\n            ],\n            \"compiler\": \"/usr/bin/gcc\",\n            \"directory\": \"/path/to/project\",\n            \"file\": [\n                \"/path/to/project/file1.c\"\n            ],\n            \"id\": \"23ba91c4f1ae11edb2e4fa163e78cf7a\",\n            \"language\": \"C_LANG\",\n            \"object\": [\n                \"/path/to/project/file1.o\"\n            ],\n            \"timestamp\": 1683996285773040,\n            \"original_command_id\": \"21f3529cf1ae11edb2e4fa163e78cf7a\",\n            \"uuid\": \"cfc0dbb9c58d9ee084ee0bec7cf69c25\",\n            \"head_include\": [],\n            \"preprocess_file\": [\n                \"/path/to/project/file1.i\"\n            ]\n        },\n        {\n            \"arguments\": [\n                \"clang\",\n                \"-c\",\n                \"file2.c\"\n            ],\n            \"compiler\": \"/usr/bin/clang\",\n            \"directory\": \"/path/to/project\",\n            \"file\": [\n                \"/path/to/project/file2.c\"\n            ],\n            \"id\": \"23bc7a02f1ae11edb2e4fa163e78cf7a\",\n            \"language\": \"C_LANG\",\n            \"object\": [],\n            \"timestamp\": 1683996379854618,\n            \"original_command_id\": \"21f3529ef1ae11edb2e4fa163e78cf7a\",\n            \"uuid\": \"d15a90fcd7c5a199fbccab08440fd12e\",\n            \"head_include\": [],\n            \"preprocess_file\": [\n                \"/path/to/project/file2.i\"\n            ]\n        }\n    ]\n}\n```\n\nRunning the file through the following filter:\n\n```bash\njq '.compilation_unit | map(.file = .file[0] | .output = .object[0] | del(.compiler, .id, .language, .timestamp, .original_command_id, .uuid, .head_include, .preprocess_file, .preprocess_status, .object)) | del(..|nulls)' \u003cexample.json \u003ecompile_commands.json\n```\n\n\u0026mdash; will result in the `compile_commands.json` of the following content:\n\n```json\n[\n  {\n    \"arguments\": [\n      \"gcc\",\n      \"-c\",\n      \"file1.c\"\n    ],\n    \"directory\": \"/path/to/project\",\n    \"file\": \"/path/to/project/file1.c\",\n    \"output\": \"/path/to/project/file1.o\"\n  },\n  {\n    \"arguments\": [\n      \"clang\",\n      \"-c\",\n      \"file2.c\"\n    ],\n    \"directory\": \"/path/to/project\",\n    \"file\": \"/path/to/project/file2.c\"\n  }\n]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaveourtool%2Fkompiledb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaveourtool%2Fkompiledb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaveourtool%2Fkompiledb/lists"}