mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
refactor: unify project handling (cmdline = projects/default)
This commit is contained in:
+28
-1
@@ -1,14 +1,22 @@
|
||||
import logging
|
||||
import shutil
|
||||
|
||||
from model.defs import *
|
||||
from model.payload import Payload
|
||||
from model.exehost import ExeHost
|
||||
from model.settings import Settings
|
||||
from model.carrier import Carrier
|
||||
|
||||
|
||||
logger = logging.getLogger("Project")
|
||||
|
||||
|
||||
class WebProject():
|
||||
def __init__(self, name: str, settings: Settings):
|
||||
self.name = name
|
||||
self.settings: Settings = settings
|
||||
self.comment: str = ""
|
||||
|
||||
|
||||
class Project():
|
||||
def __init__(self, settings: Settings):
|
||||
self.name: str = ""
|
||||
@@ -26,3 +34,22 @@ class Project():
|
||||
self.payload.init()
|
||||
self.exe_host.init()
|
||||
self.carrier.init()
|
||||
|
||||
|
||||
def prepare_project(project_name, settings):
|
||||
src = "{}{}/".format(PATH_CARRIER, settings.source_style.value)
|
||||
dst = "{}{}/".format(PATH_WEB_PROJECT, project_name)
|
||||
|
||||
# delete all files in dst directory
|
||||
for file in os.listdir(dst):
|
||||
if file == "project.pickle":
|
||||
continue
|
||||
if file.startswith("."):
|
||||
continue
|
||||
os.remove(dst + file)
|
||||
|
||||
# copy *.c *.h files from src directory to dst directory
|
||||
for file in os.listdir(src):
|
||||
if file.endswith(".c") or file.endswith(".h"):
|
||||
logger.info("Copy {} to {}".format(src + file, dst))
|
||||
shutil.copy2(src + file, dst)
|
||||
+3
-9
@@ -1,5 +1,8 @@
|
||||
import logging
|
||||
from model.defs import *
|
||||
|
||||
logger = logging.getLogger("Views")
|
||||
|
||||
|
||||
class Settings():
|
||||
def __init__(self, web=""):
|
||||
@@ -28,15 +31,6 @@ class Settings():
|
||||
self.generate_shc_from_asm: bool = True
|
||||
|
||||
|
||||
def prep(self):
|
||||
self.main_dir = "{}{}/".format(PATH_CARRIER, self.source_style.value)
|
||||
self.template_path = self.main_dir + "template.c"
|
||||
self.main_c_path = self.main_dir + "main.c"
|
||||
self.main_asm_path = self.main_dir + "main.asm"
|
||||
self.main_exe_path = self.main_dir + "main.exe"
|
||||
self.main_shc_path = self.main_dir + "main.bin"
|
||||
|
||||
|
||||
def prep_web(self, project_name):
|
||||
self.main_dir = "{}{}/".format(PATH_WEB_PROJECT, project_name)
|
||||
self.template_path = self.main_dir + "template.c"
|
||||
|
||||
Reference in New Issue
Block a user