diff options
| author | ruki <[email protected]> | 2022-05-22 18:31:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-22 18:31:31 +0800 |
| commit | 65350947080e83310f3efff3dcf82f3b12c43f06 (patch) | |
| tree | 5d702aca2207977f950091aaf65effc29bd5b9d2 /xmake/core/base/path.lua | |
| parent | 603749bcd6eff68165f0e0695b532a6173580f67 (diff) | |
improve path and moc rule
Diffstat (limited to 'xmake/core/base/path.lua')
| -rw-r--r-- | xmake/core/base/path.lua | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua index 7ccb320e6..79eb28c3f 100644 --- a/xmake/core/base/path.lua +++ b/xmake/core/base/path.lua @@ -29,32 +29,41 @@ local _instance = _instance or {} -- new a path function _instance.new(p, transform) local instance = table.inherit(_instance) - instance._PATH = p + instance._RAWSTR = p instance._TRANSFORM = transform setmetatable(instance, _instance) table.wraplock(instance) + instance:_update() return instance end -function _instance:str() +-- update path string +function _instance:_update() local transform = self._TRANSFORM if transform then - return transform(self:rawstr()) + self._STR = transform(self:rawstr()) + else + self._STR = self:rawstr() end - return self:rawstr() +end + +function _instance:str() + return self._STR end function _instance:rawstr() - return self._PATH + return self._RAWSTR end function _instance:set(p) - self._PATH = tostring(p) + self._RAWSTR = tostring(p) + instance:_update() return self end function _instance:transform_set(transform) self._TRANSFORM = transform + instance:_update() return self end @@ -344,7 +353,7 @@ end -- is path instance? function path.instance_of(p) - return type(p) == "table" and p.normalize and p._PATH + return type(p) == "table" and p.normalize and p._RAWSTR end -- register call function |
