From 0f6285e094ceae1e3a7460150cdf482deccf03f7 Mon Sep 17 00:00:00 2001 From: jinke18 Date: Tue, 30 Jul 2024 21:36:31 +0800 Subject: add /sdl and /Zc:inline flag support for `xmake project -k vs` --- .../plugins/project/vstudio/impl/vs201x_vcxproj.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 109094a55..f7f803469 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -494,11 +494,30 @@ function _make_source_options_cl(vcxprojfile, flags, condition) vcxprojfile:print("CompileAsCpp", condition) end + + -- make SDLCheck flag: /sdl + if flagstr:find("[%-/]sdl") then + if flagstr:find("[%-/]sdl%-") then + vcxprojfile:print("false", condition) + else + vcxprojfile:print("true", condition) + end + end + + -- make RemoveUnreferencedCodeData flag: Zc:inline + if flagstr:find("[%-/]Zc:inline") then + if flagstr:find("[%-/]Zc:inline%-") then + vcxprojfile:print("false", condition) + else + vcxprojfile:print("true", condition) + end + end + -- make AdditionalOptions local excludes = { "Od", "Os", "O0", "O1", "O2", "Ot", "Ox", "W0", "W1", "W2", "W3", "W4", "WX", "Wall", "Zi", "ZI", "Z7", "MT", "MTd", "MD", "MDd", "TP", "Fd", "fp", "I", "D", "Gm%-", "Gm", "GR%-", "GR", "MP", "external:W0", "external:W1", "external:W2", "external:W3", "external:W4", "external:templates%-?", "external:I", - "std:c11", "std:c17", "std:c%+%+11", "std:c%+%+14", "std:c%+%+17", "std:c%+%+20", "std:c%+%+latest", "nologo", "wd(%d+)" + "std:c11", "std:c17", "std:c%+%+11", "std:c%+%+14", "std:c%+%+17", "std:c%+%+20", "std:c%+%+latest", "nologo", "wd(%d+)", "sdl%-?", "Zc:inline%-?" } local additional_flags = _exclude_flags(flags, excludes) if #additional_flags > 0 then -- cgit v1.3.1 From eac84edc7c302aa5372b13e327daacee58e39ca0 Mon Sep 17 00:00:00 2001 From: jinke18 Date: Tue, 30 Jul 2024 23:30:05 +0800 Subject: add ExceptionHandling flag support for `xmake project -k vs` --- .../project/vstudio/impl/vs201x_vcxproj.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index f7f803469..3ae2bd47c 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -513,11 +513,31 @@ function _make_source_options_cl(vcxprojfile, flags, condition) end end + -- make ExceptionHandling flag: + if flagstr:find("[%-/]EH[asc]+%-?") then + local args = flagstr:match("[%-/]EH([asc]+%-?)") + -- remove the last arg if flag endwith `-` + if arg:sub(-1, -1) == "-" then + args = args:sub(1, -2) + end + if args:find("a") then + -- a will overwrite s and c + vcxprojfile:print("Async", condition) + elseif args == "sc" or args == "cs" then + vcxprojfile:print("Sync", condition) + elseif args == "s" then + vcxprojfile:print("SyncCThrow", condition) + else + -- if args == "c" + -- c is ignored without s or a, do nothing here + end + end + -- make AdditionalOptions local excludes = { "Od", "Os", "O0", "O1", "O2", "Ot", "Ox", "W0", "W1", "W2", "W3", "W4", "WX", "Wall", "Zi", "ZI", "Z7", "MT", "MTd", "MD", "MDd", "TP", "Fd", "fp", "I", "D", "Gm%-", "Gm", "GR%-", "GR", "MP", "external:W0", "external:W1", "external:W2", "external:W3", "external:W4", "external:templates%-?", "external:I", - "std:c11", "std:c17", "std:c%+%+11", "std:c%+%+14", "std:c%+%+17", "std:c%+%+20", "std:c%+%+latest", "nologo", "wd(%d+)", "sdl%-?", "Zc:inline%-?" + "std:c11", "std:c17", "std:c%+%+11", "std:c%+%+14", "std:c%+%+17", "std:c%+%+20", "std:c%+%+latest", "nologo", "wd(%d+)", "sdl%-?", "Zc:inline%-?", "EH[asc]+%-?" } local additional_flags = _exclude_flags(flags, excludes) if #additional_flags > 0 then -- cgit v1.3.1 From c05b97cc1bae37ef3d62156136341377d67ccecb Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 7 Aug 2024 15:11:37 +0800 Subject: Update vs201x_vcxproj.lua --- xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 3ae2bd47c..23f685ed2 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -517,10 +517,10 @@ function _make_source_options_cl(vcxprojfile, flags, condition) if flagstr:find("[%-/]EH[asc]+%-?") then local args = flagstr:match("[%-/]EH([asc]+%-?)") -- remove the last arg if flag endwith `-` - if arg:sub(-1, -1) == "-" then + if args:endswith("-") then args = args:sub(1, -2) end - if args:find("a") then + if args:find("a", 1, true) then -- a will overwrite s and c vcxprojfile:print("Async", condition) elseif args == "sc" or args == "cs" then -- cgit v1.3.1 From 02491fbb13d6139ba8c5ec7c4eb7dd5487380890 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 7 Aug 2024 15:12:40 +0800 Subject: Update vs201x_vcxproj.lua --- xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 23f685ed2..21d4c6881 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -517,10 +517,10 @@ function _make_source_options_cl(vcxprojfile, flags, condition) if flagstr:find("[%-/]EH[asc]+%-?") then local args = flagstr:match("[%-/]EH([asc]+%-?)") -- remove the last arg if flag endwith `-` - if args:endswith("-") then + if args and args:endswith("-") then args = args:sub(1, -2) end - if args:find("a", 1, true) then + if args and args:find("a", 1, true) then -- a will overwrite s and c vcxprojfile:print("Async", condition) elseif args == "sc" or args == "cs" then -- cgit v1.3.1