forked from samcamwilliams/HyperBEAM
-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (116 loc) · 4.38 KB
/
Makefile
File metadata and controls
133 lines (116 loc) · 4.38 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
.PHONY: compile
compile:
rebar3 compile
WAMR_VERSION = 2.2.0
WAMR_DIR = _build/wamr
GENESIS_WASM_BRANCH = feat/hb-unit
GENESIS_WASM_REPO = https://github.com/permaweb/ao.git
GENESIS_WASM_SERVER_DIR = _build/genesis_wasm/genesis-wasm-server
HYPERBUDDY_UI_REPO = https://github.com/permaweb/hb-explorer
HYPERBUDDY_UI_PACKAGE_JSON = https://raw.githubusercontent.com/permaweb/hb-explorer/main/package.json
HYPERBUDDY_UI_TARGET = src/html/hyperbuddy@1.0/bundle.js
ARWEAVE_GATEWAY = https://arweave.net
ifdef HB_DEBUG
WAMR_FLAGS = -DWAMR_ENABLE_LOG=1 -DWAMR_BUILD_DUMP_CALL_STACK=1 -DCMAKE_BUILD_TYPE=Debug
else
WAMR_FLAGS = -DCMAKE_BUILD_TYPE=Release
endif
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Darwin)
WAMR_BUILD_PLATFORM = darwin
ifeq ($(UNAME_M),arm64)
WAMR_BUILD_TARGET = AARCH64
else
WAMR_BUILD_TARGET = X86_64
endif
else
WAMR_BUILD_PLATFORM = linux
WAMR_BUILD_TARGET = X86_64
endif
wamr: $(WAMR_DIR)/lib/libvmlib.a
debug: debug-clean $(WAMR_DIR)
HB_DEBUG=1 make $(WAMR_DIR)/lib/libvmlib.a
CFLAGS="-DHB_DEBUG=1" rebar3 compile
debug-clean:
rm -rf priv
rm -rf $(WAMR_DIR)
# Clone the WAMR repository at our target release
$(WAMR_DIR):
git clone \
https://github.com/bytecodealliance/wasm-micro-runtime.git \
$(WAMR_DIR) \
-b WAMR-$(WAMR_VERSION) \
--single-branch
$(WAMR_DIR)/lib/libvmlib.a: $(WAMR_DIR)
@if ! grep -Fq 'tbl_inst->is_table64 = 1;' ./_build/wamr/core/iwasm/aot/aot_runtime.c; then \
awk 'NR == 742 { print; print "tbl_inst->is_table64 = 1;"; next } { print }' \
./_build/wamr/core/iwasm/aot/aot_runtime.c > ./_build/wamr/core/iwasm/aot/aot_runtime.c.tmp && \
mv ./_build/wamr/core/iwasm/aot/aot_runtime.c.tmp ./_build/wamr/core/iwasm/aot/aot_runtime.c; \
fi; \
cmake \
$(WAMR_FLAGS) \
-S $(WAMR_DIR) \
-B $(WAMR_DIR)/lib \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DWAMR_BUILD_TARGET=$(WAMR_BUILD_TARGET) \
-DWAMR_BUILD_PLATFORM=$(WAMR_BUILD_PLATFORM) \
-DWAMR_BUILD_MEMORY64=1 \
-DWAMR_DISABLE_HW_BOUND_CHECK=1 \
-DWAMR_BUILD_EXCE_HANDLING=1 \
-DWAMR_BUILD_SHARED_MEMORY=0 \
-DWAMR_BUILD_AOT=1 \
-DWAMR_BUILD_LIBC_WASI=0 \
-DWAMR_BUILD_FAST_INTERP=0 \
-DWAMR_BUILD_INTERP=1 \
-DWAMR_BUILD_JIT=0 \
-DWAMR_BUILD_FAST_JIT=0 \
-DWAMR_BUILD_DEBUG_AOT=1 \
-DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_AOT_STACK_FRAME=1 \
-DWAMR_BUILD_MEMORY_PROFILING=1 \
-DWAMR_BUILD_DUMP_CALL_STACK=1
make -C $(WAMR_DIR)/lib -j8
clean:
rebar3 clean
# Add a new target to print the library path
print-lib-path:
@echo $(CURDIR)/lib/libvmlib.a
$(GENESIS_WASM_SERVER_DIR):
mkdir -p $(GENESIS_WASM_SERVER_DIR)
@echo "Cloning genesis-wasm repository..." && \
tmp_dir=$$(mktemp -d) && \
git clone --depth=1 -b $(GENESIS_WASM_BRANCH) $(GENESIS_WASM_REPO) $$tmp_dir && \
mkdir -p $(GENESIS_WASM_SERVER_DIR) && \
cp -r $$tmp_dir/servers/cu/* $(GENESIS_WASM_SERVER_DIR) && \
rm -rf $$tmp_dir && \
echo "Extracted servers/genesis-wasm to $(GENESIS_WASM_SERVER_DIR)"
# Set up genesis-wasm@1.0 environment
setup-genesis-wasm: $(GENESIS_WASM_SERVER_DIR)
@cp native/genesis-wasm/launch-monitored.sh $(GENESIS_WASM_SERVER_DIR) && \
if ! command -v node > /dev/null; then \
echo "Error: Node.js is not installed. Please install Node.js before continuing."; \
echo "For Ubuntu/Debian, you can install it with:"; \
echo " curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && \\"; \
echo " apt-get install -y nodejs=22.16.0-1nodesource1 --allow-downgrades && \\"; \
echo " node -v && npm -v"; \
exit 1; \
fi
@cd $(GENESIS_WASM_SERVER_DIR) && npm install > /dev/null 2>&1 && \
echo "Installed genesis-wasm@1.0 server."
# Update hyperbuddy-ui from remote bundle
update-hyperbuddy-ui:
@echo "Fetching package.json from $(HYPERBUDDY_UI_REPO)..." && \
TX_ID=$$(curl -s "$(HYPERBUDDY_UI_PACKAGE_JSON)" | grep -o '"bundle"[[:space:]]*:[[:space:]]*"[^"]*"' | cut -d'"' -f4) && \
if [ -z "$$TX_ID" ]; then \
echo "Error: Could not find 'bundle' field in package.json"; \
exit 1; \
fi && \
echo "Found transaction ID: $$TX_ID" && \
if [ -f "$(HYPERBUDDY_UI_TARGET)" ]; then \
rm "$(HYPERBUDDY_UI_TARGET)" && \
echo "Removed existing bundle.js"; \
fi && \
echo "Downloading source code from Arweave..." && \
curl -sL "$(ARWEAVE_GATEWAY)/$$TX_ID" -o "$(HYPERBUDDY_UI_TARGET)" && \
echo "Successfully updated $(HYPERBUDDY_UI_TARGET)"