diff options
| author | Syndamia <kamen@syndamia.com> | 2026-03-29 09:15:37 +0300 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2026-03-29 09:15:37 +0300 |
| commit | c7f5780d3b67da9c57d658994bcff298e6a1cac9 (patch) | |
| tree | 8d7d5bcc76d1df2cf02f34524fb678cf8489c1dc /make.sh | |
| parent | e3412d642f75fdd0e558f4403cf21dcae4d38766 (diff) | |
| download | ppm_graphics-c7f5780d3b67da9c57d658994bcff298e6a1cac9.tar ppm_graphics-c7f5780d3b67da9c57d658994bcff298e6a1cac9.tar.gz ppm_graphics-c7f5780d3b67da9c57d658994bcff298e6a1cac9.zip | |
chore: Rework file layout and add make script
Diffstat (limited to 'make.sh')
| -rwxr-xr-x | make.sh | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -0,0 +1,52 @@ +#!/bin/sh + +: ${CC:=gcc} +: ${CARGS:=-std=c99 -lm -O3} +: ${FPS:=30} +: ${PLAYER:=mpv} +: ${PLAYERARGS:=--no-correct-pts --container-fps-override=\$FPS -} +: ${RENDER:=ffmpeg} +: ${RENDERARGS:=-r \$FPS -i - \$bin.mp4} + +binname() { + name="${1%%.c}" + echo "${name##*/}" +} + +make_compile() { + bin="$(binname "$1")" + $(eval "echo \"$CC\"") $(eval "echo \"$CARGS\"") AnimationRender/*.c FrameRender/*.c RGBImage/*.c "$1" -o "$bin" +} + +make_run() { + bin="$(binname "$1")" + "./$bin" | $(eval "echo \"$PLAYER\"") $(eval "echo \"$PLAYERARGS\"") +} + +make_render() { + bin="$(binname "$1")" + "./$bin" | $(eval "echo \"$RENDER\"") $(eval "echo \"$RENDERARGS\"") +} + +if [ ! -f "$2" ] +then + echo "'$2' is not valid! Must be the path to a C file which contains main function." + exit 2 +fi + +case "$1" in + (compile) + make_compile "$2" + ;; + (run) + make_compile "$2" + make_run "$2" + ;; + (render) + make_compile "$2" + make_render "$2" + ;; + (*) + echo "Unrecognised action '$1'!" + exit 1 +esac |
