Skip to content

Projects generated for VS2017 fail [C1052] to do partial rebuild due to ProgramDataBaseFileName element #9

@assarbad

Description

@assarbad

The file src\actions\vstudio\vs2010_vcxproj.lua contains this:

		if cfg.flags.Symbols then
			_p(3,'<ProgramDataBaseFileName>$(OutDir)%s.pdb</ProgramDataBaseFileName>'
				, path.getbasename(cfg.buildtarget.name))
		end

There are two issues with this. For starters instead of retrieving the base name, the code should arguably make use of the $(TargetName) macro. If possible incompatibilities of pre-VS2010 versus VS2010+ are of concern here, one could implement a shallow function using a map (Lua table) to transform macro names (see bottom). So arguably it should have read:

		if cfg.flags.Symbols then
			_p(3,'<ProgramDataBaseFileName>$(OutDir)$(TargetName)</ProgramDataBaseFileName>')
		end

The second issue is the bigger one. There are two PDBs usually involved during compilation. One by the linker and one by the compiler. This explains why we receive a C1052 error.

The instance of <ProgramDataBaseFileName /> is meant to be the compiler one (inside <ClCompile />). However, its default value is normally $(IntDir)vc$(PlatformToolsetVersion).pdb (as per the above linked MSDN resource).

So when Premake sets it to what amounts to $(OutDir)$(TargetName) that clashes with the implicit value used for the linker PDB. That's why if I change a single source file - e.g. during debugging - and then press F5, instead of compiling, linking and debugging, I get the above mentioned error C1052.

The solution is to leave out the <ProgramDataBaseFileName /> element altogether and have it use its default. However, when looking for flags.Symbols in aforementioned .lua file, there's a second instance with a similar condition. That one positively must stay for otherwise we can't control whether a PDB file gets generated at all.

Best regards,

Oliver

PS: I found a mention of this issue over here. What struck me as odd, at best, was the lack of mentioning @starkos in the copyright notice of the README for that project, albeit claiming to be (and visibly being) a fork of Premake4.
PPS: I've made use of the following function to translate macro names in my own premake4.lua files for quite some time now:

local function transformMN(input) -- transform the macro names for older Visual Studio versions
    local new_map   = { vs2002 = 0, vs2003 = 0, vs2005 = 0, vs2008 = 0 }
    local replacements = { Platform = "PlatformName", Configuration = "ConfigurationName" }
    if new_map[action] ~= nil then
        for k,v in pairs(replacements) do
            if input:find(k) then
                input = input:gsub(k, v)
            end
        end
    end
    return input
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions