Cleaned cli app

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

@ -8,6 +8,7 @@ import webbrowser
import Log
def config(package):
Log.info(f"Reconfiguring package {package}")
if os.path.exists(f"./vendor/{package}/dependencies"):
dep = open(f"./vendor/{package}/dependencies", "r")
pkg_deps = dep.read()
@ -39,6 +40,7 @@ def config(package):
def reconfig():
Log.info("Reconfiguring build settings :")
f_conf = open("./package.json", "r")
conf = json.loads(f_conf.read())
f_conf.close()
@ -52,7 +54,7 @@ def reconfig():
for linker in linkers:
if len(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"]):
for include in linker["includes"]:
if len(include): includes += '\t"%{IncludeDirs.' + include + '}",\n'
@ -63,7 +65,7 @@ def reconfig():
f_linker.close()
def install(author, package) -> None:
Log.info(f"Installing {package}")
Log.info(f"Installing package {package}")
if os.path.exists(f"./vendor/{package}"):
Log.warning("Package already added")
return
@ -91,12 +93,14 @@ def add(author, package) -> None:
reconfig()
def update(package) -> None:
Log.info(f"Updating package {package}")
if not os.path.exists(f"./vendor/{package}"): Log.error("Package not found")
os.chdir(f"./vendor/{package}")
Command.exec("git pull")
reconfig()
def save(package, message) -> None:
Log.info(f"Saving package {package}")
if not os.path.exists(f"./vendor/{package}"): Log.error("Package not found")
os.chdir(f"./vendor/{package}")
Command.exec("git add .")
@ -115,7 +119,7 @@ def remove(package) -> None:
reconfig()
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 os.path.exists(f"./vendor/{package}/package.json") :
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)
def install_root() -> None:
Log.info("Reinstalling all packages :")
if not os.path.exists("./package.json"):
Log.error("No package config file")
f_conf = open("./package.json", "r")
@ -140,9 +145,4 @@ def load_doc(package) -> None:
if not os.path.exists(f"./vendor/{package}/Doxyfile"):
Log.error("Doxygen config file not found")
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 Premake
import Command
import Log
class Builder:
def __init__(self, conf) -> None:
@ -28,6 +29,7 @@ class Builder:
"git": self.git_repo,
"packages": []
}
Log.info("Configuring package.json")
file_conf = open("./package.json", "w")
file_conf.write(json.dumps(conf, indent=4))
file_conf.close()
@ -49,7 +51,8 @@ class Builder:
**.vcxproj*
**.make
**Makefile
**deps.lua
**dependencies.lua
**linker.lua
""")
def create_folder(self) -> None:
@ -57,7 +60,7 @@ class Builder:
os.mkdir("./app")
os.mkdir("./vendor")
os.mkdir("./app/src")
except: raise Exception("Directory already exists.")
except: Log.error("Directory already exists.")
create_file("./app/src/app.cpp")
create_file("./premake5.lua")
create_file("./app/premake5.lua")
@ -68,7 +71,9 @@ class Builder:
return os.path.exists("./.git")
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 add .")
Command.exec('git commit -m "Initial commit"')

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