diff options
| author | ruki <[email protected]> | 2022-02-10 00:38:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-02-10 00:38:19 +0800 |
| commit | 039b8b2b3dd2594c2149da5c5ccb28747de782eb (patch) | |
| tree | 40fad5e7e35ca9197a960e6beea91edb31212026 | |
| parent | 0f3c0abb00dddcb71a0aba5220ef0dd6ed260a24 (diff) | |
load toolchain from datafile
| -rw-r--r-- | xmake/core/project/project.lua | 16 | ||||
| -rw-r--r-- | xmake/modules/package/tools/xmake.lua | 9 |
2 files changed, 24 insertions, 1 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index cd5171599..c40cfbac0 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -628,6 +628,22 @@ function project._toolchains() if not toolchains then os.raise(errors) end + -- load toolchains from data file from "package.tools.xmake" module + local toolchain_datafiles = os.getenv("XMAKE_TOOLCHAIN_DATAFILES") + if toolchain_datafiles then + toolchain_datafiles = path.splitenv(toolchain_datafiles) + if toolchain_datafiles and #toolchain_datafiles > 0 then + for _, toolchain_datafile in ipairs(toolchain_datafiles) do + local toolchain_inst, errors = toolchain.load_fromfile(toolchain_datafile) + if toolchain_inst then + -- @note we use this passed toolchain configuration first if this toolchain has been defined in current project + toolchains[toolchain_inst:name()] = toolchain_inst + else + os.raise(errors) + end + end + end + end project._memcache():set("toolchains", toolchains) end return toolchains diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua index 4a1908307..53f977911 100644 --- a/xmake/modules/package/tools/xmake.lua +++ b/xmake/modules/package/tools/xmake.lua @@ -178,7 +178,14 @@ function _get_package_toolchains_envs(package, opt) -- pass custom toolchains definition in project for _, toolchain_inst in ipairs(toolchains_custom) do - print("pass", toolchain_inst:name()) + local toolchains_file = os.tmpfile() + dprint("passing toolchain(%s) to %s", toolchain_inst:name(), toolchains_file) + local ok, errors = toolchain_inst:savefile(toolchains_file) + if not ok then + raise("save toolchain failed, %s", errors or "unknown") + end + envs.XMAKE_TOOLCHAIN_DATAFILES = envs.XMAKE_TOOLCHAIN_DATAFILES or {} + table.insert(envs.XMAKE_TOOLCHAIN_DATAFILES, toolchains_file) end end return envs |
