summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-18 21:04:44 +0800
committerruki <[email protected]>2020-02-18 00:28:24 +0800
commit4394e286fca1f9c60a1f8030d96f9fc68675b07f (patch)
tree4835465ae3d6dd3a5719fca5123f30da916a76af
parenta3c18cbec05996bd9d2f9e85854109ad37a46f8d (diff)
improve trybuild
-rw-r--r--xmake/actions/build/main.lua60
1 files changed, 32 insertions, 28 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 51813413b..4b14639a2 100644
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -29,39 +29,43 @@ import("build_files")
import("cleaner")
import("statistics")
--- main
-function main()
-
- -- try building it using third-party buildsystem if xmake.lua not exists
- if not os.isfile(project.file()) then
+-- try to build
+function _trybuild()
- -- get the buildsystem tool
- local configfile = nil
- local tool = nil
- local try_tool = option.get("try-tool")
- if try_tool then
- tool = import("trybuild." .. try_tool, {try = true, anonymous = true})
- if tool then
- configfile = tool.detect()
- else
- raise("unknown build tool: %s", try_tool)
- end
+ -- get the buildsystem tool
+ local configfile = nil
+ local tool = nil
+ local try_tool = option.get("try-tool")
+ if try_tool then
+ tool = import("trybuild." .. try_tool, {try = true, anonymous = true})
+ if tool then
+ configfile = tool.detect()
else
- for _, name in ipairs({"msbuild", "xcodebuild", "cmake", "autotools", "make"}) do
- tool = import("trybuild." .. name, {anonymous = true})
- configfile = tool.detect()
- if configfile then
- try_tool = name
- break
- end
+ raise("unknown build tool: %s", try_tool)
+ end
+ else
+ for _, name in ipairs({"msbuild", "xcodebuild", "cmake", "autotools", "make"}) do
+ tool = import("trybuild." .. name, {anonymous = true})
+ configfile = tool.detect()
+ if configfile then
+ try_tool = name
+ break
end
end
+ end
- -- try building it
- if configfile and tool and utils.confirm({default = true, description = "${bright}" .. path.filename(configfile) .. "${clear} found, try building it"}) then
- tool.build()
- end
- return
+ -- try building it
+ if configfile and tool and utils.confirm({default = true, description = "${bright}" .. path.filename(configfile) .. "${clear} found, try building it"}) then
+ tool.build()
+ end
+end
+
+-- main
+function main()
+
+ -- try building it using third-party buildsystem if xmake.lua not exists
+ if not os.isfile(project.file()) then
+ return _trybuild()
end
-- post statistics before locking project