Skip to content
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

The file cpplize_debugger.py does not compile on linux. #141

Open
Malkverbena opened this issue Sep 17, 2024 · 12 comments · May be fixed by #143
Open

The file cpplize_debugger.py does not compile on linux. #141

Malkverbena opened this issue Sep 17, 2024 · 12 comments · May be fixed by #143

Comments

@Malkverbena
Copy link

Malkverbena commented Sep 17, 2024

Building for platform "linuxbsd", architecture "x86_64", target "editor".
FileNotFoundError: [Errno 2] No such file or directory: '-j8/core/__generated__debugger_ui.h':
  File "/media/cleber/DATA/COMPILATIONS/godot/SConstruct", line 1082:
    SConscript("modules/SCsub")
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 661:
    return method(*args, **kw)
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/media/cleber/DATA/COMPILATIONS/godot/modules/SCsub", line 73:
    SConscript(base_path + "/SCsub")
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 661:
    return method(*args, **kw)
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/media/cleber/DATA/COMPILATIONS/godot/modules/NetworkSynchronizer/SCsub", line 3:
    from debugger_ui import cpplize_debugger
  File "/media/cleber/DATA/COMPILATIONS/godot/modules/NetworkSynchronizer/debugger_ui/cpplize_debugger.py", line 40:
    create_debugger_header(source_path)
  File "/media/cleber/DATA/COMPILATIONS/godot/modules/NetworkSynchronizer/debugger_ui/cpplize_debugger.py", line 7:
    f = open(source_path + "/core/__generated__debugger_ui.h", "w", encoding="utf-8")
@Malkverbena
Copy link
Author

Malkverbena commented Sep 17, 2024

The "create_debugger_header" function is receiving the first argument used after the scons command. This is generating errors.
For example, if I use "-j8", the argument received by the function is "-j8".
I believe the error is in SCsub, when the function is invoked.

What the function "create_debugger_header" supose to recive?

@Malkverbena
Copy link
Author

Line 8 will also cause issues on different platforms. The ideal would be to use:
To ensure that your code works on Windows, Linux, and macOS, it is important to use directory separators that are compatible with all operating systems. In Python, the recommended way to build platform-independent file paths is by using os.path.join.
Like this:

f = open(os.path.join(source_path, "core", "__generated__debugger_ui.h"), "w", encoding="utf-8")

@AndreaCatania
Copy link
Collaborator

I think the issue is caused by a recent change I needed to make in order to use the cpplize_debugger.py with CMake.

The change I did was adding these lines https://github.com/GameNetworking/NetworkSynchronizer/blob/main/debugger_ui/cpplize_debugger.py#L34-L40

With those lines, as soon as you execute that file the file is generated. The way I'm using it with CMake is this one: https://github.com/GameNetworking/NetworkSynchronizer/blob/main/cmake/CMakeLists.txt#L35-L39

The fix is to refactor the way the SCsub is implemented so that it "executes" the script instead of importing it and calling the function. If you have any other idea, I'm open to it.

@Malkverbena
Copy link
Author

Malkverbena commented Sep 17, 2024

What do you think about including a method to fix the value of the "source_path" variable?

Somethink like:

source_path = os.path.dirname(os.path.abspath(__file__))

@AndreaCatania
Copy link
Collaborator

On the SCsub? I think that make sense

@Malkverbena
Copy link
Author

Malkverbena commented Sep 17, 2024

Yes. but also can be done on cpplize_debugger.py.
Depends what you have in mind.
Simple adding the lines below to cpplize_debugger.py you can fix it.
This makes the script determine the source_path insted to depend of poarameters coming from another scripts

	source_path = os.path.dirname(os.path.abspath(__file__))
	source_path = os.path.dirname(source_path)

@Malkverbena
Copy link
Author

What do you think about this solution?

def create_debugger_header(source_path):

	if not os.path.exists(source_path):
		source_path = os.path.dirname(os.path.abspath(__file__))
		source_path = os.path.dirname(source_path)

@AndreaCatania
Copy link
Collaborator

AndreaCatania commented Sep 17, 2024

I would prefer to have this logic inside the Scons config instead and prevent this section https://github.com/GameNetworking/NetworkSynchronizer/blob/main/debugger_ui/cpplize_debugger.py#L34-L40 from executing when the file is imported, somehow.

@Malkverbena
Copy link
Author

I dont undestood exacly when the funcion "create_debugger_header" is called.
This function is being called on SCsub and on cpplize_debugger.
In other words, it is being invoked twice.
When this function is supposed to be called?

@Malkverbena
Copy link
Author

Should the "source_path" variable be passed in the function call or discovered automatically?

@AndreaCatania
Copy link
Collaborator

I prefer that we pass the path, because automatic discovering the directory is not going to work in all situations.

@Malkverbena
Copy link
Author

I just updated my fork and cant compile at all. After the #138 I got tons of errors. Ill open a diferent issue foir that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants