Skip to content

Commit d2b0661

Browse files
authored
Merge pull request premake#1033 from tdesveauxPKFX/vstudio-staticlib-symbolspath
vstudio staticlib symbolspath
2 parents 5c6f47d + 5a1b8ad commit d2b0661

File tree

3 files changed

+101
-10
lines changed

3 files changed

+101
-10
lines changed

modules/vstudio/tests/vc2010/test_compile_settings.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,3 +1199,42 @@
11991199
</ClCompile>
12001200
]]
12011201
end
1202+
1203+
--
1204+
-- Check StaticLib SymbolsPath
1205+
--
1206+
1207+
function suite.generateProgramDataBaseFileName_onStaticLib()
1208+
kind "StaticLib"
1209+
1210+
symbols "On"
1211+
symbolspath "$(IntDir)$(TargetName).pdb"
1212+
1213+
prepare()
1214+
test.capture [[
1215+
<ClCompile>
1216+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
1217+
<WarningLevel>Level3</WarningLevel>
1218+
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
1219+
<Optimization>Disabled</Optimization>
1220+
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
1221+
</ClCompile>
1222+
]]
1223+
end
1224+
1225+
function suite.generateNotProgramDataBaseFileName_onSharedLib()
1226+
kind "SharedLib"
1227+
1228+
symbols "On"
1229+
symbolspath "$(IntDir)$(TargetName).pdb"
1230+
1231+
prepare()
1232+
test.capture [[
1233+
<ClCompile>
1234+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
1235+
<WarningLevel>Level3</WarningLevel>
1236+
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
1237+
<Optimization>Disabled</Optimization>
1238+
</ClCompile>
1239+
]]
1240+
end

modules/vstudio/tests/vc2010/test_link.lua

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,37 @@
226226
-- Test the handling of the SymbolsPath flag.
227227
--
228228

229-
function suite.generateDebugInfo_onSymbolsOn_on2010()
229+
function suite.generateProgramDataBaseFile_onStaticLib()
230+
kind "StaticLib"
231+
232+
symbols "On"
233+
symbolspath "$(IntDir)$(TargetName).pdb"
234+
prepare()
235+
test.capture [[
236+
<Link>
237+
<SubSystem>Windows</SubSystem>
238+
<GenerateDebugInformation>true</GenerateDebugInformation>
239+
</Link>
240+
]]
241+
end
242+
243+
function suite.generateProgramDataBaseFile_onSharedLib()
244+
kind "SharedLib"
245+
246+
symbols "On"
247+
symbolspath "$(IntDir)$(TargetName).pdb"
248+
prepare()
249+
test.capture [[
250+
<Link>
251+
<SubSystem>Windows</SubSystem>
252+
<GenerateDebugInformation>true</GenerateDebugInformation>
253+
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
254+
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
255+
</Link>
256+
]]
257+
end
258+
259+
function suite.generateProgramDatabaseFile_onSymbolsOn_on2010()
230260
p.action.set("vs2010")
231261
symbols "On"
232262
symbolspath "$(IntDir)$(TargetName).pdb"
@@ -241,7 +271,7 @@
241271
]]
242272
end
243273

244-
function suite.generateDebugInfo_onSymbolsFastLink_on2010()
274+
function suite.generateProgramDatabaseFile_onSymbolsFastLink_on2010()
245275
p.action.set("vs2010")
246276
symbols "Off"
247277
symbolspath "$(IntDir)$(TargetName).pdb"
@@ -255,7 +285,7 @@
255285
]]
256286
end
257287

258-
function suite.generateDebugInfo_onSymbolsFull_on2010()
288+
function suite.generateProgramDatabaseFile_onSymbolsFull_on2010()
259289
p.action.set("vs2010")
260290
symbols "Full"
261291
symbolspath "$(IntDir)$(TargetName).pdb"
@@ -270,7 +300,7 @@
270300
]]
271301
end
272302

273-
function suite.generateDebugInfo_onSymbolsOn_on2015()
303+
function suite.generateProgramDatabaseFile_onSymbolsOn_on2015()
274304
p.action.set("vs2015")
275305
symbols "On"
276306
symbolspath "$(IntDir)$(TargetName).pdb"
@@ -285,7 +315,7 @@
285315
]]
286316
end
287317

288-
function suite.generateDebugInfo_onSymbolsFastLink_on2015()
318+
function suite.generateProgramDatabaseFile_onSymbolsFastLink_on2015()
289319
p.action.set("vs2015")
290320
symbols "FastLink"
291321
symbolspath "$(IntDir)$(TargetName).pdb"
@@ -301,7 +331,7 @@
301331
]]
302332
end
303333

304-
function suite.generateDebugInfo_onSymbolsFull_on2015()
334+
function suite.generateProgramDatabaseFile_onSymbolsFull_on2015()
305335
p.action.set("vs2015")
306336
symbols "Full"
307337
symbolspath "$(IntDir)$(TargetName).pdb"
@@ -316,7 +346,7 @@
316346
]]
317347
end
318348

319-
function suite.generateDebugInfo_onSymbolsFull_on2017()
349+
function suite.generateProgramDatabaseFile_onSymbolsFull_on2017()
320350
p.action.set("vs2017")
321351
symbols "Full"
322352
symbolspath "$(IntDir)$(TargetName).pdb"

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
--
314314

315315
m.elements.clCompile = function(cfg)
316-
return {
316+
local calls = {
317317
m.precompiledHeader,
318318
m.warningLevel,
319319
m.treatWarningAsError,
@@ -348,6 +348,12 @@
348348
m.callingConvention,
349349
m.languageStandard,
350350
}
351+
352+
if cfg.kind == p.STATICLIB then
353+
table.insert(calls, m.programDatabaseFileName)
354+
end
355+
356+
return calls
351357
end
352358

353359
function m.clCompile(cfg)
@@ -2175,13 +2181,29 @@
21752181
end
21762182
end
21772183

2184+
local function getSymbolsPathRelative(cfg)
2185+
if cfg.symbolspath and cfg.symbols ~= p.OFF and cfg.debugformat ~= "c7" then
2186+
return p.project.getrelative(cfg.project, cfg.symbolspath)
2187+
else
2188+
return nil
2189+
end
2190+
end
21782191

21792192
function m.programDatabaseFile(cfg)
2180-
if cfg.symbolspath and cfg.symbols ~= p.OFF and cfg.debugformat ~= "c7" then
2181-
m.element("ProgramDatabaseFile", nil, p.project.getrelative(cfg.project, cfg.symbolspath))
2193+
local value = getSymbolsPathRelative(cfg)
2194+
2195+
if value then
2196+
m.element("ProgramDatabaseFile", nil, value)
21822197
end
21832198
end
21842199

2200+
function m.programDatabaseFileName(cfg)
2201+
local value = getSymbolsPathRelative(cfg)
2202+
2203+
if value then
2204+
m.element("ProgramDataBaseFileName", nil, value)
2205+
end
2206+
end
21852207

21862208
function m.projectGuid(prj)
21872209
m.element("ProjectGuid", nil, "{%s}", prj.uuid)

0 commit comments

Comments
 (0)