diff options
| author | ruki <[email protected]> | 2016-06-02 09:01:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-06-02 09:01:27 +0800 |
| commit | 5c4e11744a8c181be6f96048f94289dbdc8df38b (patch) | |
| tree | 147dff66c555b08e24d38bcd4a3173429bb71119 | |
| parent | effb1055c467886ad873c01ee67167008e39ee9b (diff) | |
modify project version and name for doxygen
| -rw-r--r-- | xmake/core/project/project.lua | 1 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 28 | ||||
| -rwxr-xr-x | xmake/plugins/doxygen/main.lua | 97 | ||||
| -rwxr-xr-x | xmake/plugins/doxygen/xmake.lua | 5 |
4 files changed, 96 insertions, 35 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 5d2effef8..6e326add7 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -339,6 +339,7 @@ function project._interpreter() interp:api_register_set_values("target", "kind" , "config_h_prefix" , "version" + , "project" , "strip" , "options" , "symbols" diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index cbf4832c0..42550f3a8 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -24,6 +24,7 @@ local sandbox_core_project_project = sandbox_core_project_project or {} -- load modules +local table = require("base/table") local config = require("project/config") local project = require("project/project") local raise = require("sandbox/modules/raise") @@ -87,5 +88,32 @@ function sandbox_core_project_project.mtimes() return project.mtimes() end +-- get the project version +function sandbox_core_project_project.version() + + -- get version + for _, target in pairs(table.wrap(project.targets())) do + local version = target:get("version") + if version then + return version + end + end +end + +-- get the project name +function sandbox_core_project_project.name() + + -- get version + for _, target in pairs(table.wrap(project.targets())) do + local name = target:get("project") + if name then + return name + end + end + + -- uses the project directory name + return path.basename(project.directory()) +end + -- return module return sandbox_core_project_project diff --git a/xmake/plugins/doxygen/main.lua b/xmake/plugins/doxygen/main.lua index 72af8124e..5ac2f1ae4 100755 --- a/xmake/plugins/doxygen/main.lua +++ b/xmake/plugins/doxygen/main.lua @@ -23,6 +23,8 @@ -- imports import("core.base.option") import("core.tool.tool") +import("core.project.config") +import("core.project.project") -- main function main() @@ -33,51 +35,82 @@ function main() end) assert(doxygen, "doxygen not found!") - -- generate doxyfile first if not exists - local doxyfile = option.get("doxyfile") - if not os.isfile(doxyfile) then + -- generate doxyfile first + local doxyfile = path.join(os.tmpdir(), "doxyfile") - -- generate the default doxyfile - os.run("%s -g %s", doxygen, doxyfile) + -- generate the default doxyfile + os.run("%s -g %s", doxygen, doxyfile) - -- enable recursive - -- - -- RECURSIVE = YES - -- - io.gsub(doxyfile, "RECURSIVE%s-=%s-NO", "RECURSIVE = YES") + -- load configure + config.load() - -- set the source directory - -- - -- INPUT = xxx - -- - local srcdir = option.get("srcdir") - if srcdir and os.isdir(srcdir) then - io.gsub(doxyfile, "INPUT%s-=.-\n", format("INPUT = %s\n", srcdir)) - end + -- load project + project.load() - -- set the output directory - -- - -- HTML_OUTPUT = html - -- LATEX_OUTPUT = latex - -- - local outputdir = option.get("outputdir") - if outputdir then + -- enable recursive + -- + -- RECURSIVE = YES + -- + io.gsub(doxyfile, "RECURSIVE%s-=%s-NO", "RECURSIVE = YES") - -- update the doxyfile - io.gsub(doxyfile, "HTML_OUTPUT%s-=.-\n", format("HTML_OUTPUT = %s/html\n", outputdir)) - io.gsub(doxyfile, "LATEX_OUTPUT%s-=.-\n", format("LATEX_OUTPUT = %s/latex\n", outputdir)) + -- set the source directory + -- + -- INPUT = xxx + -- + local srcdir = option.get("srcdir") + if srcdir and os.isdir(srcdir) then + io.gsub(doxyfile, "INPUT%s-=.-\n", format("INPUT = %s\n", srcdir)) + end + + -- set the output directory + -- + -- OUTPUT_DIRECTORY = + -- + local outputdir = option.get("outputdir") or config.get("buildir") or "build" + if outputdir then + + -- update the doxyfile + io.gsub(doxyfile, "OUTPUT_DIRECTORY%s-=.-\n", format("OUTPUT_DIRECTORY = %s\n", outputdir)) + + -- ensure the output directory + os.mkdir(outputdir) + end - -- ensure the output directory - os.mkdir(outputdir) - end + -- set the project version + -- + -- PROJECT_NUMBER = + -- + local version = project.version() + if version then + io.gsub(doxyfile, "PROJECT_NUMBER%s-=.-\n", format("PROJECT_NUMBER = %s\n", version)) + end + + -- set the project name + -- + -- PROJECT_NAME = + -- + local name = project.name() + if name then + io.gsub(doxyfile, "PROJECT_NAME%s-=.-\n", format("PROJECT_NAME = %s\n", name)) end -- check assert(os.isfile(doxyfile), "%s not found!", doxyfile) + -- enter the project directory + os.cd(project.directory()) + -- generate document - os.run("%s %s", doxygen, doxyfile) + if option.get("verbose") then + os.exec("%s %s", doxygen, doxyfile) + else + os.run("%s %s", doxygen, doxyfile) + end + + -- leave the project directory + os.cd("-") -- trace + print("result: %s/html/index.html", outputdir) print("doxygen ok!") end diff --git a/xmake/plugins/doxygen/xmake.lua b/xmake/plugins/doxygen/xmake.lua index 7694d46be..94ed40f53 100755 --- a/xmake/plugins/doxygen/xmake.lua +++ b/xmake/plugins/doxygen/xmake.lua @@ -40,10 +40,9 @@ task("doxygen") -- options , options = { - {nil, "doxyfile", "kv", "Doxyfile", "Set the doxygen config file." } - , {'o', "outputdir", "kv", "build/doxygen", "Set the output directory." } + {'o', "outputdir", "kv", nil, "Set the output directory." } , {} - , {nil, "srcdir", "v", "src", "Set the source code directory." } + , {nil, "srcdir", "v", "src", "Set the source code directory." } } }) |
