forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwabt.mk
More file actions
236 lines (197 loc) · 5.84 KB
/
wabt.mk
File metadata and controls
236 lines (197 loc) · 5.84 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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#/
# @license Apache-2.0
#
# Copyright (c) 2017 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/
# VARIABLES #
# Define the path to an executable for checking CMake:
DEPS_CHECK_CMAKE ?= $(TOOLS_DIR)/scripts/check_cmake
# Define the path to an executable for checking git:
DEPS_CHECK_GIT ?= $(TOOLS_DIR)/scripts/check_git
# Define the download URL:
DEPS_WABT_URL ?= https://github.com/WebAssembly/wabt
# Determine the basename for the download:
deps_wabt_basename := wabt
# Define the path to the file containing a checksum to verify a download:
DEPS_WABT_CHECKSUM ?= $(shell $(CAT) $(DEPS_CHECKSUMS_DIR)/$(subst .,_,$(deps_wabt_basename))/sha256)
# Define the output path when downloading:
DEPS_WABT_DOWNLOAD_OUT ?= $(DEPS_TMP_DIR)/$(deps_wabt_basename)
# Define the output path after extracting:
deps_wabt_extract_out := $(DEPS_BUILD_DIR)/wabt_extracted
# Define the path to the directory containing tests:
DEPS_WABT_TEST_DIR ?= $(DEPS_DIR)/test/wabt
# Define the output directory path for compiled tests:
DEPS_WABT_TEST_OUT ?= $(DEPS_WABT_TEST_DIR)/build
# Define the path to a test file for checking an installation:
DEPS_WABT_TEST_INSTALL ?= $(DEPS_WABT_TEST_DIR)/test_install.wasm
# Define output path for a compiled test file:
DEPS_WABT_TEST_INSTALL_WAT_OUT ?= $(DEPS_WABT_TEST_OUT)/test.wat
DEPS_WABT_TEST_INSTALL_WASM_OUT ?= $(DEPS_WABT_TEST_OUT)/test.wasm
# RULES #
#/
# Downloads the WebAssembly Binary Toolkit (WABT).
#
# @private
#/
$(DEPS_WABT_DOWNLOAD_OUT): | $(DEPS_TMP_DIR)
$(QUIET) echo 'Downloading WebAssembly Binary Toolkit...' >&2
$(QUIET) $(GIT) clone --recursive $(DEPS_WABT_URL) $(DEPS_WABT_DOWNLOAD_OUT)
#/
# Extracts a WebAssembly Binary Toolkit (WABT) download.
#
# @private
#/
$(DEPS_WABT_BUILD_OUT): | $(DEPS_BUILD_DIR) $(DEPS_WABT_DOWNLOAD_OUT)
$(QUIET) echo 'Extracting WebAssembly Binary Toolkit...' >&2
$(QUIET) $(CP) -a $(DEPS_WABT_DOWNLOAD_OUT) $(deps_wabt_extract_out)
$(QUIET) mv $(deps_wabt_extract_out) $(DEPS_WABT_BUILD_OUT)
#/
# Creates a directory for storing compiled tests for testing a WebAssembly Binary Toolkit (WABT) installation.
#
# @private
#/
$(DEPS_WABT_TEST_OUT):
$(QUIET) $(MKDIR_RECURSIVE) $(DEPS_WABT_TEST_OUT)
#/
# Compiles a WAT test file for testing a WebAssembly Binary Toolkit (WABT) installation.
#
# @private
#/
$(DEPS_WABT_TEST_INSTALL_WAT_OUT): $(DEPS_WABT_BUILD_OUT) $(DEPS_WABT_TEST_OUT)
$(QUIET) $(DEPS_WABT_WASM2WAT) $(DEPS_WABT_TEST_INSTALL) \
-o $(DEPS_WABT_TEST_INSTALL_WAT_OUT)
#/
# Compiles a WASM test file for testing a WebAssembly Binary Toolkit (WABT) installation.
#
# @private
#/
$(DEPS_WABT_TEST_INSTALL_WASM_OUT): $(DEPS_WABT_TEST_INSTALL_WAT_OUT)
$(QUIET) $(DEPS_WABT_WAT2WASM) $(DEPS_WABT_TEST_INSTALL_WAT_OUT) \
-o $(DEPS_WABT_TEST_INSTALL_WASM_OUT)
#/
# Downloads the WebAssembly Binary Toolkit (WABT).
#
# @private
#
# @example
# make deps-download-wabt
#/
deps-download-wabt: $(DEPS_WABT_DOWNLOAD_OUT)
.PHONY: deps-download-wabt
#/
# Verifies a WebAssembly Binary Toolkit (WABT) download.
#
# @private
#
# @example
# make deps-verify-wabt
#/
deps-verify-wabt: deps-download-wabt
$(QUIET) echo 'Verifying download...' >&2
$(QUIET) echo 'Nothing to verify.' >&2
.PHONY: deps-verify-wabt
#/
# Extracts a WebAssembly Binary Toolkit (WABT) download.
#
# @private
#
# @example
# make deps-extract-wabt
#/
deps-extract-wabt: $(DEPS_WABT_BUILD_OUT)
.PHONY: deps-extract-wabt
#/
# Checks a host system for WebAssembly Binary Toolkit (WABT) installation prerequisites.
#
# @private
#
# @example
# make deps-prerequisites-wabt
#/
deps-prerequisites-wabt:
$(QUIET) $(DEPS_CHECK_CMAKE)
$(QUIET) $(DEPS_CHECK_GIT)
.PHONY: deps-prerequisites-wabt
#/
# Installs WebAssembly Binary Toolkit (WABT).
#
# @private
#
# @example
# make deps-install-wabt
#/
deps-install-wabt: $(DEPS_WABT_BUILD_OUT) deps-prerequisites-wabt
$(QUIET) cd $(DEPS_WABT_BUILD_OUT) && \
$(MKDIR_RECURSIVE) build && \
cd build && \
$(CMAKE) .. && \
$(CMAKE) --build .
.PHONY: deps-install-wabt
#/
# Updates the WebAssembly Binary Toolkit (WABT).
#
# @private
#
# @example
# make deps-update-wabt
#/
deps-update-wabt: $(DEPS_WABT_BUILD_OUT)
$(QUIET) cd $(DEPS_WABT_BUILD_OUT) && \
$(GIT) pull && \
$(GIT) submodule update --init --recursive && \
$(DELETE) $(DELETE_FLAGS) $(DEPS_WABT_BUILD_OUT)/build &&
$(MKDIR_RECURSIVE) $(DEPS_WABT_BUILD_OUT)/build && \
cd $(DEPS_WABT_BUILD_OUT)/build && \
$(CMAKE) .. && \
$(CMAKE) --build .
.PHONY: deps-update-wabt
#/
# Tests a WebAssembly Binary Toolkit (WABT) installation.
#
# @private
#
# @example
# make deps-test-wabt
#/
deps-test-wabt: $(DEPS_WABT_TEST_INSTALL_WAT_OUT) $(DEPS_WABT_TEST_INSTALL_WASM_OUT)
$(QUIET) echo '' >&2
$(QUIET) echo 'Success.' >&2
.PHONY: deps-test-wabt
#/
# Installs the WebAssembly Binary Toolkit (WABT).
#
# @example
# make install-deps-wabt
#/
install-deps-wabt: deps-download-wabt deps-verify-wabt deps-extract-wabt deps-install-wabt deps-test-wabt
.PHONY: install-deps-wabt
#/
# Removes a WebAssembly Binary Toolkit (WABT) install (but does not remove a download if one exists).
#
# @example
# make clean-deps-wabt
#/
clean-deps-wabt: clean-deps-wabt-tests
$(QUIET) $(DELETE) $(DELETE_FLAGS) $(DEPS_WABT_BUILD_OUT)
.PHONY: clean-deps-wabt
#/
# Removes WebAssembly Binary Toolkit (WABT) installation tests.
#
# @example
# make clean-deps-wabt-tests
#/
clean-deps-wabt-tests:
$(QUIET) $(DELETE) $(DELETE_FLAGS) $(DEPS_WABT_TEST_OUT)
.PHONY: clean-deps-wabt-tests