Magpie/scripts/wiki.py
Xu 04ff6ea0a3
支持使用 clang-cl 编译 (#1195)
* chore: native 项目支持 clang-cl

* chore: 修复 clang 编译错误

* chore: 修复部分 clang 编译警告

* chore: 修复警告

* chore: 修复所有警告,优化 llvm 查找

* chore: 启用 LTO

* chore: 支持 ARM64

* chore: _ConanDeps 支持 clang-cl

* chore: 编译选项改变 _ConanDeps 自动重新编译

* chore: profile 更改时重新编译 _ConanDeps

* chore: 将 hu 和 ka 加入项目文件,但不参与生成
否则不参与批量替换

* chore: Magpie 项目支持并行编译

* chore: 添加几个提高性能的编译选项

* chore: 优化 _ConanDeps

* chore: publish.py 支持参数

* chore: CI 支持 clang 编译

* chore: 修复 CI 的 conan 缓存

* chore: 优化编译选项,修复 CI

* chore: 修复 CI

* chore: 改变参数顺序

* chore: 添加编译选项支持针对当前硬件生成优化代码

* chore: 优化 CI 脚本

* chore: publish.py 添加 --use-native-march 选项

* chore: 脚本集中在 scripts 文件夹,msbuild 启用并行编译

* chore: clang, x64 配置启用 CX16 指令

* chore: 更新依赖

* chore: 更新格式设置

* chore: 增加额外的斜杠以提高兼容性

* chore: 修复效果文件复制
2025-07-15 17:40:04 +08:00

52 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sys
import os
import tempfile
import glob
import shutil
import subprocess
import argparse
try:
# https://docs.github.com/en/actions/learn-github-actions/variables
if os.environ["GITHUB_ACTIONS"].lower() == "true":
# 不知为何在 Github Actions 中运行时默认编码为 ANSI并且 print 需刷新流才能正常显示
for stream in [sys.stdout, sys.stderr]:
stream.reconfigure(encoding="utf-8")
except:
pass
argParser = argparse.ArgumentParser()
argParser.add_argument("access_token")
args = argParser.parse_args()
wikiRepoUrl = f"https://{args.access_token}@github.com/{os.environ["GITHUB_REPOSITORY"]}.wiki.git"
# 创建临时目录
wikiRepoDir = tempfile.mkdtemp()
os.chdir(wikiRepoDir)
p = subprocess.run("git init")
if p.returncode != 0:
raise Exception("git init 失败")
actor = os.environ["GITHUB_ACTOR"]
subprocess.run("git config user.name " + actor)
subprocess.run(f"git config user.email {actor}@users.noreply.github.com")
# 拉取
p = subprocess.run(f'git pull "{wikiRepoUrl}"')
if p.returncode != 0:
raise Exception("git pull 失败")
# 将文档拷贝到临时目录
docsDir = os.path.normpath(os.path.dirname(__file__) + "\\..\\docs")
for file in glob.glob(docsDir + "\\*.md"):
shutil.copy(file, wikiRepoDir)
print("已拷贝 " + file, flush=True)
# 推送
subprocess.run("git add .")
subprocess.run('git commit -m "Published by CI"')
p = subprocess.run(f'git push --set-upstream "{wikiRepoUrl}" master')
if p.returncode != 0:
raise Exception("git push 失败")