-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprecompiled-mac.py
46 lines (39 loc) · 1.44 KB
/
precompiled-mac.py
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
import os
import subprocess
# 编译器和选项
COMPILER = "g++-14"
CXX_STANDARD = "-std=c++23"
OPTIMIZATION = "-O2"
WARNINGS = "-Wall"
DEFINE = "-Dlocal"
INCLUDE_DIR = "-I/Users/noya/libra"
# 目录设置
SEARCH_DIR = "./"
def generate_gch_files(directory):
for root, _, files in os.walk(directory):
for file in files:
if file.endswith("head.hpp") or file.endswith("all.hpp") or file.endswith("stdc++.h"):
header_file = os.path.join(root, file)
gch_file = f"{header_file}.gch"
# 打印正在生成的信息
print(f"Generating precompiled header for {header_file}")
# 生成 .gch 文件
result = subprocess.run([
COMPILER,
CXX_STANDARD,
OPTIMIZATION,
WARNINGS,
DEFINE,
INCLUDE_DIR,
"-x", "c++-header",
header_file,
"-o", gch_file
], capture_output=True, text=True)
# 检查生成是否成功
if result.returncode == 0:
print(f"Successfully generated {gch_file}")
else:
print(f"Failed to generate {gch_file}")
print(result.stderr)
if __name__ == "__main__":
generate_gch_files(SEARCH_DIR)