Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
# build products
build/

# Nix
result
result-*/

# direnv
.direnv/

# CMake
CMakeFiles
CMakeCache.txt
Expand Down
32 changes: 32 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Repository Guidelines

## Project Structure & Module Organization
libansilove is a C library that converts ANSI and related art files to PNG. Core headers live in `include/`, while the implementation sits in `src/` with `loaders/` containing format-specific decoders and `fonts/` bundling built-in typefaces. Cross-platform fallbacks are under `compat/`. The `example/` directory shows how to invoke the API end-to-end, and `man/` provides installed manual pages. Dedicated fuzzing harnesses reside in `fuzz/`; build them only when running sanitizer-heavy tests.

## Build, Test, and Development Commands
- `cmake -S . -B build -DCMAKE_BUILD_TYPE=Release`: configure the project after installing GD headers and libs.
- `cmake --build build`: compile shared and static variants of the library.
- `cmake --build build --target install`: install artifacts into the default prefix.
- `cmake -S fuzz -B fuzz-build`: set up clang-based libFuzzer targets.
- `cmake --build fuzz-build`: produce fuzz binaries such as `ansi` and `tundra`.
- `nix develop`: enter the flake-backed dev shell with clang, pkg-config, GD, and platform-appropriate debugger preinstalled.
- `nix build`: build the default flake package (shared/static library) without touching your host toolchain.
- `nix flake check`: validate the flake packages and dev shell evaluate cleanly across supported systems.

## Coding Style & Naming Conventions
- Target C99 with the default warning set (`-Wall -Wextra -pedantic`).
- Indent with tabs for blocks; align wrapped parameters using spaces as needed, and avoid trailing whitespace.
- Public APIs stay in `include/ansilove.h` and use the `ansilove_*` prefix; internal helpers remain lowercase with underscores and `static` linkage.
- Mirror existing filenames (`loadfile.c`, `savefile.c`) when adding new modules or loaders.

## Testing Guidelines
- There is no unit-test harness; validate behavior with the example app and fuzzers.
- After building, run `build/example/ansilove_example <input.ans>` to confirm PNG output.
- For fuzzing, execute `./fuzz-build/ansi -runs=10000 corpus/` (seed the corpus with representative art files). Investigate sanitizer reports immediately and add reproducer samples.
- Ensure new formats or options ship with updated example inputs or fuzz seeds that exercise the paths.
- If you touch the flake, rerun `nix build` and `nix flake check` and commit the updated `flake.lock` (keep changes reproducible).

## Commit & Pull Request Guidelines
- Commit messages follow sentence case with concise statements ending in a period (for example, `Update ChangeLog.`).
- Keep functional changes and formatting adjustments in separate commits and ensure files build before pushing.
- Pull requests should summarize the change, call out impacted loaders, and link tracking issues. Note which build or fuzz commands were run, and attach PNG outputs or screenshots when visual diffs help reviewers.
1 change: 1 addition & 0 deletions CLAUDE.md
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
description = "Development environment for libansilove";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
version = "1.4.2";
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version is hardcoded in the flake. Consider extracting this from CMakeLists.txt or another authoritative source to avoid version drift between the build system and the Nix package.

Suggested change
version = "1.4.2";
# Extract version from CMakeLists.txt
version = let
cmakeContents = builtins.readFile ./CMakeLists.txt;
matches = builtins.match ''set *\( *PROJECT_VERSION +([0-9]+\.[0-9]+\.[0-9]+) *\)'' cmakeContents;
in if matches != null && matches != [] then builtins.elemAt matches 0 else throw "Could not extract version from CMakeLists.txt";

Copilot uses AI. Check for mistakes.
in {
packages.default = pkgs.stdenv.mkDerivation {
pname = "libansilove";
inherit version;
src = ./.;
nativeBuildInputs = [
pkgs.cmake
pkgs.pkg-config
];
buildInputs = [
pkgs.gd
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
];
meta = with pkgs.lib; {
description = "Library to convert ANSI and artscene formats to PNG";
homepage = "https://www.ansilove.org";
license = licenses.bsd2;
maintainers = [];
platforms = platforms.unix;
};
};

devShells.default = pkgs.mkShell {
packages =
[
pkgs.cmake
pkgs.ninja
pkgs.pkg-config
pkgs.gd
pkgs.clang
pkgs.clang-tools
]
++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
pkgs.gdb
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.lldb
];
shellHook = ''
export CC=${pkgs.clang}/bin/clang
export CXX=${pkgs.clang}/bin/clang++
echo "libansilove dev shell loaded."
'';
};
}
);
}