version: '3' dotenv: ['.env'] vars: PROGRAM: vmrcli SHELL: pwsh CC: gcc SRC_DIR: src INC_DIR: include OBJ_DIR: obj BIN_DIR: bin CPPFLAGS: -I{{.INC_DIR}} -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: - | {{.SHELL}} -Command " if (!(Test-Path -Path '{{.BIN_DIR}}')) { New-Item -ItemType Directory -Path '{{.BIN_DIR}}' } {{.CC}} {{.LDFLAGS}} {{.OBJ_DIR}}/*.o {{.LDLIBS}} -o {{.BIN_DIR}}/{{.PROGRAM}}.exe" sources: - '{{.OBJ_DIR}}/**' generates: - '{{.BIN_DIR}}/{{.PROGRAM}}.exe' compile: desc: Compile all files in src/ and include/ for Windows cmds: - | {{.SHELL}} -Command " if (!(Test-Path -Path '{{.OBJ_DIR}}')) { New-Item -ItemType Directory -Path '{{.OBJ_DIR}}' } Get-ChildItem -Path '{{.SRC_DIR}}' -Filter '*.c' | ForEach-Object { \$_.Name -replace '\.c$', '' } | ForEach-Object { {{.CC}} {{.CPPFLAGS}} {{.CFLAGS}} -c {{.SRC_DIR}}/\$_.c -o {{.OBJ_DIR}}/\$_.o }" sources: - '{{.SRC_DIR}}/**' - '{{.INC_DIR}}/**' generates: - '{{.OBJ_DIR}}/**' clean: desc: Remove all files in obj/ and bin/ cmds: - | {{.SHELL}} -Command " if (Test-Path -Path '{{.OBJ_DIR}}') { Remove-Item -Path '{{.OBJ_DIR}}' -Recurse -Force } if (Test-Path -Path '{{.BIN_DIR}}') { Remove-Item -Path '{{.BIN_DIR}}' -Recurse -Force }" bump: desc: 'Bump the version. Usage: "task bump -- show" or "task bump -- [patch|minor|major]".' preconditions: - sh: 'pwsh -c "if (Get-Command bump) { exit 0 } else { exit 1 }"' msg: "The 'bump' command is not available. Please install the required tools to use this command." cmds: - | {{if eq .CLI_ARGS "show"}} pwsh -c "bump show -f src/vmrcli.c -p \"#define VERSION .(\d+\.\d+\.\d+).\"" {{else}} pwsh -c "bump {{.CLI_ARGS}} -w -f src/vmrcli.c -p \"#define VERSION .(\d+\.\d+\.\d+).\"" {{end}}