summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-17 12:38:41 +0800
committerruki <[email protected]>2015-06-17 12:38:41 +0800
commitdda38bb51d261f058706ada91fdf8b03701bd2e5 (patch)
tree667734bc5dbc3e535833fb960b19cfec90404262 /xmake/scripts
parent95798306093295a45c8f8671ca2f18edb16f796e (diff)
add excludes pattern for files
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/os.lua24
-rw-r--r--xmake/scripts/base/project.lua4
2 files changed, 23 insertions, 5 deletions
diff --git a/xmake/scripts/base/os.lua b/xmake/scripts/base/os.lua
index 31ff7957f..75b555651 100644
--- a/xmake/scripts/base/os.lua
+++ b/xmake/scripts/base/os.lua
@@ -26,6 +26,7 @@ local os = os or {}
-- load modules
local path = require("base/path")
local utils = require("base/utils")
+local string = require("base/string")
-- copy file or directory
function os.cp(src, dst)
@@ -160,8 +161,27 @@ end
--
function os.match(pattern, findir)
+ -- get the excludes
+ local excludes = pattern:match("|.*$")
+ if excludes then excludes = excludes:split("|") end
+
+ -- translate excludes
+ if excludes then
+ local _excludes = {}
+ for _, exclude in ipairs(excludes) do
+ exclude = path.translate(exclude)
+ exclude = exclude:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
+ exclude = exclude:gsub("%*%*", "\001")
+ exclude = exclude:gsub("%*", "\002")
+ exclude = exclude:gsub("\001", ".*")
+ exclude = exclude:gsub("\002", "[^/]*")
+ table.insert(_excludes, exclude)
+ end
+ excludes = _excludes
+ end
+
-- translate path and remove some repeat separators
- pattern = path.translate(pattern)
+ pattern = path.translate(pattern:gsub("|.*$", ""))
-- get the root directory
local rootdir = pattern
@@ -182,7 +202,7 @@ function os.match(pattern, findir)
pattern = pattern:gsub("\002", "[^/]*")
-- find it
- return os.find(rootdir, pattern, recurse, findir)
+ return os.find(rootdir, pattern, recurse, findir, excludes)
end
-- return module: os
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index 41b754a45..e8769d57b 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -1074,13 +1074,11 @@ function project.menu()
local projectfile = xmake._PROJECT_FILE
if projectfile and os.isfile(projectfile) then
configs, errors = project._load_options(projectfile)
- else
- errors = string.format("load %s failed!", projectfile)
end
-- failed?
if not configs then
- utils.error(errors)
+ if errors then utils.error(errors) end
return {}
end