From 0d1ef97b9c4becae014acbd1b7608f6c9c8b3301 Mon Sep 17 00:00:00 2001 From: Rune Date: Wed, 11 Mar 2026 19:55:29 +0100 Subject: [PATCH] Use template --- BeefProj.toml | 4 +- BeefSpace.toml | 4 +- README.md | 15 ------- Setup/BeefProj.toml | 6 +-- Setup/BeefSpace.toml | 4 +- Setup/src/Program.bf | 8 ++-- replace.py | 99 -------------------------------------------- 7 files changed, 13 insertions(+), 127 deletions(-) delete mode 100644 README.md delete mode 100644 replace.py diff --git a/BeefProj.toml b/BeefProj.toml index eb13655..4304fad 100644 --- a/BeefProj.toml +++ b/BeefProj.toml @@ -1,9 +1,9 @@ FileVersion = 1 [Project] -Name = "" +Name = "Glfw" TargetType = "BeefLib" -StartupObject = ".Program" +StartupObject = "Glfw.Program" [Configs.Debug.Win32] PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] diff --git a/BeefSpace.toml b/BeefSpace.toml index 6f7badd..b93d3f2 100644 --- a/BeefSpace.toml +++ b/BeefSpace.toml @@ -1,6 +1,6 @@ FileVersion = 1 -Projects = {"" = {Path = "."}} +Projects = {"Glfw" = {Path = "."}} ExtraPlatforms = ["Linux32", "Linux64", "macOS"] [Workspace] -StartupProject = "" +StartupProject = "Glfw" diff --git a/README.md b/README.md deleted file mode 100644 index 2a48373..0000000 --- a/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Cpp2Beef Template -Template for [Cpp2Beef](https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef) Bindings - -## Usage -```sh -# fork the repo -git clone --depth 1 https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.Template.git -cd -git remote rename origin upstream -git remote add origin - -# replace all occurences of with -python ./replace.py -rm replace.py -``` diff --git a/Setup/BeefProj.toml b/Setup/BeefProj.toml index 8f36b8f..ba20939 100644 --- a/Setup/BeefProj.toml +++ b/Setup/BeefProj.toml @@ -2,9 +2,9 @@ FileVersion = 1 Dependencies = {corlib = "*", "Clang-C.git" = "*", "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}} [Project] -Name = ".Setup" -StartupObject = ".Setup.Program" -DefaultNamespace = ".Setup" +Name = "Glfw.Setup" +StartupObject = "Glfw.Setup.Program" +DefaultNamespace = "Glfw.Setup" [Configs.Debug.Win32] PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] diff --git a/Setup/BeefSpace.toml b/Setup/BeefSpace.toml index 25b7a06..10b56a3 100644 --- a/Setup/BeefSpace.toml +++ b/Setup/BeefSpace.toml @@ -1,6 +1,6 @@ FileVersion = 1 -Projects = {".Setup" = {Path = "."}, "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}} +Projects = {"Glfw.Setup" = {Path = "."}, "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}} ExtraPlatforms = ["Linux32", "Linux64", "macOS"] [Workspace] -StartupProject = ".Setup" +StartupProject = "Glfw.Setup" diff --git a/Setup/src/Program.bf b/Setup/src/Program.bf index 1afdd2b..b71485a 100644 --- a/Setup/src/Program.bf +++ b/Setup/src/Program.bf @@ -6,9 +6,9 @@ using System.Diagnostics; using Cpp2Beef; using LibClang; -namespace .Setup; +namespace Glfw.Setup; -class Generator : Cpp2BeefGenerator, this(Span args) +class GlfwGenerator : Cpp2BeefGenerator, this(Span args) { protected override Span Args => args; protected override Flags Flags => .None; @@ -19,7 +19,7 @@ class Generator : Cpp2BeefGenerator, this(Span args) using System; using System.Interop; - namespace ; + namespace Glfw; """); @@ -46,7 +46,7 @@ class Program public static int Main(String[] args) { - scope Generator(char8*[?]("--language=c")).Generate(TODO, null); + scope GlfwGenerator(char8*[?]("--language=c")).Generate(TODO, null); return 0; } } \ No newline at end of file diff --git a/replace.py b/replace.py deleted file mode 100644 index 74d829b..0000000 --- a/replace.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python3 -import os -import sys -import argparse -import shutil - -def find_files_with_project_name(root_dir="."): - """Find all files that contain but exclude specified files""" - target_files = [] - ignored_dirs = {".git", ".svn", ".hg", ".vscode", "__pycache__"} - ignored_files = { - "./README.md", - "./replace.py" - } - - # Normalize ignored files for comparison - normalized_ignored = set() - for f in ignored_files: - normalized_ignored.add(os.path.normpath(f).replace("\\", "/")) - - for dirpath, dirnames, filenames in os.walk(root_dir): - # Filter out hidden directories - dirnames[:] = [d for d in dirnames if d not in ignored_dirs and not d.startswith('.')] - - for filename in filenames: - if filename.startswith('.') or filename.endswith(('.pyc', '.pyo', '~')): - continue - - filepath = os.path.join(dirpath, filename) - rel_path = os.path.relpath(filepath).replace("\\", "/") - - # Skip ignored files - if rel_path in normalized_ignored: - continue - - try: - with open(filepath, 'r', encoding='utf-8') as f: - content = f.read() - if '' in content: - target_files.append(filepath) - except (UnicodeDecodeError, PermissionError): - # Skip unreadable or binary files - pass - - return sorted(target_files) - -def main(): - parser = argparse.ArgumentParser(description='Replace with custom project name') - parser.add_argument('project_name', help='The new project name to replace with') - - args = parser.parse_args() - - if len(sys.argv) != 2: - print("Usage: python replace_project_name.py ") - sys.exit(1) - - project_name = args.project_name - - if not project_name: - print("Error: Project name cannot be empty") - sys.exit(1) - - # Find all files containing - files_with_project_name = find_files_with_project_name() - - if not files_with_project_name: - print("No files found containing ") - sys.exit(1) - - print(f"Found {len(files_with_project_name)} file(s) containing :") - for f in files_with_project_name: - print(f" • {f}") - - # Perform replacements - modified_count = 0 - for file_path in files_with_project_name: - try: - # Read the file - with open(file_path, 'r', encoding='utf-8') as f: - content = f.read() - - # Check if replacement is needed - if '' in content: - # Replace all occurrences - new_content = content.replace('', project_name) - - # Write back to file - with open(file_path, 'w', encoding='utf-8') as f: - f.write(new_content) - - print(f"Updated: {file_path}") - modified_count += 1 - except Exception as e: - print(f"Error processing {file_path}: {e}") - - print(f"\nSuccessfully replaced with '{project_name}' in {modified_count} file(s)") - -if __name__ == "__main__": - main()