-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (129 loc) · 5.67 KB
/
Makefile
File metadata and controls
148 lines (129 loc) · 5.67 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
# Milvus Spark Connector Makefile
# Author: Zilliz
# Description: Simplified build system using milvus-storage JNI library
# Configuration
SCALA_VERSION := 2.13
SBT := sbt
JAVA_HOME ?= $(shell dirname $(shell dirname $(shell readlink -f $(shell which java))))
# Directories
RESOURCES_DIR := src/main/resources
MILVUS_STORAGE_CPP := milvus-storage/cpp
MILVUS_STORAGE_BUILD := $(MILVUS_STORAGE_CPP)/build/Release/lib
TARGET_DIR := target
# Colors for output
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[0;33m
BLUE := \033[0;34m
NC := \033[0m # No Color
# All phony targets
.PHONY: all help check-deps init-submodules build-milvus-storage copy-native-libs clean package test run-demo rebuild quick-build status
# Default target
all: clean build-milvus-storage copy-native-libs package
# Help target
help:
@echo "$(BLUE)Milvus Spark Connector Build System$(NC)"
@echo ""
@echo "$(YELLOW)Available targets:$(NC)"
@echo " $(GREEN)all$(NC) - Complete build process"
@echo " $(GREEN)clean$(NC) - Clean all build artifacts"
@echo " $(GREEN)build-milvus-storage$(NC) - Build milvus-storage with JNI support"
@echo " $(GREEN)copy-native-libs$(NC) - Copy native libraries to resources"
@echo " $(GREEN)package$(NC) - Package JAR with native libraries"
@echo " $(GREEN)test$(NC) - Run tests"
@echo " $(GREEN)run-demo$(NC) - Run demo"
@echo " $(GREEN)init-submodules$(NC) - Initialize Git submodules"
@echo " $(GREEN)check-deps$(NC) - Check system dependencies"
@echo ""
@echo "$(YELLOW)Environment variables:$(NC)"
@echo " JAVA_HOME=$(JAVA_HOME)"
@echo " SCALA_VERSION=$(SCALA_VERSION)"
# Check system dependencies
check-deps:
@echo "$(BLUE)Checking system dependencies...$(NC)"
@command -v java >/dev/null 2>&1 || { echo "$(RED)Error: Java not found$(NC)"; exit 1; }
@command -v javac >/dev/null 2>&1 || { echo "$(RED)Error: javac not found$(NC)"; exit 1; }
@command -v $(SBT) >/dev/null 2>&1 || { echo "$(RED)Error: sbt not found$(NC)"; exit 1; }
@command -v make >/dev/null 2>&1 || { echo "$(RED)Error: make not found$(NC)"; exit 1; }
@command -v conan >/dev/null 2>&1 || { echo "$(RED)Error: conan not found$(NC)"; exit 1; }
@echo "$(GREEN)All dependencies found$(NC)"
# Initialize Git submodules
init-submodules:
@echo "$(BLUE)Initializing Git submodules...$(NC)"
@git submodule update --init --recursive
@echo "$(GREEN)Submodules initialized$(NC)"
# Build milvus-storage with JNI support
build-milvus-storage: check-deps init-submodules
@echo "$(BLUE)Building milvus-storage with JNI support...$(NC)"
@if [ ! -d "$(MILVUS_STORAGE_CPP)" ]; then \
echo "$(RED)Error: milvus-storage/cpp directory not found$(NC)"; \
echo "$(YELLOW)Run 'make init-submodules' first$(NC)"; \
exit 1; \
fi
@cd $(MILVUS_STORAGE_CPP) && make java-lib
@if [ -f "$(MILVUS_STORAGE_BUILD)/libmilvus-storage.so" ] && [ -f "$(MILVUS_STORAGE_BUILD)/libmilvus-storage-jni.so" ]; then \
echo "$(GREEN)✓ Successfully built milvus-storage with JNI$(NC)"; \
ls -lh $(MILVUS_STORAGE_BUILD)/*.so; \
else \
echo "$(RED)Error: Failed to build milvus-storage JNI libraries$(NC)"; \
exit 1; \
fi
# Copy native libraries to resources directory
copy-native-libs: $(RESOURCES_DIR)/native
@echo "$(BLUE)Copying native libraries to resources directory...$(NC)"
@if [ ! -f "$(MILVUS_STORAGE_BUILD)/libmilvus-storage.so" ] || [ ! -f "$(MILVUS_STORAGE_BUILD)/libmilvus-storage-jni.so" ]; then \
echo "$(YELLOW)Native libraries not found, building first...$(NC)"; \
$(MAKE) build-milvus-storage; \
fi
@cp $(MILVUS_STORAGE_BUILD)/*.so* $(RESOURCES_DIR)/native/
@echo "$(GREEN)✓ Copied native libraries to resources$(NC)"
@ls -lh $(RESOURCES_DIR)/native/ | head -20
# Create necessary directories
$(RESOURCES_DIR)/native:
@mkdir -p $(RESOURCES_DIR)/native
# Clean build artifacts
clean:
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
@rm -rf $(TARGET_DIR)
@rm -rf project/target
@rm -rf project/project
@echo "$(YELLOW)Cleaning native libraries from resources...$(NC)"
@rm -f $(RESOURCES_DIR)/native/libmilvus-storage-jni.so
@rm -f $(RESOURCES_DIR)/native/libmilvus-storage.so
@$(SBT) clean
@echo "$(GREEN)Clean complete$(NC)"
# Clean everything including milvus-storage build
clean-all: clean
@echo "$(BLUE)Cleaning milvus-storage build...$(NC)"
@if [ -d "$(MILVUS_STORAGE_CPP)" ]; then \
cd $(MILVUS_STORAGE_CPP) && make clean; \
fi
@echo "$(GREEN)Clean all complete$(NC)"
# Package JAR with native libraries
package: copy-native-libs
@echo "$(BLUE)Packaging JAR with native libraries...$(NC)"
@$(SBT) package
@echo "$(GREEN)Packaging complete$(NC)"
# Run tests
test: package
@echo "$(BLUE)Running tests...$(NC)"
@$(SBT) test
@echo "$(GREEN)Tests complete$(NC)"
# Run demo
run-demo: package
@echo "$(BLUE)Running demo...$(NC)"
@$(SBT) "runMain com.zilliz.spark.connector.jni.MilvusStorageJNI"
# Development targets
rebuild: clean-all all
quick-build: copy-native-libs package
# Show build status
status:
@echo "$(BLUE)Build Status:$(NC)"
@echo -n "Milvus Storage SO: "
@if [ -f "$(MILVUS_STORAGE_BUILD)/libmilvus-storage.so" ]; then echo "$(GREEN)✓$(NC)"; else echo "$(RED)✗$(NC)"; fi
@echo -n "Milvus Storage JNI SO: "
@if [ -f "$(MILVUS_STORAGE_BUILD)/libmilvus-storage-jni.so" ]; then echo "$(GREEN)✓$(NC)"; else echo "$(RED)✗$(NC)"; fi
@echo -n "Native libs in resources: "
@if [ -f "$(RESOURCES_DIR)/native/libmilvus-storage.so" ] && [ -f "$(RESOURCES_DIR)/native/libmilvus-storage-jni.so" ]; then echo "$(GREEN)✓$(NC)"; else echo "$(RED)✗$(NC)"; fi
@echo -n "JAR package: "
@if ls $(TARGET_DIR)/scala-$(SCALA_VERSION)/*.jar 1> /dev/null 2>&1; then echo "$(GREEN)✓$(NC)"; else echo "$(RED)✗$(NC)"; fi