diff options
| author | ruki <[email protected]> | 2021-09-29 22:41:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-29 22:41:19 +0800 |
| commit | 9b11147b98d5b51bc5064757c7f3629e5ad37cbb (patch) | |
| tree | 7b11541cefddf6b96b398b5c962619911b4514dd /xmake/core/package/package.lua | |
| parent | 9b6ed10af9394ac3db541f848ab3405b7d0daf3d (diff) | |
add local package dir
Diffstat (limited to 'xmake/core/package/package.lua')
| -rw-r--r-- | xmake/core/package/package.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 5c7a04d34..e6a8335ee 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -461,6 +461,18 @@ function _instance:is_parallelize() return self:get("parallelize") ~= false end +-- is local embed package? +-- we install directly from the local source code instead of downloading it remotely +function _instance:is_embed() + return self:get("sourcedir") and #self:urls() == 0 and self:script("install") +end + +-- is local package? +-- we will use local installdir and cachedir in current project +function _instance:is_local() + return self:is_embed() +end + -- is debug package? (deprecated) function _instance:debug() return self:is_debug() @@ -526,7 +538,8 @@ function _instance:cachedir() cachedir = self:get("cachedir") if not cachedir then local name = self:name():lower():gsub("::", "_") - cachedir = path.join(package.cachedir(), name:sub(1, 1):lower(), name, self:version_str()) + local rootdir = self:is_local() and path.join(config.directory(), "cache", "packages") or package.cachedir() + cachedir = path.join(rootdir, name:sub(1, 1):lower(), name, self:version_str()) end self._CACHEDIR = cachedir end @@ -540,7 +553,8 @@ function _instance:installdir(...) installdir = self:get("installdir") if not installdir then local name = self:name():lower():gsub("::", "_") - installdir = path.join(package.installdir(), name:sub(1, 1):lower(), name) + local rootdir = self:is_local() and path.join(config.directory(), "packages") or package.installdir() + installdir = path.join(rootdir, name:sub(1, 1):lower(), name) if self:version_str() then installdir = path.join(installdir, self:version_str()) end |
