Formatting Cpp Files

Actually, formatting C++ files are hard. VSCode comes with a default formatting style - backed by MS C/C++ or clang-format. Also, most of legacy code are not formatted using standard tools, so you will get a lot of git differences when you have changed a bit of code, and pressed Alt+Shift+F; this is a key difference compared to Python. The solution was to format all C++ files before touching the code - so an automated tool was necessary. ...

May 10, 2025

using Makefile On Windows with powershell

Actually, makefile can be used on Windows. I have used them when intergrating SuRun with Go. remove directory pwsh -nop -c "rm -r -Force ../build-ig || 1" create directory pwsh -nop -c "mkdir ReleaseUx64" || true launch makefile in MSYS2 msys-surun: pwsh -nop msys.ps1 -ucrt64 -c "make _msys_surun" _msys_surun: # commands in MSYS2

May 10, 2025

SuRun Development Environment Setup

IDE Since we are on Windows, the preferred compiler is Visual C++. You can install Visual Studio, it provides the compiler and an integrated editor. Note that Visual Studio Community is free even for commericial use. See License for more details. If you prefer other editors, you can just install Visual Studio Build Tools. installation details In addiction to the standard “Desktop Development with C++”, you need also install component ATL and MFC. This is true for both Visual Studio Community and Visual Studio Build Tools. ...

May 9, 2025

Remove Unused Confs

Get the confs Input collapsed: from surun_tools.glob1 import glob_files glob_files("*.vcxproj") [WindowsPath('C:/src/surun/src/PC/InstallSuRun.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRun.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRunExt.vcxproj'), WindowsPath('C:/src/surun/tests/TestScreenshot/TestScreenshot.vcxproj'), WindowsPath('C:/src/surun/tests/TestScreenshotSuRun/TestScreenshotSuRun.vcxproj')] some confs are test projects. filter out them proj_files = list(filter(lambda x: "test" not in str(x), glob_files("*.vcxproj"))) proj_files [WindowsPath('C:/src/surun/src/PC/InstallSuRun.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRun.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRunExt.vcxproj')] Select a demo proj file ext_proj = glob_files("*.vcxproj")[2] print(ext_proj) C:\src\surun\src\PC\SuRunExt.vcxproj from lxml import etree parser = etree.XMLParser(remove_comments=False) tree = etree.parse(ext_proj, parser) def is_correct_conf(s: str) -> bool: if "x64 Unicode Debug|x64" in s: return True elif "SuRun32 Unicode Debug|Win32" in s: return True return False def save(): global tree tree.write(ext_proj, encoding="utf-8", xml_declaration=True) from pathlib import Path content = Path(ext_proj).read_text(encoding="utf8") content = content.replace("ns0:", "").replace(":ns0", "").replace('/>', ' />') Path(ext_proj).write_text(content, encoding="utf8") # idea from Gemini ns = {"default": "http://schemas.microsoft.com/developer/msbuild/2003"} def remove(tag, tag2="Condition"): tag = "/".join(map(lambda x: "default:" + x, tag.split("/"))) root = tree.getroot() for i in root.findall(f"{tag}", ns): if tag2 not in i.attrib: continue if not is_correct_conf(i.attrib[tag2]): i.getparent().remove(i) save() Test gradually ...

May 7, 2025

Remove Bscmake

from surun_tools.glob1 import glob_files glob_files("*.vcxproj") [WindowsPath('C:/src/surun/src/PC/InstallSuRun.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRun.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRunExt.vcxproj'), WindowsPath('C:/src/surun/tests/TestScreenshot/TestScreenshot.vcxproj'), WindowsPath('C:/src/surun/tests/TestScreenshotSuRun/TestScreenshotSuRun.vcxproj')] lines = [] for i in glob_files("*.vcxproj"): content = i.read_text(encoding="utf8") for line in content.split('\n'): if "bscmake" in line.lower(): lines.append(line) lines[:3] [] from lxml import etree ns = {"default": "http://schemas.microsoft.com/developer/msbuild/2003"} def remove_bscmake_nodes(xml_file): """ Removes all nodes with the name 'bscmake' and their contents from an XML file. Args: xml_file (str): The path to the XML file. """ try: parser = etree.XMLParser(remove_comments=False) tree = etree.parse(xml_file, parser) root = tree.getroot() for i in root.findall('default:ItemDefinitionGroup', ns): for j in i.findall("default:Bscmake", ns): i.remove(j) tree.write(xml_file, encoding="utf-8", xml_declaration=True) from pathlib import Path content = Path(xml_file).read_text(encoding="utf8") content = content.replace("ns0:", "").replace(":ns0", "").replace('/>', ' />') Path(xml_file).write_text(content, encoding="utf8") except FileNotFoundError: print(f"Error: File not found at '{xml_file}'.") except etree.XMLSyntaxError: print(f"Error: Could not parse the XML file '{xml_file}'.") except Exception as e: print(f"An unexpected error occurred: {e}") for file_path in glob_files("*.vcxproj"): remove_bscmake_nodes(file_path)

May 7, 2025

Rename Vc9

# vc9 files from surun_tools.glob1 import glob_files glob_files("*VC9.sln") [WindowsPath('C:/src/surun/src/PC/SuRunVC9.sln')] glob_files("*VC9.vcxproj*") [WindowsPath('C:/src/surun/src/install_surun/InstallSuRunVC9.vcxproj.user'), WindowsPath('C:/src/surun/src/PC/InstallSuRunVC9.vcxproj'), WindowsPath('C:/src/surun/src/PC/InstallSuRunVC9.vcxproj.filters'), WindowsPath('C:/src/surun/src/PC/InstallSuRunVC9.vcxproj.user'), WindowsPath('C:/src/surun/src/PC/SuRunExtVC9.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRunExtVC9.vcxproj.filters'), WindowsPath('C:/src/surun/src/PC/SuRunExtVC9.vcxproj.user'), WindowsPath('C:/src/surun/src/PC/SuRunVC9.vcxproj'), WindowsPath('C:/src/surun/src/PC/SuRunVC9.vcxproj.filters'), WindowsPath('C:/src/surun/src/PC/SuRunVC9.vcxproj.user'), WindowsPath('C:/src/surun/src/PC/DebugUx64/SuRunExtVC9.vcxproj.FileListAbsolute.txt'), WindowsPath('C:/src/surun/src/PC/DebugUx64/SuRunVC9.vcxproj.FileListAbsolute.txt')] from pathlib import Path for i in glob_files("*VC9.vcxproj*"): new_name = str(i).replace("VC9", "") import shutil shutil.move(i, Path(new_name)) from pathlib import Path for i in glob_files("*VC9.*"): new_name = str(i).replace("VC9", "") import shutil shutil.move(i, Path(new_name)) sln = glob_files("*.sln")[0] sln WindowsPath('C:/src/surun/src/PC/SuRun.sln') c: str = sln.read_text(encoding="utf8") c = c.replace("VC9", "") sln.write_text(c, encoding="utf8") 15758

May 7, 2025

finished: todo: Bscmake

Currently, when building SuRun, I always get this error: A quick search finds that it’s been deprecated since VS2008. BscMake is no longer used by the Visual Studio IDE. Since Visual Studio 2008, browse information is stored automatically in an .sdf file in the Solution folder. But there are a bunch of them in the project files: So I want to remove them programatically. ...

May 6, 2025

No Interactive Cpp on Windows

Seems that it’s frutile to seek a C++ interpreter on Windows. CERN’s root project already created a cling interperter, but it doesn’t provides a Windows version. Also, it’s using old LLVM libs. see also this blog post. the newer one is clang-repl, but it’s still unstable…the build instructions is also frightening. Well, clang-repl can be executed if you installed LLVM prebuilt exes. however, you will get weird errors due to CLANG not shipping Windows libs, and rather use Visual Studio’s libs. ...

May 4, 2025

Building SuRun

As with any modern C++ applications, the support for GCC and MINGW is deprecated. you must install Visual Studio first. This is the same with npm and flutter packages. Building SuRun contains both 64bit and 32bit parts. to build you can use config “x64 Unicode Debug|x64” and “SuRun32 Unicode Debug|win32”. As with decisions, I have dropped Release builds. You can just run surun_build in the python venv, it calls the build script. ...

May 4, 2025

Git Subtree Guide

see https://www.atlassian.com/git/tutorials/git-subtree init git subtree add --prefix docs/themes/PaperMod https://github.com/soda92/PaperMod2 my --squash Pull git subtree pull --prefix docs/themes/PaperMod https://github.com/soda92/PaperMod2 my --squash

May 4, 2025