-
Notifications
You must be signed in to change notification settings - Fork 25
Fix SCsub, fix cpplize_debugger.py and add missing header (<tuple>). #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Malkverbena
wants to merge
1
commit into
GameNetworking:main
Choose a base branch
from
Malkverbena:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,40 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| from debugger_ui import cpplize_debugger | ||
|
|
||
| cpplize_debugger.create_debugger_header() | ||
| import os | ||
| from debugger_ui import cpplize_debugger | ||
|
|
||
| Import("env") | ||
| Import("env_modules") | ||
|
|
||
| # Get the absolute path to the current directory where SCsub is located | ||
| source_path = env.Dir('.').abspath | ||
| print(f"source_path: {source_path}") | ||
|
|
||
| # Call the function with the correct source_path | ||
| cpplize_debugger.create_debugger_header(source_path) | ||
|
|
||
| # Clone the module environment | ||
| env_network_synchronizer = env_modules.Clone() | ||
|
|
||
| # Check if Tracy is enabled and add the definition if necessary | ||
| if "tracy_enable" in env and env["tracy_enable"] == "yes": | ||
| env_network_synchronizer.Append(CPPDEFINES=["TRACY_ENABLE"]) | ||
|
|
||
| # TODO ensure debugs are enabled only in debug builds. | ||
| # TODO: Ensure that debugs are enabled only in debug builds. | ||
| env_network_synchronizer.Append(CPPDEFINES=["NS_DEBUG_ENABLED"]) | ||
|
|
||
| # Add the definition to disable the debug data buffer | ||
| env_network_synchronizer.Append(CPPDEFINES=["DISABLE_DEBUG_DATA_BUFFER"]) | ||
|
|
||
| # Add the GENERATE_DEBUG_SYMBOLS preprocessor definition | ||
| env_network_synchronizer.Append(CPPDEFINES=["GENERATE_DEBUG_SYMBOLS=ON"]) | ||
|
|
||
| # Add source files to the environment | ||
| env_network_synchronizer.add_source_files(env.modules_sources, "core/**.cpp") | ||
| env_network_synchronizer.add_source_files(env.modules_sources, "godot4/**.cpp") | ||
| env_network_synchronizer.add_source_files(env.modules_sources, "*.cpp") | ||
| env_network_synchronizer.add_source_files(env.modules_sources, "tests/**.cpp") | ||
|
|
||
| # Invoke CMake with the GENERATE_DEBUG_SYMBOLS flag | ||
| env.Execute("cmake ../cmake/ -DGENERATE_DEBUG_SYMBOLS=ON") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,58 @@ | ||
| from os import listdir | ||
| from os.path import isfile, join, isdir, exists | ||
| import os | ||
| import sys | ||
|
|
||
| def create_debugger_header(source_path): | ||
|
|
||
| f = open(source_path + "/core/__generated__debugger_ui.h", "w", encoding="utf-8") | ||
| f.write("#pragma once\n") | ||
| f.write("\n") | ||
| f.write("/// This is a generated file by `cpplize_debugger.py`, executed by `SCsub`.\n") | ||
| f.write("/// \n") | ||
| f.write("/// DO NOT EDIT this header.\n") | ||
| f.write("/// If you want to modify this python code, you can simply change `debugger.py`\n") | ||
| f.write("/// During the next compilation this header will be updated.\n") | ||
| f.write("/// \n") | ||
| f.write("/// HOWEVER! The file will not be copied into the `bin` folder unless you remove the\n") | ||
| f.write("/// existing `bin/debugger.py` first; this algorithm prevents destroying eventual\n") | ||
| f.write("/// changes made on that file.\n") | ||
| f.write("\n") | ||
| f.write("static const char __debugger_ui_code[] = R\"TheCodeRKS(") | ||
|
|
||
| size = 0 | ||
| with open(source_path + '/debugger_ui/debugger.py', encoding="utf-8") as deb_f: | ||
| for l in deb_f.readlines(): | ||
| l_utf8 = l.encode('utf-8') | ||
| size += len(l_utf8) | ||
| f.write(l); | ||
|
|
||
| f.write(" )TheCodeRKS\";\n") | ||
| f.write("static unsigned int __debugger_ui_code_size = "+str(size)+";\n") | ||
| f.close() | ||
|
|
||
| """ | ||
| Creates the generated header file for the debugger UI. | ||
|
|
||
| if len(sys.argv) < 2: | ||
| print("Usage: cpplize_debugger.py <source_path>") | ||
| sys.exit(1) | ||
| Args: | ||
| source_path (str): The path to the source directory where the header will be created. | ||
| """ | ||
| # Define the path to the 'core' directory | ||
| core_dir = os.path.join(source_path, "core") | ||
|
|
||
| # Create the 'core' directory if it doesn't exist | ||
| os.makedirs(core_dir, exist_ok=True) | ||
|
|
||
| # Define the full path to the generated header file | ||
| header_path = os.path.join(core_dir, "__generated__debugger_ui.h") | ||
|
|
||
| try: | ||
| with open(header_path, "w", encoding="utf-8") as f: | ||
| f.write("#pragma once\n\n") | ||
| f.write("/// This is a generated file by `cpplize_debugger.py`, executed by `SCsub`.\n") | ||
| f.write("///\n") | ||
| f.write("/// DO NOT EDIT this header.\n") | ||
| f.write("/// If you want to modify this Python code, simply change `debugger.py`\n") | ||
| f.write("/// During the next compilation, this header will be updated.\n") | ||
| f.write("///\n") | ||
| f.write("/// HOWEVER! The file will not be copied into the `bin` folder unless you remove the\n") | ||
| f.write("/// existing `bin/debugger.py` first; this algorithm prevents destroying any\n") | ||
| f.write("/// changes made to that file.\n\n") | ||
| f.write("static const char __debugger_ui_code[] = R\"TheCodeRKS(\n") | ||
|
|
||
| size = 0 | ||
| debugger_py_path = os.path.join(source_path, 'debugger_ui', 'debugger.py') | ||
|
|
||
| if not os.path.isfile(debugger_py_path): | ||
| print(f"Error: The file '{debugger_py_path}' was not found.") | ||
| sys.exit(1) | ||
|
|
||
| with open(debugger_py_path, encoding="utf-8") as deb_f: | ||
| for line in deb_f: | ||
| line_utf8 = line.encode('utf-8') | ||
| size += len(line_utf8) | ||
| f.write(line) | ||
|
|
||
| f.write(")TheCodeRKS\";\n") | ||
| f.write(f"static unsigned int __debugger_ui_code_size = {size};\n") | ||
|
|
||
| print(f"Header file successfully generated at '{header_path}'.") | ||
|
|
||
| except IOError as e: | ||
| print(f"Error writing the header file: {e}") | ||
| sys.exit(1) | ||
|
|
||
| source_path = sys.argv[1] | ||
| # The create_debugger_header function is called directly from SCsub, | ||
| # so there's no need for a main function handling sys.argv. | ||
|
|
||
| create_debugger_header(source_path) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to ensure the function is called when using CMake. It should not create any issue on the Godot side, is it an issue?