From 13a36efbef96d29fb116c92863b5bfea42a95183 Mon Sep 17 00:00:00 2001 From: ochafik Date: Sat, 13 Apr 2024 17:04:17 +0100 Subject: [PATCH] build: workaround lack of -n on gnu xxd --- Makefile | 2 +- build.zig | 5 +---- examples/server/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7c840d77f..74db04d07 100644 --- a/Makefile +++ b/Makefile @@ -794,7 +794,7 @@ server: examples/server/server.cpp examples/server/utils.hpp examples/server/htt $(CXX) $(CXXFLAGS) $(filter-out %.h %.hpp $<,$^) -Iexamples/server $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS) $(LWINSOCK2) examples/server/%.hpp: examples/server/public/% - xxd -n $(notdir $<) -i $< $@ + ( cd examples/server/public && xxd -i $(notdir $<) ../$(notdir $<).hpp ) gguf: examples/gguf/gguf.cpp ggml.o $(OBJS) $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<) diff --git a/build.zig b/build.zig index 7421d6b27..3e33d24bd 100644 --- a/build.zig +++ b/build.zig @@ -142,10 +142,7 @@ pub fn build(b: *std.build.Builder) !void { const server_assets = [_][]const u8{ "index.html", "index.js", "completion.js", "json-schema-to-grammar.mjs" }; for (server_assets) |asset| { - // Note: code can be simplified once setCwd is standard. - const gen_hpp = b.addSystemCommand( - &.{ "xxd", "-n", asset, "-i", b.fmt("examples/server/public/{s}", .{asset}), b.fmt("examples/server/{s}.hpp", .{asset}) }, - ); + const gen_hpp = b.addSystemCommand(&.{ "bash", "-c", b.fmt("cd examples/server/public && xxd -i {s} ../{s}.hpp", .{ asset, asset }) }); server.step.dependOn(&gen_hpp.step); } } diff --git a/examples/server/CMakeLists.txt b/examples/server/CMakeLists.txt index 5ddea9721..df71cee53 100644 --- a/examples/server/CMakeLists.txt +++ b/examples/server/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SERVER_ASSETS +set(SERVER_ASSETS index.html index.js completion.js