Skip to content

Commit fa7aa1e

Browse files
committed
Added the PROFILE flag for msc and Visual Studio
1 parent e22633d commit fa7aa1e

File tree

7 files changed

+100
-1
lines changed

7 files changed

+100
-1
lines changed

modules/vstudio/tests/vc2010/test_link.lua

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,3 +767,33 @@
767767
</Link>
768768
]]
769769
end
770+
771+
772+
--
773+
-- Test for the Profile flag.
774+
--
775+
776+
function suite.profileOn()
777+
profile "On"
778+
prepare()
779+
test.capture [[
780+
<Link>
781+
<SubSystem>Windows</SubSystem>
782+
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
783+
<Profile>true</Profile>
784+
</Link>
785+
]]
786+
end
787+
788+
789+
function suite.profileOff()
790+
profile "Off"
791+
prepare()
792+
test.capture [[
793+
<Link>
794+
<SubSystem>Windows</SubSystem>
795+
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
796+
<Profile>false</Profile>
797+
</Link>
798+
]]
799+
end

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@
825825
m.additionalLinkOptions,
826826
m.programDatabaseFile,
827827
m.assemblyDebug,
828+
m.profile,
828829
}
829830
end
830831
end
@@ -2550,7 +2551,14 @@
25502551

25512552
function m.assemblyDebug(cfg)
25522553
if cfg.assemblydebug then
2553-
m.element("AssemblyDebug", nil, "true")
2554+
m.element("AssemblyDebug", nil, "true")
2555+
end
2556+
end
2557+
2558+
2559+
function m.profile(cfg)
2560+
if cfg.profile ~= nil then
2561+
m.element("Profile", nil, iif(cfg.profile, "true", "false"))
25542562
end
25552563
end
25562564

src/_premake_init.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,12 @@
11881188
kind = "list:string",
11891189
}
11901190

1191+
p.api.register {
1192+
name = "profile",
1193+
scope = "config",
1194+
kind = "boolean"
1195+
}
1196+
11911197

11921198
-----------------------------------------------------------------------------
11931199
--

src/tools/msc.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,13 @@
386386
table.insert(flags, '/NODEFAULTLIB:' .. ignore)
387387
end
388388

389+
-- If the type is ConsoleApp, WindowedApp, or SharedLib and PROFILE is set, add the appropriate flag.
390+
if cfg.kind == "ConsoleApp" or cfg.kind == "WindowedApp" or cfg.kind == "SharedLib" then
391+
if cfg.profile then
392+
table.insert(flags, "/PROFILE")
393+
end
394+
end
395+
389396
return flags
390397
end
391398

tests/tools/test_msc.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,26 @@ end
628628
test.contains("/DLL", msc.getldflags(cfg))
629629
end
630630

631+
function suite.ldflags_onProfile()
632+
kind "ConsoleApp"
633+
profile "On"
634+
prepare()
635+
test.contains("/PROFILE", msc.getldflags(cfg))
636+
end
631637

638+
function suite.ldflags_onNoProfile()
639+
kind "ConsoleApp"
640+
profile "Off"
641+
prepare()
642+
test.missing("/PROFILE", msc.getldflags(cfg))
643+
end
644+
645+
function suite.ldflags_onProfileInvalidKind()
646+
kind "StaticLib"
647+
profile "On"
648+
prepare()
649+
test.missing("/PROFILE", msc.getldflags(cfg))
650+
end
632651

633652
--
634653
-- Check handling of CLR settings.

website/docs/profile.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Enable or disable instrumented performance profiling support in Visual Studio projects.
2+
3+
```lua
4+
profile "value"
5+
```
6+
7+
### Parameters ###
8+
| Value | Description |
9+
-------------------------------------------------------------------------------------
10+
| Default | Use the toolset's default instrumentated performance profiling setting. |
11+
| On | Turn on instrumented performance profiling. |
12+
| Off | Turn off instrumented performance profiling. |
13+
14+
### Applies To ###
15+
16+
Project configurations where the `kind` is an executable or a shared library.
17+
18+
### Availability ###
19+
20+
Premake 5.0-beta6 or later on Visual Studio or where the toolset is MSC.
21+
22+
### Examples ###
23+
24+
```lua
25+
project "MyProject"
26+
kind "ConsoleApp"
27+
profile "On"
28+
```

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ module.exports = {
215215
'preferredtoolarchitecture',
216216
'prelinkcommands',
217217
'prelinkmessage',
218+
'profile',
218219
'project',
219220
'propertydefinition',
220221
'rebuildcommands',

0 commit comments

Comments
 (0)