summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-04 22:34:40 +0800
committerruki <[email protected]>2020-04-04 22:34:40 +0800
commitf3c457bc3fd98a7c06383e260aec3f5b358ceaae (patch)
treeaec3b9eb7231f267b6ac87a7707aaf9a4f43bc2d
parent0f2d5d416b658b44752021fdac3be264afee3324 (diff)
impl xcode.application
-rw-r--r--tests/projects/objc/application/src/Info.plist54
-rw-r--r--tests/projects/objc/application/xmake.lua3
-rw-r--r--xmake/rules/xcode/application/xmake.lua68
-rw-r--r--xmake/scripts/PkgInfo1
4 files changed, 125 insertions, 1 deletions
diff --git a/tests/projects/objc/application/src/Info.plist b/tests/projects/objc/application/src/Info.plist
new file mode 100644
index 000000000..968bf5d3d
--- /dev/null
+++ b/tests/projects/objc/application/src/Info.plist
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>BuildMachineOSBuild</key>
+ <string>18G95</string>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>test</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.tboox.test</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>test</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSupportedPlatforms</key>
+ <array>
+ <string>MacOSX</string>
+ </array>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>DTCompiler</key>
+ <string>com.apple.compilers.llvm.clang.1_0</string>
+ <key>DTPlatformBuild</key>
+ <string>11B52</string>
+ <key>DTPlatformVersion</key>
+ <string>GM</string>
+ <key>DTSDKBuild</key>
+ <string>19B81</string>
+ <key>DTSDKName</key>
+ <string>macosx10.15</string>
+ <key>DTXcode</key>
+ <string>1120</string>
+ <key>DTXcodeBuild</key>
+ <string>11B52</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.14</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2020 tboox. All rights reserved.</string>
+ <key>NSMainStoryboardFile</key>
+ <string>Main</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+ <key>NSSupportsAutomaticTermination</key>
+ <true/>
+ <key>NSSupportsSuddenTermination</key>
+ <true/>
+</dict>
+</plist>
diff --git a/tests/projects/objc/application/xmake.lua b/tests/projects/objc/application/xmake.lua
index 83522c669..12f773a1d 100644
--- a/tests/projects/objc/application/xmake.lua
+++ b/tests/projects/objc/application/xmake.lua
@@ -1,5 +1,6 @@
add_rules("mode.debug", "mode.release")
-target("demo")
+target("test")
add_rules("xcode.application")
add_files("src/main.m")
+ add_installfiles("src/Info.plist")
diff --git a/xmake/rules/xcode/application/xmake.lua b/xmake/rules/xcode/application/xmake.lua
index 91ec7dbda..756d94d6c 100644
--- a/xmake/rules/xcode/application/xmake.lua
+++ b/xmake/rules/xcode/application/xmake.lua
@@ -23,6 +23,74 @@ rule("xcode.application")
-- we must set kind before target.on_load(), may we will use target in on_load()
before_load(function (target)
+
+ -- get app directory
+ local targetdir = target:targetdir()
+ local appdir = path.join(targetdir, target:basename() .. ".app")
+ target:data_set("xcode.appdir", appdir)
+
+ -- set target info for app
target:set("kind", "binary")
+ target:set("filename", target:basename())
+ if is_plat("macosx") then
+ target:set("targetdir", path.join(appdir, "Contents", "MacOS"))
+ else
+ target:set("targetdir", appdir)
+ end
+
+ -- register clean files for `xmake clean`
+ target:add("cleanfiles", appdir)
end)
+ after_build(function (target)
+
+ -- imports
+ import("private.tools.codesign")
+
+ -- get app directory
+ local appdir = path.absolute(target:data("xcode.appdir"))
+
+ -- get contents directory
+ local contentsdir = appdir
+ if is_plat("macosx") then
+ contentsdir = path.join(appdir, "Contents")
+ end
+
+ -- copy PkgInfo to the contents directory
+ os.cp(path.join(os.programdir(), "scripts", "PkgInfo"), contentsdir)
+
+ -- copy resource files to the contents directory
+ local srcfiles, dstfiles = target:installfiles(contentsdir)
+ if srcfiles and dstfiles then
+ local i = 1
+ for _, srcfile in ipairs(srcfiles) do
+ local dstfile = dstfiles[i]
+ if dstfile then
+ os.vcp(srcfile, dstfile)
+ end
+ i = i + 1
+ end
+ end
+
+ -- do codesign
+ codesign(appdir)
+ end)
+
+ on_install(function (target)
+ local appdir = path.absolute(target:data("xcode.appdir"))
+ local installdir = target:installdir()
+ if not os.isdir(installdir) then
+ os.mkdir(installdir)
+ end
+ os.vcp(appdir, installdir)
+ end)
+
+ on_uninstall(function (target)
+ local appdir = path.absolute(target:data("xcode.appdir"))
+ local installdir = target:installdir()
+ os.tryrm(path.join(installdir, path.filename(appdir)))
+ end)
+
+ -- disable package
+ on_package(function (target) end)
+
diff --git a/xmake/scripts/PkgInfo b/xmake/scripts/PkgInfo
new file mode 100644
index 000000000..bd04210fb
--- /dev/null
+++ b/xmake/scripts/PkgInfo
@@ -0,0 +1 @@
+APPL???? \ No newline at end of file