-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSConstruct
67 lines (52 loc) · 1.98 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
import os
import sys
# Create a main environment for godot
godot_env = SConscript("godot-cpp/SConstruct")
llamacpp_path = ARGUMENTS.get('llamacpp_path', 'llama_dot_cpp')
# make it an absolute path
llamacpp_path = os.path.abspath(llamacpp_path)
# Create a main environment for llama
llama_env = SConscript( os.path.join(llamacpp_path, "SConstruct"))
# llama_env.Append(CPPPATH=["src/", llamacpp_path, os.path.join(llamacpp_path, 'common')])
headers_and_libraries_paths = [
os.path.join(llamacpp_path, 'common'),
llamacpp_path,
"src/",
]
# Append paths to both environments
godot_env.Append(CPPPATH=headers_and_libraries_paths)
llama_env.Append(CPPPATH=headers_and_libraries_paths)
# Compile and link settings
sources = Glob("src/*.cpp")
# Add 'pthread' to libraries for both environments
# godot_env.Append(LIBS=['pthread'])
godot_env.Append(LIBS=['llama', 'pthread'])
godot_env.Append(LIBPATH=[llamacpp_path])
llama_env.Append(LIBS=['pthread'])
# Object files from the specified path for llama_env
# object_files = [
# os.path.join(llamacpp_path, 'ggml-alloc.o'),
# os.path.join(llamacpp_path, 'k_quants.o'),
# os.path.join(llamacpp_path, 'ggml.o'),
# os.path.join(llamacpp_path, 'common.o'),
# os.path.join(llamacpp_path, 'llama.o')
# ]
# Create a static library from the object files using llama_env
# static_lib = llama_env.StaticLibrary('llama', object_files)
# Link the shared library against the static library using godot_env
if godot_env["platform"] == "macos":
library = godot_env.SharedLibrary(
"the-game/bin/libgdllm.{}.{}.framework/libgdllm.{}.{}".format(
godot_env["platform"], godot_env["target"], godot_env["platform"], godot_env["target"]
),
source=sources,
# LIBS=[static_lib]
)
else:
library = godot_env.SharedLibrary(
"the-game/bin/libgdllm{}{}".format(godot_env["suffix"], godot_env["SHLIBSUFFIX"]),
source=sources,
# LIBS=[static_lib]
)
Default(library)