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

Improvements to the PDB hook readme #123

Merged
merged 4 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Makes a ZIP with all the licenses from the graph

#### [PDBs](extensions/hooks/_hook_copy_pdbs_to_package.py)

Post pacakge hook that copies PDBs to the package folder.
Post package hook that copies PDBs to the package folder.

### Testing

Expand Down
26 changes: 19 additions & 7 deletions extensions/hooks/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## Installing hooks

To install just the hooks from this repository, without the other extensions, use the command:

`conan config install https://github.com/conan-io/conan-extensions.git -sf=extensions/hooks -tf=extensions/hooks`

The hooks are named so they won't be run by default, so we need to change the name of the hook
we want to use to start with `hook_`. As explained in the
[hooks documentation](https://docs.conan.io/2/reference/extensions/hooks.html).
To locate the path where the hook was placed, run the command `conan config home` to find
your local cache path and go to the `extensions/hooks` folder to rename the desired hook. Be aware that
the hooks will run everytime they are called unless disabled, which can be done by renaming the hook back to start with `_hook_`.

## PDBs hook
This hook copies the PDBs from their original location in the build folder to the package folder.
This is required for debugging libraries with Visual Studio when the original source files aren't present.
Expand All @@ -9,8 +22,8 @@ A PDB has the information to link the source code of a debuggable object to the
specific file (executable or library) and contains the source file name and line numbers to display in the IDE.

When compiling shared libraries in Debug mode the created binary will contain the information of where the PDB will be
generated, which by default is the same path where the file is being compiled. The PDBs are created by the ``cl.exe``
compiler with the ``/Zi`` flag, or by the ``link.exe`` when linking a DLL or executable.
generated, which by default is the same path where the file is being compiled. The PDBs are created by the `cl.exe`
compiler with the `/Zi` flag, or by the `link.exe` when linking a DLL or executable.

PDBs are created when compiling a library or executable in Debug mode and are created by default in the same directory
as the file it is associated with. This means that when using Conan they will be created in the build directory in the
Expand All @@ -24,10 +37,9 @@ When using the Visual Studio debugger, it will look for PDBs to load in the foll

### Locating PDBs

To locate the PDB of a DLL we can use the ``dumpbin.exe`` tool, which comes with Visual by default and can be located
using the ``vswhere`` tool. PDBs will usually have the same name as it's
DLL, but it's not always the case, so checking with the ``dumpbin \PDBPATH`` command makes sure we are getting the PDB
corresponding to each DLL.
To locate the PDB of a DLL we can use the `dumpbin.exe` tool, which comes with Visual by default and can be located
using the `vswhere` tool. PDBs will usually have the same name as its DLL, but it's not always the case, so checking
with the `dumpbin \PDBPATH` command makes sure we are getting the PDB corresponding to each DLL.

When a DLL is created it contains the information of the path where its corresponding PDB was generated. This can be
manually checked by running the following commands:
Expand Down Expand Up @@ -57,4 +69,4 @@ folder can be used instead by telling Visual where to find them, as it is explai
PDBs can sometimes be generated for LIB files, but for now the feature only focuses on shared libraries and
will only work with PDBs generated for DLLs. This is because the linking of PDBs and static libraries works differently
than with shared libraries and the PDBs are generated differently, which doesn't allow us to get the name and path
of a PDB through the ``dumpbin`` tool and will require different methods.
of a PDB through the `dumpbin` tool and will require different methods.
2 changes: 1 addition & 1 deletion extensions/hooks/_hook_copy_pdbs_to_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import re
from io import StringIO
from conans.errors import ConanException
from conan.errors import ConanException


def post_package(conanfile):
Expand Down
Loading