diff options
| author | ruki <[email protected]> | 2016-11-08 09:53:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-11-08 09:53:00 +0800 |
| commit | d7afb89f2a54c1590d8823e3f0f79cecb69100a6 (patch) | |
| tree | 4f6388ef635caeeef3091d0d79064e7399b82ce4 | |
| parent | 50bacc9a7544d568db4db6e850dfa4de6301d5a9 (diff) | |
add app2ipa plugin
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rwxr-xr-x | xmake/plugins/app2ipa/main.lua | 83 | ||||
| -rwxr-xr-x | xmake/plugins/app2ipa/xmake.lua | 48 |
3 files changed, 133 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 806ed9dc7..e5b932bcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### New features * Add `--links`, `--linkdirs` and `--includedirs` configure arguments +* Add app2ipa plugin ### Bugs fixed @@ -178,6 +179,7 @@ ### ������ * ����`--links`, `--linkdirs` and `--includedirs` ���� +* ����app2ipa��� ### Bugs�� diff --git a/xmake/plugins/app2ipa/main.lua b/xmake/plugins/app2ipa/main.lua new file mode 100755 index 000000000..26d834a74 --- /dev/null +++ b/xmake/plugins/app2ipa/main.lua @@ -0,0 +1,83 @@ +--!The Make-like Build Utility based on Lua +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import("core.base.option") +import("core.tool.tool") + +-- main +function main() + + -- check the zip + local zip = tool.check("zip", nil, function (shellname) + os.run("%s -v", shellname) + end) + assert(zip, "zip not found!") + + -- get the .app file path + local app = option.get("app") + assert(app, "please input the .app path!") + assert(os.isdir(app), "%s not found!", app) + + -- get the app name + local appname = path.basename(app) + + -- get the .ipa file path + local ipa = option.get("ipa") + if not ipa then + ipa = path.join(path.directory(app), appname .. ".ipa") + end + + -- get icon file path + local icon = option.get("icon") + assert(icon, "please input the icon path!") + assert(os.isfile(icon), "%s not found!", icon) + + -- the temporary directory + local tmpdir = path.join(os.tmpdir(), "app2ipa", 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(app, path.join(tmpdir, "Payload")) + + -- copy icon to iTunesArtwork + os.cp(icon, path.join(tmpdir, "iTunesArtwork")) + + -- generate .ipa file + os.cd(tmpdir) + os.run("%s -r %s Payload iTunesArtwork", zip, ipa) + os.cd("-") + + -- remove the temporary directory + os.rm(tmpdir) + + -- check + assert(os.isfile(ipa), "generate %s failed!", ipa) + + -- trace + cprint("${bright}generate %s ok!${ok_hand}", ipa) +end diff --git a/xmake/plugins/app2ipa/xmake.lua b/xmake/plugins/app2ipa/xmake.lua new file mode 100755 index 000000000..bcd444c1a --- /dev/null +++ b/xmake/plugins/app2ipa/xmake.lua @@ -0,0 +1,48 @@ +--!The Make-like Build Utility based on Lua +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file app2ipa.lua +-- + +-- define task +task("app2ipa") + + -- set category + set_category("plugin") + + -- on run + on_run("main") + + -- set menu + set_menu({ + -- usage + usage = "xmake app2ipa [options] xxx.app" + + -- description + , description = "Generate .ipa file from the given .app" + + -- options + , options = + { + {'o', "ipa", "kv", nil, "Set the .ipa file path." } + , {nil, "icon", "kv", nil, "Set the icon file path." } + , {} + , {nil, "app", "v", nil, "Set the .app directory." } + } + }) |
