diff options
| author | ruki <[email protected]> | 2020-02-18 22:38:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-18 09:49:18 +0800 |
| commit | 8b831931741f696c3b90940877d4bc7eca1347cf (patch) | |
| tree | c25d023612feb05220ac5393128d93cf1ce8a6be | |
| parent | 753309f3eca9445904c2e70d99fcdc49a67e5add (diff) | |
add try-clean
| -rw-r--r-- | xmake/actions/build/main.lua | 11 | ||||
| -rw-r--r-- | xmake/actions/clean/main.lua | 28 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/autotools.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/cmake.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/make.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/msbuild.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/xcodebuild.lua | 4 |
7 files changed, 57 insertions, 4 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 3e2f71aa2..285f2c10c 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -29,12 +29,17 @@ import("build_files") import("cleaner") import("statistics") --- try to build -function _trybuild() +-- do build for the third-party buildsystem +function _try_build() -- load config config.load() + -- rebuild it? do clean first + if option.get("rebuild") then + task.run("clean", {target = option.get("target")}) + end + -- get the buildsystem tool local configfile = nil local tool = nil @@ -68,7 +73,7 @@ function main() -- try building it using third-party buildsystem if xmake.lua not exists if not os.isfile(project.file()) then - return _trybuild() + return _try_build() end -- post statistics before locking project diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua index 3682a7719..db2341ab6 100644 --- a/xmake/actions/clean/main.lua +++ b/xmake/actions/clean/main.lua @@ -206,9 +206,37 @@ function _clean(targetname) end end +-- do clean for the third-party buildsystem +function _try_clean() + + -- load config + config.load() + + -- get the buildsystem tool + local configfile = nil + local tool = nil + local trybuild = config.get("trybuild") + if trybuild then + tool = import("private.action.trybuild." .. trybuild, {try = true, anonymous = true}) + if tool then + configfile = tool.detect() + end + end + + -- try cleaning it + if configfile and tool and trybuild then + tool.clean() + end +end + -- main function main() + -- try cleaning it using third-party buildsystem if xmake.lua not exists + if not os.isfile(project.file()) then + return _try_clean() + end + -- lock the whole project project.lock() diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua index c2bda369e..da6c37740 100644 --- a/xmake/modules/private/action/trybuild/autotools.lua +++ b/xmake/modules/private/action/trybuild/autotools.lua @@ -27,6 +27,10 @@ function detect() return find_file("configure", os.curdir()) or find_file("configure.ac", os.curdir()) end +-- do clean +function clean() +end + -- do build function build() if not os.isfile("configure") then diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index 09ad6750c..d548ed416 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -27,6 +27,10 @@ function detect() return find_file("CMakeLists.txt", os.curdir()) end +-- do clean +function clean() +end + -- do build function build() os.mkdir("build") diff --git a/xmake/modules/private/action/trybuild/make.lua b/xmake/modules/private/action/trybuild/make.lua index 4572e4e73..2258b13b7 100644 --- a/xmake/modules/private/action/trybuild/make.lua +++ b/xmake/modules/private/action/trybuild/make.lua @@ -27,9 +27,13 @@ function detect() return find_file("[mM]akefile", os.curdir()) end +-- do clean +function clean() + os.exec("make clean") +end + -- do build function build() - os.exec("make clean") os.exec("make -j" .. option.get("jobs")) cprint("${bright}build ok!") end diff --git a/xmake/modules/private/action/trybuild/msbuild.lua b/xmake/modules/private/action/trybuild/msbuild.lua index 18005c70e..93a01ce78 100644 --- a/xmake/modules/private/action/trybuild/msbuild.lua +++ b/xmake/modules/private/action/trybuild/msbuild.lua @@ -29,6 +29,10 @@ function detect() end end +-- do clean +function clean() +end + -- do build function build() os.exec("msbuild \"%s\" -nologo -t:Rebuild -p:Configuration=Release -p:Platform=%s", buildfile, os.arch() == "x64" and "x64" or "Win32") diff --git a/xmake/modules/private/action/trybuild/xcodebuild.lua b/xmake/modules/private/action/trybuild/xcodebuild.lua index 81a15018c..2393c2174 100644 --- a/xmake/modules/private/action/trybuild/xcodebuild.lua +++ b/xmake/modules/private/action/trybuild/xcodebuild.lua @@ -29,6 +29,10 @@ function detect() end end +-- do clean +function clean() +end + -- do build function build() os.exec("xcodebuild clean build CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO") |
