summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-10-06 00:29:00 +0800
committerruki <[email protected]>2020-10-06 00:29:00 +0800
commit6576473af7c58290402609c460eb1b1062f75d34 (patch)
tree6f554837d8dddf84834153521df3161974d1eea8
parent155fe172fbb2c182e69c3c22b6f031d785ca905a (diff)
improve xcode rules
-rw-r--r--xmake/modules/core/project/depend.lua2
-rw-r--r--xmake/rules/xcode/bundle/xmake.lua52
-rw-r--r--xmake/rules/xcode/framework/xmake.lua97
3 files changed, 69 insertions, 82 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua
index c10506c6f..05065e0b0 100644
--- a/xmake/modules/core/project/depend.lua
+++ b/xmake/modules/core/project/depend.lua
@@ -138,7 +138,7 @@ end
--
-- e.g.
--
--- depend.on_changed(function (dependinfo)
+-- depend.on_changed(function ()
-- -- do some thing
-- -- ..
--
diff --git a/xmake/rules/xcode/bundle/xmake.lua b/xmake/rules/xcode/bundle/xmake.lua
index f1d4fdd7a..43da6e7fa 100644
--- a/xmake/rules/xcode/bundle/xmake.lua
+++ b/xmake/rules/xcode/bundle/xmake.lua
@@ -67,42 +67,36 @@ rule("xcode.bundle")
local contentsdir = path.absolute(target:data("xcode.bundle.contentsdir"))
local resourcesdir = path.absolute(target:data("xcode.bundle.resourcesdir"))
- -- need re-generate 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
- if is_plat("macosx") then
- os.vcp(target:targetfile(), path.join(contentsdir, "MacOS", path.filename(target:targetfile())))
- else
- os.vcp(target:targetfile(), path.join(contentsdir, path.filename(target:targetfile())))
- end
+ -- copy target file
+ if is_plat("macosx") then
+ os.vcp(target:targetfile(), path.join(contentsdir, "MacOS", path.filename(target:targetfile())))
+ else
+ os.vcp(target:targetfile(), path.join(contentsdir, path.filename(target:targetfile())))
+ end
- -- copy resource files
- 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
+ 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
- -- do codesign
- codesign(bundledir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity"))
+ -- do codesign
+ codesign(bundledir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity"))
- -- 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)
on_install(function (target)
diff --git a/xmake/rules/xcode/framework/xmake.lua b/xmake/rules/xcode/framework/xmake.lua
index 7eed4a1db..2c697bdf0 100644
--- a/xmake/rules/xcode/framework/xmake.lua
+++ b/xmake/rules/xcode/framework/xmake.lua
@@ -93,67 +93,60 @@ rule("xcode.framework")
local resourcesdir = target:data("xcode.bundle.resourcesdir")
local headersdir = path.join(contentsdir, "Headers")
- -- need re-generate 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
- if not os.isdir(contentsdir) then
- os.mkdir(contentsdir)
- end
- os.vcp(target:targetfile(), contentsdir)
+ -- copy target file
+ if not os.isdir(contentsdir) then
+ os.mkdir(contentsdir)
+ end
+ os.vcp(target:targetfile(), contentsdir)
- -- move header files
- os.tryrm(headersdir)
- os.mv(path.join(contentsdir, "Headers.tmp", target:basename()), headersdir)
- os.rm(path.join(contentsdir, "Headers.tmp"))
+ -- move header files
+ os.tryrm(headersdir)
+ os.mv(path.join(contentsdir, "Headers.tmp", target:basename()), headersdir)
+ os.rm(path.join(contentsdir, "Headers.tmp"))
- -- copy resource files
- 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
+ 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
- if not os.isdir(resourcesdir) then
- os.mkdir(resourcesdir)
- end
+ if not os.isdir(resourcesdir) then
+ os.mkdir(resourcesdir)
+ end
- -- link Versions/Current -> Versions/A
- local oldir = os.cd(path.join(bundledir, "Versions"))
- os.tryrm("Current")
- os.ln("A", "Current")
+ -- link Versions/Current -> Versions/A
+ local oldir = os.cd(path.join(bundledir, "Versions"))
+ os.tryrm("Current")
+ os.ln("A", "Current")
- -- link bundledir/* -> Versions/Current/*
- local target_filename = path.filename(target:targetfile())
- os.cd(bundledir)
- os.tryrm("Headers")
- os.tryrm("Resources")
- os.tryrm(target_filename)
- os.ln("Versions/Current/Headers", "Headers")
- os.ln("Versions/Current/Resources", "Resources")
- os.ln(path.join("Versions/Current", target_filename), target_filename)
- os.cd(oldir)
+ -- link bundledir/* -> Versions/Current/*
+ local target_filename = path.filename(target:targetfile())
+ os.cd(bundledir)
+ os.tryrm("Headers")
+ os.tryrm("Resources")
+ os.tryrm(target_filename)
+ os.ln("Versions/Current/Headers", "Headers")
+ os.ln("Versions/Current/Resources", "Resources")
+ os.ln(path.join("Versions/Current", target_filename), target_filename)
+ os.cd(oldir)
- -- do codesign, only for dynamic library
- if target:targetkind() == "shared" then
- codesign(contentsdir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity"))
- end
-
- -- update files and values to the dependent file
- dependinfo.files = {bundledir, target:targetfile()}
- depend.save(dependinfo, dependfile)
+ -- do codesign, only for dynamic library
+ if target:targetkind() == "shared" then
+ codesign(contentsdir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity"))
+ end
+ end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}})
end)
on_install(function (target)