summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-02-16 00:04:03 +0800
committerruki <[email protected]>2024-02-16 00:04:03 +0800
commite0663e1dad8b060a07e07e21574374929c26de03 (patch)
tree243a991429818225f68c00c1f5810725d526da5d
parent0abc694eb2fd8efeb0150482e10c9d903c26de67 (diff)
fix is_cross
-rw-r--r--xmake/core/project/config.lua26
-rw-r--r--xmake/core/project/project.lua6
-rw-r--r--xmake/core/sandbox/modules/import/core/project/config.lua94
-rw-r--r--xmake/core/sandbox/modules/is_cross.lua23
4 files changed, 47 insertions, 102 deletions
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index a979ffa54..b77e6e93b 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -28,6 +28,7 @@ local path = require("base/path")
local table = require("base/table")
local utils = require("base/utils")
local option = require("base/option")
+local is_cross = require("base/private/is_cross")
-- always use workingdir?
--
@@ -96,6 +97,26 @@ function config.set(name, value, opt)
end
end
+-- get the current platform
+function config.plat()
+ return config.get("plat")
+end
+
+-- get the current architecture
+function config.arch()
+ return config.get("arch")
+end
+
+-- get the current mode
+function config.mode()
+ return config.get("mode")
+end
+
+-- get the current host
+function config.host()
+ return config.get("host")
+end
+
-- get all options
function config.options()
@@ -257,6 +278,11 @@ function config.is_arch(...)
return config.is_value("arch", ...)
end
+-- is cross-compilation?
+function config.is_cross()
+ return is_cross(config.plat(), config.arch())
+end
+
-- the current config is belong to the given config values?
function config.is_value(name, ...)
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 502ea5f3d..af92f8998 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -85,6 +85,11 @@ function project._api_is_arch(interp, ...)
return config.is_arch(...)
end
+-- the current platform and architecture is cross-complation?
+function project._api_is_cross(interp)
+ return config.is_cross()
+end
+
-- the current kind is belong to the given kinds?
function project._api_is_kind(interp, ...)
@@ -605,6 +610,7 @@ function project.apis()
, {"is_arch", project._api_is_arch }
, {"is_mode", project._api_is_mode }
, {"is_plat", project._api_is_plat }
+ , {"is_cross", project._api_is_cross }
, {"is_config", project._api_is_config }
-- get_xxx
, {"get_config", project._api_get_config }
diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua
index 8779555f9..21eefa453 100644
--- a/xmake/core/sandbox/modules/import/core/project/config.lua
+++ b/xmake/core/sandbox/modules/import/core/project/config.lua
@@ -27,69 +27,21 @@ local project = require("project/project")
local platform = require("platform/platform")
local raise = require("sandbox/modules/raise")
--- get the build directory
-function sandbox_core_project_config.buildir()
- return config.buildir()
-end
-
--- get the current platform
-function sandbox_core_project_config.plat()
- return config.get("plat")
-end
-
--- get the current architecture
-function sandbox_core_project_config.arch()
- return config.get("arch")
-end
-
--- get the current mode
-function sandbox_core_project_config.mode()
- return config.get("mode")
-end
-
--- get the current host
-function sandbox_core_project_config.host()
- return config.get("host")
-end
-
--- get the configuration file path
-function sandbox_core_project_config.filepath()
- local filepath = config.filepath()
- assert(filepath)
- return filepath
-end
-
--- get the configuration directory
-function sandbox_core_project_config.directory()
- local dir = config.directory()
- assert(dir)
- return dir
-end
-
--- get the given configuration from the current
-function sandbox_core_project_config.get(name)
- return config.get(name)
-end
-
--- set the given configuration to the current
---
--- @param name the name
--- @param value the value
--- @param opt the argument options, e.g. {readonly = false, force = false}
---
-function sandbox_core_project_config.set(name, value, opt)
- return config.set(name, value, opt)
-end
-
--- this config name is readonly?
-function sandbox_core_project_config.readonly(name)
- return config.readonly(name)
-end
-
--- load the configuration
-function sandbox_core_project_config.load(filepath, opt)
- return config.load(filepath, opt)
-end
+-- inherit some builtin interfaces
+sandbox_core_project_config.buildir = config.buildir
+sandbox_core_project_config.plat = config.plat
+sandbox_core_project_config.arch = config.arch
+sandbox_core_project_config.mode = config.mode
+sandbox_core_project_config.host = config.host
+sandbox_core_project_config.get = config.get
+sandbox_core_project_config.set = config.set
+sandbox_core_project_config.directory = config.directory
+sandbox_core_project_config.filepath = config.filepath
+sandbox_core_project_config.readonly = config.readonly
+sandbox_core_project_config.load = config.load
+sandbox_core_project_config.read = config.read
+sandbox_core_project_config.clear = config.clear
+sandbox_core_project_config.dump = config.dump
-- save the configuration
function sandbox_core_project_config.save(filepath, opt)
@@ -99,21 +51,5 @@ function sandbox_core_project_config.save(filepath, opt)
end
end
--- read the value from the configuration file directly
-function sandbox_core_project_config.read(name)
- return config.read(name)
-end
-
--- clear the configuration
-function sandbox_core_project_config.clear()
- config.clear()
-end
-
--- dump the configuration
-function sandbox_core_project_config.dump()
- config.dump()
-end
-
-
-- return module
return sandbox_core_project_config
diff --git a/xmake/core/sandbox/modules/is_cross.lua b/xmake/core/sandbox/modules/is_cross.lua
deleted file mode 100644
index 09b4e0ed4..000000000
--- a/xmake/core/sandbox/modules/is_cross.lua
+++ /dev/null
@@ -1,23 +0,0 @@
---!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 is_cross.lua
---
-
--- return module
-return require("base/private/is_cross")
-