'Compute the path for the final output of the spec.'

def ComputeOutput(self, spec, arch=None):

    type = spec['type']
    if (self.flavor == 'win'):
        override = self.msvs_settings.GetOutputName(self.config_name, self.ExpandSpecial)
        if override:
            return override
    if ((arch is None) and (self.flavor == 'mac') and (type in ('static_library', 'executable', 'shared_library', 'loadable_module'))):
        filename = self.xcode_settings.GetExecutablePath()
    else:
        filename = self.ComputeOutputFileName(spec, type)
    if ((arch is None) and ('product_dir' in spec)):
        path = os.path.join(spec['product_dir'], filename)
        return self.ExpandSpecial(path)
    type_in_output_root = ['executable', 'loadable_module']
    if ((self.flavor == 'mac') and (self.toolset == 'target')):
        type_in_output_root += ['shared_library', 'static_library']
    elif ((self.flavor == 'win') and (self.toolset == 'target')):
        type_in_output_root += ['shared_library']
    if (arch is not None):
        archdir = 'arch'
        if (self.toolset != 'target'):
            archdir = os.path.join('arch', ('%s' % self.toolset))
        return os.path.join(archdir, AddArch(filename, arch))
    elif ((type in type_in_output_root) or self.is_standalone_static_library):
        return filename
    elif (type == 'shared_library'):
        libdir = 'lib'
        if (self.toolset != 'target'):
            libdir = os.path.join('lib', ('%s' % self.toolset))
        return os.path.join(libdir, filename)
    else:
        return self.GypPathToUniqueOutput(filename, qualified=False)
