-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Makefile
143 lines (108 loc) · 3.34 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
133
134
135
136
137
138
139
140
141
142
143
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
################################################################################
# Definitions #
################################################################################
-include facebook/Makefile.defs
ifeq ($(OS), Windows_NT)
EXE=.exe
else
EXE=
endif
SWITCH=ocaml-variants.5.2.0+options
JS_OF_OCAML_VERSION=5.7.2
OUNIT_VERSION=2.2.2.6
# set FLOW_RELEASE=[1|true] or CI=true for an optimized build; otherwise,
# defaults to dev mode that builds faster but is less efficient at runtime.
ifndef FLOW_RELEASE
FLOW_RELEASE?=$(CI)
endif
ifeq ($(FLOW_RELEASE),false)
FLOW_RELEASE=
endif
ifeq ($(FLOW_RELEASE),0)
FLOW_RELEASE=
endif
DUNE_PROFILE=$(if $(FLOW_RELEASE),opt,dev)
NPM?=npm
YARN?=yarn
################################################################################
# Rules #
################################################################################
all: bin/flow$(EXE)
all-homebrew:
export OPAMROOT="$(shell mktemp -d 2> /dev/null || mktemp -d -t opam)"; \
export OPAMYES="1"; \
export FLOW_RELEASE="1"; \
opam init --bare --no-setup --disable-sandboxing && \
rm -rf _opam && \
opam switch create . --deps-only $(SWITCH) && \
opam exec -- make
.PHONY: deps
deps:
[ -d _opam ] || opam switch create . $(SWITCH) --deps-only --yes
.PHONY: deps-js
deps-js:
opam install js_of_ocaml.$(JS_OF_OCAML_VERSION) --yes
.PHONY: deps-test
deps-test:
opam install ounit$(OUNIT_VERSION)
clean:
if command -v dune >/dev/null; then dune clean; fi
rm -rf _build
rm -rf bin
.PHONY: bin/flow$(EXE)
bin/flow$(EXE):
dune build --profile $(DUNE_PROFILE) src/flow.exe
mkdir -p $(@D)
install -C _build/default/src/flow.exe "$@"
.PHONY: ounit-tests
ounit-tests:
dune runtest
.PHONY: ounit-tests-ci
ounit-tests-ci:
mkdir -p test-results/ounit
OUNIT_CI=true OUNIT_OUTPUT_JUNIT_FILE='$(shell pwd)/test-results/ounit/$$(suite_name).xml' dune runtest --force
do-test-js: bin/flow.js
node src/__tests__/flow_dot_js_smoke_test.js $(realpath bin/flow.js)
do-test:
./runtests.sh bin/flow$(EXE)
bin/flow$(EXE) check packages/flow-dev-tools
${MAKE} do-test-tool
./tool test
do-test-tool:
FLOW_BIN=../../bin/flow$(EXE) ${YARN} --cwd packages/flow-dev-tools test
test-tool: bin/flow$(EXE)
${MAKE} do-test-tool
test-js: bin/flow.js do-test-js
test: bin/flow$(EXE) bin/flow.js
${MAKE} do-test do-test-js
.PHONY: bin/flow.js
bin/flow.js:
@mkdir -p $(@D)
dune build --profile $(DUNE_PROFILE) src/flow_dot_js.bc.js
install -C _build/default/src/flow_dot_js.bc.js "$@"
# Run `make js FLOW_RELEASE=1` to do an optimized build
js: bin/flow.js
dist/flow/flow$(EXE): bin/flow$(EXE)
mkdir -p $(@D)
install -C bin/flow$(EXE) "$@"
dist/flow.zip: dist/flow/flow$(EXE)
cd dist && zip -r $(@F) flow/flow$(EXE)
dist/npm-%.tgz: FORCE
@mkdir -p $(@D)
@mkdir -p npm-$(*F)-tmp
cd npm-$(*F)-tmp && ${NPM} pack ../packages/$(*F)/
mv npm-$(*F)-tmp/$(*F)-*.tgz dist/npm-$(*F).tgz
@rm -rf npm-$(*F)-tmp
FORCE:
.PHONY: all js FORCE
# Don't run in parallel because of https://github.com/ocaml/ocamlbuild/issues/300
.NOTPARALLEL:
-include facebook/Makefile
print-switch:
@echo $(SWITCH)
print-jsoo-version:
@echo $(JS_OF_OCAML_VERSION)
print-ounit-version:
@echo $(OUNIT_VERSION)