Skip to content

Commit 8da85dc

Browse files
committed
json: move json-schema-to-grammar to common lib
nit
1 parent 1ef7fab commit 8da85dc

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ llama.o: llama.cpp unicode.h ggml.h ggml-alloc.h ggml-backend.h ggml-cuda.h ggml
688688
$(CXX) $(CXXFLAGS) -c $< -o $@
689689

690690
COMMON_H_DEPS = common/common.h common/sampling.h common/log.h
691-
COMMON_DEPS = common.o sampling.o grammar-parser.o build-info.o
691+
COMMON_DEPS = common.o sampling.o grammar-parser.o build-info.o json-schema-to-grammar.o
692692

693693
common.o: common/common.cpp $(COMMON_H_DEPS)
694694
$(CXX) $(CXXFLAGS) -c $< -o $@
@@ -733,7 +733,7 @@ clean:
733733
# Helper function that replaces .c, .cpp, and .cu file endings with .o:
734734
GET_OBJ_FILE = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(patsubst %.cu,%.o,$(1))))
735735

736-
main: examples/main/main.cpp ggml.o llama.o $(COMMON_DEPS) console.o grammar-parser.o json-schema-to-grammar.o $(OBJS)
736+
main: examples/main/main.cpp ggml.o llama.o $(COMMON_DEPS) console.o grammar-parser.o $(OBJS)
737737
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
738738
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
739739
@echo
@@ -756,7 +756,7 @@ batched: examples/batched/batched.cpp ggml.o llama.o $(C
756756
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
757757
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
758758

759-
batched-bench: examples/batched-bench/batched-bench.cpp build-info.o ggml.o llama.o common.o $(OBJS)
759+
batched-bench: examples/batched-bench/batched-bench.cpp build-info.o ggml.o llama.o $(COMMON_DEPS) $(OBJS)
760760
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
761761
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
762762

@@ -788,7 +788,7 @@ save-load-state: examples/save-load-state/save-load-state.cpp ggml.o llama.o $(C
788788
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
789789
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
790790

791-
server: examples/server/server.cpp examples/server/utils.hpp examples/server/httplib.h common/json.hpp examples/server/index.html.hpp examples/server/index.js.hpp examples/server/completion.js.hpp json-schema-to-grammar.o common/stb_image.h ggml.o llama.o $(COMMON_DEPS) grammar-parser.o $(OBJS)
791+
server: examples/server/server.cpp examples/server/utils.hpp examples/server/httplib.h common/json.hpp examples/server/index.html.hpp examples/server/index.js.hpp examples/server/completion.js.hpp common/stb_image.h ggml.o llama.o $(COMMON_DEPS) grammar-parser.o $(OBJS)
792792
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
793793
$(CXX) $(CXXFLAGS) $(filter-out %.h %.hpp $<,$^) -Iexamples/server $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS) $(LWINSOCK2)
794794

common/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ if (BUILD_SHARED_LIBS)
4747
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
4848
endif()
4949

50-
set(TARGET json-schema-to-grammar)
51-
add_library(${TARGET} OBJECT json-schema-to-grammar.cpp json-schema-to-grammar.h)
52-
5350
set(TARGET common)
5451

5552
add_library(${TARGET} STATIC
@@ -63,6 +60,7 @@ add_library(${TARGET} STATIC
6360
grammar-parser.h
6461
grammar-parser.cpp
6562
json.hpp
63+
json-schema-to-grammar.cpp
6664
train.h
6765
train.cpp
6866
ngram-cache.h

examples/main/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(TARGET main)
22
add_executable(${TARGET} main.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
4-
target_link_libraries(${TARGET} PRIVATE common llama json-schema-to-grammar ${CMAKE_THREAD_LIBS_INIT})
4+
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
55
target_compile_features(${TARGET} PRIVATE cxx_std_11)

examples/server/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install(TARGETS ${TARGET} RUNTIME)
1111
target_compile_definitions(${TARGET} PRIVATE
1212
SERVER_VERBOSE=$<BOOL:${LLAMA_SERVER_VERBOSE}>
1313
)
14-
target_link_libraries(${TARGET} PRIVATE common json-schema-to-grammar ${CMAKE_THREAD_LIBS_INIT})
14+
target_link_libraries(${TARGET} PRIVATE common ${CMAKE_THREAD_LIBS_INIT})
1515
if (LLAMA_SERVER_SSL)
1616
find_package(OpenSSL REQUIRED)
1717
target_link_libraries(${TARGET} PRIVATE OpenSSL::SSL OpenSSL::Crypto)

tests/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function(llama_test source)
2525

2626
add_executable(${TEST_TARGET} ${source} get-model.cpp)
2727
install(TARGETS ${TEST_TARGET} RUNTIME)
28-
target_link_libraries(${TEST_TARGET} PRIVATE common json-schema-to-grammar)
28+
target_link_libraries(${TEST_TARGET} PRIVATE common)
2929
add_test(
3030
NAME ${TEST_TARGET}
3131
WORKING_DIRECTORY ${LLAMA_TEST_WORKING_DIRECTORY}

0 commit comments

Comments
 (0)