diff options
| author | ruki <[email protected]> | 2020-02-19 23:16:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-19 13:37:57 +0800 |
| commit | 83be106cb6ef6f55dc992f97afa938ffed231087 (patch) | |
| tree | f36f4ad629249fcfbdd03cad3fdbcef0658667b1 /xmake/modules | |
| parent | ed49fcb8e77087a12b01cae2bb7841a75a25b0fc (diff) | |
impl trybuild/meson
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/action/trybuild/autotools.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/cmake.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/make.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/meson.lua | 32 |
4 files changed, 44 insertions, 20 deletions
diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua index cbb36a166..cbedd70e6 100644 --- a/xmake/modules/private/action/trybuild/autotools.lua +++ b/xmake/modules/private/action/trybuild/autotools.lua @@ -152,10 +152,10 @@ end function clean() if find_file("[mM]akefile", os.curdir()) then if option.get("all") then - os.exec("make distclean") + os.vexec("make distclean") os.tryrm(_get_artifacts_dir()) else - os.exec("make clean") + os.vexec("make clean") end end end @@ -172,9 +172,9 @@ function build() -- generate configure if not os.isfile("configure") then if os.isfile("autogen.sh") then - os.execv("sh", {"./autogen.sh"}) + os.vexecv("sh", {"./autogen.sh"}) elseif os.isfile("configure.ac") then - os.exec("autoreconf --install --symlink") + os.vexec("autoreconf --install --symlink") end end @@ -191,12 +191,12 @@ function build() end end end - os.execv("./configure", argv, {envs = _get_buildenvs()}) + os.vexecv("./configure", argv, {envs = _get_buildenvs()}) end -- do build - os.exec("make -j" .. option.get("jobs")) - os.exec("make install") + os.vexec("make -j" .. option.get("jobs")) + os.vexec("make install") cprint("output to ${bright}%s", artifacts_dir) cprint("${bright}build ok!") end diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index 287b8aefc..7cef45c37 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -47,9 +47,9 @@ function clean() if configfile then local oldir = os.cd(buildir) if is_plat("windows") then - os.exec("msbuild \"%s\" -nologo -t:Clean -p:Configuration=%s -p:Platform=%s", configfile, is_mode("debug") and "Debug" or "Release", is_arch("x64") and "x64" or "Win32") + os.vexec("msbuild \"%s\" -nologo -t:Clean -p:Configuration=%s -p:Platform=%s", configfile, is_mode("debug") and "Debug" or "Release", is_arch("x64") and "x64" or "Win32") else - os.exec("make clean") + os.vexec("make clean") end os.cd(oldir) end @@ -76,20 +76,20 @@ function build() table.insert(argv, "x64") end table.insert(argv, '..') - os.execv(cmake.program, argv) + os.vexecv(cmake.program, argv) end -- do build if is_plat("windows") then local slnfile = assert(find_file("*.sln", os.curdir()), "*.sln file not found!") - os.exec("msbuild \"%s\" -nologo -t:Build -p:Configuration=%s -p:Platform=%s", slnfile, is_mode("debug") and "Debug" or "Release", is_arch("x64") and "x64" or "Win32") + os.vexec("msbuild \"%s\" -nologo -t:Build -p:Configuration=%s -p:Platform=%s", slnfile, is_mode("debug") and "Debug" or "Release", is_arch("x64") and "x64" or "Win32") local projfile = os.isfile("INSTALL.vcxproj") and "INSTALL.vcxproj" or "INSTALL.vcproj" if os.isfile(projfile) then - os.exec("msbuild \"%s\" /property:configuration=%s", projfile, is_mode("debug") and "Debug" or "Release") + os.vexec("msbuild \"%s\" /property:configuration=%s", projfile, is_mode("debug") and "Debug" or "Release") end else - os.exec("make -j" .. option.get("jobs")) - os.exec("make install") + os.vexec("make -j" .. option.get("jobs")) + os.vexec("make install") end cprint("output to ${bright}%s", artifacts_dir) cprint("${bright}build ok!") diff --git a/xmake/modules/private/action/trybuild/make.lua b/xmake/modules/private/action/trybuild/make.lua index 2258b13b7..34f0ccaaa 100644 --- a/xmake/modules/private/action/trybuild/make.lua +++ b/xmake/modules/private/action/trybuild/make.lua @@ -29,12 +29,12 @@ end -- do clean function clean() - os.exec("make clean") + os.vexec("make clean") end -- do build function build() - os.exec("make -j" .. option.get("jobs")) + os.vexec("make -j" .. option.get("jobs")) cprint("${bright}build ok!") end diff --git a/xmake/modules/private/action/trybuild/meson.lua b/xmake/modules/private/action/trybuild/meson.lua index 17982e190..7268b243a 100644 --- a/xmake/modules/private/action/trybuild/meson.lua +++ b/xmake/modules/private/action/trybuild/meson.lua @@ -43,6 +43,20 @@ end function clean() local buildir = _get_buildir() if os.isdir(buildir) then + local configfile = find_file("build.ninja", buildir) + if configfile then + local ninja = assert(find_tool("ninja"), "ninja not found!") + local ninja_argv = {"-C", buildir} + if option.get("verbose") or option.get("diagnosis") then + table.insert(ninja_argv, "-v") + end + table.insert(ninja_argv, "-t") + table.insert(ninja_argv, "clean") + os.vexecv(ninja.program, ninja_argv) + if option.get("all") then + os.tryrm(buildir) + end + end end end @@ -54,17 +68,27 @@ function build() if not os.isdir(artifacts_dir) then os.mkdir(artifacts_dir) end - os.cd(_get_buildir()) -- generate makefile + local buildir = _get_buildir() local meson = assert(find_tool("meson"), "meson not found!") - local configfile = nil + local configfile = find_file("build.ninja", buildir) if not configfile then local argv = {"--prefix=" .. artifacts_dir} - table.insert(argv, _get_buildir()) - os.execv("meson", argv) + table.insert(argv, buildir) + os.vexecv(meson.program, argv) end + -- do build + local ninja = assert(find_tool("ninja"), "ninja not found!") + local ninja_argv = {"-C", buildir} + if option.get("verbose") or option.get("diagnosis") then + table.insert(ninja_argv, "-v") + end + table.insert(ninja_argv, "-j") + table.insert(ninja_argv, option.get("jobs")) + os.vexecv(ninja.program, ninja_argv) + os.vexecv(ninja.program, table.join("install", ninja_argv)) cprint("output to ${bright}%s", artifacts_dir) cprint("${bright}build ok!") end |
