1#!/usr/bin/env python 2# encoding: utf-8 3# Rafaël Kooi 2019 4 5from waflib import TaskGen 6 7@TaskGen.feature('c', 'cxx', 'fc') 8@TaskGen.after_method('propagate_uselib_vars') 9def add_pdb_per_object(self): 10 """For msvc/fortran, specify a unique compile pdb per object, to work 11 around LNK4099. Flags are updated with a unique /Fd flag based on the 12 task output name. This is separate from the link pdb. 13 """ 14 if not hasattr(self, 'compiled_tasks'): 15 return 16 17 link_task = getattr(self, 'link_task', None) 18 19 for task in self.compiled_tasks: 20 if task.inputs and task.inputs[0].name.lower().endswith('.rc'): 21 continue 22 23 add_pdb = False 24 for flagname in ('CFLAGS', 'CXXFLAGS', 'FCFLAGS'): 25 # several languages may be used at once 26 for flag in task.env[flagname]: 27 if flag[1:].lower() == 'zi': 28 add_pdb = True 29 break 30 31 if add_pdb: 32 node = task.outputs[0].change_ext('.pdb') 33 pdb_flag = '/Fd:' + node.abspath() 34 35 for flagname in ('CFLAGS', 'CXXFLAGS', 'FCFLAGS'): 36 buf = [pdb_flag] 37 for flag in task.env[flagname]: 38 if flag[1:3] == 'Fd' or flag[1:].lower() == 'fs' or flag[1:].lower() == 'mp': 39 continue 40 buf.append(flag) 41 task.env[flagname] = buf 42 43 if link_task and not node in link_task.dep_nodes: 44 link_task.dep_nodes.append(node) 45 if not node in task.outputs: 46 task.outputs.append(node) 47