-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
212 lines (189 loc) · 8.86 KB
/
Copy pathMakefile
File metadata and controls
212 lines (189 loc) · 8.86 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
# HOLOGRAM Makefile
# Builds HOLOGRAM along with derod and simulator from derohe source
#
# Usage:
# make - Build HOLOGRAM + derod + simulator
# make release - Distribution build (clean + trimpath + build metadata)
# make derod - Build derod only
# make simulator - Build simulator only
# make clean - Clean build artifacts
# make dev - Run in development mode
#
# The derod and simulator binaries are built from the derohe dependency
# and placed alongside the HOLOGRAM executable in build/bin/
.PHONY: all hologram release derod simulator mtp-anchor clean dev test test-live test-mtp test-mtp-integration check-invariants help
# Build metadata - injected into the binary via ldflags.
# VERSION file is the single source of truth (must match latest CHANGELOG section).
VERSION := $(shell tr -d '[:space:]' < VERSION)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X main.AppVersion=$(VERSION) -X main.BuildDate=$(DATE) -X main.GitCommit=$(COMMIT)
# Detect OS and architecture
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
# Binary names based on platform
ifeq ($(GOOS),windows)
HOLOGRAM_BIN = Hologram.exe
DEROD_BIN = derod.exe
SIMULATOR_BIN = simulator.exe
else ifeq ($(GOOS),darwin)
HOLOGRAM_BIN = Hologram.app
DEROD_BIN = derod-darwin
SIMULATOR_BIN = simulator-darwin
else
HOLOGRAM_BIN = Hologram
DEROD_BIN = derod-linux-$(GOARCH)
SIMULATOR_BIN = simulator-linux-$(GOARCH)
endif
# Linux: link against webkit2gtk-4.1 (libsoup3) instead of the default
# webkit2gtk-4.0 (libsoup2). All current distros (Ubuntu 24.04+, Debian 13,
# Fedora 40+, Arch) ship 4.1 only — building without this tag fails to link
# or crashes at runtime due to libsoup2 ↔ libsoup3 conflicts.
# Override on the command line if you really need the legacy 4.0 binding:
# make WAILS_TAGS= ...
ifeq ($(GOOS),linux)
WAILS_TAGS ?= -tags webkit2_41
else
WAILS_TAGS ?=
endif
# Build directories
BUILD_DIR = build/bin
DEROHE_PKG = github.com/deroproject/derohe
# Toolchain for the chain binaries ONLY. HOLOGRAM itself follows your default Go.
#
# derod is the node our users run, so it has to behave like the rest of the
# network. Some of that behaviour is decided by the Go standard library rather
# than by derohe's source, and those details change between Go releases — a
# derod built on an unvalidated toolchain can differ from the network while
# looking normal and passing every test.
#
# So these two binaries are pinned to a toolchain that has been checked against
# the network, and both targets verify the result afterwards: removing the pin
# fails the build instead of silently shipping.
#
# ⚠️ DO NOT raise or delete this pin without asking DHEBP first. It is not stale
# and it is not lint. The specific rationale is recorded outside this repository,
# deliberately.
DEROD_TOOLCHAIN ?= go1.26.5
# Get derohe module path from go mod
# Default target - build derod/simulator FIRST, then hologram
# This order is important because wails build runs go mod tidy which
# can remove "unused" dependencies needed for derod/simulator
all: derod simulator hologram
@echo ""
@echo "✅ Build complete!"
@echo " HOLOGRAM: $(BUILD_DIR)/$(HOLOGRAM_BIN)"
@echo " derod: $(BUILD_DIR)/$(DEROD_BIN)"
@echo " simulator: $(BUILD_DIR)/$(SIMULATOR_BIN)"
@echo ""
ifeq ($(GOOS),darwin)
@echo "Run with: open $(BUILD_DIR)/Hologram.app"
else
@echo "Run with: ./$(BUILD_DIR)/$(HOLOGRAM_BIN)"
endif
# Build HOLOGRAM using wails (dev/local build with metadata)
hologram: check-invariants
@echo "🔨 Building HOLOGRAM ($(VERSION), $(COMMIT))..."
wails build $(WAILS_TAGS) -ldflags "$(LDFLAGS)"
@echo "✅ HOLOGRAM built"
# Release build — clean, trimpath, metadata injected (use this for distribution)
# derod/simulator MUST be built AFTER `wails build`, not before: its -clean flag
# wipes build/bin/ first, so anything built earlier gets deleted before packaging
# ever sees it (caught live via a CI workflow_dispatch test run, 2026-08-21).
release: check-invariants
@echo "🚀 Building HOLOGRAM release ($(VERSION), $(COMMIT))..."
wails build $(WAILS_TAGS) -ldflags "$(LDFLAGS)" -clean -trimpath
@$(MAKE) derod simulator
@echo "✅ Release build complete: $(BUILD_DIR)/$(HOLOGRAM_BIN)"
# Build derod from derohe source
# Note: We build from HOLOGRAM's module context so dependencies resolve correctly
derod: check-derohe
@echo "🔨 Building derod from derohe source..."
@mkdir -p $(BUILD_DIR)
GOTOOLCHAIN=$(DEROD_TOOLCHAIN) go build -o $(BUILD_DIR)/$(DEROD_BIN) $(DEROHE_PKG)/cmd/derod
@chmod +x $(BUILD_DIR)/$(DEROD_BIN)
@go version -m $(BUILD_DIR)/$(DEROD_BIN) | head -1 | grep -q '$(DEROD_TOOLCHAIN)' \
|| { echo "❌ derod was built with $$(go version -m $(BUILD_DIR)/$(DEROD_BIN) | head -1 | awk '{print $$2}'), expected $(DEROD_TOOLCHAIN) — refusing"; exit 1; }
@echo "✅ derod built: $(BUILD_DIR)/$(DEROD_BIN) ($(DEROD_TOOLCHAIN))"
# Build simulator from derohe source
# Note: We build from HOLOGRAM's module context so dependencies resolve correctly
simulator: check-derohe
@echo "🔨 Building simulator from derohe source..."
@mkdir -p $(BUILD_DIR)
GOTOOLCHAIN=$(DEROD_TOOLCHAIN) go build -o $(BUILD_DIR)/$(SIMULATOR_BIN) $(DEROHE_PKG)/cmd/simulator
@chmod +x $(BUILD_DIR)/$(SIMULATOR_BIN)
@go version -m $(BUILD_DIR)/$(SIMULATOR_BIN) | head -1 | grep -q '$(DEROD_TOOLCHAIN)' \
|| { echo "❌ simulator was built with $$(go version -m $(BUILD_DIR)/$(SIMULATOR_BIN) | head -1 | awk '{print $$2}'), expected $(DEROD_TOOLCHAIN) — refusing"; exit 1; }
@echo "✅ simulator built: $(BUILD_DIR)/$(SIMULATOR_BIN) ($(DEROD_TOOLCHAIN))"
# Check that derohe dependency is available and add cmd dependencies.
# No version is pinned here: the derohe module is resolved by go.mod (currently a
# replace onto the public fork), and these go get calls only pull the cmd-only
# transitive deps (readline, dns, lumberjack) into go.sum so derod/simulator build.
check-derohe:
@echo "🔍 Checking derohe dependency..."
@go get $(DEROHE_PKG)/cmd/derod 2>/dev/null || true
@go get $(DEROHE_PKG)/cmd/simulator 2>/dev/null || true
# Build mtp-anchor CLI tool
mtp-anchor:
@echo "🔨 Building mtp-anchor..."
@mkdir -p $(BUILD_DIR)
go build -o $(BUILD_DIR)/mtp-anchor ./cmd/mtp-anchor
@chmod +x $(BUILD_DIR)/mtp-anchor
@echo "✅ mtp-anchor built: $(BUILD_DIR)/mtp-anchor"
# Run unit tests for the messenger/mtp package (no simulator required)
test-mtp:
@echo "🧪 Running messenger/mtp unit tests..."
go test ./messenger/mtp/... -v -count=1
# Run the full integration test suite against a live simulator
# Prerequisites: simulator daemon + wallet RPC must be running.
# Optional env vars:
# WALLET_RPC (default http://127.0.0.1:30000/json_rpc)
# DAEMON_RPC (default http://127.0.0.1:20000/json_rpc)
# SCID (only needed with --skip-deploy)
test-mtp-integration: mtp-anchor
@echo "🧪 Running MTP integration tests..."
@bash cmd/mtp-anchor/integration_test.sh \
--wallet-rpc "$${WALLET_RPC:-http://127.0.0.1:30000/json_rpc}" \
--daemon-rpc "$${DAEMON_RPC:-http://127.0.0.1:20000/json_rpc}"
# A14 data-dir consolidation invariant gates (see redteam-hologram-datadir-consolidation.md).
# Prerequisite of every hologram/release build; also runnable standalone.
check-invariants:
@bash scripts/check-datadir-invariants.sh
# Run the Go unit-test suite plus the invariant gates.
# -short skips genuine multi-hour live grinds (e.g. TestMineRegistrationFromSeed_Live,
# which mines a real 28-bit registration PoW). Use `make test-live` to run those too.
test: check-invariants
@echo "🧪 Running Go unit tests..."
go test -short ./... -count=1
# Full suite including multi-hour live PoW grinds. Not for routine use.
test-live: check-invariants
@echo "🧪 Running FULL Go test suite (including multi-hour live PoW grinds)..."
go test ./... -count=1
# Development mode
dev: check-invariants
wails dev $(WAILS_TAGS)
# Clean build artifacts
clean:
@echo "🧹 Cleaning build artifacts..."
rm -rf $(BUILD_DIR)
@echo "✅ Clean complete"
# Help
help:
@echo "HOLOGRAM Build System"
@echo ""
@echo "Targets:"
@echo " all - Build HOLOGRAM + derod + simulator (recommended)"
@echo " hologram - Build HOLOGRAM only (with build metadata)"
@echo " release - Distribution build: clean + trimpath + metadata"
@echo " derod - Build derod from derohe source"
@echo " simulator - Build simulator from derohe source"
@echo " mtp-anchor - Build the mtp-anchor CLI tool"
@echo " test-mtp - Run messenger/mtp unit tests (no simulator needed)"
@echo " test-mtp-integration - Run full integration suite (simulator required)"
@echo " clean - Remove build artifacts"
@echo " help - Show this help"
@echo ""
@echo "Platform: $(GOOS)/$(GOARCH)"
@echo ""
@echo "The 'make all' command builds everything needed to run HOLOGRAM"
@echo "without downloading any pre-built binaries."