cli/config.nims
2023-10-15 18:22:33 +02:00

68 lines
No EOL
1.9 KiB
Nim

#### config.nims ####
# Set some common options
switch("d", "release")
switch("d", "ssl")
switch("hints", "off")
# Helper procs to abstract away OS-specific commands
proc createDirectory(dir: string) =
when defined(windows):
exec "cmd /c mkdir " & dir
else:
exec "mkdir -p " & dir
proc removeFileOrDir(path: string) =
when defined(windows):
if path.endsWith("/"):
exec "cmd /c rmdir /s /q " & path
else:
exec "cmd /c del /f /q " & path
else:
exec "rm -rf " & path
# Build task for intermediate builds
task build, "Compile the project for intermediate builds":
createDirectory("build") ## Ensure the build directory exists
exec "nim c -o:build/dashinit src/main.nim" ## Compile the main project file into the build directory
# # Distribution task for final builds
# task dist, "Compile the project for distribution":
# createDirectory("dist") ## Ensure the directory exists
# exec "nim c -o:dist/dashinit src/main.nim" ## Compile the main project file into the dist directory
# Dev task (Compiles and runs main.nim)
task dev, "Run tests":
switch("undef", "release") ## Unset the release switch for this task
createDirectory("build/dev") ## Ensure dev directory exists
exec "nim c -o:build/dev/dashinit -r src/main.nim"
# Clean task to remove generated files
task clean, "Clean up generated files":
removeFileOrDir("build/*")
# removeFileOrDir("dist/*")
# removeFileOrDir("dev/*")
task deepclean, "Clean up by removing build/ and dist/ directories":
removeFileOrDir("build/")
# removeFileOrDir("dist/")
# removeFileOrDir("dev/")
#### Aliases ####
# Build shorthand
task b, "Alias for build task":
exec "nim build"
# Dist shorthand
task d, "Alias for dist task":
exec "nim dist"
# Clean shorthand
task cl, "Alias for clean task":
exec "nim clean"
# Deepclean shorthand
task dcl, "Alias for deep clean task":
exec "nim deepclean"