summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-02-06 00:49:12 +0800
committerruki <[email protected]>2018-02-05 22:55:15 +0800
commitd38a8d50bb1ea28d203b70617e5ba18eef1d9924 (patch)
tree6db714264037a3da9debbc202ed7f4e0cec5f508
parentf544576e010e2d37defa0592a7b5b919375bd2c3 (diff)
add FAQ to auto-generated xmake.lua
-rw-r--r--CHANGELOG.md12
-rw-r--r--xmake/actions/config/scanner.lua4
-rw-r--r--xmake/core/project/template.lua77
-rw-r--r--xmake/core/sandbox/modules/import/core/project/template.lua5
4 files changed, 96 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1bd8bb46a..29859b7d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## master (unreleased)
+### Changes
+
+* Add FAQ to the auto-generated xmake.lua
+
### Bugs fixed
* Fix force to add flags bug
@@ -430,7 +434,11 @@
## master (开发中)
-## Bugs修复
+### 改进
+
+* 添加FAQ到自动生成的xmake.lua文件,方便用户快速上手
+
+### Bugs修复
* 修复无法通过`add_ldflags("xx", "xx", {force = true})`强制设置多个flags的问题
@@ -461,7 +469,7 @@
* 增加对linux/arm, arm64的支持,可以在arm linux上运行xmake
* 改进vs201x工程生成插件,更好的includedirs设置支持
-## Bugs修复
+### Bugs修复
* 修复依赖修改编译和链接问题
* [#151](https://github.com/tboox/xmake/issues/151): 修复`os.nuldev()`在mingw上传入gcc时出现问题
diff --git a/xmake/actions/config/scanner.lua b/xmake/actions/config/scanner.lua
index 51e1efa9f..2af0d40eb 100644
--- a/xmake/actions/config/scanner.lua
+++ b/xmake/actions/config/scanner.lua
@@ -25,6 +25,7 @@
-- imports
import("core.project.config")
import("core.project.project")
+import("core.project.template")
import("core.language.language")
-- scan project and generate xmake.lua automaticlly if the project codes exist
@@ -140,6 +141,9 @@ function make()
file:print("")
end
end
+
+ -- add FAQ
+ file:print(template.faq())
-- exit file
file:close()
diff --git a/xmake/core/project/template.lua b/xmake/core/project/template.lua
index c4339d4c3..e72209523 100644
--- a/xmake/core/project/template.lua
+++ b/xmake/core/project/template.lua
@@ -275,9 +275,86 @@ function template.create(language, templateid, targetname)
end
end
+ -- append FAQ to xmake.lua
+ local projectfile = path.join(projectdir, "xmake.lua")
+ if os.isfile(projectfile) then
+ local file = io.open("xmake.lua", "a+")
+ if file then
+ file:print(template.faq())
+ file:close()
+ end
+ end
+
-- ok
return true
end
+-- get FAQ
+function template.faq()
+ return [[
+-- FAQ
+--
+-- You can enter the project directory firstly before building project.
+--
+-- $ cd projectdir
+--
+-- 1. How to build project?
+--
+-- $ xmake
+--
+-- 2. How to configure project?
+--
+-- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release]
+--
+-- 3. Where is the build output directory?
+--
+-- The default output directory is `./build` and you can configure the output directory.
+--
+-- $ xmake f -o outputdir
+-- $ xmake
+--
+-- 4. How to run and debug target after building project?
+--
+-- $ xmake run [targetname]
+-- $ xmake run -d [targetname]
+--
+-- 5. How to install target to the system directory or other output directory?
+--
+-- $ xmake install
+-- $ xmake install -o installdir
+--
+-- 6. Add some frequently-used compilation flags in xmake.lua
+--
+-- @code
+-- -- add macro defination
+-- add_defines("NDEBUG", "_GNU_SOURCE=1")
+--
+-- -- set warning all as error
+-- set_warnings("all", "error")
+--
+-- -- set language: c99, c++11
+-- set_languages("c99", "cxx11")
+--
+-- -- set optimization: none, faster, fastest, smallest
+-- set_optimize("fastest")
+--
+-- -- add include search directories
+-- add_includedirs("/usr/include", "/usr/local/include")
+--
+-- -- add link libraries and search directories
+-- add_links("tbox", "z", "pthread")
+-- add_linkdirs("/usr/local/lib", "/usr/lib")
+--
+-- -- add compilation and link flags
+-- add_cxflags("-stdnolib", "-fno-strict-aliasing")
+-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
+--
+-- @endcode
+--
+-- 7. If you want to known more usage about xmake, please see http://xmake.io/#/home
+--
+ ]]
+end
+
-- return module: template
return template
diff --git a/xmake/core/sandbox/modules/import/core/project/template.lua b/xmake/core/sandbox/modules/import/core/project/template.lua
index 989e23ead..bddf7b6ed 100644
--- a/xmake/core/sandbox/modules/import/core/project/template.lua
+++ b/xmake/core/sandbox/modules/import/core/project/template.lua
@@ -61,5 +61,10 @@ function sandbox_core_project_template.create(language, templateid, targetname)
end
end
+-- get FAQ
+function sandbox_core_project_template.faq()
+ return template.faq()
+end
+
-- return module
return sandbox_core_project_template