Create pdbs that work when using pch or doing extract object (sadly not both).

pull/684/head
Jussi Pakkanen 9 years ago
parent 402ef505fe
commit 1bed33fba2
  1. 34
      mesonbuild/backend/ninjabackend.py
  2. 24
      mesonbuild/compilers.py

@ -1433,6 +1433,33 @@ rule FORTRAN_DEP_HACK
return []
return compiler.get_no_stdinc_args()
def get_pdb_name_suffix(self, target):
if isinstance(target, build.Executable):
suffix = '__exe'
elif isinstance(target, build.SharedLibrary):
suffix = '__dll'
elif isinstance(target, build.StaticLibrary):
suffix = '__lib'
else:
raise MesonException('Tried to build PDB for a non-buildtarget. Please file a bug.')
return suffix
def get_compile_debugfile_args(self, compiler, target, objfile):
if compiler.id != 'msvc':
return []
suffix = self.get_pdb_name_suffix(target)
if target.has_pch():
tfilename = self.get_target_filename_abs(target)
return compiler.get_compile_debugfile_args(tfilename, suffix)
else:
return compiler.get_compile_debugfile_args(objfile, suffix)
def get_link_debugfile_args(self, linker, target, outname):
suffix = self.get_pdb_name_suffix(target)
return linker.get_link_debugfile_args(outname, suffix)
def generate_single_compile(self, target, outfile, src, is_generated=False, header_deps=[], order_deps=[]):
if(isinstance(src, str) and src.endswith('.h')):
raise RuntimeError('Fug')
@ -1522,7 +1549,7 @@ rule FORTRAN_DEP_HACK
if self.environment.coredata.base_options.get('b_pch', False):
commands += self.get_pch_include_args(compiler, target)
commands += compiler.get_compile_debugfile_args(self.get_target_filename_abs(target))
commands += self.get_compile_debugfile_args(compiler, target, rel_obj)
crstr = ''
if target.is_cross:
crstr = '_CROSS'
@ -1591,8 +1618,7 @@ rule FORTRAN_DEP_HACK
just_name = os.path.split(header)[1]
(objname, pch_args) = compiler.gen_pch_args(just_name, source, dst)
commands += pch_args
tfilename = self.get_target_filename_abs(target)
commands += compiler.get_compile_debugfile_args(tfilename)
commands += self.get_compile_debugfile_args(compiler, target, objname)
dep = dst + '.' + compiler.get_depfile_suffix()
return (commands, dep, dst, [objname])
@ -1672,7 +1698,7 @@ rule FORTRAN_DEP_HACK
linker)
commands += linker.get_buildtype_linker_args(self.environment.coredata.get_builtin_option('buildtype'))
commands += linker.get_option_link_args(self.environment.coredata.compiler_options)
commands += linker.get_link_debugfile_args(outname)
commands += self.get_link_debugfile_args(linker, target, outname)
if not(isinstance(target, build.StaticLibrary)):
commands += self.environment.coredata.external_link_args[linker.get_language()]
if isinstance(target, build.Executable):

@ -354,10 +354,10 @@ class Compiler():
# Some compilers (msvc) write debug info to a separate file.
# These args specify where it should be written.
def get_compile_debugfile_args(self, rel_obj):
def get_compile_debugfile_args(self, rel_obj, fname_suffix):
return []
def get_link_debugfile_args(self, rel_obj):
def get_link_debugfile_args(self, rel_obj, fname_suffix):
return []
class CCompiler(Compiler):
@ -1607,12 +1607,16 @@ class VisualStudioCCompiler(CCompiler):
raise MesonException('Compiling test app failed.')
return not(warning_text in stde or warning_text in stdo)
def get_compile_debugfile_args(self, rel_obj):
pdbarr = rel_obj.split('.')[:-1] + ['pdb']
def get_compile_debugfile_args(self, rel_obj, name_suffix):
pdbarr = rel_obj.split('.')[:-1]
pdbarr[-1] += name_suffix
pdbarr += ['pdb']
return ['/Fd' + '.'.join(pdbarr)]
def get_link_debugfile_args(self, targetfile):
pdbarr = targetfile.split('.')[:-1] + ['pdb']
def get_link_debugfile_args(self, targetfile, name_suffix):
pdbarr = targetfile.split('.')[:-1]
pdbarr[-1] += name_suffix
pdbarr += ['pdb']
return ['/DEBUG', '/PDB:' + '.'.join(pdbarr)]
class VisualStudioCPPCompiler(VisualStudioCCompiler):
@ -2291,8 +2295,10 @@ class VisualStudioLinker():
def unix_compile_flags_to_native(self, args):
return args[:]
def get_link_debugfile_args(self, targetfile):
pdbarr = targetfile.split('.')[:-1] + ['pdb']
def get_link_debugfile_args(self, targetfile, name_suffix):
pdbarr = targetfile.split('.')[:-1]
pdbarr[-1] += name_suffix
pdbarr += ['pdb']
return ['/DEBUG', '/PDB:' + '.'.join(pdbarr)]
class ArLinker():
@ -2344,5 +2350,5 @@ class ArLinker():
def unix_compile_flags_to_native(self, args):
return args[:]
def get_link_debugfile_args(self, targetfile):
def get_link_debugfile_args(self, targetfile, suffix):
return []

Loading…
Cancel
Save