Cleaned cli app

dev
anulax1225 ago%!(EXTRA string=11 months)
parent b89395a611
commit ba336b7bad
  1. 16
      src/Package.py
  2. 11
      src/Project.py
  3. 7
      src/ToolChaine.py

@ -8,6 +8,7 @@ import webbrowser
import Log import Log
def config(package): def config(package):
Log.info(f"Reconfiguring package {package}")
if os.path.exists(f"./vendor/{package}/dependencies"): if os.path.exists(f"./vendor/{package}/dependencies"):
dep = open(f"./vendor/{package}/dependencies", "r") dep = open(f"./vendor/{package}/dependencies", "r")
pkg_deps = dep.read() pkg_deps = dep.read()
@ -39,6 +40,7 @@ def config(package):
def reconfig(): def reconfig():
Log.info("Reconfiguring build settings :")
f_conf = open("./package.json", "r") f_conf = open("./package.json", "r")
conf = json.loads(f_conf.read()) conf = json.loads(f_conf.read())
f_conf.close() f_conf.close()
@ -52,7 +54,7 @@ def reconfig():
for linker in linkers: for linker in linkers:
if len(linker["links"]): if len(linker["links"]):
for link in linker["links"]: for link in linker["links"]:
if len(link): links += '\t"%{' + link + '}",\n' if len(link): links += '\t"' + link + '",\n'
if len(linker["includes"]): if len(linker["includes"]):
for include in linker["includes"]: for include in linker["includes"]:
if len(include): includes += '\t"%{IncludeDirs.' + include + '}",\n' if len(include): includes += '\t"%{IncludeDirs.' + include + '}",\n'
@ -63,7 +65,7 @@ def reconfig():
f_linker.close() f_linker.close()
def install(author, package) -> None: def install(author, package) -> None:
Log.info(f"Installing {package}") Log.info(f"Installing package {package}")
if os.path.exists(f"./vendor/{package}"): if os.path.exists(f"./vendor/{package}"):
Log.warning("Package already added") Log.warning("Package already added")
return return
@ -91,12 +93,14 @@ def add(author, package) -> None:
reconfig() reconfig()
def update(package) -> None: def update(package) -> None:
Log.info(f"Updating package {package}")
if not os.path.exists(f"./vendor/{package}"): Log.error("Package not found") if not os.path.exists(f"./vendor/{package}"): Log.error("Package not found")
os.chdir(f"./vendor/{package}") os.chdir(f"./vendor/{package}")
Command.exec("git pull") Command.exec("git pull")
reconfig() reconfig()
def save(package, message) -> None: def save(package, message) -> None:
Log.info(f"Saving package {package}")
if not os.path.exists(f"./vendor/{package}"): Log.error("Package not found") if not os.path.exists(f"./vendor/{package}"): Log.error("Package not found")
os.chdir(f"./vendor/{package}") os.chdir(f"./vendor/{package}")
Command.exec("git add .") Command.exec("git add .")
@ -115,7 +119,7 @@ def remove(package) -> None:
reconfig() reconfig()
def r_remove(package) -> None: def r_remove(package) -> None:
Log.info(f"Removing {package}") Log.info(f"Removing package {package}")
if not os.path.exists(f"./vendor/{package}/") : Log.error(f"Package {package} not the dependencies") if not os.path.exists(f"./vendor/{package}/") : Log.error(f"Package {package} not the dependencies")
if os.path.exists(f"./vendor/{package}/package.json") : if os.path.exists(f"./vendor/{package}/package.json") :
r_pkgs = json.loads(open(f"./vendor/{package}/package.json", "r").read())["packages"] r_pkgs = json.loads(open(f"./vendor/{package}/package.json", "r").read())["packages"]
@ -125,6 +129,7 @@ def r_remove(package) -> None:
shutil.rmtree(f"./vendor/{package}/", ignore_errors=True) shutil.rmtree(f"./vendor/{package}/", ignore_errors=True)
def install_root() -> None: def install_root() -> None:
Log.info("Reinstalling all packages :")
if not os.path.exists("./package.json"): if not os.path.exists("./package.json"):
Log.error("No package config file") Log.error("No package config file")
f_conf = open("./package.json", "r") f_conf = open("./package.json", "r")
@ -141,8 +146,3 @@ def load_doc(package) -> None:
Log.error("Doxygen config file not found") Log.error("Doxygen config file not found")
Command.exec(f"doxygen ./vendor/{package}") Command.exec(f"doxygen ./vendor/{package}")
webbrowser.open("file://" + os.path.realpath(f"./vendor/{package}/docs/html/index.html")) webbrowser.open("file://" + os.path.realpath(f"./vendor/{package}/docs/html/index.html"))

@ -2,6 +2,7 @@ import os
import json import json
import Premake import Premake
import Command import Command
import Log
class Builder: class Builder:
def __init__(self, conf) -> None: def __init__(self, conf) -> None:
@ -28,6 +29,7 @@ class Builder:
"git": self.git_repo, "git": self.git_repo,
"packages": [] "packages": []
} }
Log.info("Configuring package.json")
file_conf = open("./package.json", "w") file_conf = open("./package.json", "w")
file_conf.write(json.dumps(conf, indent=4)) file_conf.write(json.dumps(conf, indent=4))
file_conf.close() file_conf.close()
@ -49,7 +51,8 @@ class Builder:
**.vcxproj* **.vcxproj*
**.make **.make
**Makefile **Makefile
**deps.lua **dependencies.lua
**linker.lua
""") """)
def create_folder(self) -> None: def create_folder(self) -> None:
@ -57,7 +60,7 @@ class Builder:
os.mkdir("./app") os.mkdir("./app")
os.mkdir("./vendor") os.mkdir("./vendor")
os.mkdir("./app/src") os.mkdir("./app/src")
except: raise Exception("Directory already exists.") except: Log.error("Directory already exists.")
create_file("./app/src/app.cpp") create_file("./app/src/app.cpp")
create_file("./premake5.lua") create_file("./premake5.lua")
create_file("./app/premake5.lua") create_file("./app/premake5.lua")
@ -68,7 +71,9 @@ class Builder:
return os.path.exists("./.git") return os.path.exists("./.git")
def init_git_repo(self) -> None: def init_git_repo(self) -> None:
if not self.as_git_repo(): return if self.as_git_repo():
Log.warning("Git folder already exists.")
return
Command.exec("git init --initial-branch=main") Command.exec("git init --initial-branch=main")
Command.exec("git add .") Command.exec("git add .")
Command.exec('git commit -m "Initial commit"') Command.exec('git commit -m "Initial commit"')

@ -16,6 +16,7 @@ def search_tools(tools: str) -> str:
return none_tools return none_tools
def verifie_build_tools() -> None: def verifie_build_tools() -> None:
Log.info(f"Verifing build tools")
none_tools: str = [] none_tools: str = []
match platform.system(): match platform.system():
case "Windows": case "Windows":
@ -36,13 +37,17 @@ def run(config) -> None:
def build(config) -> None: def build(config) -> None:
Log.info(f"Starting build with config {config}")
verifie_build_tools() verifie_build_tools()
match platform.system(): match platform.system():
case "Windows": case "Windows":
Command.exec("premake5 vs2022") Command.exec("premake5 vs2022")
Command.exec("dotnet build") Command.exec("dotnet build")
case "Linux": case "Linux":
Command.exec(f"premake5 gmake2 && make config={config.lower()}") Command.exec("premake5 gmake2")
Command.exec(f"make config={config.lower()}")
case _: case _:
Log.error("Platform not supported") Log.error("Platform not supported")
Log.info("Finished build")
Loading…
Cancel
Save