diff options
| author | ruki <[email protected]> | 2024-08-07 16:07:56 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-07 16:07:56 +0800 |
| commit | 5e1dfa56a99d03d0252a51e0f730b2efb78d1bdc (patch) | |
| tree | 3be4ce55e05783b683a3b2bbefde505fa7fdb645 | |
| parent | 5fdc3b22e827617582e5c1c2e754870fb195b66b (diff) | |
| parent | 02491fbb13d6139ba8c5ec7c4eb7dd5487380890 (diff) | |
Merge pull request #5416 from jinke18/dev-jk240730-2
add /sdl, /Zc:inline and ExceptionHandling flag support for `xmake project -k vs`
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 109094a55..21d4c6881 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -494,11 +494,50 @@ function _make_source_options_cl(vcxprojfile, flags, condition) vcxprojfile:print("<CompileAs%s>CompileAsCpp</CompileAs>", condition) end + + -- make SDLCheck flag: /sdl + if flagstr:find("[%-/]sdl") then + if flagstr:find("[%-/]sdl%-") then + vcxprojfile:print("<SDLCheck%s>false</SDLCheck>", condition) + else + vcxprojfile:print("<SDLCheck%s>true</SDLCheck>", condition) + end + end + + -- make RemoveUnreferencedCodeData flag: Zc:inline + if flagstr:find("[%-/]Zc:inline") then + if flagstr:find("[%-/]Zc:inline%-") then + vcxprojfile:print("<RemoveUnreferencedCodeData%s>false</RemoveUnreferencedCodeData>", condition) + else + vcxprojfile:print("<RemoveUnreferencedCodeData%s>true</RemoveUnreferencedCodeData>", 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 args and args:endswith("-") then + args = args:sub(1, -2) + end + if args and args:find("a", 1, true) then + -- a will overwrite s and c + vcxprojfile:print("<ExceptionHandling%s>Async</ExceptionHandling>", condition) + elseif args == "sc" or args == "cs" then + vcxprojfile:print("<ExceptionHandling%s>Sync</ExceptionHandling>", condition) + elseif args == "s" then + vcxprojfile:print("<ExceptionHandling%s>SyncCThrow</ExceptionHandling>", 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+)" + "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 |
