"vscode:/vscode.git/clone" did not exist on "3df5f8f56e0d22ac24c85c1eb014d31715ccdec1"
Makefile.sync 2.58 KB
Newer Older
1
UPSTREAM=https://github.com/ggml-org/llama.cpp.git
Michael Yang's avatar
Michael Yang committed
2
WORKDIR=llama/vendor
Daniel Hiltgen's avatar
Daniel Hiltgen committed
3
FETCH_HEAD=3cfa9c3f125763305b4226bc032f1954f08990dc
Michael Yang's avatar
Michael Yang committed
4
5
6
7
8
9
10
11
12
13
14

.PHONY: help
help:
	@echo "Available targets:"
	@echo "    sync                 Sync with upstream repositories"
	@echo "    checkout             Checkout upstream repository"
	@echo "    apply-patches        Apply patches to local repository"
	@echo "    format-patches       Format patches from local repository"
	@echo "    clean                Clean local repository"
	@echo
	@echo "Example:"
15
	@echo "    make -f $(lastword $(MAKEFILE_LIST)) clean apply-patches sync"
Michael Yang's avatar
Michael Yang committed
16
17

.PHONY: sync
18
sync: llama/build-info.cpp ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-embed.metal
19

20
21
22
23
24
llama/build-info.cpp: llama/build-info.cpp.in llama/llama.cpp
	sed -e 's|@FETCH_HEAD@|$(FETCH_HEAD)|' <$< >$@

ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-embed.metal: ml/backend/ggml/ggml
	go generate ./$(@D)
Michael Yang's avatar
Michael Yang committed
25
26

.PHONY: llama/llama.cpp
27
28
llama/llama.cpp: llama/vendor
	rsync -arvzc --delete -f "include LICENSE" -f "merge $@/.rsync-filter" $(addprefix $<,/LICENSE /) $@
Michael Yang's avatar
Michael Yang committed
29

30
.PHONY: ml/backend/ggml/ggml
31
32
ml/backend/ggml/ggml: llama/vendor
	rsync -arvzc --delete -f "include LICENSE" -f "merge $@/.rsync-filter" $(addprefix $<,/LICENSE /ggml/) $@
Michael Yang's avatar
Michael Yang committed
33
34

PATCHES=$(wildcard llama/patches/*.patch)
35
PATCHED=$(join $(dir $(PATCHES)), $(addsuffix ed, $(addprefix ., $(notdir $(PATCHES)))))
Michael Yang's avatar
Michael Yang committed
36
37
38

.PHONY: apply-patches
.NOTPARALLEL:
39
apply-patches: $(PATCHED)
Michael Yang's avatar
Michael Yang committed
40

41
llama/patches/.%.patched: llama/patches/%.patch
42
43
44
45
46
47
48
49
50
	@if git -c user.name=nobody -c 'user.email=<>' -C $(WORKDIR) am -3 $(realpath $<); then \
		touch $@;                                                                           \
	else                                                                                    \
		echo "Patch failed. Resolve any conflicts then continue.";                          \
		echo "1. Run 'git -C $(WORKDIR) am --continue'";                                    \
		echo "2. Run 'make -f $(lastword $(MAKEFILE_LIST)) format-patches'";                \
		echo "3. Run 'make -f $(lastword $(MAKEFILE_LIST)) clean apply-patches'";           \
		exit 1;                                                                             \
	fi
Michael Yang's avatar
Michael Yang committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

.PHONY: checkout
checkout: $(WORKDIR)
	git -C $(WORKDIR) fetch
	git -C $(WORKDIR) checkout -f $(FETCH_HEAD)

$(WORKDIR):
	git clone $(UPSTREAM) $(WORKDIR)

.PHONE: format-patches
format-patches: llama/patches
	git -C $(WORKDIR) format-patch \
		--no-signature \
		--no-numbered \
		--zero-commit \
		-o $(realpath $<) \
		$(FETCH_HEAD)

.PHONE: clean
clean: checkout
71
	@git -C $(WORKDIR) am --abort || true
72
	$(RM) llama/patches/.*.patched