Skip to content

Commit e5587d6

Browse files
authored
Merge pull request #67 from Srekel/asset_compiler_dep_file
AssetCompiler now writes a dep file
2 parents f738197 + e744d01 commit e5587d6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.vscode/launch.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
"--output",
8080
"${workspaceFolder}/tools/asset_compiler/src",
8181
// "${workspaceFolder}/zig-out/bin/content/prefabs/environment/terrain",
82+
"--dep",
83+
"${workspaceFolder}/tools/asset_compiler/src/test.dep",
8284
],
8385
"stopAtEntry": false,
8486
"cwd": "${workspaceFolder}/tools/binaries/asset_compiler/",

tools/asset_compiler/src/main.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const TextureFormat = enum {
1212
const TextureInfoV1 = struct {
1313
destination_path: []const u8,
1414
source_path: []const u8,
15+
dep_path: []const u8,
1516
format: TextureFormat,
1617
width: ?u32,
1718
height: ?u32,
@@ -24,11 +25,13 @@ pub fn main() !void {
2425
const parsed_args = args.parseForCurrentProcess(struct {
2526
input: []const u8 = "",
2627
output: []const u8 = "",
28+
dep: []const u8 = "",
2729
@"generate-metadata": bool = false,
2830

2931
pub const shorthands = .{
3032
.i = "input",
3133
.o = "output",
34+
.d = "dep",
3235
};
3336
}, std.heap.page_allocator, .print) catch unreachable;
3437
defer parsed_args.deinit();
@@ -51,6 +54,7 @@ pub fn main() !void {
5154

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

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

235+
// Write the .dep file
236+
{
237+
var file = try std.fs.cwd().createFile(desc.dep_path, .{});
238+
defer file.close();
239+
240+
// Add the source image as input
241+
try file.writeAll("INPUT: ");
242+
try file.writeAll(source_absolute_path);
243+
}
244+
231245
const term = try cmd.wait();
232246
std.debug.assert(term == .Exited);
233247
}

0 commit comments

Comments
 (0)