test: libhectic

This commit is contained in:
2025-03-20 18:15:52 +00:00
parent a7e754f48d
commit 18b36e43b7
9 changed files with 252 additions and 101 deletions

View File

@@ -0,0 +1,34 @@
{ stdenv, gcc, lib }:
stdenv.mkDerivation {
pname = "libhectic";
version = "1.0";
src = ./.;
doCheck = true;
buildPhase = ''
mkdir -p target
${gcc}/bin/cc -Wall -Wextra -g -pedantic -fsanitize=address -c libhectic.c -o target/libhectic.o
${gcc}/bin/ar rcs target/libhectic.a target/libhectic.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 -l:libhectic.a -o "$exe"
"$exe"
done
'';
installPhase = ''
mkdir -p $out/lib $out/include
cp target/libhectic.a $out/lib/
cp libhectic.h $out/include/
'';
meta = {
description = "libhectic";
license = lib.licenses.mit;
};
}