ChatON+: Cleanup integration with CMake

Rename chaton-meta hpp to cpp and include this cpp file which brings
in the compile time built-in global chaton configurable template data
into the common library, and avoid the nop hpp file references.

Update chaton.hpp to not include the meta-cpp, instead just make a
reference to the global ChatTemplates instance, so that the hpp can
be used as a header file proper.

Avoid pragma once in the chaton-meta.cpp, including the script, which
helps create it.
This commit is contained in:
HanishKVC 2024-05-16 11:50:57 +05:30
parent 7a3ac0cc15
commit 239b5be219
4 changed files with 5 additions and 8 deletions

View file

@ -65,8 +65,7 @@ add_library(${TARGET} STATIC
train.cpp
ngram-cache.h
ngram-cache.cpp
chaton.hpp
groupkv.hpp
chaton_meta.cpp
)
if (BUILD_SHARED_LIBS)

View file

@ -537,9 +537,8 @@ public:
};
// The compiled-in configurable template data (the meta)
#include "chaton_meta.hpp"
//ChatTemplates gCT = {{}};
// The compiled-in configurable template data (the meta) from chaton_meta.cpp
extern ChatTemplates gCT;
inline bool chaton_tmpl_exists(const std::string &tmpl) {

View file

@ -1,5 +1,4 @@
//This is auto created/converted from chaton-meta-json file
#pragma once
#include "chaton.hpp"

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Convert chaton meta json file to c++ hpp file
# Convert chaton meta json file to equivalent c++ cpp format
# by Humans for All
import sys
@ -19,7 +19,7 @@ def kv_bool(j, tmpl, k1, comma):
fp=open(sys.argv[1])
j=json.load(fp)
print("//This is auto created/converted from chaton-meta-json file")
print("#pragma once\n\n#include \"chaton.hpp\"\n\nChatTemplates gCT = {{")
print("\n\n#include \"chaton.hpp\"\n\nChatTemplates gCT = {{")
for tmpl in j:
print("\t{{ \"{}\", {{".format(tmpl))