vmrcli/Taskfile.yml

72 lines
1.7 KiB
YAML
Raw Normal View History

2025-02-03 06:08:33 +00:00
version: '3'
2025-02-07 23:02:10 +00:00
dotenv: ['.env']
2025-02-03 06:08:33 +00:00
vars:
2025-02-03 16:38:33 +00:00
PROGRAM: vmrcli
2025-02-07 11:39:07 +00:00
SHELL: pwsh
2025-02-03 06:08:33 +00:00
CC: gcc
SRC_DIR: src
2025-02-03 16:54:17 +00:00
INC_DIR: include
2025-02-03 06:08:33 +00:00
OBJ_DIR: obj
BIN_DIR: bin
2025-02-03 16:54:17 +00:00
CPPFLAGS: -I{{.INC_DIR}} -MMD -MP {{if eq .LOG_USE_COLOR "yes"}}-DLOG_USE_COLOR{{end}}
2025-02-03 06:08:33 +00:00
CFLAGS: -O -Wall -W -pedantic -ansi -std=c2x
LDFLAGS: -Llib
LDLIBS: -lm
tasks:
default:
2025-02-07 23:02:10 +00:00
desc: Build vmrcli for Windows
2025-02-03 06:08:33 +00:00
deps: [build]
build:
2025-02-07 23:02:10 +00:00
desc: Build vmrcli for Windows
2025-02-03 06:08:33 +00:00
deps: [link]
link:
2025-02-07 23:02:10 +00:00
desc: Link all files in obj/ for Windows
2025-02-03 06:08:33 +00:00
deps: [compile]
cmds:
2025-02-07 11:39:07 +00:00
- |
{{.SHELL}} -Command "
if (!(Test-Path -Path '{{.BIN_DIR}}')) {
2025-02-03 16:38:33 +00:00
New-Item -ItemType Directory -Path '{{.BIN_DIR}}'
2025-02-07 11:39:07 +00:00
}
{{.CC}} {{.LDFLAGS}} {{.OBJ_DIR}}/*.o {{.LDLIBS}} -o {{.BIN_DIR}}/{{.PROGRAM}}.exe"
2025-02-03 06:08:33 +00:00
sources:
2025-02-03 06:45:30 +00:00
- '{{.OBJ_DIR}}/**'
2025-02-03 06:08:33 +00:00
generates:
2025-02-03 16:38:33 +00:00
- '{{.BIN_DIR}}/{{.PROGRAM}}.exe'
2025-02-03 06:08:33 +00:00
compile:
2025-02-07 23:02:10 +00:00
desc: Compile all files in src/ and include/ for Windows
2025-02-03 06:08:33 +00:00
cmds:
2025-02-07 11:39:07 +00:00
- |
{{.SHELL}} -Command "
if (!(Test-Path -Path '{{.OBJ_DIR}}')) {
2025-02-03 16:38:33 +00:00
New-Item -ItemType Directory -Path '{{.OBJ_DIR}}'
2025-02-07 11:39:07 +00:00
}
Get-ChildItem -Path '{{.SRC_DIR}}' -Filter '*.c' |
2025-02-03 16:38:33 +00:00
ForEach-Object { \$_.Name -replace '\.c$', '' } |
2025-02-03 16:54:17 +00:00
ForEach-Object { {{.CC}} {{.CPPFLAGS}} {{.CFLAGS}} -c {{.SRC_DIR}}/\$_.c -o {{.OBJ_DIR}}/\$_.o }"
2025-02-03 06:08:33 +00:00
sources:
2025-02-03 06:45:30 +00:00
- '{{.SRC_DIR}}/**'
2025-02-03 16:54:17 +00:00
- '{{.INC_DIR}}/**'
2025-02-03 06:08:33 +00:00
generates:
2025-02-03 15:24:42 +00:00
- '{{.OBJ_DIR}}/**'
2025-02-03 06:08:33 +00:00
clean:
2025-02-07 23:02:10 +00:00
desc: Remove all files in obj/ and bin/
2025-02-03 06:08:33 +00:00
cmds:
2025-02-07 11:39:07 +00:00
- |
{{.SHELL}} -Command "
if (Test-Path -Path '{{.OBJ_DIR}}') { Remove-Item -Path '{{.OBJ_DIR}}' -Recurse -Force }
2025-02-07 23:02:10 +00:00
if (Test-Path -Path '{{.BIN_DIR}}') { Remove-Item -Path '{{.BIN_DIR}}' -Recurse -Force }"