import os

from scripts.build import run
from scripts.context import Context
from utils import SystemUtils
from utils.logger_utils import init

if __name__ == '__main__':
    context = Context.from_json(open("build_config.json", "r").read())

    if SystemUtils.is_windows():
        context.project_original_path = context.project_original_path.replace("/", os.sep)
        pass
    logger = init()

    run(context)
    # # 系统信息示例
    # print(f"当前系统: {SystemUtils.get_platform_name()}")
    # print(f"是Windows系统吗? {SystemUtils.is_windows()}")
    #
    # # 命令执行示例
    # if SystemUtils.is_windows():
    #     cmd = "echo Hello Windows"
    # else:
    #     cmd = "echo 'Hello Unix/Linux/macOS'"
    #
    # # 执行并获取输出
    # return_code, output, error = CommandUtils.execute(cmd)
    # print(f"\n命令执行结果:")
    # print(f"返回码: {return_code}")
    # print(f"输出: {output.strip()}")
    # if error:
    #     print(f"错误: {error}")
    #
    # # 实时输出示例
    # print("\n实时输出示例:")
    # CommandUtils.execute_with_real_time_output(
    #     "ping -c 4 127.0.0.1" if not SystemUtils.is_windows() else "ping -n 4 127.0.0.1")
