This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (115 loc) · 4.86 KB
/
Copy pathMakefile
File metadata and controls
158 lines (115 loc) · 4.86 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
MODE ?= release
top_srcdir ?= ..
include $(top_srcdir)/Makefile.common
########## LiveCode Script test parameters
TEST_DIR ?= $(top_srcdir)/_tests
LCM_DIR ?= $(TEST_DIR)/_build
# When running on headless Linux, run tests in -ui mode.
LCS_ENGINE ?= $(guess_engine)
LCS_ENGINE_FLAGS ?= $(guess_engine_flags)
LCS_LOG = _lcs_test_suite.log
LCS_TESTRUNNER ?= $(top_srcdir)/tests/_testrunner.livecodescript
LCS_TESTS_DIR ?= $(top_srcdir)/tests/lcs
ifeq ($(LCS_TESTENGINE),development)
LCS_CMD = $(LCS_ENGINE) $(LCS_ENGINE_FLAGS) $(LCS_TESTRUNNER) run $(guess_dev_engine) $(LCS_ENGINE_FLAGS)
else
LCS_CMD = $(LCS_ENGINE) $(LCS_ENGINE_FLAGS) $(LCS_TESTRUNNER) run $(LCS_TESTS_DIR)
endif
########## LiveCode Builder test parameters
MODULE_DIR ?= $(bin_dir)/modules/lci
LC_COMPILE ?= $(bin_dir)/lc-compile
LC_COMPILE_FLAGS += --modulepath $(LCM_DIR) --modulepath $(MODULE_DIR)
LC_RUN ?= $(bin_dir)/lc-run
LCB_LOG = _lcb_test_suite.log
LCB_TESTRUNNER = $(LCM_DIR)/_testrunner.lcm
LCB_TESTLIB = $(LCM_DIR)/_testlib.lcm
########## LiveCode Builder Compiler test parameters
LCC_COMPILERTESTRUNNER ?= $(top_srcdir)/tests/_compilertestrunner.livecodescript
LCC_CMD = $(LCS_ENGINE) -ui $(LCC_COMPILERTESTRUNNER) run
LCC_LOG = _compiler_test_suite.log
################################################################
# Top-level targets
################################################################
.DEFAULT: check
check: lcs-check lcb-check compiler-check
clean:
-rm -rf $(TEST_DIR) $(LCS_LOG) $(LCB_LOG)
.PHONY: check clean
################################################################
# LCB test compilation rules
################################################################
LCM_SOURCES ?= $(patsubst ./%,%,$(shell find . -name '*.lcb' | sort))
LCM_LIB_SOURCES = $(shell for f in $(LCM_SOURCES); do echo $$f | grep '_[^/]*.lcb$$'; done)
LCM_TEST_SOURCES ?= $(shell for f in $(LCM_SOURCES); do echo $$f | grep -v '_[^/]*.lcb$$'; done)
LCM_MODULES = $(patsubst %.lcb,$(LCM_DIR)/%.lcm,$(LCM_SOURCES))
LCM_TEST_MODULES = $(patsubst %.lcb,$(LCM_DIR)/%.lcm,$(LCM_TEST_SOURCES))
########## Build dependencies rules
ifneq ($(LCM_SOURCES),)
include $(LCM_DIR)/deps.mk
endif
$(LCM_DIR):
mkdir -p $(LCM_DIR)
# We need to rewrite some of the rules to make sure that lcm files
# inherit the correct dependencies. Specifically, we need to make
# sure that .lcm files depend on all the same things that their
# corresponding .lci files depend on.
$(LCM_DIR)/deps.mk: $(LCM_SOURCES) Makefile $(LC_COMPILE) | $(LCM_DIR)
@set -e; rm -f $@; \
for lcb in $(LCM_SOURCES); do \
lcm=`echo $$lcb | sed 's/lcb$$/lcm/'` ; \
$(LC_COMPILE) $(LC_COMPILE_FLAGS) --deps make \
--output $(LCM_DIR)/$$lcm -- $$lcb >> $@; \
done; \
$(LC_COMPILE) $(LC_COMPILE_FLAGS) --deps make -- $(LCM_SOURCES) >> $@ ; \
sed -i 's,\(.* \([^ ]*\)\.lcb\)$$,$(LCM_DIR)/\2.lcm \1,g' $@
########## Build rules
lcm_compile: $(LCM_MODULES)
$(LCM_DIR)/%.lcm: %.lcb | $(LCM_DIR)
@set -e; \
cmd="mkdir -p $$(dirname $@)" ; \
echo "$$cmd" $(_PRINT_RULE); \
$$cmd
@set -e; \
cmd="$(LC_COMPILE) $(LC_COMPILE_FLAGS) --output $@ -- $<" ; \
echo "$$cmd" $(_PRINT_RULE); \
$$cmd
.PHONY: lcm_compile
################################################################
# Engine-based tests
################################################################
lcs-check: $(LCS_ENGINE) lcm_compile
@rm -f $(LCS_LOG)
@cmd="$(LCS_CMD)"; \
echo "$$cmd" $(_PRINT_RULE); \
$$cmd
.PHONY: lcs-check
################################################################
# LCB compiler tests
################################################################
compiler-check: $(LC_COMPILE)
@rm -f $(LCC_LOG)
@export LC_COMPILE="$(LC_COMPILE)"; \
export LCC_VERBOSE="$(LCC_VERBOSE)"; \
cmd="$(LCC_CMD)"; \
echo "$$cmd" $(_PRINT_RULE); \
$$cmd
################################################################
# LCB-only tests
################################################################
LCB_TEST_LOGS = $(patsubst %.lcb,$(TEST_DIR)/%.log,$(LCM_TEST_SOURCES))
LC_RUN_FLAGS += -l $(LCB_TESTLIB)
lcb-check: lcm_compile
@set -e; \
for lcbfile in $(LCM_TEST_SOURCES); do \
lcmfile="$(LCM_DIR)/`echo $$lcbfile | sed -e 's:lcb$$:lcm:'`" ; \
logfile="$(TEST_DIR)/`echo $$lcbfile | sed -e's:lcb$$:log:'`" ; \
parent="`echo $$lcbfile | sed -e 's:.*/\([^/]*\)/tests.*$$:\1:'`"; \
loadfile="$(LCM_DIR)/`echo $$lcbfile | sed -e 's:tests/.*\.lcb$$::'`$$parent.lcm"; \
mkdir -p `dirname $$logfile`; \
if [ -e $$loadfile ] ; then \
$(LC_RUN) $(LC_RUN_FLAGS) --handler RunModuleTests -- $(LCB_TESTRUNNER) --lc-run "$(LC_RUN) --load $$loadfile $(LC_RUN_FLAGS)" $$lcmfile > $$logfile; \
else \
$(LC_RUN) $(LC_RUN_FLAGS) --handler RunModuleTests -- $(LCB_TESTRUNNER) --lc-run "$(LC_RUN) $(LC_RUN_FLAGS)" $$lcmfile > $$logfile; \
fi; \
done; \
$(LC_RUN) $(LC_RUN_FLAGS) --handler SummarizeTests -- $(LCB_TESTRUNNER) --summary-log $(LCB_LOG) $(LCB_TEST_LOGS)