Scripts: Srcgen

This commit is contained in:
Isuru Samarathunga
2025-11-01 01:23:31 +05:30
parent 9d85e3d822
commit dd2d2e1ae8
21 changed files with 456 additions and 9 deletions

View File

@ -1,2 +0,0 @@
#!/bin/python3

View File

@ -1,2 +0,0 @@
#!/bin/python3

View File

@ -1,2 +0,0 @@
#!/bin/python3

View File

@ -0,0 +1,26 @@
#!/bin/python3
# IAEngine: 2D Game Engine by IA
# Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
import sys
def main(args: list[str]):
os.system("cmake -S. -B./Build/Windows -DCMAKE_BUILD_TYPE=Debug -DBUILD_SAMPLES=ON")
os.system("cmake --build ./Build/Windows")
main(sys.argv)

View File

@ -1 +0,0 @@
#!/bin/python3

View File

@ -0,0 +1,120 @@
#!/bin/python3
# IAEngine: 2D Game Engine by IA
# Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys
def get_header_file_content(className: str):
return f"""// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
namespace ia::iae
{{
class {className}
{{
public:
{className}();
~{className}();
private:
}};
}}
"""
def get_source_file_content(className: str, headerPath: str):
return f"""// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <{headerPath}>
namespace ia::iae
{{
{className}::{className}()
{{
}}
{className}::~{className}()
{{
}}
}}
"""
def add_header_file(className: str, fileName: str, fileDirectory: str):
print(f"\033[32mAdding Header File '{fileName}' to '{fileDirectory}'..\033[39m")
with open(f"{fileDirectory}/{fileName}", 'w') as f:
f.write(get_header_file_content(className))
def add_source_file(className: str, headerPath: str, fileName: str, fileDirectory: str):
print(f"\033[32mAdding Source File '{fileName}' to '{fileDirectory}'..\033[39m")
with open(f"{fileDirectory}/{fileName}", 'w') as f:
f.write(get_source_file_content(className, headerPath))
def on_invalid_args():
print(f"\033[33mUsage: {sys.argv[0]} <ProjectName> <PRIVATE|PUBLIC> <ClassName>\033[39m")
exit(1)
def main(args: list[str]):
if (len(args) < 4) or ((args[2] != "PUBLIC") and (args[2] != "PRIVATE")):
on_invalid_args()
fileName = f"{args[3]}.hpp"
headerPath = ""
fileDirectory = ""
if args[2] == "PUBLIC":
headerPath = f"{args[1]}/{fileName}"
fileDirectory = f"Src/{args[1]}/inc/{args[1]}"
else:
headerPath = f"{fileName}"
fileDirectory = f"Src/{args[1]}/imp/hpp"
add_header_file(args[3], fileName, fileDirectory)
fileName = f"{args[3]}.cpp"
fileDirectory = f"Src/{args[1]}/imp/cpp"
add_source_file(args[3], headerPath, fileName, fileDirectory)
main(sys.argv)

View File

@ -0,0 +1,67 @@
#!/bin/python3
# IAEngine: 2D Game Engine by IA
# Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys
FILE_TEMPLATE = """// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <IAEngine/Base.hpp>
namespace ia::iae
{
}
"""
def on_invalid_args():
print(f"\033[33mUsage: {sys.argv[0]} <ProjectName> <PRIVATE|PUBLIC> <FileName>\033[39m")
exit(1)
def add_header_file(fileName: str, fileDirectory: str):
print(f"\033[32mAdding Header File '{fileName}' to '{fileDirectory}'..\033[39m")
with open(f"{fileDirectory}/{fileName}", 'w') as f:
f.write(FILE_TEMPLATE)
def main(args: list[str]):
if (len(args) < 4) or ((args[2] != "PUBLIC") and (args[2] != "PRIVATE")):
on_invalid_args()
fileName = f"{args[3]}.hpp"
fileDirectory = ""
if args[2] == "PUBLIC":
fileDirectory = f"Src/{args[1]}/inc/{args[1]}"
else:
fileDirectory = f"Src/{args[1]}/imp/hpp"
add_header_file(fileName, fileDirectory)
main(sys.argv)

View File

@ -0,0 +1,59 @@
#!/bin/python3
# IAEngine: 2D Game Engine by IA
# Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys
FILE_TEMPLATE = """// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
namespace ia::iae
{
}
"""
def on_invalid_args():
print(f"\033[33mUsage: {sys.argv[0]} <ProjectName> <FileName>\033[39m")
exit(1)
def add_source_file(fileName: str, fileDirectory: str):
print(f"\033[32mAdding Source File '{fileName}' to '{fileDirectory}'..\033[39m")
with open(f"{fileDirectory}/{fileName}", 'w') as f:
f.write(FILE_TEMPLATE)
def main(args: list[str]):
if len(args) < 3:
on_invalid_args()
fileName = f"{args[3]}.cpp"
fileDirectory = f"Src/{args[1]}/imp/cpp"
add_source_file(fileName, fileDirectory)
main(sys.argv)

View File

@ -0,0 +1,18 @@
#!/bin/python3
# IAEngine: 2D Game Engine by IA
# Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.