-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (61 loc) · 2.21 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
export NODE_OPTIONS=--max-old-space-size=4096
brotli-pack = node scripts/brotli-pack.js
pkg-zh-tw = packages/jieba-zh-tw
pkg-zh-cn = packages/jieba-zh-cn
.PHONY: build
build: dist/jieba.js dist/jieba.emcc.js zh-tw zh-cn
.PHONY: clean
clean:
rm -r dist packages/jieba-zh-tw/dist packages/jieba-zh-cn/dist
.PHONY: zh-tw
zh-tw: $(pkg-zh-tw)/dist/jieba.dict.br.js $(pkg-zh-tw)/dist/hmm.model.br.js $(pkg-zh-tw)/dist/idf.br.js
.PHONY: zh-cn
zh-cn: $(pkg-zh-cn)/dist/jieba.dict.br.js $(pkg-zh-cn)/dist/hmm.model.br.js $(pkg-zh-cn)/dist/idf.br.js $(pkg-zh-cn)/dist/stop.words.br.js
dist/jieba.js: dist/jieba.emcc.js node_modules
npm run build:jieba
dist/jieba.emcc.js: cppjieba dist
emcc \
-O1 \
-I./cppjieba/include \
-I./cppjieba/deps \
-s ALLOW_MEMORY_GROWTH=1 \
-s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall"]' \
-s WASM=0 \
--no-heap-copy \
--closure 0 \
-s BINARYEN_ASYNC_COMPILATION=0 \
-s MODULARIZE=0 \
--js-library ./emcc/library.js \
--pre-js ./emcc/pre.js \
--post-js ./emcc/post.js \
--embed-file ./emcc/root@/ \
./emcc/main.cpp \
-o ./dist/jieba.emcc.js
dist:
mkdir -p dist
node_modules:
npm i
cppjieba:
git clone --depth=2 --branch=master https://github.com/yanyiwu/cppjieba.git cppjieba
jieba-tw:
git clone --depth=2 https://github.com/APCLab/jieba-tw.git jieba-tw
jieba-tw/hmm_model.txt: jieba-tw
./make_hmm.py > jieba-tw/hmm_model.txt
$(pkg-zh-tw)/dist:
mkdir -p $(pkg-zh-tw)/dist
$(pkg-zh-tw)/dist/jieba.dict.br.js: jieba-tw $(pkg-zh-tw)/dist
$(brotli-pack) jieba-tw/jieba/dict.txt $@
$(pkg-zh-tw)/dist/hmm.model.br.js: jieba-tw $(pkg-zh-tw)/dist
$(brotli-pack) jieba-tw/hmm_model.txt $@
$(pkg-zh-tw)/dist/idf.br.js: jieba-tw $(pkg-zh-tw)/dist
$(brotli-pack) jieba-tw/jieba/analyse/idf.txt $@
$(pkg-zh-cn)/dist:
mkdir -p $(pkg-zh-cn)/dist
$(pkg-zh-cn)/dist/jieba.dict.br.js: cppjieba $(pkg-zh-cn)/dist
$(brotli-pack) cppjieba/dict/jieba.dict.utf8 $@
$(pkg-zh-cn)/dist/hmm.model.br.js: cppjieba $(pkg-zh-cn)/dist
$(brotli-pack) cppjieba/dict/hmm_model.utf8 $@
$(pkg-zh-cn)/dist/user.dict.br.js: cppjieba $(pkg-zh-cn)/dist
$(brotli-pack) cppjieba/dict/user.dict.utf8 $@
$(pkg-zh-cn)/dist/stop.words.br.js: cppjieba $(pkg-zh-cn)/dist
$(brotli-pack) cppjieba/dict/stop_words.utf8 $@