add build script for nixos support

This commit is contained in:
opfez 2021-09-26 19:54:27 +02:00
parent bb57c8e853
commit e9f32da983
3 changed files with 12 additions and 1 deletions

View File

@ -1,4 +1,3 @@
CC = clang
CFLAGS = -Wall -Wextra -std=c99 -pedantic -O2
LIBS = -lSDL2 -lm

10
build.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
source /etc/os-release
# Don't know how to just have SDL2 available on NixOS
if echo $ID | grep "nixos" 2>/dev/null >/dev/null; then
nix-shell -p SDL2 --run make
else
make
fi

2
main.c
View File

@ -372,6 +372,8 @@ main(void)
uint32_t buttons = SDL_GetMouseState(NULL, NULL);
if (buttons & SDL_BUTTON(3))
break;
else if (buttons & SDL_BUTTON(1))
screenshot(state.canvas);
clear_canvas(state.canvas, BLACK);