diff options
| author | ruki <[email protected]> | 2022-12-09 00:43:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-12-08 22:18:48 +0800 |
| commit | e7965d5d0176bf620fac9a71e48bfa588314c956 (patch) | |
| tree | 14eaff8f8785f2bf1e2187a3ff0e85c4257be173 | |
| parent | 604fd4101a1c337965c253889aadaa806dd6abeb (diff) | |
improve doxygen #3147
| -rw-r--r-- | xmake/plugins/doxygen/main.lua | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/xmake/plugins/doxygen/main.lua b/xmake/plugins/doxygen/main.lua index 958f87ff3..6b68d633e 100644 --- a/xmake/plugins/doxygen/main.lua +++ b/xmake/plugins/doxygen/main.lua @@ -26,37 +26,11 @@ import("lib.detect.find_tool") import("private.action.require.impl.packagenv") import("private.action.require.impl.install_packages") --- main -function main() - - -- load configuration - config.load() - - -- enter the environments of doxygen - local oldenvs = packagenv.enter("doxygen") - - -- find doxygen - local packages = {} - local doxygen = find_tool("doxygen") - if not doxygen then - table.join2(packages, install_packages("doxygen")) - end - - -- enter the environments of installed packages - for _, instance in ipairs(packages) do - instance:envs_enter() - end - - -- we need force to detect and flush detect cache after loading all environments - if not doxygen then - doxygen = find_tool("doxygen", {force = true}) - end - assert(doxygen, "doxygen not found!") - - -- generate doxyfile first - local doxyfile = path.join(os.tmpdir(), "doxyfile") +-- generate doxyfile +function _generate_doxyfile() -- generate the default doxyfile + local doxyfile = path.join(os.tmpdir(), "doxyfile") os.vrunv(doxygen.program, {"-g", doxyfile}) -- enable recursive @@ -78,7 +52,7 @@ function main() -- -- OUTPUT_DIRECTORY = -- - local outputdir = option.get("outputdir") or config.get("buildir") or "build" + local outputdir = option.get("outputdir") or config.buildir() if outputdir then io.gsub(doxyfile, "OUTPUT_DIRECTORY%s-=.-\n", format("OUTPUT_DIRECTORY = %s\n", outputdir)) os.mkdir(outputdir) @@ -101,17 +75,47 @@ function main() if name then io.gsub(doxyfile, "PROJECT_NAME%s-=.-\n", format("PROJECT_NAME = %s\n", name)) end + return doxyfile +end - -- check - assert(os.isfile(doxyfile), "%s not found!", doxyfile) +function main() - -- trace - cprint("generating ..${beer}") + -- load configuration + config.load() + + -- enter the environments of doxygen + local oldenvs = packagenv.enter("doxygen") + + -- find doxygen + local packages = {} + local doxygen = find_tool("doxygen") + if not doxygen then + table.join2(packages, install_packages("doxygen")) + end + + -- enter the environments of installed packages + for _, instance in ipairs(packages) do + instance:envs_enter() + end + + -- we need force to detect and flush detect cache after loading all environments + if not doxygen then + doxygen = find_tool("doxygen", {force = true}) + end + assert(doxygen, "doxygen not found!") + + -- get doxyfile first + local doxyfile = "doxyfile" + if not os.isfile(doxyfile) then + doxyfile = _generate_doxyfile() + end + assert(os.isfile(doxyfile), "%s not found!", doxyfile) -- generate document + cprint("generating ..${beer}") os.vrunv(doxygen.program, {doxyfile}, {curdir = project.directory()}) - -- trace + -- done cprint("${bright green}result: ${default green}%s/html/index.html", outputdir) cprint("${color.success}doxygen ok!") os.setenvs(oldenvs) |
