blob: 21fad4bd2fa5fb0839bbf62c40a739da4f3d3d1f (
plain) (
blame)
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
177
178
|
# Core: Autopatch.
CORE_AUTOPATCH_TARGETS = $(call list_targets,core-autopatch)
.PHONY: core-autopatch $(CORE_AUTOPATCH_TARGETS)
core-autopatch: $(CORE_AUTOPATCH_TARGETS)
core-autopatch-extended: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add Ranch to the list of dependencies"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = ranch\n"}' $(APP)/Makefile
$i "Extend autopatch-ranch to create an additional module"
$t echo "autopatch-ranch:: ; rm -f \$$(DEPS_DIR)/ranch/src/ranch_protocol.erl" >> $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v
$i "Check that the module was removed"
$t ! test -e $(APP)/deps/ranch/src/ranch_protocol.erl
$t ! test -e $(APP)/deps/ranch/ebin/ranch_protocol.beam
core-autopatch-extended-erlc-opts: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add couchbeam to the list of dependencies"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = couchbeam\n"}' $(APP)/Makefile
$i "Extend autopatch-couchbeam to add options to its ERLC_OPTS"
$t echo "autopatch-couchbeam:: ; printf '\nERLC_OPTS += -DWITH_JIFFY\n' >> \$$(DEPS_DIR)/couchbeam/Makefile" >> $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v
$i "Check that couchbeam_ejson was compiled with the added option"
$t $(ERL) -pa $(APP)/deps/couchbeam/ebin -eval 'c:m(couchbeam_ejson), halt()' | grep -c "WITH_JIFFY" | grep -q 1
core-autopatch-no-autopatch: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add Cowboy to the list of dependencies and Cowlib to the NO_AUTOPATCH list"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\nNO_AUTOPATCH = cowlib\n"}' $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v
$i "Check that all dependencies were fetched"
$t test -d $(APP)/deps/cowboy
$t test -d $(APP)/deps/cowlib
$t test -d $(APP)/deps/ranch
$i "Check that Cowlib was not autopatched"
$t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
core-autopatch-no-autopatch-erlang-mk: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add Cowlib to the list of dependencies and set NO_AUTOPATCH_ERLANG_MK=1"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowlib\nNO_AUTOPATCH_ERLANG_MK = 1\n"}' $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v
$i "Check that all dependencies were fetched"
$t test -d $(APP)/deps/cowlib
$i "Check that Erlang.mk was not autopatched"
$t grep -q Hoguin $(APP)/deps/cowlib/erlang.mk
core-autopatch-no-autopatch-rebar: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add Lager to the list of dependencies and to the NO_AUTOPATCH list"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\nNO_AUTOPATCH = lager\n"}' $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v
$i "Check that all dependencies were fetched"
$t test -d $(APP)/deps/goldrush
$t test -d $(APP)/deps/lager
$i "Check that Lager was not autopatched"
$t if grep -q erlang\.mk $(APP)/deps/goldrush/Makefile; then false; fi
$t if grep -q erlang\.mk $(APP)/deps/lager/Makefile; then false; fi
core-autopatch-port_env: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Bootstrap a new NIF named my_dep inside $(APP) that uses rebar"
$t mkdir $(APP)/my_dep
$t cp ../erlang.mk $(APP)/my_dep/
$t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v
$t $(MAKE) -C $(APP)/my_dep/ new-nif n=my_dep $v
$t rm $(APP)/my_dep/erlang.mk $(APP)/my_dep/Makefile
$i "Add a rebar.config file with port_env to my_dep"
$t echo "{port_env, [" >> $(APP)/my_dep/rebar.config
$t echo "{\"CFLAGS\", \"\$$CFLAGS \$$(pkg-config --cflags domain-classifier 2>/dev/null)\"}," >> $(APP)/my_dep/rebar.config
$t echo "{\"LDFLAGS\", \"\$$LDFLAGS \$$(pkg-config --libs domain-classifier 2>/dev/null)\"}" >> $(APP)/my_dep/rebar.config
$t echo "]}." >> $(APP)/my_dep/rebar.config
$i "Add my_dep to the list of dependencies"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile
ifdef LEGACY
$i "Add my_dep to the applications key in the .app.src file"
$t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src
endif
$i "Build the application"
$t $(MAKE) -C $(APP) $v
$i "Check that all dependencies were fetched"
$t test -d $(APP)/deps/my_dep
$i "Confirm that the port_env configuration was expanded properly"
$t grep -q "shell pkg-config" $(APP)/deps/my_dep/c_src/Makefile.erlang.mk
core-autopatch-rebar: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add erlsha2 to the list of dependencies"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlsha2\n"}' $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v
$i "Check that erlsha2 was fetched and built"
$t test -d $(APP)/deps/erlsha2
$t test -f $(APP)/deps/erlsha2/ebin/erlsha2.beam
ifneq ($(PLATFORM),msys2)
$t test -f $(APP)/deps/erlsha2/priv/erlsha2_nif.so
endif
# This test is expected to fail when run in parallel and flock/lockf is not available.
core-autopatch-two-rebar: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
$i "Add two Rebar projects to the list of dependencies"
$t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = epgsql mochiweb\n"}' $(APP)/Makefile
$i "Build the application"
$t $(MAKE) -C $(APP) $v
|