From b673bd17ca0bc1a27ea5e16e1a7f45d873cba929 Mon Sep 17 00:00:00 2001 From: Inari0 <42310255+xq114@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:00:59 +0800 Subject: [PATCH 1/2] add profile mode for windows --- xmake/rules/mode/xmake.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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") From 08d49c4e6f53b91382825e8634a67890d962372c Mon Sep 17 00:00:00 2001 From: Inari0 <42310255+xq114@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:02:19 +0800 Subject: [PATCH 2/2] add profile to vs project --- xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 8 ++++++++ 1 file changed, 8 insertions(+) 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