From 452bf6f6de1b44ded43e5d18133b76182442f017 Mon Sep 17 00:00:00 2001 From: onyx Date: Mon, 3 Feb 2025 06:08:33 +0000 Subject: [PATCH] add Taskfile + .env --- .env | 1 + .gitignore | 3 +++ Taskfile.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 .env create mode 100644 Taskfile.yml diff --git a/.env b/.env new file mode 100644 index 0000000..c112f51 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +LOG_USE_COLOR=yes \ No newline at end of file diff --git a/.gitignore b/.gitignore index f9c490a..b2d777c 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,9 @@ Module.symvers Mkfile.old dkms.conf +# Task Runner +.task/ + .vscode/ test* \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..2435e60 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,55 @@ +version: '3' + +dotenv: [ '.env' ] + +vars: + program: vmrcli + + CC: gcc + + SRC_DIR: src + OBJ_DIR: obj + BIN_DIR: bin + + CPPFLAGS: -Iinclude -MMD -MP {{if eq .LOG_USE_COLOR "yes"}}-DLOG_USE_COLOR{{end}} + + CFLAGS: -O -Wall -W -pedantic -ansi -std=c2x + LDFLAGS: -Llib + LDLIBS: -lm + +tasks: + default: + desc: "Build vmrcli for Windows" + deps: [build] + + build: + desc: "Build vmrcli for Windows" + deps: [link] + + link: + desc: "Link all files in obj/ for Windows" + deps: [compile] + cmds: + - powershell -Command "if (!(Test-Path -Path '{{.BIN_DIR}}')) { New-Item -ItemType Directory -Path '{{.BIN_DIR}}' }" + - powershell -Command "{{.CC}} {{.LDFLAGS}} obj/*.o {{.LDLIBS}} -o bin/{{.program}}.exe" + sources: + - obj/** + generates: + - bin/{{.program}}.exe + + compile: + desc: "Compile all files in src/ and include/ for Windows" + cmds: + - powershell -Command "if (!(Test-Path -Path '{{.OBJ_DIR}}')) { New-Item -ItemType Directory -Path '{{.OBJ_DIR}}' }" + - powershell -Command "Get-ChildItem -Path 'src' -Filter '*.c' | ForEach-Object { \$_.Name -replace '\.c$', '' } | ForEach-Object { {{.CC}} {{.CPPFLAGS}} {{.CFLAGS}} -c src/\$_.c -Iinclude -o obj/\$_.o }" + sources: + - src/** + - include/** + generates: + - obj/** + + clean: + desc: "Remove all files in obj/ and bin/" + cmds: + - powershell -Command "Remove-Item -Path 'obj' -Recurse -Force" + - powershell -Command "Remove-Item -Path 'bin' -Recurse -Force" \ No newline at end of file