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

How to obtain filename of currently building library or executable #5976

Open
jabamaus opened this issue Apr 8, 2023 · 4 comments
Open

How to obtain filename of currently building library or executable #5976

jabamaus opened this issue Apr 8, 2023 · 4 comments

Comments

@jabamaus
Copy link

jabamaus commented Apr 8, 2023

I'm trying to make a change to the build system so that the name of the program database is specified. This is necessary for debugging under visual studio and will also prevent a stray vc143.pdb file from being generated directly in the mruby root.

In order to do this, for each src file that is being compiled I need to know the filename of the library or executable that it will end up in so I can base the pdb name on that, eg libmruby.lib -> libmruby.pdb, mrbc.exe -> mrbc.pdb etc. I thought that something like Build.current might lead me there but I've been unable to find a way to do it. The build system is rather complex...

Anyone help me out?

@jabamaus
Copy link
Author

jabamaus commented Apr 8, 2023

The other, really simple option is to use the /Z7 switch instead of /Zi which will embed the debug info in the library/exe itself, but using a separate pdb is better.

@dearblue
Copy link
Contributor

dearblue commented Apr 9, 2023

If in the build configuration file, you can refer to MRuby::Build#build_dir.

MRuby::Build.new do |conf|
  ...
  bindir = File.join(conf.build_dir, "bin")
  libdir = File.join(conf.build_dir, "lib")
  ...
end

@jabamaus
Copy link
Author

jabamaus commented Apr 9, 2023

Thanks. That gets me part of the way there. Now I need the name of the current library or executable being built. I'm happy to delve into the build system to do this (and submit a PR) but I've not been able to find a method to return me this information anywhere.

@dearblue
Copy link
Contributor

dearblue commented Apr 9, 2023

Currently, there is no mechanism to obtain the final library and executable names from within the build configuration file.
Therefore, you will need to type the file name yourself.

  • libmruby.lib => File.join(conf.build_dir, "lib/libmruby.lib")
  • mrbc.exe => File.join(conf.build_dir, "bin/mrbc.exe")
  • mruby.exe => File.join(conf.build_dir, "bin/mruby.exe")

One thing to note is that when executing the linker, it is not possible to specify a different debug file name for each individual executable name (Build system needs to be extended).
However, since the .pdb file says that it can incrementally update debugging information for multiple executables, I would expect this to not be a problem.
https://learn.microsoft.com/en-us/visualstudio/debugger/specify-symbol-dot-pdb-and-source-files-in-the-visual-studio-debugger?view=vs-2022#cc-options

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

No branches or pull requests

2 participants