-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
111 lines (92 loc) · 2.94 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
all: lib-in-docker examples-in-docker demo docs
# override -in-docker commond
.PHONY: all-in-docker
all-in-docker: all
# Docker configuration
# When multiple jobs running (e.g. make -j2) The interactive TTY is not available
NUM_JOBS = $(patsubst -j%,%,$(filter -j%,$(MAKEFLAGS)))
INTERACTIVE = $(if $(NUM_JOBS),,$(shell [ -t 0 ] && echo 1))
DOCKER_OPT = \
--rm \
-v $$(pwd):/build \
$(if $(INTERACTIVE),-it,) \
$(if $(CI),,-u $$(id -u):$$(id -g))
# Every commands can be run in a docker container when *-in-docker is appended.
# e.g make start => make start-in-docker,
# make test => make test-docker
%-in-docker:
docker run $(DOCKER_OPT) \
kbumsik/emscripten \
make $(patsubst %-in-docker,%,$@)
##############
# Common tasks
##############
install:
yarn install
lib: blogsearch blogsearch-crawler
.PHONY: lib-in-docker
lib-in-docker: blogsearch-in-docker blogsearch-crawler-in-docker
test: blogsearch
cd blogsearch && yarn test
start:
cd examples/demo && yarn build && yarn start
# Port 9000 is used by the webserver of examples/demo
start-in-docker: DOCKER_OPT += -p 9000:9000
.PHONY: examples
examples: crawler-reactjs crawler-kubernetes gatsby-reactjs jekyll-circleci
# override -in-docker command
.PHONY: examples-in-docker
examples-in-docker: crawler-reactjs-in-docker crawler-kubernetes-in-docker gatsby-reactjs-in-docker jekyll-circleci-in-docker
.PHONY: docs
docs: examples-in-docker
cd docs && make all
# override -in-docker command
.PHONY: docs-in-docker
docs-in-docker:
cd docs && make all
#######################
# Libray build commands
#######################
.PHONY: blogsearch
blogsearch:
cd blogsearch && yarn build
.PHONY: blogsearch-crawler
blogsearch-crawler:
cd blogsearch-crawler && yarn build
################
# Example builds
################
crawler-reactjs: blogsearch-crawler
cd examples/crawler-examples/reactjs.org && yarn build
crawler-kubernetes: blogsearch-crawler
cd examples/crawler-examples/kubernetes.io && yarn build
gatsby-reactjs:
cd examples/gatsby-examples/reactjs.org && yarn build
jekyll-circleci:
cd examples/jekyll-examples/circleci-docs && yarn build
# Override -in-docker command because circleci needs its own docker
.PHONY: jekyll-circleci-in-docker
jekyll-circleci-in-docker: jekyll-circleci
.PHONY: demo
demo: blogsearch examples-in-docker
cd examples/demo && yarn build
# override -in-docker command
.PHONY: demo-in-docker
demo-in-docker: blogsearch
cd examples/demo && yarn build
######
# etc.
######
docker-image: Dockerfile
docker build . --tag kbumsik/emscripten:$$(date +'%Y-%m-%d') --file $<
clean:
cd blogsearch && yarn clean
cd blogsearch-crawler && yarn clean
cd examples/crawler-examples/reactjs.org && yarn clean
cd examples/crawler-examples/kubernetes.io && yarn clean
cd examples/gatsby-examples/reactjs.org && yarn clean
cd examples/jekyll-examples/circleci-docs && yarn clean
cd examples/demo && yarn clean
# Just to work in the docker container, so you can run bash-in-docker
bash:
bash