summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-06-01 15:00:25 +0800
committerruki <[email protected]>2016-06-01 15:00:25 +0800
commiteffb1055c467886ad873c01ee67167008e39ee9b (patch)
treee72120bda5926dde4f1157772e15fbb793565707
parenta695fd4b26ed7c5bdba3bd18d9adb3075190b1ee (diff)
impl doxygen plugin
-rwxr-xr-xxmake/actions/build/main.lua1
-rw-r--r--xmake/core/platform/platform.lua50
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/tool.lua4
-rw-r--r--xmake/core/tool/tool.lua24
-rwxr-xr-xxmake/platforms/android/xmake.lua3
-rwxr-xr-xxmake/platforms/iphoneos/xmake.lua3
-rwxr-xr-xxmake/platforms/iphonesimulator/xmake.lua3
-rwxr-xr-xxmake/platforms/linux/xmake.lua3
-rwxr-xr-xxmake/platforms/macosx/xmake.lua3
-rwxr-xr-xxmake/platforms/watchos/xmake.lua3
-rwxr-xr-xxmake/platforms/watchsimulator/xmake.lua3
-rwxr-xr-xxmake/plugins/doxygen/main.lua50
-rwxr-xr-xxmake/plugins/doxygen/xmake.lua5
-rw-r--r--xmake/tools/doxygen.lua50
14 files changed, 125 insertions, 80 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index b44a53a42..948bf400f 100755
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -87,5 +87,4 @@ function main()
-- trace
print("build ok!")
-
end
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index 7669f9ddb..57c0299ae 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -77,6 +77,13 @@ function _instance:archs()
return self._INFO.archs
end
+-- get the platform tooldirs
+function _instance:tooldirs()
+
+ -- get it
+ return self._INFO.tooldirs
+end
+
-- get the checker
function _instance:checker()
@@ -228,25 +235,28 @@ function platform._interpreter()
-- register api: platform()
interp:api_register_scope("platform")
- -- register api: set_platform_os()
+ -- register api: set_os()
interp:api_register_set_values("platform", "os")
- -- register api: set_platform_hosts()
+ -- register api: set_hosts()
interp:api_register_set_values("platform", "hosts")
- -- register api: set_platform_archs()
+ -- register api: set_archs()
interp:api_register_set_values("platform", "archs")
- -- register api: set_platform_menu()
+ -- register api: set_menu()
interp:api_register_set_values("platform", "menu")
- -- register api: set_platform_checker()
+ -- register api: set_checker()
interp:api_register_set_values("platform", "checker")
- -- register api: set_platform_environment()
+ -- register api: set_tooldirs()
+ interp:api_register_set_values("platform", "tooldirs")
+
+ -- register api: set_environment()
interp:api_register_set_values("platform", "environment")
- -- register api: on_platform_load()
+ -- register api: on_load()
interp:api_register_on_script("platform", "load")
-- save interpreter
@@ -260,7 +270,7 @@ end
function platform.load(plat)
-- get platform name
- plat = plat or config.get("plat")
+ plat = plat or config.get("plat") or xmake._HOST
if not plat then
return nil, string.format("unknown platform!")
end
@@ -317,12 +327,9 @@ function platform.os(plat)
-- load the platform
local instance = platform.load(plat)
- if not instance then
- return
+ if instance then
+ return instance:os()
end
-
- -- get it
- return instance:os()
end
-- get the given platform configure
@@ -340,12 +347,9 @@ function platform.archs(plat)
-- load the platform
local instance = platform.load(plat)
- if not instance then
- return
+ if instance then
+ return instance:archs()
end
-
- -- get it
- return instance:archs()
end
-- get the all platforms
@@ -379,6 +383,16 @@ function platform.plats()
return plats
end
+-- get the tool directories
+function platform.tooldirs(plat)
+
+ -- get the tool directories for the current platform
+ local instance = platform.load(plat)
+ if instance then
+ return instance:tooldirs()
+ end
+end
+
-- get the given tool
function platform.tool(name)
diff --git a/xmake/core/sandbox/modules/import/core/tool/tool.lua b/xmake/core/sandbox/modules/import/core/tool/tool.lua
index 3b2f054c1..ed8c52b39 100644
--- a/xmake/core/sandbox/modules/import/core/tool/tool.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/tool.lua
@@ -52,10 +52,10 @@ function sandbox_core_tool.run(name, ...)
end
-- check the tool and return the absolute path if exists
-function sandbox_core_tool.check(shellname, dirs)
+function sandbox_core_tool.check(shellname, check)
-- check it
- return tool.check(shellname, dirs)
+ return tool.check(shellname, platform.tooldirs(), check)
end
-- return module
diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua
index d16d27a7b..90110fc71 100644
--- a/xmake/core/tool/tool.lua
+++ b/xmake/core/tool/tool.lua
@@ -184,17 +184,29 @@ function tool._load(shellname, kind)
end
-- check the shellname
-function tool._check(shellname)
+function tool._check(shellname, check)
+
+ -- uses the passed checker
+ if check ~= nil then
+
+ -- check it
+ local ok, errors = sandbox.load(check, shellname)
+ if not ok then
+ utils.verbose(errors)
+ end
+
+ -- ok?
+ return ok
+ end
-- load the tool module
local module, errors = tool._load(shellname)
if not module then
utils.verbose(errors)
- return false
end
-- no checker? attempt to run it directly
- if not module.check then
+ if not module or not module.check then
return 0 == os.execute(string.format("%s > %s 2>&1", shellname, xmake._NULDEV))
end
@@ -227,13 +239,13 @@ function tool.load(kind)
end
-- check the tool and return the absolute path if exists
-function tool.check(shellname, dirs)
+function tool.check(shellname, dirs, check)
-- check
assert(shellname)
-- attempt to check it directly first
- if tool._check(shellname) then
+ if tool._check(shellname, check) then
return shellname
end
@@ -246,7 +258,7 @@ function tool.check(shellname, dirs)
if os.isfile(toolpath) then
-- check it
- if tool._check(toolpath) then
+ if tool._check(toolpath, check) then
return toolpath
end
end
diff --git a/xmake/platforms/android/xmake.lua b/xmake/platforms/android/xmake.lua
index 50ba4db4b..2bb1eb55d 100755
--- a/xmake/platforms/android/xmake.lua
+++ b/xmake/platforms/android/xmake.lua
@@ -35,6 +35,9 @@ platform("android")
-- set checker
set_checker("checker")
+ -- set tooldirs
+ set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin")
+
-- on load
on_load(function ()
diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua
index 5a0420fce..4a5700e14 100755
--- a/xmake/platforms/iphoneos/xmake.lua
+++ b/xmake/platforms/iphoneos/xmake.lua
@@ -35,6 +35,9 @@ platform("iphoneos")
-- set checker
set_checker("checker")
+ -- set tooldirs
+ set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin")
+
-- on load
on_load(function ()
diff --git a/xmake/platforms/iphonesimulator/xmake.lua b/xmake/platforms/iphonesimulator/xmake.lua
index 387ff9b83..80959effe 100755
--- a/xmake/platforms/iphonesimulator/xmake.lua
+++ b/xmake/platforms/iphonesimulator/xmake.lua
@@ -35,6 +35,9 @@ platform("iphonesimulator")
-- set checker
set_checker("checker")
+ -- set tooldirs
+ set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin")
+
-- on load
on_load(function ()
diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua
index c6d6cce0b..b7f47b15b 100755
--- a/xmake/platforms/linux/xmake.lua
+++ b/xmake/platforms/linux/xmake.lua
@@ -35,6 +35,9 @@ platform("linux")
-- set checker
set_checker("checker")
+ -- set tooldirs
+ set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin")
+
-- on load
on_load(function ()
diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua
index 38f60a11d..dbaf98174 100755
--- a/xmake/platforms/macosx/xmake.lua
+++ b/xmake/platforms/macosx/xmake.lua
@@ -35,6 +35,9 @@ platform("macosx")
-- set checker
set_checker("checker")
+ -- set tooldirs
+ set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin")
+
-- on load
on_load(function ()
diff --git a/xmake/platforms/watchos/xmake.lua b/xmake/platforms/watchos/xmake.lua
index f12b4a542..0815eccae 100755
--- a/xmake/platforms/watchos/xmake.lua
+++ b/xmake/platforms/watchos/xmake.lua
@@ -35,6 +35,9 @@ platform("watchos")
-- set checker
set_checker("checker")
+ -- set tooldirs
+ set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin")
+
-- on load
on_load(function ()
diff --git a/xmake/platforms/watchsimulator/xmake.lua b/xmake/platforms/watchsimulator/xmake.lua
index 9932010dd..13533f894 100755
--- a/xmake/platforms/watchsimulator/xmake.lua
+++ b/xmake/platforms/watchsimulator/xmake.lua
@@ -35,6 +35,9 @@ platform("watchsimulator")
-- set checker
set_checker("checker")
+ -- set tooldirs
+ set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin")
+
-- on load
on_load(function ()
diff --git a/xmake/plugins/doxygen/main.lua b/xmake/plugins/doxygen/main.lua
index bcc7fd7db..72af8124e 100755
--- a/xmake/plugins/doxygen/main.lua
+++ b/xmake/plugins/doxygen/main.lua
@@ -27,9 +27,57 @@ import("core.tool.tool")
-- main
function main()
+ -- check the doxygen
+ local doxygen = tool.check("doxygen", function (shellname)
+ os.run("%s -v", shellname)
+ end)
+ assert(doxygen, "doxygen not found!")
+
-- generate doxyfile first if not exists
local doxyfile = option.get("doxyfile")
if not os.isfile(doxyfile) then
- tool.run("doxygen", "doxygen -g " .. 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")
+
+ -- 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
+ --
+ -- HTML_OUTPUT = html
+ -- LATEX_OUTPUT = latex
+ --
+ local outputdir = option.get("outputdir")
+ if outputdir then
+
+ -- 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))
+
+ -- ensure the output directory
+ os.mkdir(outputdir)
+ end
end
+
+ -- check
+ assert(os.isfile(doxyfile), "%s not found!", doxyfile)
+
+ -- generate document
+ os.run("%s %s", doxygen, doxyfile)
+
+ -- trace
+ print("doxygen ok!")
end
diff --git a/xmake/plugins/doxygen/xmake.lua b/xmake/plugins/doxygen/xmake.lua
index 3342df331..7694d46be 100755
--- a/xmake/plugins/doxygen/xmake.lua
+++ b/xmake/plugins/doxygen/xmake.lua
@@ -40,9 +40,10 @@ task("doxygen")
-- options
, options =
{
- {nil, "doxyfile", "kv", "Doxyfile", "Set the doxygen config file." }
+ {nil, "doxyfile", "kv", "Doxyfile", "Set the doxygen config file." }
+ , {'o', "outputdir", "kv", "build/doxygen", "Set the output directory." }
, {}
- , {nil, "srcdir", "v", "src", "Set the source code directory." }
+ , {nil, "srcdir", "v", "src", "Set the source code directory." }
}
})
diff --git a/xmake/tools/doxygen.lua b/xmake/tools/doxygen.lua
deleted file mode 100644
index 5afda2c72..000000000
--- a/xmake/tools/doxygen.lua
+++ /dev/null
@@ -1,50 +0,0 @@
---!The Automatic Cross-platform Build Tool
---
--- XMake is free software; you can redistribute it and/or modify
--- it under the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
---
--- XMake is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public License
--- along with XMake;
--- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
---
--- Copyright (C) 2015 - 2016, ruki All rights reserved.
---
--- @author ruki
--- @file ccache.lua
---
-
--- init it
-function init(shellname)
-
- -- save name
- _g.shellname = shellname or "doxygen"
-
-end
-
--- get the property
-function get(name)
-
- -- get it
- return _g[name]
-end
-
--- run it
-function run(...)
-
- -- run it
- os.run(...)
-end
-
--- check the given flags
-function check(flags)
-
- -- check it
- os.run("%s %s -h", _g.shellname, ifelse(flags, flags, ""))
-end