-
Notifications
You must be signed in to change notification settings - Fork 9
adding assets support #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hm. It would be nice if an example like maybe |
I built it locally, referenced my project, added the assets folder, and then loaded a png in raylib by path. |
I started trying to add it to minimal, and it didn't work. seems the regular filesystem commands don't work on zig. |
aapt2link.addArg("-A"); // additional directory in which to find raw asset files | ||
const val = dir.src_path.sub_path; | ||
|
||
aapt2link.addArg(val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this to be:
aapt2link.addArg(val);
aapt2link.addFileInput(dir);
This will ensure if the file added is changed that the Zig compiler is aware of the change and we will re-run the aapt2link step.
From the Zig build system itself:
/// Adds an additional input files that, when modified, indicates that this Run
/// step should be re-executed.
/// If the Run step is determined to have side-effects, the Run step is always
/// executed when it appears in the build graph, regardless of whether this
/// file has been modified.
pub fn addFileInput(self: *Run, file_input: std.Build.LazyPath) void {
file_input.addStepDependencies(&self.step);
self.file_inputs.append(self.step.owner.allocator, file_input.dupe(self.step.owner)) catch @panic("OOM");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like addFileInput
is expecting only a file. There are compile issues with this method. I did not immediately see a directory implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I mean the ideal thing would be adding each asset directly by walking the directory recursively.
It's something I've also had in the backlog for "addResourceDirectory".
Ideally just something that walks the tree and and at least does aapt2link.addFileInput(file)
would be good.
i forgot to mention that the logcat is logging a panic with "file not found" |
I've spent quite a few hours on this now. I even took a look at the raylib code for loading the image, since loading files works on raylib. I couldn't immediately see if anything special was done, so possibly the posix way of opening a file is different. My best guess at this point is that zig std library on android the std.fs.cwd() method is not correct. I tried using walk through the This was meant to be an easy PR. I'm sorry its not working on the default android minimal project. I can add the method you suggested to resources and assets which will help the build step link at some later point. For right now we can leave this open. |
Adding assets support. Let me know if I need to jump through any other hoops :)