From b9286a4d7b929b077f1d05395e2bc9ecadf5a99a Mon Sep 17 00:00:00 2001 From: ochafik Date: Mon, 15 Apr 2024 21:17:28 +0100 Subject: [PATCH] build: nits --- Makefile | 8 ++++---- build.zig | 2 ++ examples/server/CMakeLists.txt | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5fdfbfa5f..5bf969833 100644 --- a/Makefile +++ b/Makefile @@ -795,10 +795,10 @@ server: examples/server/server.cpp examples/server/utils.hpp examples/server/htt # Portable equivalent of `cd examples/server/public && xxd -i $(notdir $<) ../$(notdir $<).hpp`: examples/server/%.hpp: examples/server/public/% Makefile @( export NAME=$(subst .,_,$(subst -,_,$(notdir $<))) && \ - echo "unsigned char $${NAME}[] = {" && \ - cat $< | od -v -t x1 -An | sed -E 's/([0-9a-fA-F]+)/0x\1, /g' && \ - echo "};" && \ - echo "unsigned int $${NAME}_len = $(shell cat $< | wc -c );" \ + echo "unsigned char $${NAME}[] = {" && \ + cat $< | od -v -t x1 -An | sed -E 's/([0-9a-fA-F]+)/0x\1, /g' && \ + echo "};" && \ + echo "unsigned int $${NAME}_len = $(shell cat $< | wc -c );" \ ) > $@ gguf: examples/gguf/gguf.cpp ggml.o $(OBJS) diff --git a/build.zig b/build.zig index ea9da4bc6..55da3762a 100644 --- a/build.zig +++ b/build.zig @@ -145,6 +145,8 @@ pub fn build(b: *std.build.Builder) !void { const input_path = b.fmt("examples/server/public/{s}", .{asset}); const output_path = b.fmt("examples/server/{s}.hpp", .{asset}); + // Portable equivalent of `b.addSystemCommand(&.{ "xxd", "-n", asset, "-i", input_path, output_path }) })`: + const input = try std.fs.cwd().readFileAlloc(b.allocator, input_path, std.math.maxInt(usize)); defer b.allocator.free(input); diff --git a/examples/server/CMakeLists.txt b/examples/server/CMakeLists.txt index 9a1576594..fcc98ab47 100644 --- a/examples/server/CMakeLists.txt +++ b/examples/server/CMakeLists.txt @@ -9,7 +9,7 @@ foreach(asset ${SERVER_ASSETS}) set(input "${CMAKE_CURRENT_SOURCE_DIR}/public/${asset}") set(output "${CMAKE_CURRENT_BINARY_DIR}/${asset}.hpp") - string(REGEX REPLACE "\\.| |-" "_" name "${asset}") + string(REGEX REPLACE "\\.|-" "_" name "${asset}") file(READ "${input}" data HEX) string(LENGTH ${data} hex_len) math(EXPR len "${hex_len} / 2")