summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/package/package.lua10
-rw-r--r--xmake/core/platform/menu.lua2
-rw-r--r--xmake/core/sandbox/modules/import/core/base/scheduler.lua6
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/error.lua36
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/getmetatable.lua32
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/next.lua36
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/pcall.lua36
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/rawequal.lua33
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/rawget.lua34
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/rawset.lua33
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/select.lua36
-rw-r--r--xmake/core/sandbox/modules/import/lib/lua/setmetatable.lua36
12 files changed, 327 insertions, 3 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index ca5d84204..3d98a3743 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -3116,12 +3116,20 @@ end
--
-- @param opt the options, e.g. {localdir = true}
-- - localdir: return the local project packages directory (build/.packages)
--- instead of the global directory (~/.xmake/packages)
+-- instead of the global directory (~/.xmake/packages),
+-- it can be overridden with `XMAKE_PKG_LOCALDIR`
--
-- @return the install directory path
--
function package.installdir(opt)
if opt and opt.localdir then
+ -- the parent process passes its local directory to the sub-process which builds
+ -- a package, so the packages it installs locally land in the same place and are
+ -- not installed twice, @see https://github.com/xmake-io/xmake/issues/7716
+ local localdir = os.getenv("XMAKE_PKG_LOCALDIR")
+ if localdir then
+ return path.normalize(path.absolute(localdir))
+ end
return path.join(config.builddir({absolute = true}), ".packages")
end
local installdir = package._INSTALLDIR
diff --git a/xmake/core/platform/menu.lua b/xmake/core/platform/menu.lua
index cec901ee8..77a57381d 100644
--- a/xmake/core/platform/menu.lua
+++ b/xmake/core/platform/menu.lua
@@ -42,7 +42,7 @@ function _remote_build_is_connected()
local projectdir = os.projectdir()
local projectfile = os.projectfile()
if projectfile and os.isfile(projectfile) and projectdir then
- local workdir = path.join(config.directory(), "remote_build")
+ local workdir = path.join(config.directory(), "service", "remote_build")
local statusfile = path.join(workdir, "status.txt")
if os.isfile(statusfile) then
local status = io.load(statusfile)
diff --git a/xmake/core/sandbox/modules/import/core/base/scheduler.lua b/xmake/core/sandbox/modules/import/core/base/scheduler.lua
index 222bee391..a3f9741c3 100644
--- a/xmake/core/sandbox/modules/import/core/base/scheduler.lua
+++ b/xmake/core/sandbox/modules/import/core/base/scheduler.lua
@@ -96,7 +96,11 @@ end
-- resume the given coroutine
function sandbox_core_base_scheduler.co_resume(co, ...)
- return scheduler:resume(co:thread(), ...)
+ local ok, errors = scheduler:co_resume(co, ...)
+ if not ok then
+ raise(errors)
+ end
+ return ok, errors
end
-- suspend the current coroutine
diff --git a/xmake/core/sandbox/modules/import/lib/lua/error.lua b/xmake/core/sandbox/modules/import/lib/lua/error.lua
new file mode 100644
index 000000000..4f38f1647
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/error.lua
@@ -0,0 +1,36 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file error.lua
+--
+
+-- the native lua `error`
+--
+-- it is not in the sandbox by default, `raise` is the one to use: it formats the
+-- message and it is what `try`/`catch` understands. `error` is the plain one, for the
+-- code which wants to throw a value rather than a message
+--
+-- @note the same in lua 5.1 and 5.4
+--
+-- e.g.
+--
+-- import("lib.lua.error")
+--
+-- error("something went wrong")
+-- error({code = 1}) -- a value, not a message
+--
+return error
diff --git a/xmake/core/sandbox/modules/import/lib/lua/getmetatable.lua b/xmake/core/sandbox/modules/import/lib/lua/getmetatable.lua
new file mode 100644
index 000000000..fcef76eb3
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/getmetatable.lua
@@ -0,0 +1,32 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file getmetatable.lua
+--
+
+-- the native lua `getmetatable`
+--
+-- @note the same in lua 5.1 and 5.4, it returns the `__metatable` field when the
+-- metatable is protected
+--
+-- e.g.
+--
+-- import("lib.lua.getmetatable")
+--
+-- local mt = getmetatable(obj)
+--
+return getmetatable
diff --git a/xmake/core/sandbox/modules/import/lib/lua/next.lua b/xmake/core/sandbox/modules/import/lib/lua/next.lua
new file mode 100644
index 000000000..65313dd1a
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/next.lua
@@ -0,0 +1,36 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file next.lua
+--
+
+-- the native lua `next`
+--
+-- it is not in the sandbox by default, `pairs` covers the iteration of a table. `next`
+-- is what is left for the two things `pairs` cannot say: whether a table is empty, and
+-- stepping a traversal by hand
+--
+-- @note the same in lua 5.1 and 5.4
+--
+-- e.g.
+--
+-- import("lib.lua.next")
+--
+-- if next(tbl) == nil then ... end -- the table is empty
+-- local key, value = next(tbl) -- the first entry, in no particular order
+--
+return next
diff --git a/xmake/core/sandbox/modules/import/lib/lua/pcall.lua b/xmake/core/sandbox/modules/import/lib/lua/pcall.lua
new file mode 100644
index 000000000..1ad150943
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/pcall.lua
@@ -0,0 +1,36 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file pcall.lua
+--
+
+-- the native lua `pcall`
+--
+-- it is not in the sandbox by default, `try`/`catch` is the idiomatic way to handle the
+-- errors of a script, and it keeps the traceback and the error message which xmake
+-- builds. `pcall` is the plain one, for the code which only needs a boolean
+--
+-- @note the same in lua 5.1 and 5.4. `xpcall` is not exported, its message handler
+-- takes the extra arguments only since 5.2
+--
+-- e.g.
+--
+-- import("lib.lua.pcall")
+--
+-- local ok, result = pcall(function () return 1 end)
+--
+return pcall
diff --git a/xmake/core/sandbox/modules/import/lib/lua/rawequal.lua b/xmake/core/sandbox/modules/import/lib/lua/rawequal.lua
new file mode 100644
index 000000000..b9f9ea683
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/rawequal.lua
@@ -0,0 +1,33 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file rawequal.lua
+--
+
+-- the native lua `rawequal`
+--
+-- it compares two values without going through the `__eq` metamethod
+--
+-- @note the same in lua 5.1 and 5.4
+--
+-- e.g.
+--
+-- import("lib.lua.rawequal")
+--
+-- if rawequal(a, b) then ... end
+--
+return rawequal
diff --git a/xmake/core/sandbox/modules/import/lib/lua/rawget.lua b/xmake/core/sandbox/modules/import/lib/lua/rawget.lua
new file mode 100644
index 000000000..fe5115001
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/rawget.lua
@@ -0,0 +1,34 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file rawget.lua
+--
+
+-- the native lua `rawget`
+--
+-- it reads a field of a table without going through its `__index` metamethod, so it
+-- sees what the table itself holds and not what its metatable would answer
+--
+-- @note the same in lua 5.1 and 5.4
+--
+-- e.g.
+--
+-- import("lib.lua.rawget")
+--
+-- local value = rawget(tbl, "key")
+--
+return rawget
diff --git a/xmake/core/sandbox/modules/import/lib/lua/rawset.lua b/xmake/core/sandbox/modules/import/lib/lua/rawset.lua
new file mode 100644
index 000000000..917bc3d86
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/rawset.lua
@@ -0,0 +1,33 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file rawset.lua
+--
+
+-- the native lua `rawset`
+--
+-- it writes a field of a table without going through its `__newindex` metamethod
+--
+-- @note the same in lua 5.1 and 5.4
+--
+-- e.g.
+--
+-- import("lib.lua.rawset")
+--
+-- rawset(tbl, "key", value)
+--
+return rawset
diff --git a/xmake/core/sandbox/modules/import/lib/lua/select.lua b/xmake/core/sandbox/modules/import/lib/lua/select.lua
new file mode 100644
index 000000000..45fb1bbc9
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/select.lua
@@ -0,0 +1,36 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file select.lua
+--
+
+-- the native lua `select`
+--
+-- it is not in the sandbox by default, the scripts of a project rarely need to look at
+-- a raw argument list, but it is the only way to count the arguments of a vararg
+-- function without losing the nils in it
+--
+-- @note the same in lua 5.1 and 5.4
+--
+-- e.g.
+--
+-- import("lib.lua.select")
+--
+-- local count = select("#", ...) -- how many arguments, nils included
+-- local second = select(2, ...) -- everything from the second one on
+--
+return select
diff --git a/xmake/core/sandbox/modules/import/lib/lua/setmetatable.lua b/xmake/core/sandbox/modules/import/lib/lua/setmetatable.lua
new file mode 100644
index 000000000..6f1d4c330
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/lib/lua/setmetatable.lua
@@ -0,0 +1,36 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file setmetatable.lua
+--
+
+-- the native lua `setmetatable`
+--
+-- it is not in the sandbox by default: a module which builds objects with metatables is
+-- a module which is hard to serialize and to cache, and xmake passes plain tables
+-- around on purpose. it is here for the code which really wants operator overloading or
+-- an `__index` fallback
+--
+-- @note the same in lua 5.1 and 5.4
+--
+-- e.g.
+--
+-- import("lib.lua.setmetatable")
+--
+-- local obj = setmetatable({}, {__index = function (tbl, key) return "?" end})
+--
+return setmetatable