Hi!
I'm writing a GUI-library for embedded and made a Macro to load images from files into arrays. This works fine until I want to compile it for the microcontroller (pico2 using picosdk4nim), then it complains: Error: undeclared identifier: 'walkDir'
I guess this makes sense since it is compiled with os=any in config.nims. Is this guess correct? And is there a way I can get this to work?
Thanks, Simon
I used template for folder embedding, not macros:
import std/os
template embedFolder*(folder: static string): untyped =
const fulldir = instantiationInfo(-1, true).filename.parentDir / folder
const tmp = static:
var files: seq[string]
for relpath in walkDirRec(fulldir, relative = true):
files.add(relpath.replace("\\", "/"))
files.add(staticRead(fulldir / relpath))
files
tmp
# seq[string] of pairs: file-name + file-data
const platformsData = embedFolder("../data/platforms")
usage:
# platforms.
removeDir("znak_platforms")
var i = 0
while i < platformsData.len:
let file = platformsData[i]
createDir("znak_platforms" / file.parentDir)
writeFile("znak_platforms" / file, platformsData[i + 1])
i += 2 Funny that someone else made a similar thread, leaving it here for reference: {.compile.} for submodules and pathing for os=any
I'm quite happy with the workaround actually, but even the workaround could be integrated in a Macro/Plugin, so I guess I will get back to this at some time.
@Araq: At some point I want to learn Nimony anyway, would you consider it ready for something close to production?