build: nits
This commit is contained in:
parent
5ab711e7e9
commit
b9286a4d7b
3 changed files with 7 additions and 5 deletions
8
Makefile
8
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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue