Skip to content

AssetCompiler now writes a dep file #67

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

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
"--output",
"${workspaceFolder}/tools/asset_compiler/src",
// "${workspaceFolder}/zig-out/bin/content/prefabs/environment/terrain",
"--dep",
"${workspaceFolder}/tools/asset_compiler/src/test.dep",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/tools/binaries/asset_compiler/",
Expand Down
14 changes: 14 additions & 0 deletions tools/asset_compiler/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const TextureFormat = enum {
const TextureInfoV1 = struct {
destination_path: []const u8,
source_path: []const u8,
dep_path: []const u8,
format: TextureFormat,
width: ?u32,
height: ?u32,
Expand All @@ -24,11 +25,13 @@ pub fn main() !void {
const parsed_args = args.parseForCurrentProcess(struct {
input: []const u8 = "",
output: []const u8 = "",
dep: []const u8 = "",
@"generate-metadata": bool = false,

pub const shorthands = .{
.i = "input",
.o = "output",
.d = "dep",
};
}, std.heap.page_allocator, .print) catch unreachable;
defer parsed_args.deinit();
Expand All @@ -51,6 +54,7 @@ pub fn main() !void {

var texture_info = std.mem.zeroes(TextureInfoV1);
texture_info.destination_path = try arena.dupe(u8, parsed_args.options.output);
texture_info.dep_path = try arena.dupe(u8, parsed_args.options.dep);

var buffer: [1024]u8 = undefined;
while (try in_stream.readUntilDelimiterOrEof(&buffer, '\n')) |line| {
Expand Down Expand Up @@ -228,6 +232,16 @@ fn executeTextureConversionV1(desc: *TextureInfoV1, arena: std.mem.Allocator) !v
var cmd = std.process.Child.init(@ptrCast(argv.items), std.heap.page_allocator);
try cmd.spawn();

// Write the .dep file
{
var file = try std.fs.cwd().createFile(desc.dep_path, .{});
defer file.close();

// Add the source image as input
try file.writeAll("INPUT: ");
try file.writeAll(source_absolute_path);
}

const term = try cmd.wait();
std.debug.assert(term == .Exited);
}
Expand Down