diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e10828 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.cache +compile_commands.json diff --git a/Makefile b/Makefile index e8e07c9..dd5e09b 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/flake.lock b/flake.lock index 40d4d4a..ffe3698 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } } diff --git a/flake.nix b/flake.nix index 479c7f8..acd1e65 100644 --- a/flake.nix +++ b/flake.nix @@ -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; };