File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ BUILD_DIR := build
2+ CMAKE := cmake
3+ BUILD_TOOL := ninja
4+ LLVM_FLAGS := -DCMAKE_BUILD_TYPE=Release \
5+ -DLLVM_TARGETS_TO_BUILD="X86" \
6+ -DLLVM_ENABLE_PROJECTS="" \
7+ -DLLVM_BUILD_EXAMPLES=ON \
8+ -DLLVM_INCLUDE_EXAMPLES=ON \
9+
10+ LLVM_DIR := $(BUILD_DIR ) /llvm-build
11+
12+ # 可执行程序路径
13+ # EXECUTABLE := $(BUILD_DIR)/release/bin/myapp$(if $(filter Windows_NT,$(OS)),.exe,)
14+
15+ .PHONY : all run build_llvm clean_llvm distclean_llvm help
16+
17+ all : build_llvm
18+
19+ # 配置并构建调试版本
20+ # debug:
21+ # @mkdir -p $(DEBUG_DIR)
22+ # @cd $(DEBUG_DIR) && $(CMAKE) -G Ninja $(CMAKE_FLAGS) ../.. # 添加 Ninja 生成器
23+ # @$(BUILD_TOOL) -C $(DEBUG_DIR)
24+ # @cd $(DEBUG_DIR) && rm -rf ./src
25+
26+ # 配置并构建发布版本
27+ run : build_llvm
28+ @./$(LLVM_DIR ) /bin/BuildingAJIT-Ch1
29+
30+ build_llvm :
31+ @mkdir -p $(LLVM_DIR )
32+ @cd $(LLVM_DIR ) && $(CMAKE ) -G Ninja $(LLVM_FLAGS ) ../../llvm # 添加模块支持
33+ @cd $(LLVM_DIR ) && ninja
34+
35+ clean_llvm :
36+ @[ -d $( LLVM_DIR) ] && $(BUILD_TOOL ) -C $(LLVM_DIR ) clean || true
37+
38+ distclean_llvm :
39+ @rm -rf $(LLVM_DIR )
40+
41+ help :
42+ @echo " 可用目标:"
43+ @echo " all - 默认构建 (release版本)"
44+ @echo " debug - 调试构建"
45+ @echo " release - 发布构建 (默认)"
46+ @echo " run - 构建并运行程序 (release)"
47+ @echo " run_debug - 构建并运行debug版本"
48+ @echo " test - 运行测试"
49+ @echo " clean - 清理构建文件"
50+ @echo " distclean - 删除整个构建目录"
51+ @echo " help - 显示帮助信息"
52+
53+ # 添加 Ninja 检查
54+ check-ninja :
55+ ifeq (, $(shell which ninja) )
56+ $(error "Ninja 构建工具未安装,请先安装 ninja (https://ninja-build.org/)")
57+ endif
You can’t perform that action at this time.
0 commit comments