summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-10-17 22:54:12 +0800
committerruki <[email protected]>2022-10-17 22:54:12 +0800
commit3cf635758acdcdafcc7199adc6e05d8747c5910a (patch)
tree198c69aeb510278303445b791106143c2f29c5ea
parentfcf701fe3d96f8c24d5bf708a8b0b229c6977bd5 (diff)
add component stub
-rw-r--r--tests/projects/package/components/xmake.lua4
-rw-r--r--xmake/core/package/component.lua92
-rw-r--r--xmake/core/package/package.lua2
3 files changed, 95 insertions, 3 deletions
diff --git a/tests/projects/package/components/xmake.lua b/tests/projects/package/components/xmake.lua
index 7851638c5..1b0d39c2d 100644
--- a/tests/projects/package/components/xmake.lua
+++ b/tests/projects/package/components/xmake.lua
@@ -56,7 +56,7 @@ package("sfml")
add_configs("main", {description = "Link to the sfml-main library", default = true, type = "boolean"})
end
- on_components("graphics", function (package, component)
+ on_component("graphics", function (package, component)
local e = package:config("shared") and "" or "-s"
component:add("links", "sfml-graphics" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
@@ -65,7 +65,7 @@ package("sfml")
end
end)
- on_components("window", function (package, component)
+ on_component("window", function (package, component)
local e = package:config("shared") and "" or "-s"
component:add("links", "sfml-window" .. e)
if package:is_plat("windows", "mingw") and not package:config("shared") then
diff --git a/xmake/core/package/component.lua b/xmake/core/package/component.lua
new file mode 100644
index 000000000..d9f9b78dd
--- /dev/null
+++ b/xmake/core/package/component.lua
@@ -0,0 +1,92 @@
+--!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 component.lua
+--
+
+-- define module
+local component = component or {}
+local _instance = _instance or {}
+
+-- load modules
+local os = require("base/os")
+local io = require("base/io")
+local path = require("base/path")
+local utils = require("base/utils")
+local table = require("base/table")
+local option = require("base/option")
+local hashset = require("base/hashset")
+local scopeinfo = require("base/scopeinfo")
+local interpreter = require("base/interpreter")
+local memcache = require("cache/memcache")
+local config = require("project/config")
+
+-- new an instance
+function _instance.new(name, info, opt)
+ opt = opt or {}
+ local instance = table.inherit(_instance)
+ instance._NAME = name
+ instance._INFO = info
+ return instance
+end
+
+-- get the component name
+function _instance:name()
+ return self._NAME
+end
+
+-- get the type: component
+function _instance:type()
+ return "component"
+end
+
+-- get the component configuration
+function _instance:get(name)
+ return self._INFO:get(name)
+end
+
+-- set the value to the component info
+function _instance:set(name, ...)
+ self._INFO:apival_set(name, ...)
+end
+
+-- add the value to the component info
+function _instance:add(name, ...)
+ self._INFO:apival_add(name, ...)
+end
+
+-- get the extra configuration
+function _instance:extraconf(name, item, key)
+ local conf = self._INFO:extraconf(name, item, key)
+ if conf == nil and self:base() then
+ conf = self:base():extraconf(name, item, key)
+ end
+ return conf
+end
+
+-- set the extra configuration
+function _instance:extraconf_set(name, item, key, value)
+ return self._INFO:extraconf_set(name, item, key, value)
+end
+
+-- new component
+function component.new(name, info, opt)
+ return _instance.new(name, info, opt)
+end
+
+-- return module
+return component
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 5d521f7a4..e8df7b553 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -9,7 +9,7 @@
-- 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 package governing permissions and
+-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-present, TBOOX Open Source Group.