diff options
| author | ruki <[email protected]> | 2016-06-30 10:17:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-06-30 10:17:13 +0800 |
| commit | b3f129d3137855271bd929f4d6df7e51cf99f7ac (patch) | |
| tree | e4c2b32b01e93c76ecd32fbb7c0af0f2690b5bfa | |
| parent | 1cdf952d5a7d754a99d21c30930032f91ddf4860 (diff) | |
fix install config header and update api for template
| -rwxr-xr-x | README.md | 7 | ||||
| -rwxr-xr-x | xmake/actions/clean/main.lua | 2 | ||||
| -rwxr-xr-x | xmake/actions/config/configheader.lua (renamed from xmake/actions/config/config_h.lua) | 12 | ||||
| -rwxr-xr-x | xmake/actions/config/main.lua | 4 | ||||
| -rwxr-xr-x | xmake/actions/package/main.lua | 6 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 46 | ||||
| -rw-r--r-- | xmake/platforms/macosx/installer.lua | 12 | ||||
| -rw-r--r-- | xmake/templates/c++/console_tbox/project/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/c++/shared_library_tbox/project/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/c++/static_library_tbox/project/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/c/console_tbox/project/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/c/shared_library_tbox/project/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/templates/c/static_library_tbox/project/xmake.lua | 2 |
13 files changed, 67 insertions, 34 deletions
@@ -375,13 +375,6 @@ xmake的目标是开发者更加关注于项目本身开发,简化项目的描 * [libsvx](https://github.com/caikelun/libsvx) * [更多项目](https://github.com/waruqi/xmake/wiki/%E4%BD%BF%E7%94%A8xmake%E7%9A%84%E5%BC%80%E6%BA%90%E5%BA%93) -####后续工作 - -1. 实现生成.ipa、.apk、.app、.deb、.rmp的打包插件 -2. 实现包的自动依赖管理,如果依赖包不存在,会去自动下载编译安装后,继续进行构建,支持交叉平台的包管理 -3. 实现转换automake、cmake的工到xmake的描述文件的插件,实现无缝编译 -4. 实现vs、xcode等工程文件生成插件 - ####简单例子 -- the debug mode diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua index ba4330d40..040b43f8c 100755 --- a/xmake/actions/clean/main.lua +++ b/xmake/actions/clean/main.lua @@ -74,7 +74,7 @@ function _on_clean_target(target) if option.get("all") then -- remove the config.h file - _remove(target:get("config_h")) + _remove(target:configheader()) end end diff --git a/xmake/actions/config/config_h.lua b/xmake/actions/config/configheader.lua index 585e651d5..0871e5909 100755 --- a/xmake/actions/config/config_h.lua +++ b/xmake/actions/config/configheader.lua @@ -17,7 +17,7 @@ -- Copyright (C) 2015 - 2016, ruki All rights reserved. -- -- @author ruki --- @file config_h.lua +-- @file configheader.lua -- -- imports @@ -29,17 +29,17 @@ import("core.project.project") function _make_for_target(files, target) -- get the target configure file - local config_h = target:get("config_h") - if not config_h then return end + local configheader = target:configheader() + if not configheader then return end -- the prefix local prefix = target:get("config_h_prefix") or (target:name():upper() .. "_CONFIG") -- open the file - local file = files[config_h] or io.open(config_h, "w") + local file = files[configheader] or io.open(configheader, "w") -- make the head - if files[config_h] then file:print("") end + if files[configheader] then file:print("") end file:print("#ifndef %s_H", prefix) file:print("#define %s_H", prefix) file:print("") @@ -102,7 +102,7 @@ function _make_for_target(files, target) file:print("#endif") -- cache the file - files[config_h] = file + files[configheader] = file end diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index b042793af..0144ee3c6 100755 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -27,7 +27,7 @@ import("core.project.global") import("core.project.project") import("core.platform.platform") import("core.project.cache") -import("config_h") +import("configheader") -- filter option function _option_filter(name) @@ -185,7 +185,7 @@ function main() cache.flush() -- make the config.h - config_h.make() + configheader.make() -- dump it config.dump() diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua index 6128eec15..986d28d17 100755 --- a/xmake/actions/package/main.lua +++ b/xmake/actions/package/main.lua @@ -41,9 +41,9 @@ function _package_library(target) os.cp(target:targetfile(), format("%s/%s.pkg/lib/$(mode)/$(plat)/$(arch)/%s", outputdir, targetname, path.filename(target:targetfile()))) -- copy the config.h to the output directory - local config_h = target:get("config_h") - if config_h then - os.cp(config_h, format("%s/%s.pkg/inc/$(plat)/%s", outputdir, targetname, path.filename(config_h))) + local configheader = target:configheader() + if configheader then + os.cp(configheader, format("%s/%s.pkg/inc/$(plat)/%s", outputdir, targetname, path.filename(configheader))) end -- copy headers diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 991816e96..a1f75be5f 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -139,6 +139,38 @@ function target:targetfile() return path.join(targetdir, filename) end +-- get the config header files +function target:configheader(outputdir) + + -- get config header + local configheader = self:get("config_h") + if not configheader then + return + end + + -- get the root directory + local rootdir, count = configheader:gsub("|.*$", ""):gsub("%(.*%)$", "") + if count == 0 then + rootdir = nil + end + + -- remove '(' and ')' + configheader = configheader:gsub("[%(%)]", "") + + -- get the output header + local outputheader = nil + if outputdir then + if rootdir then + outputheader = path.absolute(path.relative(configheader, rootdir), outputdir) + else + outputheader = path.join(outputdir, path.filename(configheader)) + end + end + + -- ok + return configheader, outputheader +end + -- get the source files function target:sourcefiles() @@ -302,7 +334,10 @@ function target:headerfiles(outputdir) for _, header in ipairs(table.wrap(headers)) do -- get the root directory - local rootdir = header:gsub("%(.*%)", ""):gsub("|.*$", "") + local rootdir, count = header:gsub("|.*$", ""):gsub("%(.*%)$", "") + if count == 0 then + rootdir = nil + end -- remove '(' and ')' local srcpathes = header:gsub("[%(%)]", "") @@ -318,8 +353,13 @@ function target:headerfiles(outputdir) -- add the destinate headers for _, srcpath in ipairs(srcpathes) do - -- the header - local dstheader = path.absolute(path.relative(srcpath, rootdir), headerdir) + -- the destinate header + local dstheader = nil + if rootdir then + dstheader = path.absolute(path.relative(srcpath, rootdir), headerdir) + else + dstheader = path.join(headerdir, path.filename(srcpath)) + end assert(dstheader) -- add it diff --git a/xmake/platforms/macosx/installer.lua b/xmake/platforms/macosx/installer.lua index 426adc832..9544749d1 100644 --- a/xmake/platforms/macosx/installer.lua +++ b/xmake/platforms/macosx/installer.lua @@ -62,9 +62,9 @@ function _install_library(target) os.cp(target:targetfile(), librarydir) -- copy the config.h to the include directory - local config_h = target:get("config_h") - if config_h then - os.cp(config_h, includedir) + local configheader, configoutput = target:configheader(includedir) + if configheader and configoutput then + os.cp(configheader, configoutput) end -- copy headers to the include directory @@ -110,9 +110,9 @@ function _uninstall_library(target) os.rm(path.join(librarydir, path.filename(target:targetfile()))) -- reove the config.h from the include directory - local config_h = target:get("config_h") - if config_h then - os.rm(path.join(includedir, path.filename(config_h))) + local _, configoutput = target:configheader(includedir) + if configoutput then + os.rm(configoutput) end -- remove headers from the include directory diff --git a/xmake/templates/c++/console_tbox/project/xmake.lua b/xmake/templates/c++/console_tbox/project/xmake.lua index 048bb99ba..9fc47c0ea 100644 --- a/xmake/templates/c++/console_tbox/project/xmake.lua +++ b/xmake/templates/c++/console_tbox/project/xmake.lua @@ -105,7 +105,7 @@ if is_plat("windows") then end -- add packages -add_pkgdirs("pkg") +add_packagedirs("pkg") -- add projects add_subdirs("src") diff --git a/xmake/templates/c++/shared_library_tbox/project/xmake.lua b/xmake/templates/c++/shared_library_tbox/project/xmake.lua index 808c17645..d94875110 100644 --- a/xmake/templates/c++/shared_library_tbox/project/xmake.lua +++ b/xmake/templates/c++/shared_library_tbox/project/xmake.lua @@ -112,7 +112,7 @@ option("demo") set_option_description("Enable or disable the demo module") -- add packages -add_pkgdirs("pkg") +add_packagedirs("pkg") -- add projects add_subdirs("src/[targetname]") diff --git a/xmake/templates/c++/static_library_tbox/project/xmake.lua b/xmake/templates/c++/static_library_tbox/project/xmake.lua index 808c17645..d94875110 100644 --- a/xmake/templates/c++/static_library_tbox/project/xmake.lua +++ b/xmake/templates/c++/static_library_tbox/project/xmake.lua @@ -112,7 +112,7 @@ option("demo") set_option_description("Enable or disable the demo module") -- add packages -add_pkgdirs("pkg") +add_packagedirs("pkg") -- add projects add_subdirs("src/[targetname]") diff --git a/xmake/templates/c/console_tbox/project/xmake.lua b/xmake/templates/c/console_tbox/project/xmake.lua index 048bb99ba..9fc47c0ea 100644 --- a/xmake/templates/c/console_tbox/project/xmake.lua +++ b/xmake/templates/c/console_tbox/project/xmake.lua @@ -105,7 +105,7 @@ if is_plat("windows") then end -- add packages -add_pkgdirs("pkg") +add_packagedirs("pkg") -- add projects add_subdirs("src") diff --git a/xmake/templates/c/shared_library_tbox/project/xmake.lua b/xmake/templates/c/shared_library_tbox/project/xmake.lua index 808c17645..d94875110 100644 --- a/xmake/templates/c/shared_library_tbox/project/xmake.lua +++ b/xmake/templates/c/shared_library_tbox/project/xmake.lua @@ -112,7 +112,7 @@ option("demo") set_option_description("Enable or disable the demo module") -- add packages -add_pkgdirs("pkg") +add_packagedirs("pkg") -- add projects add_subdirs("src/[targetname]") diff --git a/xmake/templates/c/static_library_tbox/project/xmake.lua b/xmake/templates/c/static_library_tbox/project/xmake.lua index 808c17645..d94875110 100644 --- a/xmake/templates/c/static_library_tbox/project/xmake.lua +++ b/xmake/templates/c/static_library_tbox/project/xmake.lua @@ -112,7 +112,7 @@ option("demo") set_option_description("Enable or disable the demo module") -- add packages -add_pkgdirs("pkg") +add_packagedirs("pkg") -- add projects add_subdirs("src/[targetname]") |
