cli/config.nims

67 lines
1.9 KiB
Text
Raw Normal View History

2023-10-05 07:34:44 +00:00
#### config.nims ####
# Set some common options
switch("d", "release")
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
2023-10-05 08:10:01 +00:00
# # 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
2023-10-05 07:34:44 +00:00
# Dev task (Compiles and runs main.nim)
task dev, "Run tests":
switch("undef", "release") ## Unset the release switch for this task
2023-10-05 08:10:01 +00:00
createDirectory("build/dev") ## Ensure dev directory exists
exec "nim c -o:build/dev/dashinit -r src/main.nim"
2023-10-05 07:34:44 +00:00
# Clean task to remove generated files
task clean, "Clean up generated files":
removeFileOrDir("build/*")
2023-10-05 08:10:01 +00:00
# removeFileOrDir("dist/*")
# removeFileOrDir("dev/*")
2023-10-05 07:34:44 +00:00
task deepclean, "Clean up by removing build/ and dist/ directories":
removeFileOrDir("build/")
2023-10-05 08:10:01 +00:00
# removeFileOrDir("dist/")
# removeFileOrDir("dev/")
2023-10-05 07:34:44 +00:00
#### 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"