diff options
| author | ruki <[email protected]> | 2020-10-05 23:26:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-05 23:26:43 +0800 |
| commit | 68640a3c5df67d21022e727b25938d607c958d9b (patch) | |
| tree | 9891931f5b05680a678d2003254648fbff98344a /xmake/rules/xcode/application/build.lua | |
| parent | 7cb4cd4a4d4f29b722d611bef4b0d9a2d9e12109 (diff) | |
improve build app with depend.on_changed
Diffstat (limited to 'xmake/rules/xcode/application/build.lua')
| -rw-r--r-- | xmake/rules/xcode/application/build.lua | 88 |
1 files changed, 41 insertions, 47 deletions
diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua index f269d3d92..75840281b 100644 --- a/xmake/rules/xcode/application/build.lua +++ b/xmake/rules/xcode/application/build.lua @@ -33,65 +33,59 @@ function main (target, opt) local contentsdir = path.absolute(target:data("xcode.bundle.contentsdir")) local resourcesdir = path.absolute(target:data("xcode.bundle.resourcesdir")) - -- need re-compile it? - local dependfile = target:dependfile(bundledir) - local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then - return - end + -- do build if changed + depend.on_changed(function () - -- trace progress info - progress.show(opt.progress, "${color.build.target}generating.xcode.$(mode) %s", path.filename(bundledir)) + -- trace progress info + progress.show(opt.progress, "${color.build.target}generating.xcode.$(mode) %s", path.filename(bundledir)) - -- copy target file - local binarydir = contentsdir - if is_plat("macosx") then - binarydir = path.join(contentsdir, "MacOS") - end - os.vcp(target:targetfile(), path.join(binarydir, path.filename(target:targetfile()))) + -- copy target file + local binarydir = contentsdir + if is_plat("macosx") then + binarydir = path.join(contentsdir, "MacOS") + end + os.vcp(target:targetfile(), path.join(binarydir, path.filename(target:targetfile()))) - -- copy dependent dynamic libraries, TODO copy frameworks - for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "shared" then - os.vcp(dep:targetfile(), binarydir) + -- copy dependent dynamic libraries, TODO copy frameworks + for _, dep in ipairs(target:orderdeps()) do + if dep:targetkind() == "shared" then + os.vcp(dep:targetfile(), binarydir) + end end - end - -- copy PkgInfo to the contents directory - os.vcp(path.join(os.programdir(), "scripts", "PkgInfo"), resourcesdir) + -- copy PkgInfo to the contents directory + os.vcp(path.join(os.programdir(), "scripts", "PkgInfo"), resourcesdir) - -- copy resource files to the resources directory - local srcfiles, dstfiles = target:installfiles(resourcesdir) - 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) + -- copy resource files to the resources directory + local srcfiles, dstfiles = target:installfiles(resourcesdir) + 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 - i = i + 1 end - end - -- generate embedded.mobileprovision to *.app/embedded.mobileprovision - local mobile_provision_embedded = path.join(bundledir, "embedded.mobileprovision") - local mobile_provision = target:values("xcode.mobile_provision") or get_config("xcode_mobile_provision") - if mobile_provision and is_plat("iphoneos") then - os.tryrm(mobile_provision_embedded) - local provisions = codesign.mobile_provisions() - if provisions then - local mobile_provision_data = provisions[mobile_provision] - if mobile_provision_data then - io.writefile(mobile_provision_embedded, mobile_provision_data) + -- generate embedded.mobileprovision to *.app/embedded.mobileprovision + local mobile_provision_embedded = path.join(bundledir, "embedded.mobileprovision") + local mobile_provision = target:values("xcode.mobile_provision") or get_config("xcode_mobile_provision") + if mobile_provision and is_plat("iphoneos") then + os.tryrm(mobile_provision_embedded) + local provisions = codesign.mobile_provisions() + if provisions then + local mobile_provision_data = provisions[mobile_provision] + if mobile_provision_data then + io.writefile(mobile_provision_embedded, mobile_provision_data) + end end end - end - -- do codesign - codesign(bundledir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity"), mobile_provision, {deep = true}) + -- do codesign + codesign(bundledir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity"), mobile_provision, {deep = true}) - -- update files and values to the dependent file - dependinfo.files = {bundledir, target:targetfile()} - depend.save(dependinfo, dependfile) + end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}}) end |
