summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2015-12-16 21:34:20 +0800
committerruki <[email protected]>2015-12-16 21:35:01 +0800
commit61ae08bdfaf5f8dbde739677ce6997b28560a522 (patch)
treea45686f101d27d5a9b11ff8760770e4bdd44d736
parent686e71f6395ea37d2c496e189cc18380841083b2 (diff)
fix create template
-rwxr-xr-xcore/pkg/tbox.pkg/inc/linux/x64/tbox.config.h2
-rwxr-xr-xcore/pkg/tbox.pkg/inc/linux/x86/tbox.config.h2
-rw-r--r--xmake/scripts/action/_create.lua5
-rw-r--r--xmake/templates/c++/shared_library_tbox/_template.lua28
-rw-r--r--xmake/templates/c++/static_library_tbox/_template.lua29
-rw-r--r--xmake/templates/c/shared_library_tbox/_template.lua28
-rw-r--r--xmake/templates/c/static_library_tbox/_template.lua28
7 files changed, 94 insertions, 28 deletions
diff --git a/core/pkg/tbox.pkg/inc/linux/x64/tbox.config.h b/core/pkg/tbox.pkg/inc/linux/x64/tbox.config.h
index f3483c9a0..694c78de1 100755
--- a/core/pkg/tbox.pkg/inc/linux/x64/tbox.config.h
+++ b/core/pkg/tbox.pkg/inc/linux/x64/tbox.config.h
@@ -6,7 +6,7 @@
#define TB_CONFIG_VERSION_MAJOR 1
#define TB_CONFIG_VERSION_MINOR 5
#define TB_CONFIG_VERSION_ALTER 1
-#define TB_CONFIG_VERSION_BUILD 201512151042
+#define TB_CONFIG_VERSION_BUILD 201512162038
// defines
#define TB_CONFIG_OS_LINUX
diff --git a/core/pkg/tbox.pkg/inc/linux/x86/tbox.config.h b/core/pkg/tbox.pkg/inc/linux/x86/tbox.config.h
index f3483c9a0..1b29bae51 100755
--- a/core/pkg/tbox.pkg/inc/linux/x86/tbox.config.h
+++ b/core/pkg/tbox.pkg/inc/linux/x86/tbox.config.h
@@ -6,7 +6,7 @@
#define TB_CONFIG_VERSION_MAJOR 1
#define TB_CONFIG_VERSION_MINOR 5
#define TB_CONFIG_VERSION_ALTER 1
-#define TB_CONFIG_VERSION_BUILD 201512151042
+#define TB_CONFIG_VERSION_BUILD 201512162126
// defines
#define TB_CONFIG_OS_LINUX
diff --git a/xmake/scripts/action/_create.lua b/xmake/scripts/action/_create.lua
index 1a18c79b6..840631f65 100644
--- a/xmake/scripts/action/_create.lua
+++ b/xmake/scripts/action/_create.lua
@@ -92,9 +92,10 @@ function _create.done()
end
-- copy the project files
- if not os.cp("project/*", xmake._PROJECT_DIR) then
+ local ok, errors = os.cp("project/*", xmake._PROJECT_DIR)
+ if not ok then
-- errors
- utils.error("copy files failed!")
+ utils.error(errors)
return false
end
diff --git a/xmake/templates/c++/shared_library_tbox/_template.lua b/xmake/templates/c++/shared_library_tbox/_template.lua
index 951152bc1..1c6713b4c 100644
--- a/xmake/templates/c++/shared_library_tbox/_template.lua
+++ b/xmake/templates/c++/shared_library_tbox/_template.lua
@@ -38,30 +38,46 @@ function _template.done(targetname, projectdir, packagesdir)
-- check
assert(targetname and projectdir and packagesdir)
+ -- the target name cannot be demo
+ if targetname == "demo" then
+
+ -- warning
+ utils.warning("the target name cannot be \"demo\", rename to be \"test\"!")
+
+ -- rename it
+ targetname = "test"
+ end
+
-- replace the target name
io.gsub(projectdir .. "/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/main.cpp", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/[targetname]/xmake.lua", "%[targetname%]", targetname)
+ -- remove the target directory first
+ os.rm(projectdir .. "/src/" .. targetname)
+
-- rename the target directory
- if not os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname) then
+ local ok, errors = os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname)
+ if not ok then
-- errors
- utils.error("rename the target directory failed!")
+ utils.error(errors)
return false
end
-- copy the tbox.pkg
- if not os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg") then
+ ok, errors = os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg")
+ if not ok then
-- errors
- utils.error("copy tbox.pkg failed!")
+ utils.error(errors)
return false
end
-- copy the base.pkg
- if not os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg") then
+ ok, errors = os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg")
+ if not ok then
-- errors
- utils.error("copy base.pkg failed!")
+ utils.error(errors)
return false
end
diff --git a/xmake/templates/c++/static_library_tbox/_template.lua b/xmake/templates/c++/static_library_tbox/_template.lua
index 9312c2435..4ed8c1f2f 100644
--- a/xmake/templates/c++/static_library_tbox/_template.lua
+++ b/xmake/templates/c++/static_library_tbox/_template.lua
@@ -38,33 +38,50 @@ function _template.done(targetname, projectdir, packagesdir)
-- check
assert(targetname and projectdir and packagesdir)
+ -- the target name cannot be demo
+ if targetname == "demo" then
+
+ -- warning
+ utils.warning("the target name cannot be \"demo\", rename to be \"test\"!")
+
+ -- rename it
+ targetname = "test"
+ end
+
-- replace the target name
io.gsub(projectdir .. "/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/main.cpp", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/[targetname]/xmake.lua", "%[targetname%]", targetname)
+ -- remove the target directory first
+ os.rm(projectdir .. "/src/" .. targetname)
+
-- rename the target directory
- if not os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname) then
+ local ok, errors = os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname)
+ if not ok then
-- errors
- utils.error("rename the target directory failed!")
+ utils.error(errors)
return false
end
-- copy the tbox.pkg
- if not os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg") then
+ ok, errors = os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg")
+ if not ok then
-- errors
- utils.error("copy tbox.pkg failed!")
+ utils.error(errors)
return false
end
-- copy the base.pkg
- if not os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg") then
+ ok, errors = os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg")
+ if not ok then
-- errors
- utils.error("copy base.pkg failed!")
+ utils.error(errors)
return false
end
+
-- ok
return true
end
diff --git a/xmake/templates/c/shared_library_tbox/_template.lua b/xmake/templates/c/shared_library_tbox/_template.lua
index 1df207819..9095337d5 100644
--- a/xmake/templates/c/shared_library_tbox/_template.lua
+++ b/xmake/templates/c/shared_library_tbox/_template.lua
@@ -38,30 +38,46 @@ function _template.done(targetname, projectdir, packagesdir)
-- check
assert(targetname and projectdir and packagesdir)
+ -- the target name cannot be demo
+ if targetname == "demo" then
+
+ -- warning
+ utils.warning("the target name cannot be \"demo\", rename to be \"test\"!")
+
+ -- rename it
+ targetname = "test"
+ end
+
-- replace the target name
io.gsub(projectdir .. "/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/main.c", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/[targetname]/xmake.lua", "%[targetname%]", targetname)
+ -- remove the target directory first
+ os.rm(projectdir .. "/src/" .. targetname)
+
-- rename the target directory
- if not os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname) then
+ local ok, errors = os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname)
+ if not ok then
-- errors
- utils.error("rename the target directory failed!")
+ utils.error(errors)
return false
end
-- copy the tbox.pkg
- if not os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg") then
+ ok, errors = os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg")
+ if not ok then
-- errors
- utils.error("copy tbox.pkg failed!")
+ utils.error(errors)
return false
end
-- copy the base.pkg
- if not os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg") then
+ ok, errors = os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg")
+ if not ok then
-- errors
- utils.error("copy base.pkg failed!")
+ utils.error(errors)
return false
end
diff --git a/xmake/templates/c/static_library_tbox/_template.lua b/xmake/templates/c/static_library_tbox/_template.lua
index 18536fbc4..12f7af448 100644
--- a/xmake/templates/c/static_library_tbox/_template.lua
+++ b/xmake/templates/c/static_library_tbox/_template.lua
@@ -38,30 +38,46 @@ function _template.done(targetname, projectdir, packagesdir)
-- check
assert(targetname and projectdir and packagesdir)
+ -- the target name cannot be demo
+ if targetname == "demo" then
+
+ -- warning
+ utils.warning("the target name cannot be \"demo\", rename to be \"test\"!")
+
+ -- rename it
+ targetname = "test"
+ end
+
-- replace the target name
io.gsub(projectdir .. "/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/main.c", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/demo/xmake.lua", "%[targetname%]", targetname)
io.gsub(projectdir .. "/src/[targetname]/xmake.lua", "%[targetname%]", targetname)
+ -- remove the target directory first
+ os.rm(projectdir .. "/src/" .. targetname)
+
-- rename the target directory
- if not os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname) then
+ local ok, errors = os.mv(projectdir .. "/src/[targetname]", projectdir .. "/src/" .. targetname)
+ if not ok then
-- errors
- utils.error("rename the target directory failed!")
+ utils.error(errors)
return false
end
-- copy the tbox.pkg
- if not os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg") then
+ ok, errors = os.cp(packagesdir .. "/tbox.pkg/", projectdir .. "/pkg/tbox.pkg")
+ if not ok then
-- errors
- utils.error("copy tbox.pkg failed!")
+ utils.error(errors)
return false
end
-- copy the base.pkg
- if not os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg") then
+ ok, errors = os.cp(packagesdir .. "/base.pkg/", projectdir .. "/pkg/base.pkg")
+ if not ok then
-- errors
- utils.error("copy base.pkg failed!")
+ utils.error(errors)
return false
end