diff options
| author | ruki <[email protected]> | 2020-02-21 00:30:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-20 21:02:54 +0800 |
| commit | d233f14af9aa9173648f9ff4ff588604f5046deb (patch) | |
| tree | d3a19ef389e240f335283b7f65feb608de04f97a | |
| parent | 8a0bb07265285fc8d33649656c3ccbc7e15f0df4 (diff) | |
add ninja for trybuild
| -rw-r--r-- | xmake/actions/build/main.lua | 2 | ||||
| -rw-r--r-- | xmake/actions/config/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/action/trybuild/ninja.lua | 57 |
3 files changed, 59 insertions, 2 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index b2f00d310..38da6309b 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -55,7 +55,7 @@ function _try_build() raise("unknown build tool: %s", trybuild) end else - for _, name in ipairs({"msbuild", "xcodebuild", "cmake", "autotools", "scons", "meson", "make"}) do + for _, name in ipairs({"msbuild", "xcodebuild", "cmake", "autotools", "scons", "meson", "make", "ninja"}) do tool = import("private.action.trybuild." .. name, {anonymous = true}) configfile = tool.detect() if configfile then diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua index 0e8954c79..89e8a2b3a 100644 --- a/xmake/actions/config/xmake.lua +++ b/xmake/actions/config/xmake.lua @@ -55,7 +55,7 @@ task("config") "e.g.", " - xmake f --trybuild=auto; xmake", " - xmake f --trybuild=autotools -p android --ndk=xxx; xmake" - , values = {"auto", "make", "cmake", "scons", "meson", "autotools", "msbuild", "xcodebuild"}} + , values = {"auto", "make", "cmake", "scons", "meson", "autotools", "msbuild", "xcodebuild", "ninja"}} , {nil, "tryconfigs", "kv", nil , "Set the extra configurations of the third-party buildsystem for the try-build mode.", "e.g.", " - xmake f --trybuild=autotools --tryconfigs='--enable-shared=no'"} diff --git a/xmake/modules/private/action/trybuild/ninja.lua b/xmake/modules/private/action/trybuild/ninja.lua new file mode 100644 index 000000000..68c0901ae --- /dev/null +++ b/xmake/modules/private/action/trybuild/ninja.lua @@ -0,0 +1,57 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file ninja.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("lib.detect.find_file") +import("lib.detect.find_tool") + +-- detect build-system and configuration file +function detect() + return find_file("build.ninja", os.curdir()) +end + +-- do clean +function clean() + local ninja = assert(find_tool("ninja"), "ninja not found!") + local ninja_argv = {"-C", os.curdir()} + 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) +end + +-- do build +function build() + local ninja = assert(find_tool("ninja"), "ninja not found!") + local ninja_argv = {"-C", os.curdir()} + 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) + cprint("${bright}build ok!") +end + + |
