Hello. I can't figure out how to make a task in nimble depend on build. Right now I'm using this:
# Package
version = "0.1.0"
author = "WizardUli"
description = "A new awesome nimble package"
license = "BSD-3-Clause"
srcDir = "src"
bin = @["blinky_nim"]
# Dependencies
requires "nim >= 1.6.8"
requires "https://github.com/Abathargh/avr_io#a605fe05d4a71e677989ec3b27d36a83b53eadf7"
# Tasks
task flash, "flash":
exec "avrdude -c usbasp -p m328p -U flash:w:$1" % [bin[0]]
before flash:
exec "nimble build"
Is there a better way? Thanks.You can use the build identifier instead of your custom flash (Nimble test):
before build:
echo "before build"
after build:
echo "after build"
exec "avrdude -c usbasp -p m328p -U flash:w:$1" % [bin[0]]
Eh no need for all that complexity. I thought the same way when I first got into Nim since Nimble looks like a build system. Most of us doing embedded stuff end up doing something like you did.
Note that calling "nimble build" or more directly "nim c" will only rebuild files when they change.
Really Nimble just manages the package/library paths. The Nim compiler makes use of the module system to build up the actual dependency tree. Tasks just become proc's named "flashTask()". The before and after provide a way to chain function calls.
You could do this if I recall the syntax right to call the build task:
before flash:
buildTask()
Also, you can make Nim modules depend on external "objects" by combining staticRead and staticExec. Then the Nim module will be rebuilt if the file read by staticRead changes.
Note that calling "nimble build" or more directly "nim c" will only rebuild files when they change.
Nice to know. And thanks for pointing out staticExec!
Eh no need for all that complexity.
You are right. And if a need arise I can always use Nix which I'm already using to prepare my project specific devenvs with Nim and gcc-<xxx>-none-<yyy> toolchains and other tools.
Nice to know. And thanks for pointing out staticExec!
Glad to help!
You are right. And if a need arise I can always use Nix which I'm already using to prepare my project specific devenvs with Nim and gcc-<xxx>-none-<yyy> toolchains and other tools.
Nice! I've tried Nix but just can't seem to quite "get it". It seems quite powerful though.