Use template
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
FileVersion = 1
|
FileVersion = 1
|
||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
Name = "<ProjectName>"
|
Name = "Glfw"
|
||||||
TargetType = "BeefLib"
|
TargetType = "BeefLib"
|
||||||
StartupObject = "<ProjectName>.Program"
|
StartupObject = "Glfw.Program"
|
||||||
|
|
||||||
[Configs.Debug.Win32]
|
[Configs.Debug.Win32]
|
||||||
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"]
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
FileVersion = 1
|
FileVersion = 1
|
||||||
Projects = {"<ProjectName>" = {Path = "."}}
|
Projects = {"Glfw" = {Path = "."}}
|
||||||
ExtraPlatforms = ["Linux32", "Linux64", "macOS"]
|
ExtraPlatforms = ["Linux32", "Linux64", "macOS"]
|
||||||
|
|
||||||
[Workspace]
|
[Workspace]
|
||||||
StartupProject = "<ProjectName>"
|
StartupProject = "Glfw"
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -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 <path>
|
|
||||||
cd <path>
|
|
||||||
git remote rename origin upstream
|
|
||||||
git remote add origin <url>
|
|
||||||
|
|
||||||
# replace all occurences of <ProjectName> with <name>
|
|
||||||
python ./replace.py <name>
|
|
||||||
rm replace.py
|
|
||||||
```
|
|
||||||
@@ -2,9 +2,9 @@ FileVersion = 1
|
|||||||
Dependencies = {corlib = "*", "Clang-C.git" = "*", "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}}
|
Dependencies = {corlib = "*", "Clang-C.git" = "*", "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}}
|
||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
Name = "<ProjectName>.Setup"
|
Name = "Glfw.Setup"
|
||||||
StartupObject = "<ProjectName>.Setup.Program"
|
StartupObject = "Glfw.Setup.Program"
|
||||||
DefaultNamespace = "<ProjectName>.Setup"
|
DefaultNamespace = "Glfw.Setup"
|
||||||
|
|
||||||
[Configs.Debug.Win32]
|
[Configs.Debug.Win32]
|
||||||
PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"]
|
PreBuildCmds = ["cp $(ProjectDir Cpp2Beef.git)/CxxBuilder/dist/CxxBuilderPath.txt ../CxxBuilderPath.txt"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
FileVersion = 1
|
FileVersion = 1
|
||||||
Projects = {"<ProjectName>.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"]
|
ExtraPlatforms = ["Linux32", "Linux64", "macOS"]
|
||||||
|
|
||||||
[Workspace]
|
[Workspace]
|
||||||
StartupProject = "<ProjectName>.Setup"
|
StartupProject = "Glfw.Setup"
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ using System.Diagnostics;
|
|||||||
using Cpp2Beef;
|
using Cpp2Beef;
|
||||||
using LibClang;
|
using LibClang;
|
||||||
|
|
||||||
namespace <ProjectName>.Setup;
|
namespace Glfw.Setup;
|
||||||
|
|
||||||
class <ProjectName>Generator : Cpp2BeefGenerator, this(Span<char8*> args)
|
class GlfwGenerator : Cpp2BeefGenerator, this(Span<char8*> args)
|
||||||
{
|
{
|
||||||
protected override Span<char8*> Args => args;
|
protected override Span<char8*> Args => args;
|
||||||
protected override Flags Flags => .None;
|
protected override Flags Flags => .None;
|
||||||
@@ -19,7 +19,7 @@ class <ProjectName>Generator : Cpp2BeefGenerator, this(Span<char8*> args)
|
|||||||
using System;
|
using System;
|
||||||
using System.Interop;
|
using System.Interop;
|
||||||
|
|
||||||
namespace <ProjectName>;
|
namespace Glfw;
|
||||||
|
|
||||||
|
|
||||||
""");
|
""");
|
||||||
@@ -46,7 +46,7 @@ class Program
|
|||||||
|
|
||||||
public static int Main(String[] args)
|
public static int Main(String[] args)
|
||||||
{
|
{
|
||||||
scope <ProjectName>Generator(char8*[?]("--language=c")).Generate(TODO, null);
|
scope GlfwGenerator(char8*[?]("--language=c")).Generate(TODO, null);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
99
replace.py
99
replace.py
@@ -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 <ProjectName> 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 '<ProjectName>' 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 <ProjectName> with custom project name')
|
|
||||||
parser.add_argument('project_name', help='The new project name to replace <ProjectName> with')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
print("Usage: python replace_project_name.py <NewProjectName>")
|
|
||||||
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 <ProjectName>
|
|
||||||
files_with_project_name = find_files_with_project_name()
|
|
||||||
|
|
||||||
if not files_with_project_name:
|
|
||||||
print("No files found containing <ProjectName>")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
print(f"Found {len(files_with_project_name)} file(s) containing <ProjectName>:")
|
|
||||||
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 '<ProjectName>' in content:
|
|
||||||
# Replace all occurrences
|
|
||||||
new_content = content.replace('<ProjectName>', 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 <ProjectName> with '{project_name}' in {modified_count} file(s)")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user