[Update] Build scripts and configuration: Added new build and install scripts, updated versioning in config files, and improved project structure.
This commit is contained in:
8
utils/clean.py
Normal file
8
utils/clean.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
root = os.path.dirname(os.path.dirname(__file__))
|
||||
shutil.rmtree(os.path.join(root, 'build'), ignore_errors=True)
|
||||
shutil.rmtree(os.path.join(root, 'dist'), ignore_errors=True)
|
||||
shutil.rmtree(os.path.join(root, 'src-tauri', 'bin'), ignore_errors=True)
|
||||
shutil.rmtree(os.path.join(root, 'src-tauri', 'target'), ignore_errors=True)
|
||||
12
utils/task_kill.py
Normal file
12
utils/task_kill.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import subprocess
|
||||
|
||||
# VRCT-sidecar.exe を強制終了
|
||||
try:
|
||||
subprocess.run(
|
||||
["taskkill", "/IM", "VRCT-sidecar.exe", "/F"],
|
||||
check=False,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
39
utils/update_version.py
Normal file
39
utils/update_version.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
def update_versions():
|
||||
root = os.path.join(os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
# package.jsonからバージョンを読み取る
|
||||
with open(os.path.join(root, "package.json"), "r", encoding="utf-8") as f:
|
||||
package_json = json.load(f)
|
||||
version = package_json["version"]
|
||||
|
||||
# tauri.conf.jsonを更新
|
||||
tauri_conf_path = os.path.join(root, "src-tauri", "tauri.conf.json")
|
||||
with open(tauri_conf_path, "r", encoding="utf-8") as f:
|
||||
tauri_conf = json.load(f)
|
||||
|
||||
tauri_conf["version"] = version
|
||||
|
||||
with open(tauri_conf_path, "w", encoding="utf-8") as f:
|
||||
json.dump(tauri_conf, f, indent=4, ensure_ascii=False)
|
||||
|
||||
# config.pyを更新
|
||||
config_path = os.path.join(root, "src-python", "config.py")
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
# VERSION行を置換
|
||||
import re
|
||||
pattern = r'(self\._VERSION = ")[^"]+(")'
|
||||
replacement = rf'\g<1>{version}\g<2>'
|
||||
new_content = re.sub(pattern, replacement, content)
|
||||
|
||||
with open(config_path, "w", encoding="utf-8") as f:
|
||||
f.write(new_content)
|
||||
|
||||
print(f"✓ バージョン {version} に更新しました")
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_versions()
|
||||
70
utils/zip.py
Normal file
70
utils/zip.py
Normal file
@@ -0,0 +1,70 @@
|
||||
import zipfile
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import time
|
||||
from tqdm import tqdm # tqdmをインポート
|
||||
|
||||
def zip_files_and_directory(zip_name, file_paths, dir_paths, verbose=False):
|
||||
zip_file_path = Path(zip_name)
|
||||
# ZIPファイルを作成
|
||||
try:
|
||||
with zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
||||
# ファイルを追加
|
||||
for file_path_str in tqdm(file_paths, desc="Adding files", unit="file"):
|
||||
file_path = Path(file_path_str)
|
||||
if file_path.is_file():
|
||||
zipf.write(file_path, file_path.name)
|
||||
if verbose:
|
||||
print(f"Add file: {file_path}")
|
||||
else:
|
||||
print(f"Warning: File not found or is not a file: {file_path}")
|
||||
|
||||
# ディレクトリを追加
|
||||
for dir_path_str in dir_paths:
|
||||
dir_path = Path(dir_path_str)
|
||||
if dir_path.is_dir():
|
||||
all_files_in_dir = [item for item in dir_path.rglob("*") if item.is_file()]
|
||||
for item in tqdm(all_files_in_dir, desc=f"Adding files from {dir_path.name}", unit="file"):
|
||||
# ディレクトリ構造を保持しつつ、ルートに配置
|
||||
arcname = Path(dir_path.name) / item.relative_to(dir_path)
|
||||
zipf.write(item, arcname)
|
||||
if verbose:
|
||||
print(f"Add file: {item}")
|
||||
else:
|
||||
print(f"Warning: Directory not found or is not a directory: {dir_path}")
|
||||
print(f"Successfully created zip file: {zip_file_path}")
|
||||
except IOError as e:
|
||||
print(f"Error: Could not create zip file {zip_file_path}. Reason: {e}")
|
||||
except Exception as e:
|
||||
print(f"An unexpected error occurred: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
start_time = time.time()
|
||||
parser = argparse.ArgumentParser(description="Create a zip file from specified files and directories.")
|
||||
parser.add_argument("--zip_name", type=str, default="VRCT.zip", help="Name of the output zip file.")
|
||||
parser.add_argument(
|
||||
"--file_paths",
|
||||
type=str,
|
||||
nargs="*",
|
||||
default=["src-tauri/target/release/VRCT.exe", "src-tauri/target/release/VRCT-sidecar.exe"],
|
||||
help="List of file paths to include in the zip."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dir_paths",
|
||||
type=str,
|
||||
nargs="*",
|
||||
default=["src-tauri/target/release/_internal"],
|
||||
help="List of directory paths to include in the zip."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v", "--verbose",
|
||||
action="store_true",
|
||||
help="Increase output verbosity."
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
zip_files_and_directory(args.zip_name, args.file_paths, args.dir_paths, args.verbose)
|
||||
end_time = time.time()
|
||||
processing_time = end_time - start_time
|
||||
print(f"Complete! Processing time: {processing_time:.2f} seconds")
|
||||
Reference in New Issue
Block a user