summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunity <[email protected]>2019-11-24 18:02:56 +0800
committerOpportunity <[email protected]>2019-11-24 18:02:56 +0800
commit46fa759eda406168dc3fbbc20c6eb2d11fb2e01d (patch)
treec744e4a802d818e73a99ec9a037e346c0161b518
parenta69f6893fd449d00fe95cdf1a10d918c2613021c (diff)
skip file if is the same
-rw-r--r--xmake/plugins/project/vsxmake/vsxmake.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua
index 26eeb23fe..3f5cd024d 100644
--- a/xmake/plugins/project/vsxmake/vsxmake.lua
+++ b/xmake/plugins/project/vsxmake/vsxmake.lua
@@ -125,10 +125,18 @@ function _trycp(file, target, targetname)
targetname = targetname or path.filename(file)
local targetfile = path.join(target, targetname)
if os.isfile(targetfile) then
- dprint("skipped file %s", path.relative(targetfile))
+ dprint("skipped file %s since the file already exists", path.relative(targetfile))
return
end
- os.cp(file,targetfile)
+ os.cp(file, targetfile)
+end
+
+function _writefileifneeded(file, content)
+ if os.isfile(file) and io.readfile(file) == content then
+ dprint("skipped file %s since the file has the same content", path.relative(file))
+ return
+ end
+ io.writefile(file, content)
end
-- make
@@ -157,7 +165,7 @@ function make(version)
-- write solution file
local sln = path.join(info.solution_dir, info.slnfile .. ".sln")
- io.writefile(sln, render(template_sln, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidersln))
+ _writefileifneeded(sln, render(template_sln, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidersln))
-- add solution custom file
_trycp(template_props, info.solution_dir)
@@ -169,10 +177,10 @@ function make(version)
-- write project file
local proj = path.join(proj_dir, target .. ".vcxproj")
- io.writefile(proj, render(template_vcx, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidertarget))
+ _writefileifneeded(proj, render(template_vcx, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidertarget))
local projfil = path.join(proj_dir, target .. ".vcxproj.filters")
- io.writefile(projfil, render(template_fil, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidertarget))
+ _writefileifneeded(projfil, render(template_fil, "#([A-Za-z0-9_,%.%*%(%)]+)#", paramsprovidertarget))
-- add project custom file
_trycp(template_props, proj_dir)