parent
d7785f4a1b
commit
ff6e01acd0
8 changed files with 162 additions and 42 deletions
@ -1 +1,2 @@ |
||||
/test_app/ |
||||
/test_app/ |
||||
**__pycache__** |
@ -0,0 +1,24 @@ |
||||
import platform |
||||
|
||||
def tool_exist(name: str) -> bool: |
||||
from shutil import which |
||||
return which(name) is not None |
||||
|
||||
def search_tools(tools: str) -> str: |
||||
none_tools: str = [] |
||||
for tool in tools: |
||||
if not tool_exist(tool): |
||||
none_tools.append(tool) |
||||
return none_tools |
||||
|
||||
def verifie_tools() -> None: |
||||
none_tools: str = [] |
||||
match platform.system(): |
||||
case "Windows": |
||||
none_tools = search_tools(["git"]) |
||||
case "Linux": |
||||
none_tools = search_tools(["git"]) |
||||
case _: |
||||
raise Exception("Platform not supported") |
||||
if len(none_tools) > 0: |
||||
raise Exception(f"Tools missing {none_tools}") |
@ -0,0 +1,2 @@ |
||||
def add(name: str) -> None: |
||||
|
@ -0,0 +1,54 @@ |
||||
def get() -> str: |
||||
return '''project "App" |
||||
kind "ConsoleApp" |
||||
language "C++" |
||||
cppdialect "C++20" |
||||
systemversion "latest" |
||||
|
||||
targetdir("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}") |
||||
objdir("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}") |
||||
|
||||
files |
||||
{ |
||||
"src/**.h", |
||||
"src/**.cpp" |
||||
} |
||||
|
||||
filter "configurations:Debug" |
||||
defines |
||||
{ |
||||
"BK_DEBUG", |
||||
"DEBUG" |
||||
} |
||||
runtime "Debug" |
||||
symbols "on" |
||||
|
||||
|
||||
filter "configurations:Release" |
||||
defines |
||||
{ |
||||
"BK_RELEASE", |
||||
"NDEBUG" |
||||
} |
||||
runtime "Release" |
||||
optimize "on" |
||||
|
||||
filter "system:windows" |
||||
staticruntime "on" |
||||
defines |
||||
{ |
||||
"BK_PLATFORM_WINDOWS" |
||||
} |
||||
|
||||
filter "system:linux" |
||||
staticruntime "on" |
||||
defines |
||||
{ |
||||
"BK_PLATFORM_LINUX" |
||||
} |
||||
filter "" |
||||
includedirs |
||||
|
||||
links |
||||
|
||||
''' |
@ -0,0 +1,20 @@ |
||||
def get(name) -> str: |
||||
return '''workspace "''' + name + '''" |
||||
architecture "x64" |
||||
configurations { "Debug", "Release" } |
||||
startproject "App" |
||||
|
||||
flags |
||||
{ |
||||
"MultiProcessorCompile" |
||||
} |
||||
|
||||
linkgroups "On" |
||||
outputdir = "%{cfg.system}-%{cfg.architecture}-%{cfg.buildcfg}" |
||||
|
||||
include "Depedencies.lua" |
||||
|
||||
group "App" |
||||
include "app" |
||||
group "" |
||||
''' |
@ -0,0 +1,2 @@ |
||||
from . import Wks |
||||
from . import App |
@ -0,0 +1,49 @@ |
||||
import os |
||||
import Premake |
||||
|
||||
class Project: |
||||
def __init__(self, name) -> None: |
||||
self.name = name |
||||
self.git_repo = "" |
||||
|
||||
def set_git_repo(self, url) -> None: |
||||
self.git_repo = url |
||||
|
||||
def create(self) -> None: |
||||
self.create_folder() |
||||
self.premake_conf() |
||||
if not self.as_git_repo(): self.init_git_repo() |
||||
|
||||
def premake_conf(self) -> None: |
||||
wks = open("./premake5.lua", "w") |
||||
wks.write(Premake.Wks.get(self.name)) |
||||
wks.close() |
||||
app = open("./app/premake5.lua", "w") |
||||
app.write(Premake.App.get()) |
||||
app.close() |
||||
|
||||
def create_folder(self) -> None: |
||||
try: |
||||
os.mkdir("./app") |
||||
os.mkdir("./vendor") |
||||
os.mkdir("./app/src") |
||||
except: raise Exception("A directory already exists.") |
||||
create_file("./app/src/app.cpp") |
||||
create_file("./premake5.lua") |
||||
create_file("./app/premake5.lua") |
||||
|
||||
def as_git_repo(self) -> bool: |
||||
return os.path.exists("./.git") |
||||
|
||||
def init_git_repo(self) -> None: |
||||
os.system("git init --initial-branch=main") |
||||
os.system("git add .") |
||||
os.system('git commit -m "Initial commit"') |
||||
if len(self.git_repo) > 0: os.system(f'git remote add origin ${self.git_repo}') |
||||
|
||||
def create_file(path) -> None: |
||||
file = open(path, "w") |
||||
file.close() |
||||
|
||||
|
||||
|
@ -1,48 +1,16 @@ |
||||
import os |
||||
import sys |
||||
import platform |
||||
import numpy as np |
||||
from Buildtools import verifie_tools |
||||
from Project import Project |
||||
|
||||
def tool_exist(name: str) -> bool: |
||||
from shutil import which |
||||
return which(name) is not None |
||||
|
||||
def search_tools(tools: str) -> str: |
||||
none_tools: str = [] |
||||
for tool in tools: |
||||
if not tool_exist(tool): |
||||
none_tools.append(tool) |
||||
return none_tools |
||||
|
||||
def verifie_tools(): |
||||
none_tools: str = [] |
||||
match platform.system(): |
||||
case "Windows": |
||||
none_tools = search_tools(["git"]) |
||||
case "Linux": |
||||
none_tools = search_tools(["git"]) |
||||
case _: |
||||
print("Platform not supported") |
||||
exit(1) |
||||
if len(none_tools) > 0: |
||||
print(f"Tools missing {none_tools}") |
||||
exit(1) |
||||
|
||||
def create_file(path): |
||||
file = open(path, "w") |
||||
file.close() |
||||
|
||||
|
||||
def setup(): |
||||
if len(sys.argv[1]): |
||||
def setup() -> None: |
||||
if len(sys.argv) >= 2: |
||||
if not os.path.exists(sys.argv[1]): os.mkdir(sys.argv[1]) |
||||
os.chdir(sys.argv[1]) |
||||
verifie_tools() |
||||
os.mkdir("./app") |
||||
os.mkdir("./vendor") |
||||
os.mkdir("./app/src") |
||||
create_file("./app/src/app.cpp") |
||||
create_file("./premake5.lua") |
||||
create_file("./app/premake5.lua") |
||||
project: Project = Project("Test") |
||||
project.create() |
||||
|
||||
|
||||
if __name__ == "main": |
||||
if __name__ == "__main__": |
||||
setup() |
Loading…
Reference in New Issue