summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-09 22:50:00 +0800
committerruki <[email protected]>2020-04-09 11:00:04 +0800
commitd007420934df83431706a8fbc1cf0b7d2d02109a (patch)
treeb86c7977370238907ea6645ee941233e1b2fa301
parent7ea632ffc6675c852707e4f7c4787499960c7e11 (diff)
add ipagen
-rw-r--r--xmake/modules/private/tools/ipagen.lua72
-rw-r--r--xmake/rules/xcode/application/package.lua16
2 files changed, 87 insertions, 1 deletions
diff --git a/xmake/modules/private/tools/ipagen.lua b/xmake/modules/private/tools/ipagen.lua
new file mode 100644
index 000000000..f63307a7c
--- /dev/null
+++ b/xmake/modules/private/tools/ipagen.lua
@@ -0,0 +1,72 @@
+--!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 ipdagen.lua
+--
+
+-- imports
+import("core.base.option")
+import("lib.detect.find_tool")
+
+-- main entry
+function main (appdir, ipafile)
+
+ -- check
+ assert(appdir)
+ assert(os.isdir(appdir), "%s not found!", appdir)
+
+ -- find zip
+ local zip = find_tool("zip")
+ assert(zip, "zip not found!")
+
+ -- get the .ipa file path
+ local appname = path.basename(appdir)
+ if not ipafile then
+ ipafile = path.join(path.directory(appdir), appname .. ".ipa")
+ end
+ ipafile = path.absolute(ipafile)
+
+ -- the temporary directory
+ local tmpdir = path.join(os.tmpdir(), "ipagen", appname)
+
+ -- clean the tmpdir first
+ os.rm(tmpdir)
+
+ -- make the payload directory
+ os.mkdir(path.join(tmpdir, "Payload"))
+
+ -- copy the .app directory into payload
+ os.cp(appdir, path.join(tmpdir, "Payload"))
+
+ -- TODO
+ -- copy icon to iTunesArtwork
+-- os.cp(icon, path.join(tmpdir, "iTunesArtwork"))
+
+ -- generate .ipa file
+ local argv = {"-r", ipafile, "Payload"}
+-- table.insert(argv, "iTunesArtwork")
+ local oldir = os.cd(tmpdir)
+ os.vrunv(zip.program, argv)
+ os.cd(oldir)
+
+ -- remove the temporary directory
+ os.rm(tmpdir)
+
+ -- check
+ assert(os.isfile(ipafile), "generate %s failed!", ipafile)
+end
+
diff --git a/xmake/rules/xcode/application/package.lua b/xmake/rules/xcode/application/package.lua
index 738af9be7..c9fd9dc51 100644
--- a/xmake/rules/xcode/application/package.lua
+++ b/xmake/rules/xcode/application/package.lua
@@ -18,6 +18,20 @@
-- @file package.lua
--
+-- imports
+import("private.tools.ipagen")
+
-- main entry
-function main (target)
+function main (target, opt)
+
+ -- get app directory
+ local appdir = target:data("xcode.bundle.rootdir")
+
+ -- generate *.ipa file
+ local ipafile = path.join(path.directory(appdir), path.basename(appdir) .. ".ipa")
+ ipagen(appdir, ipafile)
+
+ -- trace
+ cprint("output: ${bright}%s", ipafile)
+ cprint("${color.success}package ok!")
end