diff options
| author | ruki <[email protected]> | 2015-06-03 13:47:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-03 13:47:32 +0800 |
| commit | 6ba8d0eb8d09d5170242837ef091c04ab4da6047 (patch) | |
| tree | 33ad58bbaccaec6d0b3a0035fd92602070454ba2 /xmake/scripts/base | |
| parent | 8f5a561006bb5b0952278075deb908633317c987 (diff) | |
add string split
Diffstat (limited to 'xmake/scripts/base')
| -rw-r--r-- | xmake/scripts/base/makefile.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/base/string.lua | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua index 68ff484e1..1624af101 100644 --- a/xmake/scripts/base/makefile.lua +++ b/xmake/scripts/base/makefile.lua @@ -232,8 +232,8 @@ function makefile.build(target) assert(buildir) -- done build - local ok = os.execute(string.format("make -f %s %s", buildir .. "/makefile", target)) - if ok ~= 0 then + local ok = platform.build(buildir .. "/makefile", target) + if not ok then -- error utils.error("build target: %s failed!", target) return false diff --git a/xmake/scripts/base/string.lua b/xmake/scripts/base/string.lua index 87e37635a..793abad00 100644 --- a/xmake/scripts/base/string.lua +++ b/xmake/scripts/base/string.lua @@ -40,5 +40,14 @@ function string.find_last(self, pattern, plain) end end +-- split string with the given pattern +function string.split(self, pattern) + + -- split it + local list = {} + self:gsub("[^" .. pattern .."]+", function(v) table.insert(list, v) end ) + return list +end + -- return module: string return string |
