nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 88 lines 2.0 kB view raw
1{ 2 llvmPackages, 3 lib, 4 fetchFromGitHub, 5 cmake, 6 python3, 7 curl, 8 libxml2, 9 libffi, 10 xar, 11 versionCheckHook, 12 rev ? "unknown", 13 debug ? false, 14 checks ? true, 15}: 16let 17 inherit (lib.strings) optionalString; 18in 19llvmPackages.stdenv.mkDerivation (finalAttrs: { 20 21 pname = "c3c${optionalString debug "-debug"}"; 22 version = "0.7.3"; 23 24 src = fetchFromGitHub { 25 owner = "c3lang"; 26 repo = "c3c"; 27 tag = "v${finalAttrs.version}"; 28 hash = "sha256-MOnYWlGcxLX+agChuk0BPq8BWsVvNP2QYqaGk24lb5Q="; 29 }; 30 31 cmakeBuildType = if debug then "Debug" else "Release"; 32 33 postPatch = '' 34 substituteInPlace git_hash.cmake \ 35 --replace-fail "\''${GIT_HASH}" "${rev}" 36 substituteInPlace CMakeLists.txt \ 37 --replace-fail "-Werror" "" 38 ''; 39 40 nativeBuildInputs = [ cmake ]; 41 cmakeFlags = [ 42 "-DC3_ENABLE_CLANGD_LSP=${if debug then "ON" else "OFF"}" 43 "-DC3_LLD_DIR=${llvmPackages.lld.lib}/lib" 44 "-DLLVM_CRT_LIBRARY_DIR=${llvmPackages.compiler-rt}/lib/darwin" 45 ]; 46 47 buildInputs = [ 48 llvmPackages.llvm 49 llvmPackages.lld 50 llvmPackages.compiler-rt 51 curl 52 libxml2 53 libffi 54 ] 55 ++ lib.optionals llvmPackages.stdenv.hostPlatform.isDarwin [ xar ]; 56 57 nativeCheckInputs = [ python3 ]; 58 59 doCheck = 60 lib.elem llvmPackages.stdenv.system [ 61 "x86_64-linux" 62 "x86_64-darwin" 63 "aarch64-darwin" 64 ] 65 && checks; 66 67 checkPhase = '' 68 runHook preCheck 69 ( cd ../resources/testproject; ../../build/c3c build --trust=full ) 70 ( cd ../test; ../build/c3c compile-run -O1 src/test_suite_runner.c3 -- ../build/c3c test_suite ) 71 runHook postCheck 72 ''; 73 74 nativeInstallCheckInputs = [ versionCheckHook ]; 75 doInstallCheck = true; 76 77 meta = with lib; { 78 description = "Compiler for the C3 language"; 79 homepage = "https://github.com/c3lang/c3c"; 80 license = licenses.lgpl3Only; 81 maintainers = with maintainers; [ 82 hucancode 83 anas 84 ]; 85 platforms = platforms.all; 86 mainProgram = "c3c"; 87 }; 88})