tools: Add dumpbin support to defcheck.py
This is needed for MSVC environment.
This commit is contained in:
parent
a5ec792c6a
commit
605470cc05
1 changed files with 23 additions and 4 deletions
|
|
@ -25,11 +25,11 @@ Invoke in the top level of the gimp source tree after compiling GIMP.
|
|||
If srcdir != builddir, run it in the build directory and pass the name
|
||||
of the source directory on the command-line.
|
||||
|
||||
Needs the tool "objdump" to work
|
||||
Needs the tool "nm", "objdump" or "dumpbin" to work
|
||||
|
||||
"""
|
||||
|
||||
import os, sys, subprocess
|
||||
import os, sys, subprocess, shutil
|
||||
|
||||
from os import path
|
||||
|
||||
|
|
@ -56,18 +56,22 @@ if len(sys.argv) > 1:
|
|||
|
||||
libextension = ".so"
|
||||
command = "nm --defined-only --extern-only "
|
||||
libprefix = "lib"
|
||||
platform_linux = True
|
||||
|
||||
if sys.platform in ['win32', 'cygwin']:
|
||||
libextension = ".dll"
|
||||
command = "objdump -p "
|
||||
if shutil.which("dumpbin"):
|
||||
command = "dumpbin /EXPORTS "
|
||||
libprefix = ""
|
||||
platform_linux = False
|
||||
|
||||
for df in def_files:
|
||||
directory, name = path.split (df)
|
||||
basename, extension = name.split (".")
|
||||
|
||||
libname = path.join(os.getcwd(), directory, "lib" + basename + "-*" + libextension)
|
||||
libname = path.join(os.getcwd(), directory, libprefix + basename + "-*" + libextension)
|
||||
#FIXME: This leaks to ninja stdout, which should not happen
|
||||
#print ("platform: " + sys.platform + " - extracting symbols from " + libname)
|
||||
|
||||
|
|
@ -105,7 +109,7 @@ for df in def_files:
|
|||
if platform_linux:
|
||||
nmsymbols = nm
|
||||
|
||||
else: # Windows
|
||||
elif not shutil.which("dumpbin"): # Windows MSYS2
|
||||
# remove parts of objdump output we don't need: anything up to a few lines
|
||||
# after Export Table: ' Ordinal RVA Name'
|
||||
|
||||
|
|
@ -120,6 +124,21 @@ for df in def_files:
|
|||
nmsymbols += s
|
||||
# else: skip this line
|
||||
|
||||
else: # Windows MSVC
|
||||
|
||||
dbin = nm.split(sep='\n')
|
||||
|
||||
found = False
|
||||
nmsymbols = ""
|
||||
for s in dbin:
|
||||
if "ordinal" in s and "hint" in s and "RVA" in s:
|
||||
found = True
|
||||
elif found and s.strip() and "Summary" not in s:
|
||||
parts = s.split()
|
||||
if len(parts) >= 4:
|
||||
nmsymbols += " 0 0 " + parts[3] # Keep the [2::3] logic happy
|
||||
# else: skip this line
|
||||
|
||||
nmsymbols = nmsymbols.split()[2::3]
|
||||
nmsymbols = [s for s in nmsymbols if s[0] != '_']
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue