Skip to content

Commit 05a32fb

Browse files
cmake(common): scope config.cpp/yaml-cpp to tools; add LLAMA_ENABLE_CONFIG_YAML guards
- Wrap --config option definition with LLAMA_ENABLE_CONFIG_YAML in arg.cpp - Guard all YAML-dependent code sections in config.cpp and config.h - Ensures yaml-cpp is only compiled when LLAMA_BUILD_TOOLS=ON - Prevents platform builds that don't need tools from pulling yaml-cpp dependencies Co-Authored-By: Jaime Mizrachi <[email protected]>
1 parent a7759dd commit 05a32fb

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

common/arg.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,13 +1341,15 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
13411341
}
13421342
));
13431343

1344+
#ifdef LLAMA_ENABLE_CONFIG_YAML
13441345
add_opt(common_arg(
13451346
{"--config"},
13461347
"<path/to/config.yaml>",
13471348
"Load parameters from a YAML config file; flags passed on the command line override values from the YAML file.",
13481349
[](common_params &, const std::string &) {
13491350
}
13501351
));
1352+
#endif
13511353
add_opt(common_arg(
13521354
{"--verbose-prompt"},
13531355
string_format("print a verbose prompt before generation (default: %s)", params.verbose_prompt ? "true" : "false"),

common/config.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifdef LLAMA_ENABLE_CONFIG_YAML
2+
13
#include "config.h"
24
#include "log.h"
35

@@ -6,6 +8,8 @@
68
#include <set>
79
#include <sstream>
810
#include <stdexcept>
11+
#include <cstdint>
12+
#include <limits>
913

1014
namespace fs = std::filesystem;
1115

@@ -335,3 +339,5 @@ bool common_load_yaml_config(const std::string & path, common_params & params) {
335339
throw std::invalid_argument("Config loading error: " + std::string(e.what()));
336340
}
337341
}
342+
343+
#endif // LLAMA_ENABLE_CONFIG_YAML

common/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
#include "common.h"
44
#include <string>
55

6+
#ifdef LLAMA_ENABLE_CONFIG_YAML
67
bool common_load_yaml_config(const std::string & path, common_params & params);
78
std::string common_yaml_valid_keys_help();
9+
#endif

0 commit comments

Comments
 (0)