From fb1111bb6fae0f6bab1d9be1464e06af8e1ba5f1 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 26 Nov 2025 22:29:42 +0800 Subject: pack mac app --- xmake/rules/xcode/application/xmake.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'xmake/rules/xcode') diff --git a/xmake/rules/xcode/application/xmake.lua b/xmake/rules/xcode/application/xmake.lua index ecffaeeac..d809261c5 100644 --- a/xmake/rules/xcode/application/xmake.lua +++ b/xmake/rules/xcode/application/xmake.lua @@ -36,6 +36,9 @@ rule("xcode.application") -- install application on_install("install") + -- install application for xpack + after_installcmd("installcmd") + -- uninstall application on_uninstall("uninstall") -- cgit v1.3.1 From 46c195785c1d52841df7500f40bba59c144cd536 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 26 Nov 2025 22:32:19 +0800 Subject: add installcmd --- xmake/rules/xcode/application/installcmd.lua | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 xmake/rules/xcode/application/installcmd.lua (limited to 'xmake/rules/xcode') diff --git a/xmake/rules/xcode/application/installcmd.lua b/xmake/rules/xcode/application/installcmd.lua new file mode 100644 index 000000000..39d64ab1c --- /dev/null +++ b/xmake/rules/xcode/application/installcmd.lua @@ -0,0 +1,48 @@ +--!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-present, Xmake Open Source Community. +-- +-- @author ruki +-- @file installcmd.lua +-- + +-- install application for xpack +function main(target, batchcmds, opt) + local package = opt.package + + -- only for macosx when packing dmg + if not target:is_plat("macosx") then + return + end + + -- get app directory + local appdir = target:data("xcode.bundle.rootdir") + if not appdir or not os.isdir(appdir) then + return + end + + -- get install directory + -- for dmg packing, we install .app to the root of install directory + local installdir = package:installdir() + if not installdir then + return + end + + -- copy .app to install directory + local appname = path.filename(appdir) + local dstappdir = path.join(installdir, appname) + batchcmds:cp(appdir, dstappdir, {symlink = true}) +end + -- cgit v1.3.1 From eba4c503ccaf873a87ec1f867ba3dffd98b45800 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 26 Nov 2025 22:35:21 +0800 Subject: improve app/on_installcmd --- xmake/plugins/pack/batchcmds.lua | 22 ++++++++++++++++++++++ xmake/rules/xcode/application/installcmd.lua | 24 +++++++++++++++++++++++- xmake/rules/xcode/application/xmake.lua | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) (limited to 'xmake/rules/xcode') diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua index b67d66b5b..09b42d7c9 100644 --- a/xmake/plugins/pack/batchcmds.lua +++ b/xmake/plugins/pack/batchcmds.lua @@ -334,6 +334,17 @@ function _on_target_installcmd(target, batchcmds_, opt) return end + -- check if target rules have on_installcmd, use rule's logic first + local done = false + for _, r in ipairs(target:orderules()) do + local on_installcmd = r:script("installcmd") + if on_installcmd then + on_installcmd(target, batchcmds_, opt) + done = true + end + end + if done then return end + -- install target binaries local scripts = { binary = _on_target_installcmd_binary, @@ -416,6 +427,17 @@ function _on_target_uninstallcmd(target, batchcmds_, opt) return end + -- check if target rules have on_uninstallcmd, use rule's logic first + local done = false + for _, r in ipairs(target:orderules()) do + local on_uninstallcmd = r:script("uninstallcmd") + if on_uninstallcmd then + on_uninstallcmd(target, batchcmds_, opt) + done = true + end + end + if done then return end + -- uninstall target binaries local scripts = { binary = _on_target_uninstallcmd_binary, diff --git a/xmake/rules/xcode/application/installcmd.lua b/xmake/rules/xcode/application/installcmd.lua index 39d64ab1c..c08a0fede 100644 --- a/xmake/rules/xcode/application/installcmd.lua +++ b/xmake/rules/xcode/application/installcmd.lua @@ -22,11 +22,16 @@ function main(target, batchcmds, opt) local package = opt.package - -- only for macosx when packing dmg + -- only for macosx when packing if not target:is_plat("macosx") then return end + -- only for xpack (package exists) + if not package then + return + end + -- get app directory local appdir = target:data("xcode.bundle.rootdir") if not appdir or not os.isdir(appdir) then @@ -44,5 +49,22 @@ function main(target, batchcmds, opt) local appname = path.filename(appdir) local dstappdir = path.join(installdir, appname) batchcmds:cp(appdir, dstappdir, {symlink = true}) + + -- install target files (skip binary installation) + local srcfiles, dstfiles = target:installfiles(installdir) + if srcfiles and dstfiles then + for idx, srcfile in ipairs(srcfiles) do + batchcmds:cp(srcfile, dstfiles[idx], {symlink = true}) + end + end + -- install dependent target files + for _, dep in ipairs(target:orderdeps()) do + local srcfiles, dstfiles = dep:installfiles(installdir, {interface = true}) + if srcfiles and dstfiles then + for idx, srcfile in ipairs(srcfiles) do + batchcmds:cp(srcfile, dstfiles[idx], {symlink = true}) + end + end + end end diff --git a/xmake/rules/xcode/application/xmake.lua b/xmake/rules/xcode/application/xmake.lua index d809261c5..8af79a585 100644 --- a/xmake/rules/xcode/application/xmake.lua +++ b/xmake/rules/xcode/application/xmake.lua @@ -37,7 +37,7 @@ rule("xcode.application") on_install("install") -- install application for xpack - after_installcmd("installcmd") + on_installcmd("installcmd") -- uninstall application on_uninstall("uninstall") -- cgit v1.3.1 From 2a9075318d77e8c7fe514754873be61ec9f2cd7d Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 26 Nov 2025 22:37:40 +0800 Subject: add icon in macapp --- .../Assets.xcassets/AppIcon.appiconset/Contents.json | 10 ++++++++++ .../AppIcon.appiconset/icon_128x128.png | Bin 0 -> 11992 bytes .../AppIcon.appiconset/icon_128x128@2x.png | Bin 0 -> 24378 bytes .../Assets.xcassets/AppIcon.appiconset/icon_16x16.png | Bin 0 -> 1377 bytes .../AppIcon.appiconset/icon_16x16@2x.png | Bin 0 -> 2478 bytes .../AppIcon.appiconset/icon_256x256.png | Bin 0 -> 24378 bytes .../AppIcon.appiconset/icon_256x256@2x.png | Bin 0 -> 91627 bytes .../Assets.xcassets/AppIcon.appiconset/icon_32x32.png | Bin 0 -> 2478 bytes .../AppIcon.appiconset/icon_32x32@2x.png | Bin 0 -> 5022 bytes .../AppIcon.appiconset/icon_512x512.png | Bin 0 -> 91627 bytes .../AppIcon.appiconset/icon_512x512@2x.png | Bin 0 -> 269353 bytes tests/plugins/pack/macapp/src/Info.plist | 2 +- tests/plugins/pack/macapp/src/assets/xmake.ico | Bin 0 -> 119943 bytes xmake/rules/xcode/application/build.lua | 2 -- 14 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512.png create mode 100644 tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png create mode 100644 tests/plugins/pack/macapp/src/assets/xmake.ico (limited to 'xmake/rules/xcode') diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json index 9d5c8a516..6fa879752 100644 --- a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,51 +1,61 @@ { "images" : [ { + "filename" : "icon_16x16.png", "idiom" : "mac", "size" : "16x16", "scale" : "1x" }, { + "filename" : "icon_16x16@2x.png", "idiom" : "mac", "size" : "16x16", "scale" : "2x" }, { + "filename" : "icon_32x32.png", "idiom" : "mac", "size" : "32x32", "scale" : "1x" }, { + "filename" : "icon_32x32@2x.png", "idiom" : "mac", "size" : "32x32", "scale" : "2x" }, { + "filename" : "icon_128x128.png", "idiom" : "mac", "size" : "128x128", "scale" : "1x" }, { + "filename" : "icon_128x128@2x.png", "idiom" : "mac", "size" : "128x128", "scale" : "2x" }, { + "filename" : "icon_256x256.png", "idiom" : "mac", "size" : "256x256", "scale" : "1x" }, { + "filename" : "icon_256x256@2x.png", "idiom" : "mac", "size" : "256x256", "scale" : "2x" }, { + "filename" : "icon_512x512.png", "idiom" : "mac", "size" : "512x512", "scale" : "1x" }, { + "filename" : "icon_512x512@2x.png", "idiom" : "mac", "size" : "512x512", "scale" : "2x" diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128.png new file mode 100644 index 000000000..5d787b620 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png new file mode 100644 index 000000000..be7f6c4f2 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16.png new file mode 100644 index 000000000..8b2771975 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png new file mode 100644 index 000000000..331c7af96 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256.png new file mode 100644 index 000000000..be7f6c4f2 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png new file mode 100644 index 000000000..a5677925b Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32.png new file mode 100644 index 000000000..331c7af96 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png new file mode 100644 index 000000000..c8e5ac0c2 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512.png new file mode 100644 index 000000000..a5677925b Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512.png differ diff --git a/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png new file mode 100644 index 000000000..d6533fea6 Binary files /dev/null and b/tests/plugins/pack/macapp/src/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png differ diff --git a/tests/plugins/pack/macapp/src/Info.plist b/tests/plugins/pack/macapp/src/Info.plist index f111cb4c3..477a62fd7 100644 --- a/tests/plugins/pack/macapp/src/Info.plist +++ b/tests/plugins/pack/macapp/src/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIconFile - + AppIcon CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion diff --git a/tests/plugins/pack/macapp/src/assets/xmake.ico b/tests/plugins/pack/macapp/src/assets/xmake.ico new file mode 100644 index 000000000..52c8ef389 Binary files /dev/null and b/tests/plugins/pack/macapp/src/assets/xmake.ico differ diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua index a98baf57a..8ea734d28 100644 --- a/xmake/rules/xcode/application/build.lua +++ b/xmake/rules/xcode/application/build.lua @@ -24,8 +24,6 @@ import("core.theme.theme") import("core.project.depend") import("private.tools.codesign") import("utils.progress") - --- main entry function main (target, opt) -- get app and resources directory -- cgit v1.3.1