-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
132 lines (122 loc) · 5.26 KB
/
Makefile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Makefile for Cortex llamacpp engine - Build, Lint, Test, and Clean
CMAKE_EXTRA_FLAGS ?= ""
RUN_TESTS ?= false
LLM_MODEL_URL ?= "https://delta.jan.ai/tinyllama-1.1b-chat-v0.3.Q2_K.gguf"
EMBEDDING_MODEL_URL ?= "https://catalog.jan.ai/dist/models/embeds/nomic-embed-text-v1.5.f16.gguf"
CODE_SIGN ?= false
AZURE_KEY_VAULT_URI ?= xxxx
AZURE_CLIENT_ID ?= xxxx
AZURE_TENANT_ID ?= xxxx
AZURE_CLIENT_SECRET ?= xxxx
AZURE_CERT_NAME ?= xxxx
DEVELOPER_ID ?= xxxx
# Default target, does nothing
all:
@echo "Specify a target to run"
# Build the Cortex engine
build-lib:
ifeq ($(OS),Windows_NT)
@powershell -Command "cmake -S ./third-party -B ./build_deps/third-party;"
@powershell -Command "cmake --build ./build_deps/third-party --config Release -j4;"
@powershell -Command "mkdir -p build; cd build; cmake .. $(CMAKE_EXTRA_FLAGS); cmake --build . --config Release;"
else ifeq ($(shell uname -s),Linux)
@cmake -S ./third-party -B ./build_deps/third-party;
@make -C ./build_deps/third-party -j4;
@rm -rf ./build_deps/third-party;
@mkdir build && cd build; \
cmake .. $(CMAKE_EXTRA_FLAGS); \
make -j4;
else
@cmake -S ./third-party -B ./build_deps/third-party
@make -C ./build_deps/third-party -j4
@rm -rf ./build_deps/third-party
@mkdir build && cd build; \
cmake .. $(CMAKE_EXTRA_FLAGS); \
make -j4;
endif
build-example-server: build-lib
ifeq ($(OS),Windows_NT)
@powershell -Command "mkdir -p .\examples\server\build; cd .\examples\server\build; cmake .. $(CMAKE_EXTRA_FLAGS); cmake --build . --config Release;"
else ifeq ($(shell uname -s),Linux)
@mkdir -p examples/server/build && cd examples/server/build; \
cmake .. $(CMAKE_EXTRA_FLAGS); \
cmake --build . --config Release;
else
@mkdir -p examples/server/build && cd examples/server/build; \
cmake ..; \
cmake --build . --config Release;
endif
pre-package:
ifeq ($(OS),Windows_NT)
@powershell -Command "mkdir -p cortex.llamacpp; cp build\Release\engine.dll cortex.llamacpp\;"
else ifeq ($(shell uname -s),Linux)
@mkdir -p cortex.llamacpp; \
cp build/libengine.so cortex.llamacpp/;
else
@mkdir -p cortex.llamacpp; \
cp build/libengine.dylib cortex.llamacpp/;
endif
codesign:
ifeq ($(CODE_SIGN),false)
@echo "Skipping Code Sign"
@exit 0
endif
ifeq ($(OS),Windows_NT)
@powershell -Command "dotnet tool install --global AzureSignTool;"
@powershell -Command 'azuresigntool.exe sign -kvu "$(AZURE_KEY_VAULT_URI)" -kvi "$(AZURE_CLIENT_ID)" -kvt "$(AZURE_TENANT_ID)" -kvs "$(AZURE_CLIENT_SECRET)" -kvc "$(AZURE_CERT_NAME)" -tr http://timestamp.globalsign.com/tsa/r6advanced1 -v ".\cortex.llamacpp\engine.dll";'
else ifeq ($(shell uname -s),Linux)
@echo "Skipping Code Sign for linux"
@exit 0
else
find "cortex.llamacpp" -type f -exec codesign --force -s "$(DEVELOPER_ID)" --options=runtime {} \;
endif
package:
ifeq ($(OS),Windows_NT)
@powershell -Command "7z a -ttar temp.tar cortex.llamacpp\*; 7z a -tgzip cortex.llamacpp.tar.gz temp.tar;"
else ifeq ($(shell uname -s),Linux)
@tar -czvf cortex.llamacpp.tar.gz cortex.llamacpp;
else
@tar -czvf cortex.llamacpp.tar.gz cortex.llamacpp;
endif
run-e2e-test:
ifeq ($(RUN_TESTS),false)
@echo "Skipping tests"
@exit 0
endif
ifeq ($(OS),Windows_NT)
@powershell -Command "mkdir -p examples\server\build\Release\engines\cortex.llamacpp; cd examples\server\build\Release; cp ..\..\..\..\build\Release\engine.dll engines\cortex.llamacpp; ..\..\..\..\.github\scripts\e2e-test-server-windows.bat server.exe $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);"
else ifeq ($(shell uname -s),Linux)
@mkdir -p examples/server/build/engines/cortex.llamacpp; \
cd examples/server/build/; \
cp ../../../build/libengine.so engines/cortex.llamacpp/; \
chmod +x ../../../.github/scripts/e2e-test-server-linux-and-mac.sh && ../../../.github/scripts/e2e-test-server-linux-and-mac.sh ./server $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);
else
@mkdir -p examples/server/build/engines/cortex.llamacpp; \
cd examples/server/build/; \
cp ../../../build/libengine.dylib engines/cortex.llamacpp/; \
chmod +x ../../../.github/scripts/e2e-test-server-linux-and-mac.sh && ../../../.github/scripts/e2e-test-server-linux-and-mac.sh ./server $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);
endif
run-e2e-submodule-test:
ifeq ($(RUN_TESTS),false)
@echo "Skipping tests"
@exit 0
endif
ifeq ($(OS),Windows_NT)
@powershell -Command "python -m pip install --upgrade pip"
@powershell -Command "python -m pip install requests;"
@powershell -Command "mkdir -p examples\server\build\Release\engines\cortex.llamacpp; cd examples\server\build\Release; cp ..\..\..\..\build\Release\engine.dll engines\cortex.llamacpp; python ..\..\..\..\.github\scripts\e2e-test-server.py server $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);"
else ifeq ($(shell uname -s),Linux)
python -m pip install --upgrade pip;
python -m pip install requests;
@mkdir -p examples/server/build/engines/cortex.llamacpp; \
cd examples/server/build/; \
cp ../../../build/libengine.so engines/cortex.llamacpp/; \
python ../../../.github/scripts/e2e-test-server.py server $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);
else
python -m pip install --upgrade pip;
python -m pip install requests;
@mkdir -p examples/server/build/engines/cortex.llamacpp; \
cd examples/server/build/; \
cp ../../../build/libengine.dylib engines/cortex.llamacpp/; \
python ../../../.github/scripts/e2e-test-server.py server $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);
endif