-
Notifications
You must be signed in to change notification settings - Fork 55
/
Makefile
203 lines (171 loc) · 6.04 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# Server executable file:
ROOTDIR=$(shell pwd)
# ALS version
VERSION ?=
# ALS build date
BUILD_DATE ?=
# CPU limit
PROCESSORS ?= 0
# Define platform-specific variables
ifeq ($(OS),Windows_NT)
PYTHON=python.exe
EXE=.exe
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS=unix
else ifeq ($(UNAME_S),Darwin)
OS=osx
endif
PYTHON=python3
EXE=
endif
# Location of home dir for tests
export ALS_HOME=$(ROOTDIR)/testsuite
# Command to run for tests
export ALS=$(ROOTDIR)/.obj/server/ada_language_server$(EXE)
# Tester files
TESTER=$(ROOTDIR)/.obj/tester/tester-run$(EXE)
# Env variable to set for update VS Code test references
MOCHA_ALS_UPDATE=
GPRBUILD_CARGS ?=
GPRBUILD_EXTRA ?=
GPRBUILD_FLAGS=-m -j$(PROCESSORS) $(GPRBUILD_EXTRA)
GPRBUILD=gprbuild $(GPRBUILD_FLAGS) -XSUPERPROJECT=
GPRCLEAN_EXTRA=
GPRCLEAN=gprclean -XSUPERPROJECT= $(GPRCLEAN_EXTRA)
# Installation directory
prefix ?= /usr/local
ifeq ($(DESTDIR),)
DESTDIR=$(prefix)
endif
# Library type
LIBRARY_TYPE?=relocatable
# Build mode (dev or prod)
BUILD_MODE?=dev
# Whether to enable coverage (empty for no, any other value for yes)
COVERAGE=
COVERAGE_INSTR=gnatcov instrument --level stmt $(LIBRARY_FLAGS) \
--dump-trigger=atexit --no-subprojects
ifeq (,$(shell which node))
# Node is not available so do not define node-related variables
else
# Set NODE variable as an indicator that node is available
NODE=node
# Obtain architecture and platform from the node executable. This information
# is used to deposit the ALS executable at the location expected by the VS
# Code Ada extension.
NODE_ARCH=$(shell node -e "console.log(process.arch)")
NODE_PLATFORM=$(shell node -e "console.log(process.platform)")
NODE_ARCH_PLATFORM ?= $(NODE_ARCH)/$(NODE_PLATFORM)
endif
VSCE=npx vsce
LIBRARY_FLAGS=-XBUILD_MODE=$(BUILD_MODE) \
-XOS=$(OS) \
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
-XXMLADA_BUILD=$(LIBRARY_TYPE) \
-XGPR_BUILD=$(LIBRARY_TYPE)
BUILD_FLAGS=$(LIBRARY_FLAGS)
ifeq ($(COVERAGE),)
COVERAGE_BUILD_FLAGS= $(LIBRARY_FLAGS)
else
COVERAGE_BUILD_FLAGS= $(LIBRARY_FLAGS) \
--implicit-with=gnatcov_rts \
--src-subdirs=gnatcov-instr \
-XALS_WARN_ERRORS=false \
-XSPAWN_WARN_ERRORS=false \
-gnatyN
endif
ifeq ($(ALIRE),True)
# When we use Alire to build ALS we expect BUILD_MODE and LIBRARY_TYPE
# is already set (see build_als.sh). OS is set in spawn crate TOML file.
# That's why we don't need FLAGS here.
COVERAGE_BUILD_FLAGS=
BUILD_FLAGS=
endif
all: coverage-instrument
ifeq ($(ALIRE),True)
alr build -- -XVERSION=$(VERSION) -XBUILD_DATE=$(BUILD_DATE) $(GPRBUILD_FLAGS)
else
# We have our own s-memory.adb which overwrites the default System.Memory implementation
# For unclear reasons, this file is not recompiled when the version of GNAT was changed
# and we get link errors. As a workaround, we force its recompilation explicitly here.
$(GPRBUILD) -d -ws -c -u -P gnat/lsp_server.gpr -p $(BUILD_FLAGS) s-memory.adb
$(GPRBUILD) -P gnat/lsp_server.gpr -p $(COVERAGE_BUILD_FLAGS) \
-XVERSION=$(VERSION) -XBUILD_DATE=$(BUILD_DATE) $(GPRBUILD_CARGS)
endif
$(GPRBUILD) -P gnat/lsp_3_17.gpr -p $(COVERAGE_BUILD_FLAGS) $(GPRBUILD_CARGS)
$(GPRBUILD) -P gnat/tester.gpr -p $(BUILD_FLAGS) $(GPRBUILD_CARGS)
$(GPRBUILD) -P gnat/lsp_client.gpr -p $(COVERAGE_BUILD_FLAGS) $(GPRBUILD_CARGS)
ifdef NODE
mkdir -p integration/vscode/ada/$(NODE_ARCH_PLATFORM)
cp -v -f $(ALS) integration/vscode/ada/$(NODE_ARCH_PLATFORM)
endif
generate:
python scripts/generate.py
make -C source/lsp_gen
generate_io:
python scripts/io_gen.py
coverage-instrument:
ifneq ($(COVERAGE),)
# Remove artifacts from previous instrumentations, so that stale units that
# are not overriden by new ones don't get in our way.
rm -rf .obj/*/gnatcov-instr
$(COVERAGE_INSTR) -XVERSION=$(VERSION) -XBUILD_DATE=$(BUILD_DATE) \
-Pgnat/lsp_server.gpr --projects lsp_server --projects lsp_3_17
endif
install:
gprinstall -f -P gnat/lsp_server.gpr -p -r --mode=usage \
--prefix=$(DESTDIR) $(LIBRARY_FLAGS)
gprinstall -f -P gnat/tester.gpr -p --prefix=$(DESTDIR) $(LIBRARY_FLAGS)
gprinstall -f -P gnat/lsp_client.gpr -p -r \
--mode=dev \
--prefix=$(DESTDIR) \
$(LIBRARY_FLAGS)
ifneq ($(COVERAGE),)
mkdir -p $(DESTDIR)/share/als/sids || true
cp .obj/*/*.sid $(DESTDIR)/share/als/sids/
endif
clean:
-$(GPRCLEAN) -P gnat/lsp.gpr $(LIBRARY_FLAGS)
-$(GPRCLEAN) -P gnat/lsp_3_17.gpr $(LIBRARY_FLAGS)
-$(GPRCLEAN) -P gnat/lsp_server.gpr $(LIBRARY_FLAGS)
-$(GPRCLEAN) -P gnat/tester.gpr $(LIBRARY_FLAGS)
-rm -rf integration/vscode/ada/$(NODE_ARCH_PLATFORM)
vscode:
ifneq ($(npm_config_offline),true)
# These commands may try to contact remote servers so if npm is configured to
# run in offline mode, don't bother running them
cd integration/vscode/ada; LD_LIBRARY_PATH= npm install --no-audit
cd integration/vscode/ada; LD_LIBRARY_PATH= npm run check-licenses
endif
cd integration/vscode/ada; LD_LIBRARY_PATH= npm run compile
cd integration/vscode/ada; LD_LIBRARY_PATH= npm run cilint
@echo Now run:
@echo code --extensionDevelopmentPath=`pwd`/integration/vscode/ada/ `pwd`
ifeq ($(COVERAGE),)
NPM_TEST_ARGS?=
else
NPM_TEST_ARGS?=-- --coverage --coverage-reporter text-summary --coverage-reporter html --coverage-reporter cobertura --label 0
endif
vscode-test:
# Run the VS Code integration testsuite.
cd integration/vscode/ada; MOCHA_ALS_UPDATE=$(MOCHA_ALS_UPDATE) LD_LIBRARY_PATH= npm run test $(NPM_TEST_ARGS)
vscode-package:
cd integration/vscode/ada; LD_LIBRARY_PATH= $(VSCE) package
check: all
set -e; \
export PYTHON=$(PYTHON); \
if [ `$(PYTHON) -c "import e3,sys;print('e3' in sys.modules)"` = "True" ]; then\
(cd testsuite ; sh run.sh $(test)) ; \
else \
for a in testsuite/*_lsp/*/*.json; do \
echo $$a ; \
(cd `dirname $$a ` ; $(TESTER) `basename $$a`) ;\
done; \
fi
deploy: check
integration/$(USER)/deploy.sh $(NODE_PLATFORM)
# Instantiates the VS Code workspace with default settings
configure:
cp .vscode/settings.json.tmpl .vscode/settings.json