summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-24 22:40:01 +0800
committerruki <[email protected]>2025-04-24 10:24:45 +0800
commitd75240a009a7f295e31568c83fe9e93de1be431d (patch)
tree06bf5f1da864c1f993c2f7926a507ff43221690d
parent9a69d05a1087691899587da2aeb1c37cea54c354 (diff)
rename more buildir
-rw-r--r--core/xpack.lua10
-rw-r--r--xmake/core/package/package.lua20
-rw-r--r--xmake/core/sandbox/modules/import/core/sandbox/module.lua24
-rw-r--r--xmake/modules/package/manager/conan/v1/install_package.lua10
-rw-r--r--xmake/modules/package/manager/conan/v2/install_package.lua10
-rw-r--r--xmake/modules/package/tools/cmake.lua2
-rw-r--r--xmake/modules/package/tools/meson.lua2
-rw-r--r--xmake/modules/package/tools/xmake.lua2
-rw-r--r--xmake/modules/private/action/trybuild/cmake.lua14
-rw-r--r--xmake/modules/private/action/trybuild/meson.lua32
-rw-r--r--xmake/modules/private/service/distcc_build/server_session.lua6
-rw-r--r--xmake/plugins/pack/main.lua2
-rw-r--r--xmake/plugins/pack/nsis/main.lua2
-rw-r--r--xmake/plugins/pack/runself/main.lua2
-rw-r--r--xmake/plugins/pack/srpm/main.lua8
-rw-r--r--xmake/plugins/pack/wix/main.lua4
-rw-r--r--xmake/plugins/pack/xpack.lua12
17 files changed, 87 insertions, 75 deletions
diff --git a/core/xpack.lua b/core/xpack.lua
index c0c6ae880..f0283d2a4 100644
--- a/core/xpack.lua
+++ b/core/xpack.lua
@@ -49,11 +49,11 @@ xpack("xmake")
else
url_curl = url_curl .. "-win32-mingw.zip"
end
- local archive_7z = path.join(package:buildir(), "7z.zip")
- local archive_curl = path.join(package:buildir(), "curl.zip")
- local tmpdir_7z = path.join(package:buildir(), "7z")
- local tmpdir_curl = path.join(package:buildir(), "curl")
- local winenv_bindir = path.join(package:buildir(), "winenv", "bin")
+ local archive_7z = path.join(package:builddir(), "7z.zip")
+ local archive_curl = path.join(package:builddir(), "curl.zip")
+ local tmpdir_7z = path.join(package:builddir(), "7z")
+ local tmpdir_curl = path.join(package:builddir(), "curl")
+ local winenv_bindir = path.join(package:builddir(), "winenv", "bin")
os.mkdir(winenv_bindir)
http.download(url_7z, archive_7z, {insecure = global.get("insecure-ssl")})
archive.extract(archive_7z, tmpdir_7z)
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 8f09e741e..df2be796c 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -824,19 +824,25 @@ function _instance:sourcedir()
end
-- get the build directory
-function _instance:buildir()
- local buildir = self._BUILDIR
- if not buildir then
+function _instance:builddir()
+ local builddir = self._BUILDDIR
+ if not builddir then
if self:is_local() then
local name = self:name():lower():gsub("::", "_")
local rootdir = path.join(config.builddir({absolute = true}), ".packages", name:sub(1, 1):lower(), name, self:version_str())
- buildir = path.join(rootdir, "cache", "build_" .. self:buildhash():sub(1, 8))
+ builddir = path.join(rootdir, "cache", "build_" .. self:buildhash():sub(1, 8))
else
- buildir = "build_" .. self:buildhash():sub(1, 8)
+ builddir = "build_" .. self:buildhash():sub(1, 8)
end
- self._BUILDIR = buildir
+ self._BUILDDIR = builddir
end
- return buildir
+ return builddir
+end
+
+-- get the build directory (deprecated)
+function _instance:buildir()
+ utils.warning("package:buildir() has been deprecated, please use package:builddir()")
+ return self:builddir()
end
-- get the cached directory of this package
diff --git a/xmake/core/sandbox/modules/import/core/sandbox/module.lua b/xmake/core/sandbox/modules/import/core/sandbox/module.lua
index df1d31240..7c8a77735 100644
--- a/xmake/core/sandbox/modules/import/core/sandbox/module.lua
+++ b/xmake/core/sandbox/modules/import/core/sandbox/module.lua
@@ -204,21 +204,21 @@ function core_sandbox_module._native_moduleinfo(module_fullpath, modulekind)
local programdir = path.normalize(os.programdir())
local modulename = path.basename(module_fullpath)
local modulehash = hash.strhash32(projectdir)
- local buildir
+ local builddir
local is_global = false
local modulepath
if projectdir:startswith(programdir) then
is_global = true
- buildir = path.join(global.directory(), "cache", "modules", modulehash)
+ builddir = path.join(global.directory(), "cache", "modules", modulehash)
modulepath = path.join("@programdir", path.relative(projectdir, programdir))
elseif os.isfile(os.projectfile()) then
- buildir = path.join(config.directory(), "cache", "modules", modulehash)
+ builddir = path.join(config.directory(), "cache", "modules", modulehash)
modulepath = path.relative(projectdir, os.projectdir())
else
- buildir = path.join(projectdir, "cache", "modules", modulehash)
+ builddir = path.join(projectdir, "cache", "modules", modulehash)
modulepath = projectdir
end
- return {buildir = buildir, projectdir = projectdir, is_global = is_global, modulename = modulename, modulekind = modulekind, modulepath = modulepath}
+ return {builddir = builddir, projectdir = projectdir, is_global = is_global, modulename = modulename, modulekind = modulekind, modulepath = modulepath}
end
-- build module
@@ -232,10 +232,10 @@ function core_sandbox_module._build_module(moduleinfo)
return nil, "unknown module kind!"
end
utils.cprint("${color.build.target}building native %s module(%s) in %s ...", modulekind_str, moduleinfo.modulename, moduleinfo.modulepath)
- local buildir = moduleinfo.buildir
+ local builddir = moduleinfo.builddir
local projectdir = moduleinfo.projectdir
- local envs = {XMAKE_CONFIGDIR = buildir}
- local argv = {"config", "-o", buildir, "-a", xmake.arch()}
+ local envs = {XMAKE_CONFIGDIR = builddir}
+ local argv = {"config", "-o", builddir, "-a", xmake.arch()}
core_sandbox_module._add_builtin_argv(argv, projectdir)
local ok, errors = os.execv(os.programfile(), argv, {envs = envs, curdir = projectdir})
if ok ~= 0 then
@@ -254,7 +254,7 @@ end
function core_sandbox_module._load_from_binary(module_fullpath, opt)
opt = opt or {}
local moduleinfo = core_sandbox_module._native_moduleinfo(module_fullpath, MODULE_KIND_BINARY)
- local binaryfiles = os.files(path.join(moduleinfo.buildir, "module_*"))
+ local binaryfiles = os.files(path.join(moduleinfo.builddir, "module_*"))
if #binaryfiles == 0 or (not moduleinfo.is_global and opt.always_build) then
local ok, errors = core_sandbox_module._build_module(moduleinfo)
if not ok then
@@ -264,7 +264,7 @@ function core_sandbox_module._load_from_binary(module_fullpath, opt)
end
local module
if #binaryfiles == 0 then
- binaryfiles = os.files(path.join(moduleinfo.buildir, "module_*"))
+ binaryfiles = os.files(path.join(moduleinfo.builddir, "module_*"))
end
if #binaryfiles > 0 then
module = {}
@@ -297,7 +297,7 @@ end
function core_sandbox_module._load_from_shared(module_fullpath, opt)
opt = opt or {}
local moduleinfo = core_sandbox_module._native_moduleinfo(module_fullpath, MODULE_KIND_SHARED)
- local libraryfiles = os.files(path.join(moduleinfo.buildir, "*module_*"))
+ local libraryfiles = os.files(path.join(moduleinfo.builddir, "*module_*"))
if #libraryfiles == 0 or (not moduleinfo.is_global and opt.always_build) then
local ok, errors = core_sandbox_module._build_module(moduleinfo)
if not ok then
@@ -307,7 +307,7 @@ function core_sandbox_module._load_from_shared(module_fullpath, opt)
end
local module
if #libraryfiles == 0 then
- libraryfiles = os.files(path.join(moduleinfo.buildir, "*module_*"))
+ libraryfiles = os.files(path.join(moduleinfo.builddir, "*module_*"))
end
if #libraryfiles > 0 then
local script, errors1, errors2
diff --git a/xmake/modules/package/manager/conan/v1/install_package.lua b/xmake/modules/package/manager/conan/v1/install_package.lua
index d0928c28e..37fdaa856 100644
--- a/xmake/modules/package/manager/conan/v1/install_package.lua
+++ b/xmake/modules/package/manager/conan/v1/install_package.lua
@@ -128,16 +128,16 @@ function main(conan, name, opt)
local configs = opt.configs or {}
-- get build directory
- local buildir = _conan_get_build_directory(name)
+ local builddir = _conan_get_build_directory(name)
-- clean the build directory
- os.tryrm(buildir)
- if not os.isdir(buildir) then
- os.mkdir(buildir)
+ os.tryrm(builddir)
+ if not os.isdir(builddir) then
+ os.mkdir(builddir)
end
-- enter build directory
- local oldir = os.cd(buildir)
+ local oldir = os.cd(builddir)
-- install xmake generator
_conan_install_xmake_generator(conan)
diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua
index 7b56b7d9c..d3d109a7e 100644
--- a/xmake/modules/package/manager/conan/v2/install_package.lua
+++ b/xmake/modules/package/manager/conan/v2/install_package.lua
@@ -287,16 +287,16 @@ function main(conan, name, opt)
local configs = opt.configs or {}
-- get build directory
- local buildir = _conan_get_build_directory(name)
+ local builddir = _conan_get_build_directory(name)
-- clean the build directory
- os.tryrm(buildir)
- if not os.isdir(buildir) then
- os.mkdir(buildir)
+ os.tryrm(builddir)
+ if not os.isdir(builddir) then
+ os.mkdir(builddir)
end
-- enter build directory
- local oldir = os.cd(buildir)
+ local oldir = os.cd(builddir)
-- install xmake generator
_conan_install_xmake_generator(conan)
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 8fd001d71..fb38858a8 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -984,7 +984,7 @@ end
-- enter build directory
function _enter_buildir(package, opt)
- local buildir = opt.buildir or package:buildir()
+ local buildir = opt.buildir or package:builddir()
os.mkdir(path.join(buildir, "install"))
return os.cd(buildir)
end
diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua
index 7f3260682..9209300ac 100644
--- a/xmake/modules/package/tools/meson.lua
+++ b/xmake/modules/package/tools/meson.lua
@@ -31,7 +31,7 @@ function _get_buildir(package, opt)
if opt and opt.buildir then
return opt.buildir
else
- _g.buildir = _g.buildir or package:buildir()
+ _g.buildir = _g.buildir or package:builddir()
return _g.buildir
end
end
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index 25bc0f021..0f19c6a88 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -315,7 +315,7 @@ function _get_configs(package, configs, opt)
if shflags and #shflags > 0 then
table.insert(configs, "--shflags=" .. table.concat(shflags, ' '))
end
- local buildir = opt.buildir or package:buildir()
+ local buildir = opt.buildir or package:builddir()
if buildir then
table.insert(configs, "--buildir=" .. buildir)
end
diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua
index 921d68185..c2ca3610b 100644
--- a/xmake/modules/private/action/trybuild/cmake.lua
+++ b/xmake/modules/private/action/trybuild/cmake.lua
@@ -28,13 +28,13 @@ import("lib.detect.find_tool")
import("private.utils.toolchain", {alias = "toolchain_utils"})
-- get build directory
-function _get_buildir()
+function _get_builddir()
return config.builddir() or "build"
end
-- get artifacts directory
function _get_artifacts_dir()
- return path.absolute(path.join(_get_buildir(), "artifacts"))
+ return path.absolute(path.join(_get_builddir(), "artifacts"))
end
-- get the build environment
@@ -515,11 +515,11 @@ end
-- do clean
function clean()
- local buildir = _get_buildir()
- if os.isdir(buildir) then
- local configfile = find_file("[mM]akefile", buildir) or (is_plat("windows") and find_file("*.sln", buildir))
+ local builddir = _get_builddir()
+ if os.isdir(builddir) then
+ local configfile = find_file("[mM]akefile", builddir) or (is_plat("windows") and find_file("*.sln", builddir))
if configfile then
- local oldir = os.cd(buildir)
+ local oldir = os.cd(builddir)
if is_plat("windows") then
local runenvs = _get_msvc_runenvs()
local msbuild = find_tool("msbuild", {envs = runenvs})
@@ -544,7 +544,7 @@ function build()
if not os.isdir(artifacts_dir) then
os.mkdir(artifacts_dir)
end
- os.cd(_get_buildir())
+ os.cd(_get_builddir())
opt.artifacts_dir = artifacts_dir
-- exists $CMAKE_GENERATOR? use it
diff --git a/xmake/modules/private/action/trybuild/meson.lua b/xmake/modules/private/action/trybuild/meson.lua
index d0a4f5197..1896653c6 100644
--- a/xmake/modules/private/action/trybuild/meson.lua
+++ b/xmake/modules/private/action/trybuild/meson.lua
@@ -26,13 +26,13 @@ import("lib.detect.find_file")
import("lib.detect.find_tool")
-- get build directory
-function _get_buildir()
+function _get_builddir()
return config.builddir() or "build"
end
-- get artifacts directory
function _get_artifacts_dir()
- return path.absolute(path.join(_get_buildir(), "artifacts"))
+ return path.absolute(path.join(_get_builddir(), "artifacts"))
end
-- is cross compilation?
@@ -73,8 +73,8 @@ function _get_buildenv(key)
end
-- get cross file
-function _get_cross_file(buildir)
- local crossfile = path.join(buildir, "cross_file.txt")
+function _get_cross_file(builddir)
+ local crossfile = path.join(builddir, "cross_file.txt")
if not os.isfile(crossfile) then
local file = io.open(crossfile, "w")
-- binaries
@@ -209,7 +209,7 @@ function _get_cross_file(buildir)
end
-- get configs
-function _get_configs(artifacts_dir, buildir)
+function _get_configs(artifacts_dir, builddir)
-- add prefix
local configs = {"--prefix=" .. artifacts_dir}
@@ -227,11 +227,11 @@ function _get_configs(artifacts_dir, buildir)
-- add cross file
if _is_cross_compilation() then
- table.insert(configs, "--cross-file=" .. _get_cross_file(buildir))
+ table.insert(configs, "--cross-file=" .. _get_cross_file(builddir))
end
-- add build directory
- table.insert(configs, buildir)
+ table.insert(configs, builddir)
return configs
end
@@ -242,12 +242,12 @@ end
-- do clean
function clean()
- local buildir = _get_buildir()
- if os.isdir(buildir) then
- local configfile = find_file("build.ninja", buildir)
+ local builddir = _get_builddir()
+ if os.isdir(builddir) then
+ local configfile = find_file("build.ninja", builddir)
if configfile then
local ninja = assert(find_tool("ninja"), "ninja not found!")
- local ninja_argv = {"-C", buildir}
+ local ninja_argv = {"-C", builddir}
if option.get("verbose") or option.get("diagnosis") then
table.insert(ninja_argv, "-v")
end
@@ -255,7 +255,7 @@ function clean()
table.insert(ninja_argv, "clean")
os.vexecv(ninja.program, ninja_argv)
if option.get("all") then
- os.tryrm(buildir)
+ os.tryrm(builddir)
end
end
end
@@ -271,16 +271,16 @@ function build()
end
-- generate makefile
- local buildir = _get_buildir()
+ local builddir = _get_builddir()
local meson = assert(find_tool("meson"), "meson not found!")
- local configfile = find_file("build.ninja", buildir)
+ local configfile = find_file("build.ninja", builddir)
if not configfile or os.mtime(config.filepath()) > os.mtime(configfile) then
- os.vexecv(meson.program, _get_configs(artifacts_dir, buildir))
+ os.vexecv(meson.program, _get_configs(artifacts_dir, builddir))
end
-- do build
local ninja = assert(find_tool("ninja"), "ninja not found!")
- local ninja_argv = {"-C", buildir}
+ local ninja_argv = {"-C", builddir}
if option.get("verbose") then
table.insert(ninja_argv, "-v")
end
diff --git a/xmake/modules/private/service/distcc_build/server_session.lua b/xmake/modules/private/service/distcc_build/server_session.lua
index 8e373d254..57f13a3a7 100644
--- a/xmake/modules/private/service/distcc_build/server_session.lua
+++ b/xmake/modules/private/service/distcc_build/server_session.lua
@@ -80,7 +80,7 @@ end
-- do clean
function server_session:clean()
vprint("%s: clean files in %s ..", self, self:workdir())
- os.tryrm(self:buildir())
+ os.tryrm(self:builddir())
os.tryrm(self:cachedir())
vprint("%s: clean files ok", self)
end
@@ -93,7 +93,7 @@ function server_session:compile(respmsg)
local stream = self:stream()
local cachekey = body.cachekey
local sourcename = body.sourcename
- local sourcedir = path.join(self:buildir(), (hash.uuid4():gsub("-", "")))
+ local sourcedir = path.join(self:builddir(), (hash.uuid4():gsub("-", "")))
local sourcefile = path.join(sourcedir, sourcename)
local objectfile = (cachekey and path.join(self:cachedir(), cachekey:sub(1, 2), cachekey) or sourcefile) .. ".o"
local objectfile_infofile = objectfile .. ".txt"
@@ -192,7 +192,7 @@ function server_session:workdir()
end
-- get build directory
-function server_session:buildir()
+function server_session:builddir()
return path.join(self:workdir(), "build")
end
diff --git a/xmake/plugins/pack/main.lua b/xmake/plugins/pack/main.lua
index b108be790..dd599a61d 100644
--- a/xmake/plugins/pack/main.lua
+++ b/xmake/plugins/pack/main.lua
@@ -52,7 +52,7 @@ end
function _load_package(package)
-- ensure build and output directories
- os.tryrm(package:buildir())
+ os.tryrm(package:builddir())
os.mkdir(package:outputdir())
-- load it
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 64c002042..d252d5e4f 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -254,7 +254,7 @@ end
function _pack_nsis(makensis, package)
-- install the initial specfile
- local specfile = path.join(package:buildir(), package:basename() .. ".nsi")
+ local specfile = path.join(package:builddir(), package:basename() .. ".nsi")
if not os.isfile(specfile) then
local specfile_template = package:get("specfile") or path.join(os.programdir(), "scripts", "xpack", "nsis", "makensis.nsi")
os.cp(specfile_template, specfile)
diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua
index 91284edc0..47ab74eee 100644
--- a/xmake/plugins/pack/runself/main.lua
+++ b/xmake/plugins/pack/runself/main.lua
@@ -108,7 +108,7 @@ end
function _pack_runself(makeself, package)
-- install the initial specfile
- local specfile = path.join(package:buildir(), package:basename() .. ".lsm")
+ local specfile = path.join(package:builddir(), package:basename() .. ".lsm")
if not os.isfile(specfile) then
local specfile_template = package:get("specfile") or path.join(os.programdir(), "scripts", "xpack", "runself", "makeself.lsm")
os.cp(specfile_template, specfile, {writeable = true})
diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua
index 72b76563e..e8600427a 100644
--- a/xmake/plugins/pack/srpm/main.lua
+++ b/xmake/plugins/pack/srpm/main.lua
@@ -57,7 +57,7 @@ end
-- get archive file
function _get_archivefile(package)
- return path.absolute(path.join(package:buildir(), package:basename() .. ".tar.gz"))
+ return path.absolute(path.join(package:builddir(), package:basename() .. ".tar.gz"))
end
-- translate the file path
@@ -202,7 +202,7 @@ function _pack_srpm(rpmbuild, package)
end
-- install the initial specfile
- local specfile = path.join(package:buildir(), package:basename() .. ".spec")
+ local specfile = path.join(package:builddir(), package:basename() .. ".spec")
if not os.isfile(specfile) then
local specfile_template = package:get("specfile") or path.join(os.programdir(), "scripts", "xpack", "srpm", "srpm.spec")
os.cp(specfile_template, specfile, {writeable = true})
@@ -263,8 +263,8 @@ function _pack_srpm(rpmbuild, package)
-- pack srpm package
os.vrunv(rpmbuild, {"-bs", specfile,
- "--define", "_topdir " .. package:buildir(),
- "--define", "_sourcedir " .. package:buildir(),
+ "--define", "_topdir " .. package:builddir(),
+ "--define", "_sourcedir " .. package:builddir(),
"--define", "_srcrpmdir " .. package:outputdir()})
-- pack rpm package
diff --git a/xmake/plugins/pack/wix/main.lua b/xmake/plugins/pack/wix/main.lua
index a99070def..5d04eb7f5 100644
--- a/xmake/plugins/pack/wix/main.lua
+++ b/xmake/plugins/pack/wix/main.lua
@@ -240,7 +240,7 @@ function _get_specvars(package)
rtf_string = _to_rtf_string(io.readfile(licensefile))
end
- local rtf_file = path.join(package:buildir(), "license.rtf")
+ local rtf_file = path.join(package:builddir(), "license.rtf")
io.writefile(rtf_file, rtf_string)
return rtf_file
end
@@ -258,7 +258,7 @@ end
function _pack_wix(wix, package)
-- install the initial specfile
- local specfile = path.join(package:buildir(), package:basename() .. ".wxs")
+ local specfile = path.join(package:builddir(), package:basename() .. ".wxs")
if not os.isfile(specfile) then
local specfile_template = package:get("specfile") or path.join(os.programdir(), "scripts", "xpack", "wix", "msi.wxs")
os.cp(specfile_template, specfile)
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua
index c166c78d8..780d6ca36 100644
--- a/xmake/plugins/pack/xpack.lua
+++ b/xmake/plugins/pack/xpack.lua
@@ -256,10 +256,16 @@ function xpack:with_binary()
end
-- get the build directory
-function xpack:buildir()
+function xpack:builddir()
return path.join(config.builddir(), ".xpack", self:name())
end
+-- get the build directory (deprecated)
+function xpack:buildir()
+ wprint("xpack:buildir() has been deprecated, please use xpack:builddir()")
+ return self:builddir()
+end
+
-- get the output directory
function xpack:outputdir()
local outputdir = option.get("outputdir")
@@ -420,7 +426,7 @@ end
-- get the installed root directory, this is just a temporary sandbox installation path,
-- we may replace it with the actual installation path in the specfile
function xpack:install_rootdir()
- return path.join(self:buildir(), "installed", self:format())
+ return path.join(self:builddir(), "installed", self:format())
end
-- get the installed directory
@@ -440,7 +446,7 @@ end
-- get the source root directory
function xpack:source_rootdir()
- return path.join(self:buildir(), "source", self:format())
+ return path.join(self:builddir(), "source", self:format())
end
-- get the source directory