summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-09 23:03:47 +0800
committerruki <[email protected]>2020-04-09 12:22:44 +0800
commit0a3f80680dc4cea8b3f6ac95c5cfc0380567a227 (patch)
tree3df6e66203d7cf6423ef98f243750f2215fec581
parent1cc0dbcfb9fa9d07fb84dd641b52a06259ec04cb (diff)
install ipa
-rw-r--r--xmake/modules/detect/tools/find_ideviceinstaller.lua51
-rw-r--r--xmake/rules/xcode/application/install.lua30
-rw-r--r--xmake/rules/xcode/application/package.lua15
-rw-r--r--xmake/rules/xcode/application/uninstall.lua3
4 files changed, 88 insertions, 11 deletions
diff --git a/xmake/modules/detect/tools/find_ideviceinstaller.lua b/xmake/modules/detect/tools/find_ideviceinstaller.lua
new file mode 100644
index 000000000..abebf216b
--- /dev/null
+++ b/xmake/modules/detect/tools/find_ideviceinstaller.lua
@@ -0,0 +1,51 @@
+--!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 find_ideviceinstaller.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find ideviceinstaller
+--
+-- @param opt the arguments, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local ideviceinstaller = find_ideviceinstaller()
+-- local ideviceinstaller, version = find_ideviceinstaller({version = true})
+--
+-- @endcode
+--
+function main(opt)
+
+ -- only for macosx
+ if not is_host("macosx") then
+ return
+ end
+
+ -- init options
+ opt = opt or {}
+ opt.check = "-h"
+
+ -- find program
+ return find_program(opt.program or "ideviceinstaller", opt)
+end
diff --git a/xmake/rules/xcode/application/install.lua b/xmake/rules/xcode/application/install.lua
index f235870ec..ffb34230c 100644
--- a/xmake/rules/xcode/application/install.lua
+++ b/xmake/rules/xcode/application/install.lua
@@ -18,12 +18,32 @@
-- @file install.lua
--
+-- imports
+import("lib.detect.find_tool")
+
+-- install for ios
+function _install_for_ios(target)
+
+ -- get app directory
+ local appdir = target:data("xcode.bundle.rootdir")
+
+ -- get *.ipa file
+ local ipafile = path.join(path.directory(appdir), path.basename(appdir) .. ".ipa")
+ assert(ipafile, "please run `xmake package` first!")
+
+ -- find ideviceinstaller
+ local ideviceinstaller = assert(find_tool("ideviceinstaller"), "ideviceinstaller not found!")
+
+ -- do install
+ os.vrunv(ideviceinstaller.program, {"-i", ipafile})
+
+ -- trace
+ cprint("${color.success}install ok!")
+end
+
-- main entry
function main (target)
- local bundledir = path.absolute(target:data("xcode.bundle.rootdir"))
- local installdir = target:installdir()
- if not os.isdir(installdir) then
- os.mkdir(installdir)
+ if is_plat("iphoneos") then
+ _install_for_ios(target)
end
- os.vcp(bundledir, installdir)
end
diff --git a/xmake/rules/xcode/application/package.lua b/xmake/rules/xcode/application/package.lua
index c9fd9dc51..059b7b219 100644
--- a/xmake/rules/xcode/application/package.lua
+++ b/xmake/rules/xcode/application/package.lua
@@ -21,17 +21,26 @@
-- imports
import("private.tools.ipagen")
--- main entry
-function main (target, opt)
+-- package for ios
+function _package_for_ios(target)
-- get app directory
local appdir = target:data("xcode.bundle.rootdir")
- -- generate *.ipa file
+ -- get *.ipa file
local ipafile = path.join(path.directory(appdir), path.basename(appdir) .. ".ipa")
+
+ -- generate *.ipa file
ipagen(appdir, ipafile)
-- trace
cprint("output: ${bright}%s", ipafile)
cprint("${color.success}package ok!")
end
+
+-- main entry
+function main (target, opt)
+ if is_plat("iphoneos") then
+ _package_for_ios(target)
+ end
+end
diff --git a/xmake/rules/xcode/application/uninstall.lua b/xmake/rules/xcode/application/uninstall.lua
index 1f9edb008..9f190bf60 100644
--- a/xmake/rules/xcode/application/uninstall.lua
+++ b/xmake/rules/xcode/application/uninstall.lua
@@ -20,7 +20,4 @@
-- main entry
function main (target)
- local bundledir = path.absolute(target:data("xcode.bundle.rootdir"))
- local installdir = target:installdir()
- os.tryrm(path.join(installdir, path.filename(bundledir)))
end