summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-16 22:13:48 +0800
committerruki <[email protected]>2017-09-16 22:13:48 +0800
commitf5c65f2a5fc03f81f3702486f677b3fe49d4597e (patch)
tree03f22a6a46227aa8e5701cfca243d5dc263a5d12
parentd29d3d91682bbb1552e4aee5f8b21a6a92eaf674 (diff)
update project templates with tbox
-rw-r--r--CHANGELOG.md2
-rw-r--r--xmake/templates/c++/console_tbox/project/src/xmake.lua8
-rw-r--r--xmake/templates/c++/console_tbox/project/xmake.lua86
-rw-r--r--xmake/templates/c++/console_tbox/template.lua8
-rw-r--r--xmake/templates/c++/shared_library_tbox/project/src/_demo/xmake.lua16
-rw-r--r--xmake/templates/c++/shared_library_tbox/project/src/_library/xmake.lua8
-rw-r--r--xmake/templates/c++/shared_library_tbox/project/xmake.lua92
-rw-r--r--xmake/templates/c++/shared_library_tbox/template.lua7
-rw-r--r--xmake/templates/c++/static_library_tbox/project/src/_demo/xmake.lua16
-rw-r--r--xmake/templates/c++/static_library_tbox/project/src/_library/xmake.lua8
-rw-r--r--xmake/templates/c++/static_library_tbox/project/xmake.lua92
-rw-r--r--xmake/templates/c++/static_library_tbox/template.lua7
-rw-r--r--xmake/templates/c/console_tbox/project/pkg/base.pkg/xmake.lua11
-rw-r--r--xmake/templates/c/console_tbox/project/src/xmake.lua8
-rw-r--r--xmake/templates/c/console_tbox/project/xmake.lua86
-rw-r--r--xmake/templates/c/console_tbox/template.lua6
-rw-r--r--xmake/templates/c/shared_library_tbox/project/pkg/base.pkg/xmake.lua11
-rw-r--r--xmake/templates/c/shared_library_tbox/project/src/_demo/xmake.lua16
-rw-r--r--xmake/templates/c/shared_library_tbox/project/src/_library/xmake.lua8
-rw-r--r--xmake/templates/c/shared_library_tbox/project/xmake.lua92
-rw-r--r--xmake/templates/c/shared_library_tbox/template.lua4
-rw-r--r--xmake/templates/c/static_library_tbox/project/pkg/base.pkg/xmake.lua11
-rw-r--r--xmake/templates/c/static_library_tbox/project/src/_demo/xmake.lua16
-rw-r--r--xmake/templates/c/static_library_tbox/project/src/_library/xmake.lua8
-rw-r--r--xmake/templates/c/static_library_tbox/project/xmake.lua92
-rw-r--r--xmake/templates/c/static_library_tbox/template.lua3
26 files changed, 180 insertions, 542 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f90ecb2d6..da307a965 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
* Add `COLORTERM=nocolor` to disable color output
* Remove `and_bindings` and `add_rbindings` api
* Disable to output colors code to file
+* Update project templates with tbox
### Bugs fixed
@@ -367,6 +368,7 @@
* 添加`COLORTERM=nocolor`环境变量开关,禁用彩色输出
* 移除`add_rbindings`和`add_bindings`接口
* 禁止在重定向的时候进行彩色输出,避免输出文件中带有色彩代码干扰
+* 更新tbox工程模板
### Bugs修复
diff --git a/xmake/templates/c++/console_tbox/project/src/xmake.lua b/xmake/templates/c++/console_tbox/project/src/xmake.lua
index 0a6bf6034..536155751 100644
--- a/xmake/templates/c++/console_tbox/project/src/xmake.lua
+++ b/xmake/templates/c++/console_tbox/project/src/xmake.lua
@@ -8,14 +8,10 @@ target("[targetname]")
add_defines("__tb_prefix__=\"[targetname]\"")
-- set the auto-generated config.h
- set_config_h("$(buildir)/[targetname].config.h")
- set_config_h_prefix("CONFIG")
-
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
+ set_config_header("$(buildir)/[targetname].config.h", {prefix = "CONFIG"})
-- add packages
- add_options("tbox", "base")
+ add_packages("tboox.tbox", "base")
-- add files
add_files("*.cpp")
diff --git a/xmake/templates/c++/console_tbox/project/xmake.lua b/xmake/templates/c++/console_tbox/project/xmake.lua
index 14559a49f..251c60305 100644
--- a/xmake/templates/c++/console_tbox/project/xmake.lua
+++ b/xmake/templates/c++/console_tbox/project/xmake.lua
@@ -1,5 +1,5 @@
-- version
-set_version("1.0.0")
+set_xmakever("2.1.6")
-- set warning all as error
set_warnings("all", "error")
@@ -8,14 +8,15 @@ set_warnings("all", "error")
set_languages("c99", "cxx11")
-- disable some compiler errors
-add_cxflags("-Wno-error=deprecated-declarations")
-add_mxflags("-Wno-error=deprecated-declarations")
-
--- add defines for c files
-add_defines("_GNU_SOURCE=1", "_REENTRANT")
+add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
+add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
--- the debug or check or coverage mode
-if is_mode("debug", "check", "coverage") then
+-- set the object files directory
+set_objectdir("$(buildir)/$(mode)/$(arch)/.objs")
+set_targetdir("$(buildir)/$(mode)/$(arch)")
+
+-- the debug mode
+if is_mode("debug") then
-- enable the debug symbols
set_symbols("debug")
@@ -25,62 +26,27 @@ if is_mode("debug", "check", "coverage") then
-- add defines for debug
add_defines("__tb_debug__")
-
- -- attempt to enable some checkers for pc
- if is_mode("check") and is_arch("i386", "x86_64") then
- add_cxflags("-fsanitize=address", "-ftrapv")
- add_mxflags("-fsanitize=address", "-ftrapv")
- add_ldflags("-fsanitize=address")
- end
-
- -- enable coverage
- if is_mode("coverage") then
- add_cxflags("--coverage")
- add_mxflags("--coverage")
- add_ldflags("--coverage")
- end
end
--- the release or profile mode
-if is_mode("release", "profile") then
+-- the release mode
+if is_mode("release") then
- -- the release mode
- if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
- -- strip all symbols
- set_strip("all")
+ -- strip all symbols
+ set_strip("all")
- -- fomit the frame pointer
- add_cxflags("-fomit-frame-pointer")
- add_mxflags("-fomit-frame-pointer")
-
- -- the profile mode
- else
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- enable gprof
- add_cxflags("-pg")
- add_ldflags("-pg")
- end
+ -- fomit the frame pointer
+ add_cxflags("-fomit-frame-pointer")
-- enable fastest optimization
set_optimize("fastest")
-
- -- attempt to add vector extensions
- add_vectorexts("sse2", "sse3", "ssse3", "mmx")
end
-- for the windows platform (msvc)
if is_plat("windows") then
- -- add some defines only for windows
- add_defines("NOCRYPT", "NOGDI")
-
-- the release mode
if is_mode("release") then
@@ -90,9 +56,6 @@ if is_plat("windows") then
-- the debug mode
elseif is_mode("debug") then
- -- enable some checkers
- add_cxflags("-Gs", "-RTC1")
-
-- link libcmtd.lib
add_cxflags("-MTd")
end
@@ -101,8 +64,15 @@ if is_plat("windows") then
add_ldflags("-nodefaultlib:\"msvcrt.lib\"")
end
--- add packages
-add_packagedirs("pkg")
+-- the base package
+option("base")
+ set_default(true)
+ if is_os("windows") then add_links("ws2_32")
+ elseif is_os("android") then add_links("m", "c")
+ else add_links("pthread", "dl", "m", "c") end
+
+-- add requires
+add_requires("tboox.tbox")
--- add projects
-add_subdirs("src")
+-- include project sources
+includes("src")
diff --git a/xmake/templates/c++/console_tbox/template.lua b/xmake/templates/c++/console_tbox/template.lua
index 43928ba4e..b7e432ca2 100644
--- a/xmake/templates/c++/console_tbox/template.lua
+++ b/xmake/templates/c++/console_tbox/template.lua
@@ -10,11 +10,3 @@ add_macros("targetname", "$(targetname)")
-- add macro files
add_macrofiles("src/xmake.lua")
--- set create script
-on_create(function ()
-
- -- copy packages
- os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg")
- os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg")
-
-end)
diff --git a/xmake/templates/c++/shared_library_tbox/project/src/_demo/xmake.lua b/xmake/templates/c++/shared_library_tbox/project/src/_demo/xmake.lua
index 354b01a3c..ebe9d0195 100644
--- a/xmake/templates/c++/shared_library_tbox/project/src/_demo/xmake.lua
+++ b/xmake/templates/c++/shared_library_tbox/project/src/_demo/xmake.lua
@@ -10,22 +10,6 @@ target("demo")
-- add defines
add_defines("__tb_prefix__=\"demo\"")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
- -- add links directory
- add_linkdirs("$(buildir)")
-
- -- add includes directory
- add_includedirs("$(buildir)")
- add_includedirs("$(buildir)/[targetname]")
-
- -- add links
- add_links("[targetname]")
-
- -- add packages
- add_options("tbox", "base")
-
-- add files
add_files("*.cpp")
diff --git a/xmake/templates/c++/shared_library_tbox/project/src/_library/xmake.lua b/xmake/templates/c++/shared_library_tbox/project/src/_library/xmake.lua
index 7b38208d5..2118dd2c0 100644
--- a/xmake/templates/c++/shared_library_tbox/project/src/_library/xmake.lua
+++ b/xmake/templates/c++/shared_library_tbox/project/src/_library/xmake.lua
@@ -8,8 +8,7 @@ target("[targetname]")
add_defines("__tb_prefix__=\"[targetname]\"")
-- set the auto-generated config.h
- set_config_h("$(buildir)/[targetname]/config.h")
- set_config_h_prefix("CONFIG")
+ set_config_header("$(buildir)/[targetname]/config.h", {prefix = "CONFIG"})
-- add the header files for installing
add_headers("../([targetname]/**.h)")
@@ -18,11 +17,8 @@ target("[targetname]")
add_includedirs("$(buildir)")
add_includedirs("$(buildir)/[targetname]")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
-- add packages
- add_options("tbox", "base")
+ add_packages("tboox.tbox", "base")
-- add files
add_files("*.cpp")
diff --git a/xmake/templates/c++/shared_library_tbox/project/xmake.lua b/xmake/templates/c++/shared_library_tbox/project/xmake.lua
index 770ea866d..565c3d9ee 100644
--- a/xmake/templates/c++/shared_library_tbox/project/xmake.lua
+++ b/xmake/templates/c++/shared_library_tbox/project/xmake.lua
@@ -1,5 +1,5 @@
-- version
-set_version("1.0.0")
+set_xmakever("2.1.6")
-- set warning all as error
set_warnings("all", "error")
@@ -8,14 +8,15 @@ set_warnings("all", "error")
set_languages("c99", "cxx11")
-- disable some compiler errors
-add_cxflags("-Wno-error=deprecated-declarations")
-add_mxflags("-Wno-error=deprecated-declarations")
-
--- add defines for c files
-add_defines("_GNU_SOURCE=1", "_REENTRANT")
+add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
+add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
--- the debug or check or coverage mode
-if is_mode("debug", "check", "coverage") then
+-- set the object files directory
+set_objectdir("$(buildir)/$(mode)/$(arch)/.objs")
+set_targetdir("$(buildir)/$(mode)/$(arch)")
+
+-- the debug mode
+if is_mode("debug") then
-- enable the debug symbols
set_symbols("debug")
@@ -25,62 +26,27 @@ if is_mode("debug", "check", "coverage") then
-- add defines for debug
add_defines("__tb_debug__")
-
- -- attempt to enable some checkers for pc
- if is_mode("check") and is_arch("i386", "x86_64") then
- add_cxflags("-fsanitize=address", "-ftrapv")
- add_mxflags("-fsanitize=address", "-ftrapv")
- add_ldflags("-fsanitize=address")
- end
-
- -- enable coverage
- if is_mode("coverage") then
- add_cxflags("--coverage")
- add_mxflags("--coverage")
- add_ldflags("--coverage")
- end
end
--- the release or profile mode
-if is_mode("release", "profile") then
-
- -- the release mode
- if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- strip all symbols
- set_strip("all")
+-- the release mode
+if is_mode("release") then
- -- fomit the frame pointer
- add_cxflags("-fomit-frame-pointer")
- add_mxflags("-fomit-frame-pointer")
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
- -- the profile mode
- else
-
- -- enable the debug symbols
- set_symbols("debug")
+ -- strip all symbols
+ set_strip("all")
- -- enable gprof
- add_cxflags("-pg")
- add_ldflags("-pg")
- end
+ -- fomit the frame pointer
+ add_cxflags("-fomit-frame-pointer")
-- enable fastest optimization
set_optimize("fastest")
-
- -- attempt to add vector extensions
- add_vectorexts("sse2", "sse3", "ssse3", "mmx")
end
-- for the windows platform (msvc)
if is_plat("windows") then
- -- add some defines only for windows
- add_defines("NOCRYPT", "NOGDI")
-
-- the release mode
if is_mode("release") then
@@ -90,9 +56,6 @@ if is_plat("windows") then
-- the debug mode
elseif is_mode("debug") then
- -- enable some checkers
- add_cxflags("-Gs", "-RTC1")
-
-- link libcmtd.lib
add_cxflags("-MTd")
end
@@ -101,16 +64,15 @@ if is_plat("windows") then
add_ldflags("-nodefaultlib:\"msvcrt.lib\"")
end
--- add option: demo
-option("demo")
- set_enable(true)
- set_showmenu(true)
- set_category("option")
- set_description("Enable or disable the demo module")
+-- the base package
+option("base")
+ set_default(true)
+ if is_os("windows") then add_links("ws2_32")
+ elseif is_os("android") then add_links("m", "c")
+ else add_links("pthread", "dl", "m", "c") end
--- add packages
-add_packagedirs("pkg")
+-- add requires
+add_requires("tboox.tbox")
--- add projects
-add_subdirs("src/[targetname]")
-if is_option("demo") then add_subdirs("src/demo") end
+-- include project sources
+includes("src/[targetname]", "src/[targetname]_demo")
diff --git a/xmake/templates/c++/shared_library_tbox/template.lua b/xmake/templates/c++/shared_library_tbox/template.lua
index d8fc84ee0..e42fab4ce 100644
--- a/xmake/templates/c++/shared_library_tbox/template.lua
+++ b/xmake/templates/c++/shared_library_tbox/template.lua
@@ -9,7 +9,7 @@ add_macros("targetname", "$(targetname)")
-- add macro files
add_macrofiles("xmake.lua")
-add_macrofiles("src/_demo/main.c")
+add_macrofiles("src/_demo/main.cpp")
add_macrofiles("src/_demo/xmake.lua")
add_macrofiles("src/_library/xmake.lua")
@@ -19,9 +19,4 @@ on_create(function ()
-- rename target directory
os.mv("src/_library", "src/$(targetname)")
os.mv("src/_demo", "src/$(targetname)_demo")
-
- -- copy packages
- os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg")
- os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg")
-
end)
diff --git a/xmake/templates/c++/static_library_tbox/project/src/_demo/xmake.lua b/xmake/templates/c++/static_library_tbox/project/src/_demo/xmake.lua
index 354b01a3c..ebe9d0195 100644
--- a/xmake/templates/c++/static_library_tbox/project/src/_demo/xmake.lua
+++ b/xmake/templates/c++/static_library_tbox/project/src/_demo/xmake.lua
@@ -10,22 +10,6 @@ target("demo")
-- add defines
add_defines("__tb_prefix__=\"demo\"")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
- -- add links directory
- add_linkdirs("$(buildir)")
-
- -- add includes directory
- add_includedirs("$(buildir)")
- add_includedirs("$(buildir)/[targetname]")
-
- -- add links
- add_links("[targetname]")
-
- -- add packages
- add_options("tbox", "base")
-
-- add files
add_files("*.cpp")
diff --git a/xmake/templates/c++/static_library_tbox/project/src/_library/xmake.lua b/xmake/templates/c++/static_library_tbox/project/src/_library/xmake.lua
index b1b357397..3d772e294 100644
--- a/xmake/templates/c++/static_library_tbox/project/src/_library/xmake.lua
+++ b/xmake/templates/c++/static_library_tbox/project/src/_library/xmake.lua
@@ -8,8 +8,7 @@ target("[targetname]")
add_defines("__tb_prefix__=\"[targetname]\"")
-- set the auto-generated config.h
- set_config_h("$(buildir)/[targetname]/config.h")
- set_config_h_prefix("CONFIG")
+ set_config_header("$(buildir)/[targetname]/config.h", {prefix = "CONFIG"})
-- add the header files for installing
add_headers("../([targetname]/**.h)")
@@ -18,11 +17,8 @@ target("[targetname]")
add_includedirs("$(buildir)")
add_includedirs("$(buildir)/[targetname]")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
-- add packages
- add_options("tbox", "base")
+ add_packages("tboox.tbox", "base")
-- add files
add_files("*.cpp")
diff --git a/xmake/templates/c++/static_library_tbox/project/xmake.lua b/xmake/templates/c++/static_library_tbox/project/xmake.lua
index 770ea866d..565c3d9ee 100644
--- a/xmake/templates/c++/static_library_tbox/project/xmake.lua
+++ b/xmake/templates/c++/static_library_tbox/project/xmake.lua
@@ -1,5 +1,5 @@
-- version
-set_version("1.0.0")
+set_xmakever("2.1.6")
-- set warning all as error
set_warnings("all", "error")
@@ -8,14 +8,15 @@ set_warnings("all", "error")
set_languages("c99", "cxx11")
-- disable some compiler errors
-add_cxflags("-Wno-error=deprecated-declarations")
-add_mxflags("-Wno-error=deprecated-declarations")
-
--- add defines for c files
-add_defines("_GNU_SOURCE=1", "_REENTRANT")
+add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
+add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
--- the debug or check or coverage mode
-if is_mode("debug", "check", "coverage") then
+-- set the object files directory
+set_objectdir("$(buildir)/$(mode)/$(arch)/.objs")
+set_targetdir("$(buildir)/$(mode)/$(arch)")
+
+-- the debug mode
+if is_mode("debug") then
-- enable the debug symbols
set_symbols("debug")
@@ -25,62 +26,27 @@ if is_mode("debug", "check", "coverage") then
-- add defines for debug
add_defines("__tb_debug__")
-
- -- attempt to enable some checkers for pc
- if is_mode("check") and is_arch("i386", "x86_64") then
- add_cxflags("-fsanitize=address", "-ftrapv")
- add_mxflags("-fsanitize=address", "-ftrapv")
- add_ldflags("-fsanitize=address")
- end
-
- -- enable coverage
- if is_mode("coverage") then
- add_cxflags("--coverage")
- add_mxflags("--coverage")
- add_ldflags("--coverage")
- end
end
--- the release or profile mode
-if is_mode("release", "profile") then
-
- -- the release mode
- if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- strip all symbols
- set_strip("all")
+-- the release mode
+if is_mode("release") then
- -- fomit the frame pointer
- add_cxflags("-fomit-frame-pointer")
- add_mxflags("-fomit-frame-pointer")
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
- -- the profile mode
- else
-
- -- enable the debug symbols
- set_symbols("debug")
+ -- strip all symbols
+ set_strip("all")
- -- enable gprof
- add_cxflags("-pg")
- add_ldflags("-pg")
- end
+ -- fomit the frame pointer
+ add_cxflags("-fomit-frame-pointer")
-- enable fastest optimization
set_optimize("fastest")
-
- -- attempt to add vector extensions
- add_vectorexts("sse2", "sse3", "ssse3", "mmx")
end
-- for the windows platform (msvc)
if is_plat("windows") then
- -- add some defines only for windows
- add_defines("NOCRYPT", "NOGDI")
-
-- the release mode
if is_mode("release") then
@@ -90,9 +56,6 @@ if is_plat("windows") then
-- the debug mode
elseif is_mode("debug") then
- -- enable some checkers
- add_cxflags("-Gs", "-RTC1")
-
-- link libcmtd.lib
add_cxflags("-MTd")
end
@@ -101,16 +64,15 @@ if is_plat("windows") then
add_ldflags("-nodefaultlib:\"msvcrt.lib\"")
end
--- add option: demo
-option("demo")
- set_enable(true)
- set_showmenu(true)
- set_category("option")
- set_description("Enable or disable the demo module")
+-- the base package
+option("base")
+ set_default(true)
+ if is_os("windows") then add_links("ws2_32")
+ elseif is_os("android") then add_links("m", "c")
+ else add_links("pthread", "dl", "m", "c") end
--- add packages
-add_packagedirs("pkg")
+-- add requires
+add_requires("tboox.tbox")
--- add projects
-add_subdirs("src/[targetname]")
-if is_option("demo") then add_subdirs("src/demo") end
+-- include project sources
+includes("src/[targetname]", "src/[targetname]_demo")
diff --git a/xmake/templates/c++/static_library_tbox/template.lua b/xmake/templates/c++/static_library_tbox/template.lua
index 6a1a6c732..63cac3706 100644
--- a/xmake/templates/c++/static_library_tbox/template.lua
+++ b/xmake/templates/c++/static_library_tbox/template.lua
@@ -9,7 +9,7 @@ add_macros("targetname", "$(targetname)")
-- add macro files
add_macrofiles("xmake.lua")
-add_macrofiles("src/_demo/main.c")
+add_macrofiles("src/_demo/main.cpp")
add_macrofiles("src/_demo/xmake.lua")
add_macrofiles("src/_library/xmake.lua")
@@ -19,9 +19,4 @@ on_create(function ()
-- rename target directory
os.mv("src/_library", "src/$(targetname)")
os.mv("src/_demo", "src/$(targetname)_demo")
-
- -- copy packages
- os.cp("$(packagesdir)/tbox.pkg", "pkg/tbox.pkg")
- os.cp("$(packagesdir)/base.pkg", "pkg/base.pkg")
-
end)
diff --git a/xmake/templates/c/console_tbox/project/pkg/base.pkg/xmake.lua b/xmake/templates/c/console_tbox/project/pkg/base.pkg/xmake.lua
deleted file mode 100644
index db521e677..000000000
--- a/xmake/templates/c/console_tbox/project/pkg/base.pkg/xmake.lua
+++ /dev/null
@@ -1,11 +0,0 @@
--- the base package
-option("base")
-
- -- set category
- set_category("package")
-
- -- add links
- if is_os("windows") then add_links("ws2_32")
- elseif is_os("android") then add_links("m", "c")
- else add_links("pthread", "dl", "m", "c") end
-
diff --git a/xmake/templates/c/console_tbox/project/src/xmake.lua b/xmake/templates/c/console_tbox/project/src/xmake.lua
index 08f5e89d1..766a0ff79 100644
--- a/xmake/templates/c/console_tbox/project/src/xmake.lua
+++ b/xmake/templates/c/console_tbox/project/src/xmake.lua
@@ -8,14 +8,10 @@ target("[targetname]")
add_defines("__tb_prefix__=\"[targetname]\"")
-- set the auto-generated config.h
- set_config_h("$(buildir)/[targetname].config.h")
- set_config_h_prefix("CONFIG")
-
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
+ set_config_header("$(buildir)/[targetname].config.h", {prefix = "CONFIG"})
-- add packages
- add_options("tbox", "base")
+ add_packages("tboox.tbox", "base")
-- add files
add_files("*.c")
diff --git a/xmake/templates/c/console_tbox/project/xmake.lua b/xmake/templates/c/console_tbox/project/xmake.lua
index 14559a49f..251c60305 100644
--- a/xmake/templates/c/console_tbox/project/xmake.lua
+++ b/xmake/templates/c/console_tbox/project/xmake.lua
@@ -1,5 +1,5 @@
-- version
-set_version("1.0.0")
+set_xmakever("2.1.6")
-- set warning all as error
set_warnings("all", "error")
@@ -8,14 +8,15 @@ set_warnings("all", "error")
set_languages("c99", "cxx11")
-- disable some compiler errors
-add_cxflags("-Wno-error=deprecated-declarations")
-add_mxflags("-Wno-error=deprecated-declarations")
-
--- add defines for c files
-add_defines("_GNU_SOURCE=1", "_REENTRANT")
+add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
+add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
--- the debug or check or coverage mode
-if is_mode("debug", "check", "coverage") then
+-- set the object files directory
+set_objectdir("$(buildir)/$(mode)/$(arch)/.objs")
+set_targetdir("$(buildir)/$(mode)/$(arch)")
+
+-- the debug mode
+if is_mode("debug") then
-- enable the debug symbols
set_symbols("debug")
@@ -25,62 +26,27 @@ if is_mode("debug", "check", "coverage") then
-- add defines for debug
add_defines("__tb_debug__")
-
- -- attempt to enable some checkers for pc
- if is_mode("check") and is_arch("i386", "x86_64") then
- add_cxflags("-fsanitize=address", "-ftrapv")
- add_mxflags("-fsanitize=address", "-ftrapv")
- add_ldflags("-fsanitize=address")
- end
-
- -- enable coverage
- if is_mode("coverage") then
- add_cxflags("--coverage")
- add_mxflags("--coverage")
- add_ldflags("--coverage")
- end
end
--- the release or profile mode
-if is_mode("release", "profile") then
+-- the release mode
+if is_mode("release") then
- -- the release mode
- if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
- -- strip all symbols
- set_strip("all")
+ -- strip all symbols
+ set_strip("all")
- -- fomit the frame pointer
- add_cxflags("-fomit-frame-pointer")
- add_mxflags("-fomit-frame-pointer")
-
- -- the profile mode
- else
-
- -- enable the debug symbols
- set_symbols("debug")
-
- -- enable gprof
- add_cxflags("-pg")
- add_ldflags("-pg")
- end
+ -- fomit the frame pointer
+ add_cxflags("-fomit-frame-pointer")
-- enable fastest optimization
set_optimize("fastest")
-
- -- attempt to add vector extensions
- add_vectorexts("sse2", "sse3", "ssse3", "mmx")
end
-- for the windows platform (msvc)
if is_plat("windows") then
- -- add some defines only for windows
- add_defines("NOCRYPT", "NOGDI")
-
-- the release mode
if is_mode("release") then
@@ -90,9 +56,6 @@ if is_plat("windows") then
-- the debug mode
elseif is_mode("debug") then
- -- enable some checkers
- add_cxflags("-Gs", "-RTC1")
-
-- link libcmtd.lib
add_cxflags("-MTd")
end
@@ -101,8 +64,15 @@ if is_plat("windows") then
add_ldflags("-nodefaultlib:\"msvcrt.lib\"")
end
--- add packages
-add_packagedirs("pkg")
+-- the base package
+option("base")
+ set_default(true)
+ if is_os("windows") then add_links("ws2_32")
+ elseif is_os("android") then add_links("m", "c")
+ else add_links("pthread", "dl", "m", "c") end
+
+-- add requires
+add_requires("tboox.tbox")
--- add projects
-add_subdirs("src")
+-- include project sources
+includes("src")
diff --git a/xmake/templates/c/console_tbox/template.lua b/xmake/templates/c/console_tbox/template.lua
index 6f4ea81db..b7e432ca2 100644
--- a/xmake/templates/c/console_tbox/template.lua
+++ b/xmake/templates/c/console_tbox/template.lua
@@ -10,9 +10,3 @@ add_macros("targetname", "$(targetname)")
-- add macro files
add_macrofiles("src/xmake.lua")
--- set create script
-on_create(function ()
-
- -- show tips
- print("please put tbox.pkg into pkg before building it!")
-end)
diff --git a/xmake/templates/c/shared_library_tbox/project/pkg/base.pkg/xmake.lua b/xmake/templates/c/shared_library_tbox/project/pkg/base.pkg/xmake.lua
deleted file mode 100644
index db521e677..000000000
--- a/xmake/templates/c/shared_library_tbox/project/pkg/base.pkg/xmake.lua
+++ /dev/null
@@ -1,11 +0,0 @@
--- the base package
-option("base")
-
- -- set category
- set_category("package")
-
- -- add links
- if is_os("windows") then add_links("ws2_32")
- elseif is_os("android") then add_links("m", "c")
- else add_links("pthread", "dl", "m", "c") end
-
diff --git a/xmake/templates/c/shared_library_tbox/project/src/_demo/xmake.lua b/xmake/templates/c/shared_library_tbox/project/src/_demo/xmake.lua
index c3bafab3c..7d122fecc 100644
--- a/xmake/templates/c/shared_library_tbox/project/src/_demo/xmake.lua
+++ b/xmake/templates/c/shared_library_tbox/project/src/_demo/xmake.lua
@@ -10,22 +10,6 @@ target("demo")
-- add defines
add_defines("__tb_prefix__=\"demo\"")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
- -- add links directory
- add_linkdirs("$(buildir)")
-
- -- add includes directory
- add_includedirs("$(buildir)")
- add_includedirs("$(buildir)/[targetname]")
-
- -- add links
- add_links("[targetname]")
-
- -- add packages
- add_options("tbox", "base")
-
-- add files
add_files("*.c")
diff --git a/xmake/templates/c/shared_library_tbox/project/src/_library/xmake.lua b/xmake/templates/c/shared_library_tbox/project/src/_library/xmake.lua
index cb02e1815..cd5159773 100644
--- a/xmake/templates/c/shared_library_tbox/project/src/_library/xmake.lua
+++ b/xmake/templates/c/shared_library_tbox/project/src/_library/xmake.lua
@@ -8,8 +8,7 @@ target("[targetname]")
add_defines("__tb_prefix__=\"[targetname]\"")
-- set the auto-generated config.h
- set_config_h("$(buildir)/[targetname]/config.h")
- set_config_h_prefix("CONFIG")
+ set_config_header("$(buildir)/[targetname]/config.h", {prefix = "CONFIG"})
-- add the header files for installing
add_headers("../([targetname]/**.h)")
@@ -18,11 +17,8 @@ target("[targetname]")
add_includedirs("$(buildir)")
add_includedirs("$(buildir)/[targetname]")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
-- add packages
- add_options("tbox", "base")
+ add_packages("tboox.tbox", "base")
-- add files
add_files("*.c")
diff --git a/xmake/templates/c/shared_library_tbox/project/xmake.lua b/xmake/templates/c/shared_library_tbox/project/xmake.lua
index 770ea866d..565c3d9ee 100644
--- a/xmake/templates/c/shared_library_tbox/project/xmake.lua
+++ b/xmake/templates/c/shared_library_tbox/project/xmake.lua
@@ -1,5 +1,5 @@
-- version
-set_version("1.0.0")
+set_xmakever("2.1.6")
-- set warning all as error
set_warnings("all", "error")
@@ -8,14 +8,15 @@ set_warnings("all", "error")
set_languages("c99", "cxx11")
-- disable some compiler errors
-add_cxflags("-Wno-error=deprecated-declarations")
-add_mxflags("-Wno-error=deprecated-declarations")
-
--- add defines for c files
-add_defines("_GNU_SOURCE=1", "_REENTRANT")
+add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
+add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
--- the debug or check or coverage mode
-if is_mode("debug", "check", "coverage") then
+-- set the object files directory
+set_objectdir("$(buildir)/$(mode)/$(arch)/.objs")
+set_targetdir("$(buildir)/$(mode)/$(arch)")
+
+-- the debug mode
+if is_mode("debug") then
-- enable the debug symbols
set_symbols("debug")
@@ -25,62 +26,27 @@ if is_mode("debug", "check", "coverage") then
-- add defines for debug
add_defines("__tb_debug__")
-
- -- attempt to enable some checkers for pc
- if is_mode("check") and is_arch("i386", "x86_64") then
- add_cxflags("-fsanitize=address", "-ftrapv")
- add_mxflags("-fsanitize=address", "-ftrapv")
- add_ldflags("-fsanitize=address")
- end
-
- -- enable coverage
- if is_mode("coverage") then
- add_cxflags("--coverage")
- add_mxflags("--coverage")
- add_ldflags("--coverage")
- end
end
--- the release or profile mode
-if is_mode("release", "profile") then
-
- -- the release mode
- if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- strip all symbols
- set_strip("all")
+-- the release mode
+if is_mode("release") then
- -- fomit the frame pointer
- add_cxflags("-fomit-frame-pointer")
- add_mxflags("-fomit-frame-pointer")
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
- -- the profile mode
- else
-
- -- enable the debug symbols
- set_symbols("debug")
+ -- strip all symbols
+ set_strip("all")
- -- enable gprof
- add_cxflags("-pg")
- add_ldflags("-pg")
- end
+ -- fomit the frame pointer
+ add_cxflags("-fomit-frame-pointer")
-- enable fastest optimization
set_optimize("fastest")
-
- -- attempt to add vector extensions
- add_vectorexts("sse2", "sse3", "ssse3", "mmx")
end
-- for the windows platform (msvc)
if is_plat("windows") then
- -- add some defines only for windows
- add_defines("NOCRYPT", "NOGDI")
-
-- the release mode
if is_mode("release") then
@@ -90,9 +56,6 @@ if is_plat("windows") then
-- the debug mode
elseif is_mode("debug") then
- -- enable some checkers
- add_cxflags("-Gs", "-RTC1")
-
-- link libcmtd.lib
add_cxflags("-MTd")
end
@@ -101,16 +64,15 @@ if is_plat("windows") then
add_ldflags("-nodefaultlib:\"msvcrt.lib\"")
end
--- add option: demo
-option("demo")
- set_enable(true)
- set_showmenu(true)
- set_category("option")
- set_description("Enable or disable the demo module")
+-- the base package
+option("base")
+ set_default(true)
+ if is_os("windows") then add_links("ws2_32")
+ elseif is_os("android") then add_links("m", "c")
+ else add_links("pthread", "dl", "m", "c") end
--- add packages
-add_packagedirs("pkg")
+-- add requires
+add_requires("tboox.tbox")
--- add projects
-add_subdirs("src/[targetname]")
-if is_option("demo") then add_subdirs("src/demo") end
+-- include project sources
+includes("src/[targetname]", "src/[targetname]_demo")
diff --git a/xmake/templates/c/shared_library_tbox/template.lua b/xmake/templates/c/shared_library_tbox/template.lua
index daa3d90cc..b6eafa97a 100644
--- a/xmake/templates/c/shared_library_tbox/template.lua
+++ b/xmake/templates/c/shared_library_tbox/template.lua
@@ -19,8 +19,4 @@ on_create(function ()
-- rename target directory
os.mv("src/_library", "src/$(targetname)")
os.mv("src/_demo", "src/$(targetname)_demo")
-
- -- show tips
- print("please put tbox.pkg into pkg before building it!")
-
end)
diff --git a/xmake/templates/c/static_library_tbox/project/pkg/base.pkg/xmake.lua b/xmake/templates/c/static_library_tbox/project/pkg/base.pkg/xmake.lua
deleted file mode 100644
index db521e677..000000000
--- a/xmake/templates/c/static_library_tbox/project/pkg/base.pkg/xmake.lua
+++ /dev/null
@@ -1,11 +0,0 @@
--- the base package
-option("base")
-
- -- set category
- set_category("package")
-
- -- add links
- if is_os("windows") then add_links("ws2_32")
- elseif is_os("android") then add_links("m", "c")
- else add_links("pthread", "dl", "m", "c") end
-
diff --git a/xmake/templates/c/static_library_tbox/project/src/_demo/xmake.lua b/xmake/templates/c/static_library_tbox/project/src/_demo/xmake.lua
index c3bafab3c..7d122fecc 100644
--- a/xmake/templates/c/static_library_tbox/project/src/_demo/xmake.lua
+++ b/xmake/templates/c/static_library_tbox/project/src/_demo/xmake.lua
@@ -10,22 +10,6 @@ target("demo")
-- add defines
add_defines("__tb_prefix__=\"demo\"")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
- -- add links directory
- add_linkdirs("$(buildir)")
-
- -- add includes directory
- add_includedirs("$(buildir)")
- add_includedirs("$(buildir)/[targetname]")
-
- -- add links
- add_links("[targetname]")
-
- -- add packages
- add_options("tbox", "base")
-
-- add files
add_files("*.c")
diff --git a/xmake/templates/c/static_library_tbox/project/src/_library/xmake.lua b/xmake/templates/c/static_library_tbox/project/src/_library/xmake.lua
index cec28c3d4..97dd93631 100644
--- a/xmake/templates/c/static_library_tbox/project/src/_library/xmake.lua
+++ b/xmake/templates/c/static_library_tbox/project/src/_library/xmake.lua
@@ -8,8 +8,7 @@ target("[targetname]")
add_defines("__tb_prefix__=\"[targetname]\"")
-- set the auto-generated config.h
- set_config_h("$(buildir)/[targetname]/config.h")
- set_config_h_prefix("CONFIG")
+ set_config_header("$(buildir)/[targetname]/config.h", {prefix = "CONFIG"})
-- add the header files for installing
add_headers("../([targetname]/**.h)")
@@ -18,11 +17,8 @@ target("[targetname]")
add_includedirs("$(buildir)")
add_includedirs("$(buildir)/[targetname]")
- -- set the object files directory
- set_objectdir("$(buildir)/.objs")
-
-- add packages
- add_options("tbox", "base")
+ add_packages("tboox.tbox", "base")
-- add files
add_files("*.c")
diff --git a/xmake/templates/c/static_library_tbox/project/xmake.lua b/xmake/templates/c/static_library_tbox/project/xmake.lua
index 770ea866d..565c3d9ee 100644
--- a/xmake/templates/c/static_library_tbox/project/xmake.lua
+++ b/xmake/templates/c/static_library_tbox/project/xmake.lua
@@ -1,5 +1,5 @@
-- version
-set_version("1.0.0")
+set_xmakever("2.1.6")
-- set warning all as error
set_warnings("all", "error")
@@ -8,14 +8,15 @@ set_warnings("all", "error")
set_languages("c99", "cxx11")
-- disable some compiler errors
-add_cxflags("-Wno-error=deprecated-declarations")
-add_mxflags("-Wno-error=deprecated-declarations")
-
--- add defines for c files
-add_defines("_GNU_SOURCE=1", "_REENTRANT")
+add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
+add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
--- the debug or check or coverage mode
-if is_mode("debug", "check", "coverage") then
+-- set the object files directory
+set_objectdir("$(buildir)/$(mode)/$(arch)/.objs")
+set_targetdir("$(buildir)/$(mode)/$(arch)")
+
+-- the debug mode
+if is_mode("debug") then
-- enable the debug symbols
set_symbols("debug")
@@ -25,62 +26,27 @@ if is_mode("debug", "check", "coverage") then
-- add defines for debug
add_defines("__tb_debug__")
-
- -- attempt to enable some checkers for pc
- if is_mode("check") and is_arch("i386", "x86_64") then
- add_cxflags("-fsanitize=address", "-ftrapv")
- add_mxflags("-fsanitize=address", "-ftrapv")
- add_ldflags("-fsanitize=address")
- end
-
- -- enable coverage
- if is_mode("coverage") then
- add_cxflags("--coverage")
- add_mxflags("--coverage")
- add_ldflags("--coverage")
- end
end
--- the release or profile mode
-if is_mode("release", "profile") then
-
- -- the release mode
- if is_mode("release") then
-
- -- set the symbols visibility: hidden
- set_symbols("hidden")
-
- -- strip all symbols
- set_strip("all")
+-- the release mode
+if is_mode("release") then
- -- fomit the frame pointer
- add_cxflags("-fomit-frame-pointer")
- add_mxflags("-fomit-frame-pointer")
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
- -- the profile mode
- else
-
- -- enable the debug symbols
- set_symbols("debug")
+ -- strip all symbols
+ set_strip("all")
- -- enable gprof
- add_cxflags("-pg")
- add_ldflags("-pg")
- end
+ -- fomit the frame pointer
+ add_cxflags("-fomit-frame-pointer")
-- enable fastest optimization
set_optimize("fastest")
-
- -- attempt to add vector extensions
- add_vectorexts("sse2", "sse3", "ssse3", "mmx")
end
-- for the windows platform (msvc)
if is_plat("windows") then
- -- add some defines only for windows
- add_defines("NOCRYPT", "NOGDI")
-
-- the release mode
if is_mode("release") then
@@ -90,9 +56,6 @@ if is_plat("windows") then
-- the debug mode
elseif is_mode("debug") then
- -- enable some checkers
- add_cxflags("-Gs", "-RTC1")
-
-- link libcmtd.lib
add_cxflags("-MTd")
end
@@ -101,16 +64,15 @@ if is_plat("windows") then
add_ldflags("-nodefaultlib:\"msvcrt.lib\"")
end
--- add option: demo
-option("demo")
- set_enable(true)
- set_showmenu(true)
- set_category("option")
- set_description("Enable or disable the demo module")
+-- the base package
+option("base")
+ set_default(true)
+ if is_os("windows") then add_links("ws2_32")
+ elseif is_os("android") then add_links("m", "c")
+ else add_links("pthread", "dl", "m", "c") end
--- add packages
-add_packagedirs("pkg")
+-- add requires
+add_requires("tboox.tbox")
--- add projects
-add_subdirs("src/[targetname]")
-if is_option("demo") then add_subdirs("src/demo") end
+-- include project sources
+includes("src/[targetname]", "src/[targetname]_demo")
diff --git a/xmake/templates/c/static_library_tbox/template.lua b/xmake/templates/c/static_library_tbox/template.lua
index 835308bce..b5dc8170e 100644
--- a/xmake/templates/c/static_library_tbox/template.lua
+++ b/xmake/templates/c/static_library_tbox/template.lua
@@ -19,7 +19,4 @@ on_create(function ()
-- rename target directory
os.mv("src/_library", "src/$(targetname)")
os.mv("src/_demo", "src/$(targetname)_demo")
-
- -- show tips
- print("please put tbox.pkg into pkg before building it!")
end)