summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-02-20 22:52:24 +0800
committerruki <[email protected]>2020-02-20 11:14:25 +0800
commita584475a0edd286d04bdeef81db86f925a38b5a2 (patch)
treeb9069a2ff07d26cd4aa0f84145ae3ae53fadc0ae
parentc09a825d5c499f71a4fcb5774905a58e9647e4c5 (diff)
add trybuild/scons
-rw-r--r--xmake/actions/build/main.lua2
-rw-r--r--xmake/actions/config/xmake.lua2
-rw-r--r--xmake/modules/private/action/trybuild/msbuild.lua10
-rw-r--r--xmake/modules/private/action/trybuild/scons.lua41
4 files changed, 45 insertions, 10 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 9eff98819..b2f00d310 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", "meson", "make"}) do
+ for _, name in ipairs({"msbuild", "xcodebuild", "cmake", "autotools", "scons", "meson", "make"}) 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 04f8ad996..0e8954c79 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", "meson", "autotools", "msbuild", "xcodebuild"}}
+ , values = {"auto", "make", "cmake", "scons", "meson", "autotools", "msbuild", "xcodebuild"}}
, {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/msbuild.lua b/xmake/modules/private/action/trybuild/msbuild.lua
index f66676c26..90690d364 100644
--- a/xmake/modules/private/action/trybuild/msbuild.lua
+++ b/xmake/modules/private/action/trybuild/msbuild.lua
@@ -31,18 +31,12 @@ end
-- do clean
function clean()
- local configfile = find_file("*.sln", os.curdir())
- if configfile then
- os.exec("msbuild \"%s\" -nologo -t:Clean -p:Configuration=Release -p:Platform=%s", configfile, is_arch("x64") and "x64" or "Win32")
- end
+ os.vexec("msbuild \"%s\" -nologo -t:Clean -p:Configuration=Release -p:Platform=%s", configfile, is_arch("x64") and "x64" or "Win32")
end
-- do build
function build()
- local configfile = find_file("*.sln", os.curdir())
- if configfile then
- os.exec("msbuild \"%s\" -nologo -t:Build -p:Configuration=Release -p:Platform=%s", configfile, is_arch("x64") and "x64" or "Win32")
- end
+ os.vexec("msbuild \"%s\" -nologo -t:Build -p:Configuration=Release -p:Platform=%s", configfile, is_arch("x64") and "x64" or "Win32")
cprint("${bright}build ok!")
end
diff --git a/xmake/modules/private/action/trybuild/scons.lua b/xmake/modules/private/action/trybuild/scons.lua
new file mode 100644
index 000000000..0a0303af0
--- /dev/null
+++ b/xmake/modules/private/action/trybuild/scons.lua
@@ -0,0 +1,41 @@
+--!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 scons.lua
+--
+
+-- imports
+import("core.base.option")
+import("lib.detect.find_file")
+
+-- detect build-system and configuration file
+function detect()
+ return find_file("SConstruct", os.curdir())
+end
+
+-- do clean
+function clean()
+ os.vexec("scons -c")
+end
+
+-- do build
+function build()
+ os.vexec("scons")
+ cprint("${bright}build ok!")
+end
+
+