Skip to content

Commit

Permalink
编译后复制readme时修改其中图片的路径引用。移除类型化列表以兼容旧版本的python
Browse files Browse the repository at this point in the history
  • Loading branch information
Daylily-Zeleen committed Dec 13, 2024
1 parent 939b626 commit 419f1a9
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import os
import shutil
import build_version


env = SConscript("godot-cpp/SConstruct")
lib_name = "libgddragonbones"
# For the reference:
Expand All @@ -25,7 +26,7 @@ plugin_bin_folder = f"{plugin_folder}/bin"
extension_file = "demo/addons/gddragonbones/gddragonbones.gdextension"


def add_sources_recursively(dir: str, glob_sources, exclude_folder: list[str] = []):
def add_sources_recursively(dir: str, glob_sources, exclude_folder: list = []):
for f in os.listdir(dir):
if f in exclude_folder:
continue
Expand Down Expand Up @@ -100,10 +101,27 @@ def on_complete(target, source, env):
f"{plugin_bin_folder}/{lib_name}{suffix}{share_lib_suffix}",
)

copy_file("README.md", os.path.join(plugin_folder, "README.md"))
copy_file("README.zh.md", os.path.join(plugin_folder, "README.zh.md"))
copied_readme_file_path = os.path.join(plugin_folder, "README.md")
copied_readme_zh_file_path = os.path.join(plugin_folder, "README.zh.md")

copy_file("README.md", copied_readme_file_path)
copy_file("README.zh.md", copied_readme_zh_file_path)
copy_file("LICENSE", os.path.join(plugin_folder, "LICENSE"))

# 替换 readme 中图片的路径
for fp in [copied_readme_file_path, copied_readme_zh_file_path]:
f = open(fp, "r", encoding="utf8")
lines = f.readlines()
f.close()

for i in range(len(lines)):
if lines[i].count("(demo/addons/gddragonbones/") > 0:
lines[i] = lines[i].replace("(demo/addons/gddragonbones/", "(")

f = open(fp, "w", encoding="utf8")
f.writelines(lines)
f.close()

# 更新.gdextension中的版本信息
f = open(extension_file, "r", encoding="utf8")
lines = f.readlines()
Expand Down

0 comments on commit 419f1a9

Please sign in to comment.