forked from facebook/flow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
176 lines (146 loc) · 5.07 KB
/
Makefile
File metadata and controls
176 lines (146 loc) · 5.07 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Copyright (c) 2013-present, Facebook, Inc.
# All rights reserved.
################################################################################
# Variables to override #
################################################################################
EXTRA_INCLUDE_PATHS=
EXTRA_LIB_PATHS=
################################################################################
# OS-dependent stuff #
################################################################################
OS=$(shell uname -s)
FLOWLIB=bin/flowlib.tar.gz
ifeq ($(OS), Linux)
INOTIFY=third-party/inotify
INOTIFY_STUBS=$(INOTIFY)/inotify_stubs.o
FSNOTIFY=fsnotify_linux
ELF=elf
FRAMEWORKS=
SECTCREATE=
endif
ifeq ($(OS), Darwin)
INOTIFY=fsevents
INOTIFY_STUBS=$(INOTIFY)/fsevents_stubs.o
FSNOTIFY=fsnotify_darwin
ELF=
FRAMEWORKS=CoreServices CoreFoundation
SECTCREATE=-cclib -sectcreate -cclib __text -cclib flowlib -cclib $(abspath $(FLOWLIB))
endif
################################################################################
# Definitions #
################################################################################
MODULES=\
src/commands\
src/common\
src/dts\
src/embedded\
src/parser\
src/parsing\
src/server\
src/services/autocomplete\
src/services/inference\
src/stubs\
src/typing\
hack/dfind\
hack/find\
hack/globals\
hack/heap\
hack/hhi\
hack/procs\
hack/search\
hack/socket\
hack/stubs\
hack/third-party/avl\
hack/third-party/core\
hack/utils\
hack/utils/collections\
hack/$(INOTIFY)\
hack/$(FSNOTIFY)
NATIVE_OBJECT_FILES=\
hack/$(INOTIFY_STUBS)\
hack/heap/hh_shared.o\
hack/hhi/hhi_elf.o\
hack/utils/files.o\
hack/utils/get_build_id.gen.o\
hack/utils/get_build_id.o\
hack/utils/handle_stubs.o\
hack/utils/nproc.o\
hack/utils/realpath.o\
hack/utils/sysinfo.o\
hack/utils/priorities.o\
hack/utils/win32_support.o\
hack/hhi/hhi_win32res_stubs.o\
src/embedded/flowlib_elf.o
OCAML_LIBRARIES=\
unix\
str\
bigarray
NATIVE_LIBRARIES=\
$(ELF)
FILES_TO_COPY=\
$(wildcard lib/*.js)
################################################################################
# Rules #
################################################################################
CC_FLAGS=-DNO_LZ4
CC_OPTS=$(foreach flag, $(CC_FLAGS), -ccopt $(flag))
INCLUDE_OPTS=$(foreach dir,$(MODULES),-I $(dir))
LIB_OPTS=$(foreach lib,$(OCAML_LIBRARIES),-lib $(lib))
NATIVE_LIB_OPTS=$(foreach lib, $(NATIVE_LIBRARIES),-cclib -l -cclib $(lib))
EXTRA_INCLUDE_OPTS=$(foreach dir, $(EXTRA_INCLUDE_PATHS),-ccopt -I -ccopt $(dir))
EXTRA_LIB_OPTS=$(foreach dir, $(EXTRA_LIB_PATHS),-cclib -L -cclib $(dir))
FRAMEWORK_OPTS=$(foreach framework, $(FRAMEWORKS),-cclib -framework -cclib $(framework))
LINKER_FLAGS=$(NATIVE_OBJECT_FILES) $(NATIVE_LIB_OPTS) $(EXTRA_LIB_OPTS) $(FRAMEWORK_OPTS) $(SECTCREATE)
all: $(FLOWLIB) build-flow copy-flow-files
all-ocp: build-flow-with-ocp copy-flow-files-ocp
clean:
ocamlbuild -clean
rm -rf bin
rm -f hack/utils/get_build_id.gen.c
build-flow: build-flow-native-deps $(FLOWLIB)
ocamlbuild -no-links $(INCLUDE_OPTS) $(LIB_OPTS) -lflags "$(LINKER_FLAGS)" src/flow.native
build-flow-with-ocp: build-flow-stubs-with-ocp
[ -d _obuild ] || ocp-build init
ocp-build build flow
build-flow-debug: build-flow-native-deps $(FLOWLIB)
ocamlbuild -lflags -custom -no-links $(INCLUDE_OPTS) $(LIB_OPTS) -lflags "$(LINKER_FLAGS)" src/flow.d.byte
mkdir -p bin
cp _build/src/flow.d.byte bin/flow
build-flow-native-deps: build-flow-stubs
ocamlbuild -ocamlc "ocamlopt $(EXTRA_INCLUDE_OPTS) $(CC_OPTS)"\
$(NATIVE_OBJECT_FILES)
build-flow-stubs:
echo "const char* const BuildInfo_kRevision = \"$$(git rev-parse HEAD 2>/dev/null || hg identify -i)\";" > hack/utils/get_build_id.gen.c
build-flow-stubs-with-ocp:
ocaml unix.cma scripts/gen_build_id.ml hack/utils/get_build_id.gen.c
# We only rebuild the flowlib archive if any of the libs have changed. If the
# archive has changed, then the incremental build needs to re-embed it into the
# binary. Unfortunately we rely on ocamlbuild to embed the archive on OSX and
# ocamlbuild isn't smart enough to understand dependencies outside of its
# automatic-dependency stuff.
$(FLOWLIB): $(wildcard lib/*)
mkdir -p bin
tar czf $@ -C lib .
ifeq ($(OS), Darwin)
rm -f _build/src/flow.d.byte _build/src/flow.native
endif
copy-flow-files: build-flow $(FILES_TO_COPY)
mkdir -p bin
ifeq ($(OS), Linux)
objcopy --add-section flowlib=$(FLOWLIB) _build/src/flow.native bin/flow
else
cp _build/src/flow.native bin/flow
endif
copy-flow-files-ocp: build-flow-with-ocp $(FLOWLIB) $(FILES_TO_COPY)
mkdir -p bin
ifeq ($(OS), Linux)
objcopy --add-section flowlib=$(FLOWLIB) _obuild/flow/flow.asm bin/flow
else
cp _obuild/flow/flow.asm bin/flow
endif
do-test:
./runtests.sh bin/flow
test: build-flow copy-flow-files
${MAKE} do-test
test-ocp: build-flow-with-ocp copy-flow-files-ocp
${MAKE} do-test