From 8150e06f3c7a58635e3953d9b32edfdf415ab7a1 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 16 Dec 2024 23:04:23 +0800 Subject: improve to parse linux module flags --- xmake/rules/platform/linux/module/driver_modules.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xmake/rules/platform/linux/module/driver_modules.lua b/xmake/rules/platform/linux/module/driver_modules.lua index 8218a972c..3adb39d05 100644 --- a/xmake/rules/platform/linux/module/driver_modules.lua +++ b/xmake/rules/platform/linux/module/driver_modules.lua @@ -134,9 +134,15 @@ module_exit(hello_exit); or (cflag:startswith("-W") and not cflag:startswith("-Wp,-MMD,") and not cflag:startswith("-Wp,-MD,")) or (cflag:startswith("-D") and not cflag:find("KBUILD_MODNAME=") and not cflag:find("KBUILD_BASENAME=")) then has_cflag = true - local macro = cflag:match("%-D\"(.+)\"") -- -D"KBUILD_XXX=xxx" - if macro then - cflag = "-D" .. macro + -- https://github.com/xmake-io/xmake/discussions/5972#discussioncomment-11576255 + local macro, value = cflag:match("%-D(.+)='(.+)'") -- -DXXX='"xxx"' + if macro and value and value:startswith("\"") then + cflag = "-D" .. macro .. "=" .. value + else + macro = cflag:match("%-D\"(.+)\"") -- -D"KBUILD_XXX=xxx" + if macro then + cflag = "-D" .. macro + end end elseif cflag == "-I" or cflag == "-isystem" or cflag == "-include" then include_cflag = cflag -- cgit v1.3.1