commit 97e8446b9648f53313762918a7618317f8dedd19 Author: Beef Bindings <> Date: Wed Mar 11 15:48:30 2026 +0000 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e52758 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build +recovery +BeefSpace_User.toml + +CxxBuilderPath.txt diff --git a/BeefProj.toml b/BeefProj.toml new file mode 100644 index 0000000..eb13655 --- /dev/null +++ b/BeefProj.toml @@ -0,0 +1,66 @@ +FileVersion = 1 + +[Project] +Name = "" +TargetType = "BeefLib" +StartupObject = ".Program" + +[Configs.Debug.Win32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Debug.Win64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Debug.Linux32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Debug.Linux64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Debug.macOS] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Release.Win32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Release.Win64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Release.Linux32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Release.Linux64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Release.macOS] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Paranoid.Win32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Paranoid.Win64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Paranoid.Linux32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Paranoid.Linux64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Paranoid.macOS] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Test.Win32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Test.Win64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Test.Linux32] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Test.Linux64] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] + +[Configs.Test.macOS] +PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"] diff --git a/BeefSpace.toml b/BeefSpace.toml new file mode 100644 index 0000000..6f7badd --- /dev/null +++ b/BeefSpace.toml @@ -0,0 +1,6 @@ +FileVersion = 1 +Projects = {"" = {Path = "."}} +ExtraPlatforms = ["Linux32", "Linux64", "macOS"] + +[Workspace] +StartupProject = "" diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a48373 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# 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/.gitignore b/Setup/.gitignore new file mode 100644 index 0000000..e237948 --- /dev/null +++ b/Setup/.gitignore @@ -0,0 +1,6 @@ +build +recovery +BeefSpace_User.toml + +# lock ignored by default to make template is always on the latest version +BeefSpace_Lock.toml diff --git a/Setup/BeefProj.toml b/Setup/BeefProj.toml new file mode 100644 index 0000000..8f36b8f --- /dev/null +++ b/Setup/BeefProj.toml @@ -0,0 +1,67 @@ +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" + +[Configs.Debug.Win32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Debug.Win64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Debug.Linux32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Debug.Linux64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Debug.macOS] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Release.Win32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Release.Win64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Release.Linux32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Release.Linux64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Release.macOS] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Paranoid.Win32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Paranoid.Win64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Paranoid.Linux32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Paranoid.Linux64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Paranoid.macOS] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Test.Win32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Test.Win64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Test.Linux32] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Test.Linux64] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] + +[Configs.Test.macOS] +PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"] diff --git a/Setup/BeefSpace.toml b/Setup/BeefSpace.toml new file mode 100644 index 0000000..25b7a06 --- /dev/null +++ b/Setup/BeefSpace.toml @@ -0,0 +1,6 @@ +FileVersion = 1 +Projects = {".Setup" = {Path = "."}, "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}} +ExtraPlatforms = ["Linux32", "Linux64", "macOS"] + +[Workspace] +StartupProject = ".Setup" diff --git a/Setup/src/Program.bf b/Setup/src/Program.bf new file mode 100644 index 0000000..1afdd2b --- /dev/null +++ b/Setup/src/Program.bf @@ -0,0 +1,52 @@ +using System; +using System.IO; +using System.Collections; +using System.Diagnostics; + +using Cpp2Beef; +using LibClang; + +namespace .Setup; + +class Generator : Cpp2BeefGenerator, this(Span args) +{ + protected override Span Args => args; + protected override Flags Flags => .None; + + StreamWriter writer = new .()..Create(TODO)..Write(""" + // This file was generated by Cpp2Beef + + using System; + using System.Interop; + + namespace ; + + + """); + + protected override StreamWriter GetWriterForHeader(StringView header) + { + if (header.EndsWith(TODO)) + return writer; + return null; + } + +} + +class Program +{ + [CLink] static extern int32 system(char8*); + private static mixin RunCommand(char8* cmd) + { + Console.WriteLine($"> {StringView(cmd)}"); + int32 rcode = system(cmd); + if (rcode != 0) + return rcode; + } + + public static int Main(String[] args) + { + scope Generator(char8*[?]("--language=c")).Generate(TODO, null); + return 0; + } +} \ No newline at end of file diff --git a/replace.py b/replace.py new file mode 100644 index 0000000..74d829b --- /dev/null +++ b/replace.py @@ -0,0 +1,99 @@ +#!/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()