diff options
| author | ruki <[email protected]> | 2015-06-02 14:35:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-02 14:35:30 +0800 |
| commit | 6ed13d09ec37896b0176e90ddaa99c90ecaccd1d (patch) | |
| tree | 5738abd0b031d60a531aecd53783e55493f761f8 /xmake/scripts | |
| parent | 22b67ea8ae2ce6cc7ae67fb5f7aa66df950eaec5 (diff) | |
add filename to rule
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/base/rule.lua | 23 | ||||
| -rw-r--r-- | xmake/scripts/platform/platform.lua | 17 |
2 files changed, 19 insertions, 21 deletions
diff --git a/xmake/scripts/base/rule.lua b/xmake/scripts/base/rule.lua index 09d1f6b7f..106c12eda 100644 --- a/xmake/scripts/base/rule.lua +++ b/xmake/scripts/base/rule.lua @@ -31,6 +31,23 @@ local config = require("base/config") local project = require("base/project") local platform = require("platform/platform") +-- get the filename from the given name and kind +function rule.filename(name, kind) + + -- check + assert(name and kind) + + -- get formats + local formats = platform.get("format") + assert(formats) + + -- get format + local format = formats[kind] or {"", ""} + + -- make it + return format[1] .. name .. format[2] +end + -- get target file for the given target function rule.targetfile(target_name, target, buildir) @@ -42,7 +59,7 @@ function rule.targetfile(target_name, target, buildir) assert(targetdir and type(targetdir) == "string") -- the target file name - local filename = platform.filename(target_name, target.kind) + local filename = rule.filename(target_name, target.kind) assert(filename) -- make the target file path @@ -89,7 +106,7 @@ function rule.objectfiles(target_name, target, sourcefiles, buildir) for _, sourcefile in ipairs(sourcefiles) do -- make object file - local objectfile = string.format("%s/%s/%s/%s", objectdir, target_name, path.directory(sourcefile), platform.filename(path.basename(sourcefile), "object")) + local objectfile = string.format("%s/%s/%s/%s", objectdir, target_name, path.directory(sourcefile), rule.filename(path.basename(sourcefile), "object")) -- save it objectfiles[i] = path.translate(objectfile) @@ -145,7 +162,5 @@ function rule.sourcefiles(target) return sourcefiles end - - -- return module: rule return rule diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua index ec21f0300..2858018c2 100644 --- a/xmake/scripts/platform/platform.lua +++ b/xmake/scripts/platform/platform.lua @@ -87,23 +87,6 @@ function platform.get(name) end end --- get the filename from the given name and kind -function platform.filename(name, kind) - - -- check - assert(name and kind) - - -- get formats - local formats = platform.get("format") - assert(formats) - - -- get format - local format = formats[kind] or {"", ""} - - -- make it - return format[1] .. name .. format[2] -end - -- get the linker from the given name function platform.linker(kind) |
