diff options
| author | ruki <[email protected]> | 2020-04-07 00:30:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-06 21:04:09 +0800 |
| commit | 1301d2c895a6fb481ed3cdcae96f6f45e09f0a5e (patch) | |
| tree | 666212f1c8e6d7f3f5f053c9ecfa5ba363f8eb6a /xmake/rules/xcode | |
| parent | 89415ed089e1ea087c334fa057cc440dddb65dfd (diff) | |
improve xcode.application rule again
Diffstat (limited to 'xmake/rules/xcode')
| -rw-r--r-- | xmake/rules/xcode/application/build.lua | 75 | ||||
| -rw-r--r-- | xmake/rules/xcode/application/build_file.lua | 24 | ||||
| -rw-r--r-- | xmake/rules/xcode/application/install.lua | 29 | ||||
| -rw-r--r-- | xmake/rules/xcode/application/load.lua | 47 | ||||
| -rw-r--r-- | xmake/rules/xcode/application/package.lua | 23 | ||||
| -rw-r--r-- | xmake/rules/xcode/application/uninstall.lua | 26 |
6 files changed, 224 insertions, 0 deletions
diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua new file mode 100644 index 000000000..889748bfd --- /dev/null +++ b/xmake/rules/xcode/application/build.lua @@ -0,0 +1,75 @@ +--!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 build.lua +-- + +-- imports +import("private.tools.codesign") + +-- generate Info.plist +function _gen_info_plist(target, info_plist_file) + io.gsub(info_plist_file, "(%$%((.-)%))", function (_, variable) + local maps = + { + DEVELOPMENT_LANGUAGE = "en", + EXECUTABLE_NAME = target:basename(), + PRODUCT_BUNDLE_IDENTIFIER = "org.tboox." .. target:name(), + PRODUCT_NAME = target:name(), + PRODUCT_BUNDLE_PACKAGE_TYPE = "APPL", -- application + CURRENT_PROJECT_VERSION = target:version() and tostring(target:version()) or "1.0", + MACOSX_DEPLOYMENT_TARGET = get_config("target_minver") + } + return maps[variable] + end) +end + +-- main entry +function main (target) + + -- 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) + if path.filename(srcfile) == "Info.plist" then + _gen_info_plist(target, dstfile) + end + end + i = i + 1 + end + end + + -- do codesign + codesign(appdir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity")) +end + diff --git a/xmake/rules/xcode/application/build_file.lua b/xmake/rules/xcode/application/build_file.lua new file mode 100644 index 000000000..e178e8b4c --- /dev/null +++ b/xmake/rules/xcode/application/build_file.lua @@ -0,0 +1,24 @@ +--!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 build_file.lua +-- + +-- main entry +function main (target, sourcefile) + -- TODO print(sourcefile) +end diff --git a/xmake/rules/xcode/application/install.lua b/xmake/rules/xcode/application/install.lua new file mode 100644 index 000000000..d34586cb7 --- /dev/null +++ b/xmake/rules/xcode/application/install.lua @@ -0,0 +1,29 @@ +--!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 install.lua +-- + +-- main entry +function main (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 diff --git a/xmake/rules/xcode/application/load.lua b/xmake/rules/xcode/application/load.lua new file mode 100644 index 000000000..20a4cc39f --- /dev/null +++ b/xmake/rules/xcode/application/load.lua @@ -0,0 +1,47 @@ +--!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 load.lua +-- + +-- main entry +function main (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 + + -- add frameworks + if is_plat("macosx") then + target:add("frameworks", "AppKit") + else + target:add("frameworks", "UIKit") + end + + -- register clean files for `xmake clean` + target:add("cleanfiles", appdir) +end diff --git a/xmake/rules/xcode/application/package.lua b/xmake/rules/xcode/application/package.lua new file mode 100644 index 000000000..738af9be7 --- /dev/null +++ b/xmake/rules/xcode/application/package.lua @@ -0,0 +1,23 @@ +--!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 package.lua +-- + +-- main entry +function main (target) +end diff --git a/xmake/rules/xcode/application/uninstall.lua b/xmake/rules/xcode/application/uninstall.lua new file mode 100644 index 000000000..09370734b --- /dev/null +++ b/xmake/rules/xcode/application/uninstall.lua @@ -0,0 +1,26 @@ +--!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 uninstall.lua +-- + +-- main entry +function main (target) + local appdir = path.absolute(target:data("xcode.appdir")) + local installdir = target:installdir() + os.tryrm(path.join(installdir, path.filename(appdir))) +end |
