summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/languages/c++/check_main.lua6
-rw-r--r--xmake/languages/golang/check_main.lua6
-rw-r--r--xmake/languages/objc++/check_main.lua6
3 files changed, 15 insertions, 3 deletions
diff --git a/xmake/languages/c++/check_main.lua b/xmake/languages/c++/check_main.lua
index 462ad4c6c..87a2002ae 100644
--- a/xmake/languages/c++/check_main.lua
+++ b/xmake/languages/c++/check_main.lua
@@ -27,8 +27,12 @@ function main(sourcefile)
-- load source code
local sourcecode = io.read(sourcefile)
+ -- remove comment first
+ sourcecode = sourcecode:gsub("/%*.-%*/", "")
+ sourcecode = sourcecode:gsub("//.-\n", "\n")
+
-- find int main(int argc, char** argv) {}
- if sourcecode:find("%s+main%s*%(.*%)") then
+ if sourcecode:find("%s+main%s*%(.-%)") then
return true
end
diff --git a/xmake/languages/golang/check_main.lua b/xmake/languages/golang/check_main.lua
index 38cb4a812..ab19e1e14 100644
--- a/xmake/languages/golang/check_main.lua
+++ b/xmake/languages/golang/check_main.lua
@@ -27,8 +27,12 @@ function main(sourcefile)
-- load source code
local sourcecode = io.read(sourcefile)
+ -- remove comment first
+ sourcecode = sourcecode:gsub("/%*.-%*/", "")
+ sourcecode = sourcecode:gsub("//.-\n", "\n")
+
-- find func main() {
- if sourcecode:find("func%s+main%s*%(.*%)") then
+ if sourcecode:find("func%s+main%s*%(.-%)") then
return true
end
diff --git a/xmake/languages/objc++/check_main.lua b/xmake/languages/objc++/check_main.lua
index 462ad4c6c..87a2002ae 100644
--- a/xmake/languages/objc++/check_main.lua
+++ b/xmake/languages/objc++/check_main.lua
@@ -27,8 +27,12 @@ function main(sourcefile)
-- load source code
local sourcecode = io.read(sourcefile)
+ -- remove comment first
+ sourcecode = sourcecode:gsub("/%*.-%*/", "")
+ sourcecode = sourcecode:gsub("//.-\n", "\n")
+
-- find int main(int argc, char** argv) {}
- if sourcecode:find("%s+main%s*%(.*%)") then
+ if sourcecode:find("%s+main%s*%(.-%)") then
return true
end