diff options
| author | ruki <[email protected]> | 2023-02-05 10:51:32 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-05 10:51:32 +0800 |
| commit | 0847395c81ebaad0ba239b112cb3595ea731e9bb (patch) | |
| tree | c77de5bece10386031864117baa93b50a62c92a6 | |
| parent | 03dda551aa83b8e06ffa429fa76f63144dbc9b9b (diff) | |
| parent | 23a2984cced176dd05bc27a9387e4a6d4fd7f5b9 (diff) | |
Merge pull request #3334 from glcraft/package-rules
Improve package rules loader
| -rw-r--r-- | xmake/core/project/package.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/xmake/core/project/package.lua b/xmake/core/project/package.lua index 9e899d2a3..bf1e61ea8 100644 --- a/xmake/core/project/package.lua +++ b/xmake/core/project/package.lua @@ -249,10 +249,17 @@ function _instance:rules() local installdir = self:installdir() local rulesdir = path.join(installdir, "rules") if os.isdir(rulesdir) then - local files = os.match(path.join(rulesdir, "**.lua")) + local files = os.filedirs(path.join(rulesdir, "*")) if files then for _, filepath in ipairs(files) do - local results, errors = rule._load(filepath) + local results, errors + if filepath:endswith(".lua") then + results, errors = rule._load(filepath) + elseif os.isdir(filepath) and os.isfile(path.join(filepath, "xmake.lua")) then + results, errors = rule._load(path.join(filepath, "xmake.lua")) + else + os.raise("unknown rule %s: %s", os.isdir(filepath) and "directory" or "file", filepath) + end if results then table.join2(ruleinfos, results) else |
