Обновлен README.md с инструкциями по установке и улучшить скрипт установки. Исправлены импорты в модулях и улучшить обработку сборки в run.py/build.py.

This commit is contained in:
2026-02-12 09:17:35 +08:00
parent f831183b25
commit d510efdaef
10 changed files with 133 additions and 98 deletions

View File

@@ -2,7 +2,7 @@ import time
import os
import subprocess
from ..config import flags, profile, c_comp
from dcr.utils.fs import check_dir
from ..utils.fs import check_dir
def build(args: list[str] | None = None) -> int:
@@ -31,18 +31,24 @@ def build(args: list[str] | None = None) -> int:
print(f"Запуск сборки с профилем {active_profile}")
compile_flags = flags[active_profile]
start_time: float = time.time()
subprocess.run(
[
c_comp,
"./src/main.c",
*compile_flags,
"-o",
f"./target/{active_profile}/main",
],
check=True,
)
end_time: float = time.time()
times: float = end_time - start_time
times: float = int(times * 100) / 100
print(f"Сборка завершена, за {times} секунд")
try:
subprocess.run(
[
c_comp,
"./src/main.c",
*compile_flags,
"-o",
f"./target/{active_profile}/main",
],
check=True,
)
end_time: float = time.time()
times: float = end_time - start_time
times: float = int(times * 100) / 100
print(f"Сборка завершена, за {times} секунд")
return 0
except:
print("Ошибка сборки")
return 1
return 0

View File

@@ -1,5 +1,4 @@
from dcr.utils.fs import check_dir
import os
from ..utils.fs import check_dir
import shutil

View File

@@ -1,4 +1,4 @@
from dcr.config import (
from ..config import (
file_dcr_toml,
file_main_c,
project_version,
@@ -6,13 +6,14 @@ from dcr.config import (
project_compiler,
)
import os
from dcr.utils.fs import check_dir
from ..utils.fs import check_dir
def init(args: list[str] | None = None) -> int:
if args:
print("Ошибка: команда init не поддерживает аргументы")
return 1
items = check_dir()
items: list[str] = check_dir()
project_name = os.path.basename(os.getcwd())
if items:

View File

@@ -1,4 +1,4 @@
from dcr.config import (
from ..config import (
file_dcr_toml,
file_main_c,
project_version,
@@ -6,7 +6,7 @@ from dcr.config import (
project_compiler,
)
import os
from dcr.utils.fs import check_dir
from ..utils.fs import check_dir
def new(args: list[str]) -> int:

View File

@@ -1,7 +1,6 @@
import os
import subprocess
from dcr.utils.fs import check_dir
from ..utils.fs import check_dir
from ..config import flags, profile
from .build import build
@@ -24,6 +23,14 @@ def run(args: list[str] | None = None) -> int:
print("Ошибка: флаг сборки не найден")
return 1
build(args)
print("Запуск проекта")
return subprocess.run([f"./target/{active_profile}/main"]).returncode
build_status: int = build(args)
if build_status == 0:
print("Запуск проекта")
return subprocess.run([f"./target/{active_profile}/main"]).returncode
else:
if active_profile in check_dir("target/" + active_profile):
print("Запуск последнего релиза")
return subprocess.run([f"./target/{active_profile}/main"]).returncode
else:
print("Исправьте ошибки в коде для запуска проекта")
return 0

View File

@@ -26,5 +26,6 @@ def main() -> int:
return 0
if __name__ == "__main__":
raise SystemExit(main())
raise SystemExit(main())