|
| 1 | + |
| 2 | +# VARIABLES # |
| 3 | + |
| 4 | +# Define the path to an executable for downloading a remote resource: |
| 5 | +DEPS_DOWNLOAD_BIN ?= $(TOOLS_DIR)/scripts/download |
| 6 | + |
| 7 | +# Define the path to an executable for verifying a download: |
| 8 | +DEPS_CHECKSUM_BIN ?= $(TOOLS_DIR)/scripts/checksum |
| 9 | + |
| 10 | +# Define the path to an executable for checking CMake: |
| 11 | +DEPS_CHECK_CMAKE ?= $(TOOLS_DIR)/scripts/check_cmake |
| 12 | + |
| 13 | +# Define the path to an executable for checking git: |
| 14 | +DEPS_CHECK_GIT ?= $(TOOLS_DIR)/scripts/check_git |
| 15 | + |
| 16 | +# Define the download URL: |
| 17 | +DEPS_WABT_URL ?= https://github.com/WebAssembly/wabt |
| 18 | + |
| 19 | +# Determine the basename for the download: |
| 20 | +deps_wabt_basename := wabt |
| 21 | + |
| 22 | +# Define the path to the file containing a checksum to verify a download: |
| 23 | +DEPS_WABT_CHECKSUM ?= $(shell cat $(DEPS_CHECKSUMS_DIR)/$(subst .,_,$(deps_wabt_basename))/sha256) |
| 24 | + |
| 25 | +# Define the output path when downloading: |
| 26 | +DEPS_WABT_DOWNLOAD_OUT ?= $(DEPS_TMP_DIR)/$(deps_wabt_basename) |
| 27 | + |
| 28 | +# Define the output path after extracting: |
| 29 | +deps_wabt_extract_out := $(DEPS_BUILD_DIR)/wabt_extracted |
| 30 | + |
| 31 | +# Define the path to the directory containing tests: |
| 32 | +DEPS_WABT_TEST_DIR ?= $(DEPS_DIR)/test/wabt |
| 33 | + |
| 34 | +# Define the output directory path for compiled tests: |
| 35 | +DEPS_WABT_TEST_OUT ?= $(DEPS_WABT_TEST_DIR)/build |
| 36 | + |
| 37 | +# Define the path to a test file for checking an installation: |
| 38 | +DEPS_WABT_TEST_INSTALL ?= $(DEPS_WABT_TEST_DIR)/test_install.wasm |
| 39 | + |
| 40 | +# Define output path for a compiled test file: |
| 41 | +DEPS_WABT_TEST_INSTALL_WAST_OUT ?= $(DEPS_WABT_TEST_OUT)/test.wast |
| 42 | +DEPS_WABT_TEST_INSTALL_WASM_OUT ?= $(DEPS_WABT_TEST_OUT)/test.wasm |
| 43 | + |
| 44 | +# Define the path to the `wasm2wast` utility: |
| 45 | +WASM2WAST ?= $(DEPS_WABT_BUILD_OUT)/wasm2wast |
| 46 | + |
| 47 | +# Define the path to the `wast2wasm` utility: |
| 48 | +WAST2WASM ?= $(DEPS_WABT_BUILD_OUT)/wast2wasm |
| 49 | + |
| 50 | + |
| 51 | +# TARGETS # |
| 52 | + |
| 53 | +# Download. |
| 54 | +# |
| 55 | +# This target downloads the WebAssembly Binary Toolkit (WABT). |
| 56 | + |
| 57 | +$(DEPS_WABT_DOWNLOAD_OUT): | $(DEPS_TMP_DIR) |
| 58 | + $(QUIET) echo 'Downloading WebAssembly Binary Toolkit...' >&2 |
| 59 | + $(QUIET) $(GIT) clone --recursive $(DEPS_WABT_URL) $(DEPS_WABT_DOWNLOAD_OUT) |
| 60 | + |
| 61 | + |
| 62 | +# Extract. |
| 63 | +# |
| 64 | +# This target extracts a download. |
| 65 | + |
| 66 | +$(DEPS_WABT_BUILD_OUT): | $(DEPS_BUILD_DIR) $(DEPS_WABT_DOWNLOAD_OUT) |
| 67 | + $(QUIET) echo 'Extracting WebAssembly Binary Toolkit...' >&2 |
| 68 | + $(QUIET) $(CP) -a $(DEPS_WABT_DOWNLOAD_OUT) $(deps_wabt_extract_out) |
| 69 | + $(QUIET) mv $(deps_wabt_extract_out) $(DEPS_WABT_BUILD_OUT) |
| 70 | + |
| 71 | + |
| 72 | +# Create directory for tests. |
| 73 | +# |
| 74 | +# This target creates a directory for storing compiled tests. |
| 75 | + |
| 76 | +$(DEPS_WABT_TEST_OUT): |
| 77 | + $(QUIET) $(MKDIR_RECURSIVE) $(DEPS_WABT_TEST_OUT) |
| 78 | + |
| 79 | + |
| 80 | +# Compile install WAST test. |
| 81 | +# |
| 82 | +# This target compiles a WAST test file for testing an installation. |
| 83 | + |
| 84 | +$(DEPS_WABT_TEST_INSTALL_WAST_OUT): $(DEPS_WABT_BUILD_OUT) $(DEPS_WABT_TEST_OUT) |
| 85 | + $(QUIET) $(WASM2WAST) $(DEPS_WABT_TEST_INSTALL) \ |
| 86 | + -o $(DEPS_WABT_TEST_INSTALL_WAST_OUT) |
| 87 | + |
| 88 | + |
| 89 | +# Compile install WASM test. |
| 90 | +# |
| 91 | +# This target compiles a WASM test file for testing an installation. |
| 92 | + |
| 93 | +$(DEPS_WABT_TEST_INSTALL_WASM_OUT): $(DEPS_WABT_TEST_INSTALL_WAST_OUT) |
| 94 | + $(QUIET) $(WAST2WASM) $(DEPS_WABT_TEST_INSTALL_WAST_OUT) \ |
| 95 | + -o $(DEPS_WABT_TEST_INSTALL_WASM_OUT) |
| 96 | + |
| 97 | + |
| 98 | +# Download WABT. |
| 99 | +# |
| 100 | +# This target downloads the WebAssembly Binary Toolkit (WABT). |
| 101 | + |
| 102 | +deps-download-wabt: $(DEPS_WABT_DOWNLOAD_OUT) |
| 103 | + |
| 104 | +.PHONY: deps-download-wabt |
| 105 | + |
| 106 | + |
| 107 | +# Verify download. |
| 108 | +# |
| 109 | +# This targets verifies a download. |
| 110 | + |
| 111 | +deps-verify-wabt: deps-download-wabt |
| 112 | + $(QUIET) echo 'Verifying download...' >&2 |
| 113 | + $(QUIET) echo 'Nothing to verify.' >&2 |
| 114 | + |
| 115 | +.PHONY: deps-verify-wabt |
| 116 | + |
| 117 | + |
| 118 | +# Extract WABT. |
| 119 | +# |
| 120 | +# This target extracts a WebAssembly Binary Toolkit (WABT) download. |
| 121 | + |
| 122 | +deps-extract-wabt: $(DEPS_WABT_BUILD_OUT) |
| 123 | + |
| 124 | +.PHONY: deps-extract-wabt |
| 125 | + |
| 126 | + |
| 127 | +# Check for prerequisites. |
| 128 | +# |
| 129 | +# This target checks a host system for installation prerequisites. |
| 130 | + |
| 131 | +deps-prerequisites-wabt: |
| 132 | + $(QUIET) $(DEPS_CHECK_CMAKE) |
| 133 | + $(QUIET) $(DEPS_CHECK_GIT) |
| 134 | + |
| 135 | +.PHONY: deps-prerequisites-wabt |
| 136 | + |
| 137 | + |
| 138 | +# Install WABT. |
| 139 | +# |
| 140 | +# This target performs a WebAssembly Binary Toolkit (WABT) install sequence. |
| 141 | + |
| 142 | +deps-install-wabt: $(DEPS_WABT_BUILD_OUT) deps-prerequisites-wabt |
| 143 | + $(QUIET) cd $(DEPS_WABT_BUILD_OUT) && $(CMAKE) . && $(MAKE) |
| 144 | + |
| 145 | +.PHONY: deps-install-wabt |
| 146 | + |
| 147 | + |
| 148 | +# Update WABT. |
| 149 | +# |
| 150 | +# This target updates the WebAssemby Binary Toolkit (WABT). |
| 151 | + |
| 152 | +deps-update-wabt: $(DEPS_WABT_BUILD_OUT) |
| 153 | + $(QUIET) cd $(DEPS_WABT_BUILD_OUT) && \ |
| 154 | + $(GIT) pull && \ |
| 155 | + $(GIT) submodule update --init --recursive && \ |
| 156 | + $(DELETE) $(DELETE_FLAGS) $(DEPS_WABT_BUILD_OUT)/out && |
| 157 | + $(CMAKE) . && \ |
| 158 | + $(MAKE) |
| 159 | + |
| 160 | +.PHONY: deps-update-wabt |
| 161 | + |
| 162 | + |
| 163 | +# Test install. |
| 164 | +# |
| 165 | +# This target tests an installation. |
| 166 | + |
| 167 | +deps-test-wabt: $(DEPS_WABT_TEST_INSTALL_WAST_OUT) $(DEPS_WABT_TEST_INSTALL_WASM_OUT) |
| 168 | + $(QUIET) echo '' >&2 |
| 169 | + $(QUIET) echo 'Success.' >&2 |
| 170 | + |
| 171 | +.PHONY: deps-test-wabt |
| 172 | + |
| 173 | + |
| 174 | +# Install WABT. |
| 175 | +# |
| 176 | +# This target installs the WebAsembly Binary Toolkit (WABT). |
| 177 | + |
| 178 | +install-deps-wabt: deps-download-wabt deps-verify-wabt deps-extract-wabt deps-install-wabt deps-test-wabt |
| 179 | + |
| 180 | +.PHONY: install-deps-wabt |
| 181 | + |
| 182 | + |
| 183 | +# Clean WABT. |
| 184 | +# |
| 185 | +# This target removes a WebAssembly Binary Toolkit (WABT) install (but does not remove a download if one exists). |
| 186 | + |
| 187 | +clean-deps-wabt: clean-deps-wabt-tests |
| 188 | + $(QUIET) $(DELETE) $(DELETE_FLAGS) $(DEPS_WABT_BUILD_OUT) |
| 189 | + |
| 190 | +.PHONY: clean-deps-wabt |
| 191 | + |
| 192 | + |
| 193 | +# Clean installation tests. |
| 194 | +# |
| 195 | +# This target remove installation tests. |
| 196 | + |
| 197 | +clean-deps-wabt-tests: |
| 198 | + $(QUIET) $(DELETE) $(DELETE_FLAGS) $(DEPS_WABT_TEST_OUT) |
| 199 | + |
| 200 | +.PHONY: clean-deps-wabt-tests |
0 commit comments