summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-13 22:56:49 +0800
committerruki <[email protected]>2018-09-13 11:40:56 +0800
commit6a40b32309c23e7b56403686bd10af87a2bb353a (patch)
treed7e18364bfe6d7efef32a0a0f545187e93e17a60
parent97d2487ef7cc57d0a5e7b80663eac8f8e4709e58 (diff)
add package.builder.xmake
-rw-r--r--tests/projects/package/basic/xmake.lua2
-rw-r--r--xmake/modules/package/builder/xmake.lua49
2 files changed, 50 insertions, 1 deletions
diff --git a/tests/projects/package/basic/xmake.lua b/tests/projects/package/basic/xmake.lua
index 4ac3497a8..f0c0834e6 100644
--- a/tests/projects/package/basic/xmake.lua
+++ b/tests/projects/package/basic/xmake.lua
@@ -17,5 +17,5 @@ target("console")
add_files("src/*.c")
-- add packages
- add_packages("tbox", "zlib", "pcre2")
+ add_packages("tbox", "zlib", "pcre2", "luajit")
diff --git a/xmake/modules/package/builder/xmake.lua b/xmake/modules/package/builder/xmake.lua
new file mode 100644
index 000000000..fbd8b81a0
--- /dev/null
+++ b/xmake/modules/package/builder/xmake.lua
@@ -0,0 +1,49 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you 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 - 2018, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- imports
+import("core.base.option")
+
+-- build package
+function build(package)
+ local argv = {"f", "-y"}
+ local configs = {"plat", "arch", "ndk", "ndk_sdkver", "vs", "sdk", "bin", "cross", "ld", "sh", "ar", "cc", "cxx", "mm", "mxx"}
+ for _, name in ipairs(configs) do
+ local value = get_config(name)
+ if value ~= nil then
+ if value:find(" ", 1, true) then
+ value = '"' .. value .. '"'
+ end
+ table.insert(argv, "--" .. name .. "=" .. value)
+ end
+ end
+ table.insert(argv, "--mode=" .. (is_mode("debug") and "debug" or "release"))
+ os.vrunv("xmake", argv)
+ os.vrun("xmake" .. (option.get("verbose") and " -v" or ""))
+end
+
+-- install package
+function install(package)
+ os.vrun("xmake install -o %s", package:installdir())
+end