From c99d1ee6094597d5e13f6d9b1d141faa20e6c1e4 Mon Sep 17 00:00:00 2001 From: ShifftC Date: Tue, 30 Sep 2025 10:31:42 +0200 Subject: add scriptdir to project packages --- xmake/core/package/package.lua | 10 +++++++--- xmake/modules/package/tools/xmake.lua | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 4b0ddd036..2c42a4c94 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -929,9 +929,13 @@ end function _instance:rulesdir() local rulesdir = self._RULESDIR if rulesdir == nil then - rulesdir = path.join(self:scriptdir(), "rules") - if not os.isdir(rulesdir) and self:base() then + if self:repo() == nil and self:base() then rulesdir = self:base():rulesdir() + else + rulesdir = path.join(self:scriptdir(), "rules") + if not os.isdir(rulesdir) and self:base() then + rulesdir = self:base():rulesdir() + end end if rulesdir == nil or not os.isdir(rulesdir) then rulesdir = false @@ -3063,7 +3067,7 @@ function package.load_from_project(packagename, project) end -- new an instance - instance = _instance.new(packagename, packageinfo) + instance = _instance.new(packagename, packageinfo, {scriptdir = os.projectdir()}) package._memcache():set2("packages", instance) return instance end diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua index e2b22f926..6a5d13af5 100644 --- a/xmake/modules/package/tools/xmake.lua +++ b/xmake/modules/package/tools/xmake.lua @@ -485,7 +485,7 @@ function install(package, configs, opt) -- copy the ported xmake.lua in the default position if it's missing local xmakefile = path.join(opt.curdir or os.curdir(), "xmake.lua") - if not os.isfile(xmakefile) then + if not os.isfile(xmakefile) and package:repo() ~= nil then local xmakefile_port = path.join(package:scriptdir(), "port", "xmake.lua") if os.isfile(xmakefile_port) then os.cp(xmakefile_port, xmakefile) -- cgit v1.3.1