summaryrefslogtreecommitdiff
path: root/xmake/rules/xcode/application/build_file.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/rules/xcode/application/build_file.lua')
-rw-r--r--xmake/rules/xcode/application/build_file.lua77
1 files changed, 75 insertions, 2 deletions
diff --git a/xmake/rules/xcode/application/build_file.lua b/xmake/rules/xcode/application/build_file.lua
index e178e8b4c..ae867f3d7 100644
--- a/xmake/rules/xcode/application/build_file.lua
+++ b/xmake/rules/xcode/application/build_file.lua
@@ -18,7 +18,80 @@
-- @file build_file.lua
--
+-- imports
+import("core.base.option")
+import("core.theme.theme")
+import("core.project.depend")
+
+-- build *.xcassets file
+function _build_xcassets_file(target, sourcefile, opt)
+ -- TODO
+end
+
+-- build *.storyboard file
+function _build_storyboard_file(target, sourcefile, opt)
+
+ -- get xcode sdk directory
+ local xcode_sdkdir = assert(get_config("xcode"), "xcode not found!")
+ local xcode_usrdir = path.join(xcode_sdkdir, "Contents", "Developer", "usr")
+
+ -- get base.lproj
+ local base_lproj = path.join(target:autogendir(), "rules", "xcode", "storyboard", "Base.lproj")
+
+ -- get app resources directory
+ local resourcesdir = target:data("xcode.app.resourcesdir")
+
+ -- need re-compile it?
+ local dependfile = target:dependfile(sourcefile)
+ local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
+ return
+ end
+
+ -- trace progress info
+ cprintf("${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} ", opt.progress)
+ if option.get("verbose") then
+ cprint("${dim color.build.object}compiling.xcode.storyboard %s", sourcefile)
+ else
+ cprint("${color.build.object}compiling.xcode.storyboard %s", sourcefile)
+ end
+
+ -- do compile
+ local argv = {"--errors", "--warnings", "--notices", "--auto-activate-custom-fonts", "--output-format", "human-readable-text"}
+ if is_plat("macosx") then
+ table.insert(argv, "--target-device")
+ table.insert(argv, "mac")
+ end
+ table.insert(argv, "--minimum-deployment-target")
+ table.insert(argv, get_config("target_minver"))
+ table.insert(argv, "--compilation-directory")
+ table.insert(argv, base_lproj)
+ table.insert(argv, sourcefile)
+ os.vrunv(path.join(xcode_usrdir, "bin", "ibtool"), argv, {envs = {XCODE_DEVELOPER_USR_PATH = xcode_usrdir}})
+
+ -- do link
+ argv = {"--errors", "--warnings", "--notices", "--auto-activate-custom-fonts", "--output-format", "human-readable-text"}
+ if is_plat("macosx") then
+ table.insert(argv, "--target-device")
+ table.insert(argv, "mac")
+ end
+ table.insert(argv, "--minimum-deployment-target")
+ table.insert(argv, get_config("target_minver"))
+ table.insert(argv, "--link")
+ table.insert(argv, resourcesdir)
+ table.insert(argv, path.join(base_lproj, path.filename(sourcefile) .. "c"))
+ os.vrunv(path.join(xcode_usrdir, "bin", "ibtool"), argv, {envs = {XCODE_DEVELOPER_USR_PATH = xcode_usrdir}})
+
+ -- update files and values to the dependent file
+ dependinfo.files = {sourcefile}
+ depend.save(dependinfo, dependfile)
+end
+
-- main entry
-function main (target, sourcefile)
- -- TODO print(sourcefile)
+function main (target, sourcefile, opt)
+ if sourcefile:endswith(".xcassets") then
+ _build_xcassets_file(target, sourcefile, opt)
+ elseif sourcefile:endswith(".storyboard") then
+ _build_storyboard_file(target, sourcefile, opt)
+ end
end