-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (52 loc) · 2.24 KB
/
Makefile
File metadata and controls
60 lines (52 loc) · 2.24 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
# File: Makefile
BINARY_NAME = node
MAIN_PACKAGE = ./cmd/node
OUTPUT_DIR = release
CONFIG_FILES = \
appconfig.yaml \
internal/mempool/mempool.data.json \
internal/peers/peers.data.json
# --- Windows Build (Fixed) ---
win-build:
@echo "Building for Windows..."
@if not exist "$(OUTPUT_DIR)" mkdir "$(OUTPUT_DIR)"
@go build -o "$(OUTPUT_DIR)\$(BINARY_NAME).exe" "$(MAIN_PACKAGE)"
@echo "Copying config files to $(OUTPUT_DIR)..."
@copy /Y "appconfig.yaml" "$(OUTPUT_DIR)"
@if not exist "$(OUTPUT_DIR)\internal\mempool" mkdir "$(OUTPUT_DIR)\internal\mempool"
@copy /Y "internal\mempool\mempool.data.json" "$(OUTPUT_DIR)\internal\mempool\"
@if not exist "$(OUTPUT_DIR)\internal\blockchain" mkdir "$(OUTPUT_DIR)\internal\blockchain"
@if not exist "$(OUTPUT_DIR)\internal\blockchain\data" mkdir "$(OUTPUT_DIR)\internal\blockchain\data"
@copy /Y "internal\blockchain\data\blockchain.data.json" "$(OUTPUT_DIR)\internal\blockchain\data"
@if not exist "$(OUTPUT_DIR)\internal\peers" mkdir "$(OUTPUT_DIR)\internal\peers"
@copy /Y "internal\peers\peers.data.json" "$(OUTPUT_DIR)\internal\peers\"
@echo "Windows build complete. Run with: $(OUTPUT_DIR)\$(BINARY_NAME).exe"
# --- Linux Build ---
lnx-build:
@echo "Building for Linux..."
@mkdir -p "$(OUTPUT_DIR)"
@go build -o "$(OUTPUT_DIR)/$(BINARY_NAME)" "$(MAIN_PACKAGE)"
@echo "Copying config files to $(OUTPUT_DIR)..."
@cp "appconfig.yaml" "$(OUTPUT_DIR)/"
@mkdir "$(OUTPUT_DIR)/internal/mempool"
@cp "internal/mempool/mempool.data.json" "$(OUTPUT_DIR)/internal/mempool/"
@mkdir "$(OUTPUT_DIR)/internal/peers"
@cp "internal/peers/peers.data.json" "$(OUTPUT_DIR)/internal/peers/"
@echo "Linux build complete. Run with: ./$(OUTPUT_DIR)/$(BINARY_NAME)"
mac-build:
@echo "Building for macOS..."
@mkdir $(OUTPUT_DIR)
@go build -o $(OUTPUT_DIR)/$(BINARY_NAME) $(MAIN_PACKAGE)
@$(MAKE) copy-configs
@echo "macOS build complete. Run with: ./$(OUTPUT_DIR)/$(BINARY_NAME)"
# --- Config Copying (Unix-only, used by lnx-build/mac-build) ---
copy-configs:
@echo "Copying config files to $(OUTPUT_DIR)..."
@for file in $(CONFIG_FILES); do \
dest_dir=$(OUTPUT_DIR)/$$(dirname $$file); \
mkdir -p $$dest_dir; \
cp $$file $$dest_dir/; \
done
clean:
@rm -rf $(OUTPUT_DIR)
.PHONY: win-build lnx-build mac-build copy-configs clean