Add compile_commands.json support

This commit is contained in:
Julia Lange 2024-07-14 03:51:13 -07:00
parent cc107f975c
commit 5e86f3ccb9
Signed by: Julia
SSH key fingerprint: SHA256:5DJcfxa5/fKCYn57dcabJa2vN2e6eT0pBerYi5SUbto
4 changed files with 36 additions and 7 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.cache
compile_commands.json

View file

@ -7,7 +7,7 @@ TARGET = connect4
CFILES = main.c connect4.c
OFILES = ${CFILES:.c=.o}
all: ${OFILES}
connect4: ${OFILES}
$(CC) $(CFLAGS) -o ${TARGET} ${OFILES}
clean:

17
flake.lock generated
View file

@ -1,5 +1,21 @@
{
"nodes": {
"mini-compile-commands": {
"flake": false,
"locked": {
"lastModified": 1689962671,
"narHash": "sha256-qPyV3iU8rXhIlHEELAtu2UwXtdZgsWMK9dHySlVa8Jo=",
"owner": "danielbarter",
"repo": "mini_compile_commands",
"rev": "073ad72d27287f3e8073c3ef0c9069223fb2048c",
"type": "github"
},
"original": {
"owner": "danielbarter",
"repo": "mini_compile_commands",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1720768451,
@ -17,6 +33,7 @@
},
"root": {
"inputs": {
"mini-compile-commands": "mini-compile-commands",
"nixpkgs": "nixpkgs"
}
}

View file

@ -3,9 +3,13 @@
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
mini-compile-commands = {
url = "github:danielbarter/mini_compile_commands";
flake = false;
};
};
outputs = { self, nixpkgs }:
outputs = { self, nixpkgs, mini-compile-commands }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
@ -14,13 +18,19 @@
gnumake
gcc
gdb
# clang_16
# clang-tools_16
# lld_16
# llvmPackages_16.libllvm
clang_16
clang-tools_16
lld_16
llvmPackages_16.libllvm
cmake
gtest
];
in {
devShells.${system}.default = pkgs.mkShell {
devShells.${system}.default =
with import nixpkgs { system = "${system}"; };
let mcc-env = (callPackage mini-compile-commands {}).wrap stdenv;
in (pkgs.mkShell.override {stdenv = mcc-env;}) {
buildInputs = libs;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath libs;
};