Files
util.nix/package/c/chectic/default.nix

38 lines
834 B
Nix

{ stdenv, gcc, lib }:
stdenv.mkDerivation {
pname = "chectic";
version = "1.0";
src = ./.;
doCheck = true;
buildPhase = ''
mkdir -p target
${gcc}/bin/cc -Wall -Wextra -g \
-std=c99 \
-pedantic -fsanitize=address \
-c chectic.c -o target/chectic.o
${gcc}/bin/ar rcs target/libchectic.a target/chectic.o
'';
checkPhase = ''
mkdir -p target/test
for test_file in test/*.c; do
exe="target/test/$(basename ''${test_file%.c})"
${gcc}/bin/cc -Wall -Wextra -g -pedantic -fsanitize=address -I. "$test_file" -Ltarget -lchectic -o "$exe"
"$exe"
done
'';
installPhase = ''
mkdir -p $out/lib $out/include
cp target/libchectic.a $out/lib/
cp chectic.h $out/include/
'';
meta = {
description = "libhectic";
license = lib.licenses.mit;
};
}