diff options
| author | ruki <[email protected]> | 2019-05-10 22:53:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-05-10 11:22:55 +0800 |
| commit | 13e02d0fa943dfd9ea3a0f4c2184a3df46058a20 (patch) | |
| tree | 9be65f482df4d26dc16606ef19a80f0b10511a5a /xmake/core/package/package.lua | |
| parent | 6f3d4c780f2bb0f7334f808f70189e98d0d9e49c (diff) | |
improve package:script()
Diffstat (limited to 'xmake/core/package/package.lua')
| -rw-r--r-- | xmake/core/package/package.lua | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 9ddef427d..799776582 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -671,45 +671,29 @@ function _instance:script(name, generic) local plat = self:plat() or "" local arch = self:arch() or "" - -- match script for special plat and arch - local pattern = plat .. '|' .. arch + -- match pattern + -- + -- `@macosx,linux` + -- `android@macosx,linux` + -- `android|armv7-a@macosx,linux` + -- for _pattern, _script in pairs(script) do local hosts = {} local hosts_spec = false _pattern = _pattern:gsub("@(.+)", function (v) - -- get and remove hosts for `android|armv7-a@macosx,linux` for _, host in ipairs(v:split(',')) do hosts[host] = true hosts_spec = true end return "" end) - if not _pattern:startswith("__") and pattern:find('^' .. _pattern .. '$') and (not hosts_spec or hosts[os.host()]) then + if not _pattern:startswith("__") and (not hosts_spec or hosts[os.host()]) + and (_pattern:trim() == "" or (plat .. '|' .. arch):find('^' .. _pattern .. '$') or plat:find('^' .. _pattern .. '$')) then result = _script break end end - -- match script for special plat - if result == nil then - for _pattern, _script in pairs(script) do - local hosts = {} - local hosts_spec = false - _pattern = _pattern:gsub("@(.+)", function (v) - -- get and remove hosts for `android@macosx,linux` - for _, host in ipairs(v:split(',')) do - hosts[host] = true - hosts_spec = true - end - return "" - end) - if not _pattern:startswith("__") and plat:find('^' .. _pattern .. '$') and (not hosts_spec or hosts[os.host()]) then - result = _script - break - end - end - end - -- get generic script result = result or script["__generic__"] or generic end |
