#@import all files in a folder

1 messages · Page 1 of 1 (latest)

thin jacinth
#

I want to iterate over all .zig files in a folder and add them to some struct.
Right now I have a file that looks like this:

windowlist.zig:
pub const change_name = @import("change_name.zig");
pub const chat = @import("chat.zig");
pub const controls = @import("controls.zig");
...

However every time I add a new file I forget to add it to the list and waste time debugging :​/

It seems that @import isn't allowing anything but a string literal, I cannot even make it work with a global constant:
@import operand must be a string literal

Is there any way to solve this so I don't have to remember every time to manually add my file to the list?

tame bluff
#

not in any sane way

#

the technically possible solution would be generate a zig file at build time that imports all of those files, and then import that file

heavy sleet
#

^ This is the solution I would reach for if I wanted to do that, yeah.

#

Or possibly even just write my own little build script that does that, if that works better.