refactor: 移除旧子进程模式的 main.* 源文件,Makefile 只编译 DLL

- 删除 engines/c/main.c, engines/cpp/main.cpp, engines/fortran/main.f90
- Makefile 移除 all/exe 构建目标,默认只编译 DLL
This commit is contained in:
2026-06-21 05:33:52 +08:00
parent 7468a2d458
commit e371fa8db1
6 changed files with 10 additions and 3336 deletions
+5 -46
View File
@@ -1,21 +1,17 @@
# engines/c/Makefile # engines/c/Makefile
# 跨平台编译:make → 本地系统编译 # 编译 DLL(主程序通过 ctypes 直接调用)
# make linux → Linux 交叉编译(需 x86_64-linux-gnu-gcc # make dll → 本地系统编译
# make linux → Linux 交叉编译(需 x86_64-linux-gnu-gcc
# make windows → Windows 交叉编译(需 x86_64-w64-mingw32-gcc # make windows → Windows 交叉编译(需 x86_64-w64-mingw32-gcc
# make macos → macOS 交叉编译(需 osxcross 工具链)
CC = gcc CC = gcc
CFLAGS = -O3 -march=native -Wall -Wextra CFLAGS = -O3 -march=native -Wall -Wextra
LDFLAGS = -lm LDFLAGS = -lm
SRCS = main.c
LIB_SRC = dynamics_lib.c LIB_SRC = dynamics_lib.c
# 自动检测系统 # 自动检测系统
UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) UNAME_S := $(shell uname -s 2>/dev/null || echo Windows)
# 目标文件名:统一使用 .exe 后缀(方便 Python 跨平台调用)
TARGET = build/dynamics_c.exe
# DLL 目标(平台自动选择后缀) # DLL 目标(平台自动选择后缀)
ifeq ($(UNAME_S),Linux) ifeq ($(UNAME_S),Linux)
DLL_TARGET = build/dynamics_c.so DLL_TARGET = build/dynamics_c.so
@@ -28,17 +24,12 @@ else
DLL_FLAGS = -shared DLL_FLAGS = -shared
endif endif
# ── 本地编译 ───────────────────────────────── .PHONY: all dll clean
.PHONY: all dll clean linux windows macos
all: $(TARGET) all: dll
dll: $(DLL_TARGET) dll: $(DLL_TARGET)
$(TARGET): $(SRCS) | build
$(CC) $(CFLAGS) -o $@ $(SRCS) $(LDFLAGS)
@echo " === C engine built: $@ ==="
$(DLL_TARGET): $(LIB_SRC) | build $(DLL_TARGET): $(LIB_SRC) | build
$(CC) $(CFLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) $(LDFLAGS) $(CC) $(CFLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) $(LDFLAGS)
@echo " === C DLL built: $@ ===" @echo " === C DLL built: $@ ==="
@@ -46,37 +37,5 @@ $(DLL_TARGET): $(LIB_SRC) | build
build: build:
mkdir -p build mkdir -p build
# ── 交叉编译 ─────────────────────────────────
# Linux → Linux (x86_64)
linux: CROSS_PREFIX = x86_64-linux-gnu-
linux: CC = $(CROSS_PREFIX)gcc
linux: CFLAGS = -O3 -march=x86-64 -Wall -Wextra
linux: $(SRCS) | build
$(CC) $(CFLAGS) -o build/dynamics_c_linux.exe $(SRCS) $(LDFLAGS)
@echo " === Linux binary: build/dynamics_c_linux.exe ==="
# 任意平台 → Windows (x86_64)
# 需要安装 MinGW 交叉编译器:
# apt install mingw-w64 (Debian/Ubuntu)
# brew install mingw-w64 (macOS)
windows: CROSS_PREFIX = x86_64-w64-mingw32-
windows: CC = $(CROSS_PREFIX)gcc
windows: CFLAGS = -O3 -march=x86-64 -Wall -Wextra
windows: $(SRCS) | build
$(CC) $(CFLAGS) -o build/dynamics_c_win.exe $(SRCS) $(LDFLAGS)
@echo " === Windows binary: build/dynamics_c_win.exe ==="
# 任意平台 → macOS (x86_64)
# 需要安装 osxcross 工具链
macos: CROSS_PREFIX = x86_64-apple-darwin-
macos: CC = $(CROSS_PREFIX)gcc
macos: CFLAGS = -O3 -march=x86-64 -Wall -Wextra
macos: $(SRCS) | build
$(CC) $(CFLAGS) -o build/dynamics_c_mac.exe $(SRCS) $(LDFLAGS)
@echo " === macOS binary: build/dynamics_c_mac.exe ==="
# ── 编译所有平台 ──────────────────────────────
all-platforms: linux windows macos
clean: clean:
rm -rf build *.o rm -rf build *.o
-1114
View File
File diff suppressed because it is too large Load Diff
+2 -8
View File
@@ -1,7 +1,7 @@
# engines/cpp/Makefile # engines/cpp/Makefile
# 编译 DLL(主程序通过 ctypes 直接调用)
CXX = g++ CXX = g++
SRCS = main.cpp
LIB_SRC = dynamics_lib.cpp LIB_SRC = dynamics_lib.cpp
UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) UNAME_S := $(shell uname -s 2>/dev/null || echo Windows)
@@ -15,8 +15,6 @@ else
STATIC_FLAGS = STATIC_FLAGS =
endif endif
TARGET = build/dynamics_cpp.exe
ifeq ($(UNAME_S),Linux) ifeq ($(UNAME_S),Linux)
DLL_TARGET = build/dynamics_cpp.so DLL_TARGET = build/dynamics_cpp.so
DLL_FLAGS = -shared -fPIC DLL_FLAGS = -shared -fPIC
@@ -30,14 +28,10 @@ endif
.PHONY: all dll clean .PHONY: all dll clean
all: $(TARGET) all: dll
dll: $(DLL_TARGET) dll: $(DLL_TARGET)
$(TARGET): $(SRCS) | build
$(CXX) $(CXXFLAGS) $(STATIC_FLAGS) -o $@ $(SRCS)
@echo " === C++ engine built: $@ ==="
$(DLL_TARGET): $(LIB_SRC) | build $(DLL_TARGET): $(LIB_SRC) | build
$(CXX) $(CXXFLAGS) $(STATIC_FLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) $(CXX) $(CXXFLAGS) $(STATIC_FLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC)
@echo " === C++ DLL built: $@ ===" @echo " === C++ DLL built: $@ ==="
-1025
View File
File diff suppressed because it is too large Load Diff
+3 -9
View File
@@ -1,20 +1,18 @@
# engines/fortran/Makefile # engines/fortran/Makefile
# 编译 DLL(主程序通过 ctypes 直接调用)
FC = gfortran FC = gfortran
FFLAGS = -O3 -march=native -Wall -Wextra FFLAGS = -O3 -march=native -Wall -Wextra
SRCS = main.f90
LIB_SRC = dynamics_lib.f90 LIB_SRC = dynamics_lib.f90
UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) UNAME_S := $(shell uname -s 2>/dev/null || echo Windows)
ifeq ($(UNAME_S),Windows) ifeq ($(UNAME_S),Windows)
STATIC_FLAGS = -static-libgcc -static-libgfortran -static-libquadmath STATIC_FLAGS = -static
else else
STATIC_FLAGS = STATIC_FLAGS =
endif endif
TARGET = build/dynamics_f90.exe
ifeq ($(UNAME_S),Linux) ifeq ($(UNAME_S),Linux)
DLL_TARGET = build/dynamics_f90.so DLL_TARGET = build/dynamics_f90.so
DLL_FLAGS = -shared -fPIC DLL_FLAGS = -shared -fPIC
@@ -28,14 +26,10 @@ endif
.PHONY: all dll clean .PHONY: all dll clean
all: $(TARGET) all: dll
dll: $(DLL_TARGET) dll: $(DLL_TARGET)
$(TARGET): $(SRCS) | build
$(FC) $(FFLAGS) $(STATIC_FLAGS) -o $@ $(SRCS)
@echo " === Fortran engine built: $@ ==="
$(DLL_TARGET): $(LIB_SRC) | build $(DLL_TARGET): $(LIB_SRC) | build
$(FC) $(FFLAGS) $(STATIC_FLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) $(FC) $(FFLAGS) $(STATIC_FLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC)
@echo " === Fortran DLL built: $@ ===" @echo " === Fortran DLL built: $@ ==="
File diff suppressed because it is too large Load Diff