diff options
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/base/memory.lua | 34 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 24 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/memory.lua | 24 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 1 |
4 files changed, 74 insertions, 9 deletions
diff --git a/xmake/core/base/memory.lua b/xmake/core/base/memory.lua new file mode 100644 index 000000000..da6f4b1af --- /dev/null +++ b/xmake/core/base/memory.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, TBOOX Open Source Group. +-- +-- @author ruki +-- @file memory.lua +-- + +-- define module +local memory = memory or {} + +-- load modules +local os = require("base/os") + +-- get memory info +function memory.info(name) + local meminfo = os._meminfo() + return name and meminfo[name] or meminfo +end + +-- return module +return memory diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 392047a39..7dd0f3aad 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -33,15 +33,16 @@ local process = require("base/process") -- save original interfaces os._uid = os._uid or os.uid os._gid = os._gid or os.gid -os._getpid = os._getpid or os.getpid -os._exit = os._exit or os.exit -os._mkdir = os._mkdir or os.mkdir -os._rmdir = os._rmdir or os.rmdir -os._tmpdir = os._tmpdir or os.tmpdir -os._setenv = os._setenv or os.setenv -os._getenvs = os._getenvs or os.getenvs -os._cpuinfo = os._cpuinfo or os.cpuinfo -os._readlink = os._readlink or os.readlink +os._getpid = os._getpid or os.getpid +os._exit = os._exit or os.exit +os._mkdir = os._mkdir or os.mkdir +os._rmdir = os._rmdir or os.rmdir +os._tmpdir = os._tmpdir or os.tmpdir +os._setenv = os._setenv or os.setenv +os._getenvs = os._getenvs or os.getenvs +os._cpuinfo = os._cpuinfo or os.cpuinfo +os._meminfo = os._meminfo or os.meminfo +os._readlink = os._readlink or os.readlink -- syserror code os.SYSERR_UNKNOWN = -1 @@ -1284,6 +1285,11 @@ function os.cpuinfo(name) return require("base/cpu").info(name) end +-- get memory info +function os.meminfo(name) + return require("base/memory").info(name) +end + -- get the default parallel jobs number function os.default_njob() local njob = math.ceil(os.cpuinfo().ncpu * 3 / 2) diff --git a/xmake/core/sandbox/modules/import/core/base/memory.lua b/xmake/core/sandbox/modules/import/core/base/memory.lua new file mode 100644 index 000000000..b8fffbad6 --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/base/memory.lua @@ -0,0 +1,24 @@ +--!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, TBOOX Open Source Group. +-- +-- @author ruki +-- @file memory.lua +-- + +-- load modules +return require("base/memory") + + diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index df47653b9..4c2509cc9 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -65,6 +65,7 @@ sandbox_os.joinenvs = os.joinenvs sandbox_os.pbpaste = os.pbpaste sandbox_os.pbcopy = os.pbcopy sandbox_os.cpuinfo = os.cpuinfo +sandbox_os.meminfo = os.meminfo sandbox_os.default_njob = os.default_njob sandbox_os.emptydir = os.emptydir sandbox_os.filesize = os.filesize |
