|
| 1 | + |
| 2 | +# VARIABLES # |
| 3 | + |
| 4 | +# Define the download URL: |
| 5 | +DEPS_ELECTRON_URL ?= https://github.com/electron/electron/releases/download/v$(DEPS_ELECTRON_VERSION)/electron-v$(DEPS_ELECTRON_VERSION)-$(DEPS_ELECTRON_PLATFORM)-$(DEPS_ELECTRON_ARCH).zip |
| 6 | + |
| 7 | +# Determine the basename for the download: |
| 8 | +deps_electron_basename := $(notdir $(DEPS_ELECTRON_URL)) |
| 9 | + |
| 10 | +# Define the path to the file containing a checksum verify a download: |
| 11 | +DEPS_ELECTRON_CHECKSUM ?= $(shell cat $(DEPS_CHECKSUMS_DIR)/$(subst .,_,$(subst -,_,$(deps_electron_basename)))/sha256) |
| 12 | + |
| 13 | +# Define the output path when downloading: |
| 14 | +DEPS_ELECTRON_DOWNLOAD_OUT ?= $(DEPS_TMP_DIR)/$(deps_electron_basename) |
| 15 | + |
| 16 | +# Define the path to the directory containing tests: |
| 17 | +DEPS_ELECTRON_TEST_DIR ?= $(DEPS_DIR)/test/electron |
| 18 | + |
| 19 | +# Define the path to a test file for checking an installation: |
| 20 | +DEPS_ELECTRON_TEST_INSTALL ?= $(DEPS_ELECTRON_TEST_DIR)/test_install.js |
| 21 | + |
| 22 | + |
| 23 | +# TARGETS # |
| 24 | + |
| 25 | +# Download. |
| 26 | +# |
| 27 | +# This target downloads an Electron distribution. |
| 28 | + |
| 29 | +$(DEPS_ELECTRON_DOWNLOAD_OUT): | $(DEPS_TMP_DIR) |
| 30 | + $(QUIET) echo 'Downloading Electron...' >&2 |
| 31 | + $(QUIET) $(DEPS_DOWNLOAD_BIN) $(DEPS_ELECTRON_URL) $(DEPS_ELECTRON_DOWNLOAD_OUT) |
| 32 | + |
| 33 | + |
| 34 | +# Extract. |
| 35 | +# |
| 36 | +# This target extracts a ZIP archive. |
| 37 | + |
| 38 | +$(DEPS_ELECTRON_BUILD_OUT): $(DEPS_ELECTRON_DOWNLOAD_OUT) | $(DEPS_BUILD_DIR) |
| 39 | + $(QUIET) echo 'Extracting Electron...' >&2 |
| 40 | + $(QUIET) $(UNZIP) -q $(DEPS_ELECTRON_DOWNLOAD_OUT) -d $@ |
| 41 | + |
| 42 | + |
| 43 | +# Download Electron. |
| 44 | +# |
| 45 | +# This target downloads an Electron distribution. |
| 46 | + |
| 47 | +deps-download-electron: $(DEPS_ELECTRON_DOWNLOAD_OUT) |
| 48 | + |
| 49 | +.PHONY: deps-download-electron |
| 50 | + |
| 51 | + |
| 52 | +# Verify download. |
| 53 | +# |
| 54 | +# This targets verifies a download. |
| 55 | + |
| 56 | +deps-verify-electron: deps-download-electron |
| 57 | + $(QUIET) echo 'Verifying download...' >&2 |
| 58 | + $(QUIET) $(DEPS_CHECKSUM_BIN) $(DEPS_ELECTRON_DOWNLOAD_OUT) $(DEPS_ELECTRON_CHECKSUM) >&2 |
| 59 | + |
| 60 | +.PHONY: deps-verify-electron |
| 61 | + |
| 62 | + |
| 63 | +# Extract Electron. |
| 64 | +# |
| 65 | +# This target extracts an Electron download. |
| 66 | + |
| 67 | +deps-extract-electron: $(DEPS_ELECTRON_BUILD_OUT) |
| 68 | + |
| 69 | +.PHONY: deps-extract-electron |
| 70 | + |
| 71 | + |
| 72 | +# Test install. |
| 73 | +# |
| 74 | +# This target tests an installation. |
| 75 | + |
| 76 | +deps-test-electron: $(DEPS_ELECTRON_TEST_INSTALL) |
| 77 | + $(QUIET) echo 'Running tests...' >&2 |
| 78 | + $(QUIET) $(NODE) $(DEPS_ELECTRON_TEST_INSTALL) |
| 79 | + $(QUIET) echo '' >&2 |
| 80 | + $(QUIET) echo 'Success.' >&2 |
| 81 | + |
| 82 | +.PHONY: deps-test-electron |
| 83 | + |
| 84 | + |
| 85 | +# Install Electron. |
| 86 | +# |
| 87 | +# This target installs Electron. |
| 88 | + |
| 89 | +install-deps-electron: deps-download-electron deps-verify-electron deps-extract-electron deps-test-electron |
| 90 | + |
| 91 | +.PHONY: install-deps-electron |
| 92 | + |
| 93 | + |
| 94 | +# Clean Electron. |
| 95 | +# |
| 96 | +# This target removes an Electron distribution (but does not remove an Electron download if one exists). |
| 97 | + |
| 98 | +clean-deps-electron: clean-deps-electron-tests |
| 99 | + $(QUIET) $(DELETE) $(DELETE_FLAGS) $(DEPS_ELECTRON_BUILD_OUT) |
| 100 | + |
| 101 | +.PHONY: clean-deps-electron |
| 102 | + |
| 103 | + |
| 104 | +# Clean tests. |
| 105 | +# |
| 106 | +# This targets remove installation tests. |
| 107 | + |
| 108 | +clean-deps-electron-tests: |
| 109 | + |
| 110 | +.PHONY: clean-deps-electron-tests |
0 commit comments