diff options
| author | ruki <[email protected]> | 2020-02-18 21:02:33 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-18 00:15:18 +0800 |
| commit | a3c18cbec05996bd9d2f9e85854109ad37a46f8d (patch) | |
| tree | 4ba91dd239d6a73dd4d48b70508724e24222ac3c /xmake/actions/build/main.lua | |
| parent | 531e766aff537bcd24ab0d92583f9099bc6f8567 (diff) | |
improve trybuild
Diffstat (limited to 'xmake/actions/build/main.lua')
| -rw-r--r-- | xmake/actions/build/main.lua | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 2002935b9..51813413b 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -27,15 +27,41 @@ import("core.platform.platform") import("build") import("build_files") import("cleaner") -import("trybuild") import("statistics") -- main function main() -- try building it using third-party buildsystem if xmake.lua not exists - if not os.isfile(project.file()) and option.get("try") then - return trybuild() + if not os.isfile(project.file()) then + + -- 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 + 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 end -- post statistics before locking project |
