diff options
| -rw-r--r-- | xmake/actions/create/template.lua | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/xmake/actions/create/template.lua b/xmake/actions/create/template.lua index d638034cf..1279c1d35 100644 --- a/xmake/actions/create/template.lua +++ b/xmake/actions/create/template.lua @@ -139,13 +139,19 @@ function replace_variables_in_files(files, vars) end -- get all languages from templates --- --- scanning template roots to detect languages is too slow, and the language module list does not fully match template language names, --- so we hardcode it here for better performance. function languages() - return {"c", "c++", "cuda", "dlang", "fortran", "go", - "kotlin", "nim", "objc", "objc++", "pascal", - "rust", "swift", "vala", "zig"} + local found = hashset.new() + for _, rootdir in ipairs(rootdirs()) do + local languages_dirs = os.dirs(path.join(rootdir, "*")) + if languages_dirs then + for _, d in ipairs(languages_dirs) do + found:insert(path.filename(d)) + end + end + end + local results = found:to_array() + table.sort(results) + return results end -- get all templates for the given language |
