diff options
| -rw-r--r-- | xmake/actions/build/main.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/autotools.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/cmake.lua | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 285f2c10c..2918bb95f 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -36,14 +36,16 @@ function _try_build() config.load() -- rebuild it? do clean first + local targetname = option.get("target") if option.get("rebuild") then - task.run("clean", {target = option.get("target")}) + task.run("clean", {target = targetname}) end -- get the buildsystem tool local configfile = nil local tool = nil local trybuild = config.get("trybuild") + local trybuild_detected = nil if trybuild then tool = import("private.action.trybuild." .. trybuild, {try = true, anonymous = true}) if tool then @@ -56,7 +58,7 @@ function _try_build() tool = import("private.action.trybuild." .. name, {anonymous = true}) configfile = tool.detect() if configfile then - config.set("trybuild", name, {readonly = true, force = true}) + trybuild_detected = name break end end @@ -64,6 +66,9 @@ function _try_build() -- try building it if configfile and tool and (trybuild or utils.confirm({default = true, description = "${bright}" .. path.filename(configfile) .. "${clear} found, try building it"})) then + if not trybuild then + task.run("config", {target = targetname, trybuild = trybuild_detected}) + end tool.build() end end diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua index b9f45bbc7..505054404 100644 --- a/xmake/modules/private/action/trybuild/autotools.lua +++ b/xmake/modules/private/action/trybuild/autotools.lua @@ -25,7 +25,7 @@ import("lib.detect.find_file") -- get build directory function _get_buildir() - return config.buildir() + return config.buildir() or "build" end -- get artifacts directory @@ -41,9 +41,11 @@ end -- do clean function clean() if find_file("[mM]akefile", os.curdir()) then - os.exec("make clean") if option.get("all") then + os.exec("make distclean") os.tryrm(_get_artifacts_dir()) + else + os.exec("make clean") end end end diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index 54e066311..6308df5d2 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -25,7 +25,7 @@ import("lib.detect.find_file") -- get build directory function _get_buildir() - return config.buildir() + return config.buildir() or "build" end -- get artifacts directory |
