forked from Ireneruru/PhysicalVisualizationDesign
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (102 loc) · 3.96 KB
/
Makefile
File metadata and controls
125 lines (102 loc) · 3.96 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
# Makefile for PhysicalVisualizationDesign setup (Optimizer + Execution + Demo)
# Configurable paths
ARROW_DIR=execution/third_party/arrow
ARROW_CMAKE_FILE=$(ARROW_DIR)/cpp/cmake_modules/SetupCxxFlags.cmake
ARROW_REPO=https://github.com/apache/arrow.git
PYTHON=python3
VENV_DIR=optimizer/jade
REPO_ROOT:=$(shell pwd)
VCPKG_DIR=$(REPO_ROOT)/vcpkg
EMSDK_DIR=$(REPO_ROOT)/emsdk
export PVD_BASE := $(REPO_ROOT)
# Export environment variables
export VCPKG_ROOT=$(VCPKG_DIR)
export PATH:=$(VCPKG_DIR):$(PATH)
.PHONY: all optimizer execution run_server run_http check_duckdb clean_optimizer clean_execution clean_all ensure_arrow
# Default target: set up both parts
all: optimizer execution
###########################################################
# PART 1: Optimizer Setup (Python virtual environment)
###########################################################
optimizer:
@echo "Setting up optimizer virtual environment..."
cd optimizer && $(PYTHON) -m venv jade
. $(VENV_DIR)/bin/activate && pip install -r optimizer/requirements.txt
@echo "Optimizer environment created and dependencies installed."
###########################################################
# PART 2: Execution Setup (C++ server and WASM client)
###########################################################
# Build dependencies and both targets
execution: vcpkg emsdk build_server build_client
vcpkg:
@if [ ! -d "$(VCPKG_DIR)" ]; then \
echo "Cloning vcpkg..."; \
git clone https://github.com/Microsoft/vcpkg.git $(VCPKG_DIR); \
cd $(VCPKG_DIR) && ./bootstrap-vcpkg.sh; \
else \
echo "vcpkg already cloned."; \
fi
emsdk:
@if [ ! -d "$(EMSDK_DIR)" ]; then \
echo "Cloning emsdk..."; \
git clone https://github.com/emscripten-core/emsdk.git $(EMSDK_DIR); \
cd $(EMSDK_DIR) && ./emsdk install 3.1.29 && ./emsdk activate 3.1.29; \
else \
echo "emsdk already cloned."; \
fi
@echo "Activating emsdk..."
. $(EMSDK_DIR)/emsdk_env.sh
# Check for libduckdb library before building server
check_duckdb:
@echo "Checking for DuckDB linking library in execution/server/lib..."
@if [ ! -f execution/server/lib/libduckdb.so ] && [ ! -f execution/server/lib/libduckdb.dylib ]; then \
echo "ERROR: libduckdb not found in execution/server/lib/"; \
echo "Please download the DuckDB linking library:"; \
echo " - For Linux: libduckdb.so"; \
echo " - For macOS: libduckdb.dylib"; \
echo "Then place the file into execution/server/lib/"; \
exit 1; \
else \
echo "Found DuckDB linking library."; \
fi
ensure_arrow:
@if [ ! -f $(ARROW_CMAKE_FILE) ]; then \
echo "Arrow not found. Cloning..."; \
git clone $(ARROW_REPO) $(ARROW_DIR); \
cd $(ARROW_DIR) && git submodule update --init --recursive; \
else \
echo "Arrow already present."; \
fi
build_server: check_duckdb ensure_arrow
@echo "Building server binary..."
mkdir -p execution/build
cd execution/build && cmake -S .. -B . && make -j6
@echo "Server built at execution/build/pvd_server"
build_client:
@echo "Building client WASM..."
mkdir -p execution/build_wasm
cd execution/build_wasm && emcmake cmake -S .. -B . && emmake make -j6
@echo "WASM build complete at execution/build_wasm"
###########################################################
# Demo Targets: Run the server and HTTP demo
###########################################################
# Run the compiled server binary.
run_server: build_server
@echo "Starting demo server..."
@cd execution/build && ./pvd_server
# Run the HTTP server for the demo.
run_http:
@echo "Starting HTTP server..."
@$(PYTHON) http_server.py
###########################################################
# Clean Targets
###########################################################
clean_optimizer:
rm -rf $(VENV_DIR)
@echo "Removed optimizer virtual environment."
clean_execution:
rm -rf execution/build execution/build_wasm
@echo "Cleaned execution build directories."
clean_all: clean_optimizer clean_execution
rm -rf $(VCPKG_DIR) $(EMSDK_DIR)
@echo "Cleaned all automatically installed dependencies (vcpkg and emsdk)."