diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 21d4c68814f..b69826694e0 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -816,6 +816,9 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo) -- save subsystem local subsystem = "Console" + -- save profile + local profile = false + -- make linker flags local flags = {} local excludes = { @@ -836,6 +839,8 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo) elseif flag_lower:find("[^%-/].+%.lib") then -- link file table.insert(links, flag) + elseif flag_lower:find("[%-/]profile") then + profile = true else local excluded = false for _, exclude in ipairs(excludes) do @@ -870,6 +875,9 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo) -- generate debug infomation? if linkerkinds[targetinfo.targetkind] == "Link" then + -- enable profile? + vcxprojfile:print("%s", tostring(profile)) + -- enable debug infomation? local debug = false for _, symbol in ipairs(targetinfo.symbols) do diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index 308dec90f76..06aeffdcb6e 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -156,10 +156,15 @@ rule("mode.profile") end end - -- enable gprof - target:add("cxflags", "-pg") - target:add("mxflags", "-pg") - target:add("ldflags", "-pg") + if target:is_plat("windows") then + -- enable vs profile + target:add("ldflags", "/profile") + else + -- enable gprof + target:add("cxflags", "-pg") + target:add("mxflags", "-pg") + target:add("ldflags", "-pg") + end -- enable NDEBUG macros to disables standard-C assertions target:add("cxflags", "-DNDEBUG")