summaryrefslogtreecommitdiff
path: root/xmake/scripts/base/project.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-17 21:45:48 +0800
committerruki <[email protected]>2015-06-17 21:45:48 +0800
commit6d68e7a43de8b732b1bac17c0be4ff8c0f8c8ba8 (patch)
tree5bf2106042584f3e6035eaa691fe1932c99c53f4 /xmake/scripts/base/project.lua
parent178e8a75babbe555cd5a0e21749b454a659c39ea (diff)
match subdirs and subfiles for project
Diffstat (limited to 'xmake/scripts/base/project.lua')
-rw-r--r--xmake/scripts/base/project.lua44
1 files changed, 33 insertions, 11 deletions
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index b70b08302..973d50374 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -172,14 +172,21 @@ function project._api_add_subdirs(env, ...)
-- init mtime for files
project._MTIMES = project._MTIMES or {}
- -- get all sub directories
- local subdirs = project._api_get_pathes(...)
-
-- save the current project file directory
local curdir = project._CURDIR
- -- done
+ -- get all subdirs
+ local subdirs = project._api_get_pathes(...)
+
+ -- match all subdirs
+ local subdirs_matched = {}
for _, subdir in ipairs(subdirs) do
+ local dirs = os.match(subdir, true)
+ if dirs then table.join2(subdirs_matched, dirs) end
+ end
+
+ -- done
+ for _, subdir in ipairs(subdirs_matched) do
if subdir and type(subdir) == "string" then
-- the project file
@@ -225,14 +232,21 @@ function project._api_add_subfiles(env, ...)
-- init mtime for files
project._MTIMES = project._MTIMES or {}
- -- get all files
- local files = project._api_get_pathes(...)
-
-- save the current project file directory
local curdir = project._CURDIR
+ -- get all subfiles
+ local subfiles = project._api_get_pathes(...)
+
+ -- match all subfiles
+ local subfiles_matched = {}
+ for _, subfile in ipairs(subfiles) do
+ local files = os.match(subfile)
+ if files then table.join2(subfiles_matched, files) end
+ end
+
-- done
- for _, file in ipairs(files) do
+ for _, file in ipairs(subfiles_matched) do
if file and type(file) == "string" then
-- the project file
@@ -1184,10 +1198,8 @@ function project.menu()
local menu = {}
for k, opts in pairs(options_by_category) do
- -- insert a separator
- table.insert(menu, {})
-
-- insert options
+ local first = true
for name, opt in pairs(opts) do
-- show menu?
@@ -1199,6 +1211,16 @@ function project.menu()
default = true
end
+ -- is first?
+ if first then
+
+ -- insert a separator
+ table.insert(menu, {})
+
+ -- not first
+ first = false
+ end
+
-- append it
table.insert(menu, {nil, name, "kv", default, utils.unwrap(opt.description)})
end