Skip to content

Commit

Permalink
fix is_cross
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Feb 15, 2024
1 parent 0abc694 commit e0663e1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 102 deletions.
26 changes: 26 additions & 0 deletions xmake/core/project/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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?
--
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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, ...)

Expand Down
6 changes: 6 additions & 0 deletions xmake/core/project/project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)

Expand Down Expand Up @@ -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 }
Expand Down
94 changes: 15 additions & 79 deletions xmake/core/sandbox/modules/import/core/project/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
23 changes: 0 additions & 23 deletions xmake/core/sandbox/modules/is_cross.lua

This file was deleted.

0 comments on commit e0663e1

Please sign in to comment.