diff options
| author | ruki <[email protected]> | 2021-12-29 22:30:38 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-12-29 22:30:38 +0800 |
| commit | 70e03f735c6f27e5e0d97c2c0bbeb03d239a6574 (patch) | |
| tree | 150506d5d79abad272ee56a7bda293244317e62b | |
| parent | e1ef31c2ab61b06a31adac981cfd67c873b33829 (diff) | |
improve toolchain and linux driver
| -rw-r--r-- | xmake/core/project/target.lua | 12 | ||||
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/platform/linux/driver/driver_modules.lua | 3 | ||||
| -rw-r--r-- | xmake/rules/platform/linux/driver/xmake.lua | 3 |
4 files changed, 17 insertions, 3 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 837486b06..88c3197eb 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -273,6 +273,11 @@ function _instance:_invalidate(name) end end +-- is loaded? +function _instance:_is_loaded() + return self._LOADED +end + -- get the target info -- -- e.g. @@ -649,7 +654,7 @@ end -- get target deps function _instance:deps() - if not self._LOADED then + if not self:_is_loaded() then os.raise("please call target:deps() or target:dep() in after_load()!") end return self._DEPS @@ -657,7 +662,7 @@ end -- get target ordered deps function _instance:orderdeps() - if not self._LOADED then + if not self:_is_loaded() then os.raise("please call target:orderdeps() in after_load()!") end return self._ORDERDEPS @@ -1941,6 +1946,9 @@ end -- get the program and name of the given tool kind function _instance:tool(toolkind) + if not self:_is_loaded() then + os.raise("we cannot get tool(%s) before target(%s) is loaded, maybe it is called on_load() now.", toolkind, self:name()) + end return toolchain.tool(self:toolchains(), toolkind, {cachekey = "target_" .. self:name(), plat = self:plat(), arch = self:arch(), before_get = function() -- get program from set_toolchain/set_tools (deprecated) diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 782b004cd..f4a511f0f 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -185,7 +185,7 @@ end -- get the program and name of the given tool kind function _instance:tool(toolkind) -- ensure to do load for initializing toolset first - self:check() + -- @note we cannot call self:check() here, because it can only be called on config self:_load() local toolpaths = self:get("toolset." .. toolkind) if toolpaths then diff --git a/xmake/rules/platform/linux/driver/driver_modules.lua b/xmake/rules/platform/linux/driver/driver_modules.lua index 121f391ba..b9c48e163 100644 --- a/xmake/rules/platform/linux/driver/driver_modules.lua +++ b/xmake/rules/platform/linux/driver/driver_modules.lua @@ -192,6 +192,9 @@ function load(target) -- we need only need binary kind, because we will rewrite on_link target:set("kind", "binary") target:set("extension", ".ko") +end + +function config(target) -- get and save linux-headers sdk local linux_headers = _get_linux_headers_sdk(target) diff --git a/xmake/rules/platform/linux/driver/xmake.lua b/xmake/rules/platform/linux/driver/xmake.lua index 78ba6d089..8192b9a7f 100644 --- a/xmake/rules/platform/linux/driver/xmake.lua +++ b/xmake/rules/platform/linux/driver/xmake.lua @@ -24,6 +24,9 @@ rule("platform.linux.driver") on_load(function (target) import("driver_modules").load(target) end) + on_config(function (target) + import("driver_modules").config(target) + end) on_link(function (target, opt) import("driver_modules").link(target, opt) end) |
