Skip to content

Commit 4655966

Browse files
committed
Add build and install targets for the iBeacon plugin
1 parent c004a54 commit 4655966

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Build the Battery Level plugin and install it into the app's bundled plugins.
2+
#
3+
# Requires the Embedded Swift WASM SDK:
4+
# swift sdk install <swift-<version>_wasm-embedded artifact bundle URL>
5+
# and binaryen for wasm-opt (brew install binaryen).
6+
7+
SWIFT_SDK ?= swift-6.3.3-RELEASE_wasm-embedded
8+
PRODUCT := IBeacon
9+
BUILT := .build/wasm32-unknown-wasip1/release/$(PRODUCT).wasm
10+
INSTALL := ../../../Sources/BluetoothExplorerPluginEngine/Plugins
11+
MODULE := ibeacon.wasm
12+
MANIFEST := $(INSTALL)/ibeacon.bleplugin.json
13+
14+
.PHONY: build opt install clean
15+
16+
build:
17+
swift build -c release --swift-sdk $(SWIFT_SDK) --product $(PRODUCT)
18+
19+
opt: build
20+
wasm-opt -Oz --enable-bulk-memory --enable-sign-ext $(BUILT) -o $(MODULE)
21+
22+
# Install the optimized module and refresh the manifest's sha256.
23+
install: opt
24+
cp $(MODULE) $(INSTALL)/$(MODULE)
25+
@HASH=$$(shasum -a 256 $(INSTALL)/$(MODULE) | awk '{print $$1}'); \
26+
/usr/bin/sed -i '' -E "s/\"sha256\" : \"[0-9a-f]*\"/\"sha256\" : \"$$HASH\"/; s/\"sha256\": \"[0-9a-f]*\"/\"sha256\": \"$$HASH\"/" $(MANIFEST); \
27+
echo "installed $(MODULE) sha256=$$HASH"
28+
29+
clean:
30+
rm -rf .build $(MODULE)

0 commit comments

Comments
 (0)