Skip to content

Commit 0e41def

Browse files
committed
vendor : move to common folder /vendor
ggml-ci
1 parent 72bcf19 commit 0e41def

File tree

10 files changed

+198
-14
lines changed

10 files changed

+198
-14
lines changed

common/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@ add_library(${TARGET} STATIC
7272
llguidance.cpp
7373
log.cpp
7474
log.h
75-
minja/chat-template.hpp
76-
minja/minja.hpp
7775
ngram-cache.cpp
7876
ngram-cache.h
79-
nlohmann/json.hpp
8077
regex-partial.cpp
8178
regex-partial.h
8279
sampling.cpp
@@ -147,7 +144,7 @@ if (LLAMA_LLGUIDANCE)
147144
set(LLAMA_COMMON_EXTRA_LIBS ${LLAMA_COMMON_EXTRA_LIBS} llguidance ${LLGUIDANCE_PLATFORM_LIBS})
148145
endif ()
149146

150-
target_include_directories(${TARGET} PUBLIC .)
147+
target_include_directories(${TARGET} PUBLIC . ../vendor)
151148
target_compile_features (${TARGET} PUBLIC cxx_std_17)
152149
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
153150

scripts/sync_vendor.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
import urllib.request
44

55
vendor = {
6-
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "common/nlohmann/json.hpp",
6+
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",
7+
"https://github.com/nlohmann/json/releases/latest/download/json_fwd.hpp": "vendor/nlohmann/json_fwd.hpp",
78

89
# sync manually
9-
# "https://raw.githubusercontent.com/ochafik/minja/refs/heads/main/include/minja/minja.hpp": "common/minja/minja.hpp",
10-
# "https://raw.githubusercontent.com/ochafik/minja/refs/heads/main/include/minja/chat-template.hpp": "common/minja/chat-template.hpp",
10+
# "https://raw.githubusercontent.com/ochafik/minja/refs/heads/main/include/minja/minja.hpp": "vendor/minja/minja.hpp",
11+
# "https://raw.githubusercontent.com/ochafik/minja/refs/heads/main/include/minja/chat-template.hpp": "vendor/minja/chat-template.hpp",
1112

12-
"https://raw.githubusercontent.com/nothings/stb/refs/heads/master/stb_image.h": "tools/mtmd/vendor/stb_image.h",
13+
"https://raw.githubusercontent.com/nothings/stb/refs/heads/master/stb_image.h": "vendor/stb/stb_image.h",
1314

14-
"https://github.com/mackron/miniaudio/raw/refs/tags/0.11.22/miniaudio.h": "tools/mtmd/vendor/miniaudio.h",
15+
"https://github.com/mackron/miniaudio/raw/refs/tags/0.11.22/miniaudio.h": "vendor/miniaudio/miniaudio.h",
1516

16-
"https://raw.githubusercontent.com/yhirose/cpp-httplib/refs/tags/v0.20.1/httplib.h": "tools/server/httplib.h",
17+
"https://raw.githubusercontent.com/yhirose/cpp-httplib/refs/tags/v0.20.1/httplib.h": "vendor/cpp-httplib/httplib.h",
1718
}
1819

1920
for url, filename in vendor.items():

tools/mtmd/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ add_library(mtmd_helper OBJECT
2323

2424
target_link_libraries(mtmd_helper PRIVATE ggml llama mtmd ${CMAKE_THREAD_LIBS_INIT})
2525
target_include_directories(mtmd_helper PUBLIC .)
26-
target_include_directories(mtmd_helper PRIVATE ./vendor)
27-
target_include_directories(mtmd_helper PRIVATE ../..)
26+
target_include_directories(mtmd_helper PRIVATE ../../vendor)
2827
target_compile_features(mtmd_helper PRIVATE cxx_std_17)
2928

3029
if (BUILD_SHARED_LIBS)

tools/mtmd/mtmd-helper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
#define MA_NO_ENGINE
2828
#define MA_NO_GENERATION
2929
#define MA_API static
30-
#include "vendor/miniaudio.h"
30+
#include "miniaudio/miniaudio.h"
3131

3232
#define STB_IMAGE_IMPLEMENTATION
33-
#include "vendor/stb_image.h"
33+
#include "stb/stb_image.h"
3434

3535
#define LOG_INF(...) fprintf(stdout, __VA_ARGS__)
3636
#define LOG_ERR(...) fprintf(stderr, __VA_ARGS__)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

vendor/nlohmann/json_fwd.hpp

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// __ _____ _____ _____
2+
// __| | __| | | | JSON for Modern C++
3+
// | | |__ | | | | | | version 3.12.0
4+
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
5+
//
6+
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
7+
// SPDX-License-Identifier: MIT
8+
9+
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
10+
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
11+
12+
#include <cstdint> // int64_t, uint64_t
13+
#include <map> // map
14+
#include <memory> // allocator
15+
#include <string> // string
16+
#include <vector> // vector
17+
18+
// #include <nlohmann/detail/abi_macros.hpp>
19+
// __ _____ _____ _____
20+
// __| | __| | | | JSON for Modern C++
21+
// | | |__ | | | | | | version 3.12.0
22+
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
23+
//
24+
// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me>
25+
// SPDX-License-Identifier: MIT
26+
27+
28+
29+
// This file contains all macro definitions affecting or depending on the ABI
30+
31+
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
32+
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
33+
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
34+
#warning "Already included a different version of the library!"
35+
#endif
36+
#endif
37+
#endif
38+
39+
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
40+
#define NLOHMANN_JSON_VERSION_MINOR 12 // NOLINT(modernize-macro-to-enum)
41+
#define NLOHMANN_JSON_VERSION_PATCH 0 // NOLINT(modernize-macro-to-enum)
42+
43+
#ifndef JSON_DIAGNOSTICS
44+
#define JSON_DIAGNOSTICS 0
45+
#endif
46+
47+
#ifndef JSON_DIAGNOSTIC_POSITIONS
48+
#define JSON_DIAGNOSTIC_POSITIONS 0
49+
#endif
50+
51+
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
52+
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
53+
#endif
54+
55+
#if JSON_DIAGNOSTICS
56+
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
57+
#else
58+
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
59+
#endif
60+
61+
#if JSON_DIAGNOSTIC_POSITIONS
62+
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
63+
#else
64+
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
65+
#endif
66+
67+
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
68+
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
69+
#else
70+
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
71+
#endif
72+
73+
#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
74+
#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
75+
#endif
76+
77+
// Construct the namespace ABI tags component
78+
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
79+
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
80+
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
81+
82+
#define NLOHMANN_JSON_ABI_TAGS \
83+
NLOHMANN_JSON_ABI_TAGS_CONCAT( \
84+
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
85+
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
86+
NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
87+
88+
// Construct the namespace version component
89+
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
90+
_v ## major ## _ ## minor ## _ ## patch
91+
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
92+
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
93+
94+
#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
95+
#define NLOHMANN_JSON_NAMESPACE_VERSION
96+
#else
97+
#define NLOHMANN_JSON_NAMESPACE_VERSION \
98+
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
99+
NLOHMANN_JSON_VERSION_MINOR, \
100+
NLOHMANN_JSON_VERSION_PATCH)
101+
#endif
102+
103+
// Combine namespace components
104+
#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
105+
#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
106+
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
107+
108+
#ifndef NLOHMANN_JSON_NAMESPACE
109+
#define NLOHMANN_JSON_NAMESPACE \
110+
nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
111+
NLOHMANN_JSON_ABI_TAGS, \
112+
NLOHMANN_JSON_NAMESPACE_VERSION)
113+
#endif
114+
115+
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
116+
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
117+
namespace nlohmann \
118+
{ \
119+
inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
120+
NLOHMANN_JSON_ABI_TAGS, \
121+
NLOHMANN_JSON_NAMESPACE_VERSION) \
122+
{
123+
#endif
124+
125+
#ifndef NLOHMANN_JSON_NAMESPACE_END
126+
#define NLOHMANN_JSON_NAMESPACE_END \
127+
} /* namespace (inline namespace) NOLINT(readability/namespace) */ \
128+
} // namespace nlohmann
129+
#endif
130+
131+
132+
/*!
133+
@brief namespace for Niels Lohmann
134+
@see https://github.com/nlohmann
135+
@since version 1.0.0
136+
*/
137+
NLOHMANN_JSON_NAMESPACE_BEGIN
138+
139+
/*!
140+
@brief default JSONSerializer template argument
141+
142+
This serializer ignores the template arguments and uses ADL
143+
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
144+
for serialization.
145+
*/
146+
template<typename T = void, typename SFINAE = void>
147+
struct adl_serializer;
148+
149+
/// a class to store JSON values
150+
/// @sa https://json.nlohmann.me/api/basic_json/
151+
template<template<typename U, typename V, typename... Args> class ObjectType =
152+
std::map,
153+
template<typename U, typename... Args> class ArrayType = std::vector,
154+
class StringType = std::string, class BooleanType = bool,
155+
class NumberIntegerType = std::int64_t,
156+
class NumberUnsignedType = std::uint64_t,
157+
class NumberFloatType = double,
158+
template<typename U> class AllocatorType = std::allocator,
159+
template<typename T, typename SFINAE = void> class JSONSerializer =
160+
adl_serializer,
161+
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
162+
class CustomBaseClass = void>
163+
class basic_json;
164+
165+
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
166+
/// @sa https://json.nlohmann.me/api/json_pointer/
167+
template<typename RefStringType>
168+
class json_pointer;
169+
170+
/*!
171+
@brief default specialization
172+
@sa https://json.nlohmann.me/api/json/
173+
*/
174+
using json = basic_json<>;
175+
176+
/// @brief a minimal map-like container that preserves insertion order
177+
/// @sa https://json.nlohmann.me/api/ordered_map/
178+
template<class Key, class T, class IgnoredLess, class Allocator>
179+
struct ordered_map;
180+
181+
/// @brief specialization that maintains the insertion order of object keys
182+
/// @sa https://json.nlohmann.me/api/ordered_json/
183+
using ordered_json = basic_json<nlohmann::ordered_map>;
184+
185+
NLOHMANN_JSON_NAMESPACE_END
186+
187+
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
File renamed without changes.

0 commit comments

Comments
 (0)