summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-07-22 18:25:16 +0200
committerArthur LAURENT <[email protected]>2024-07-22 18:25:16 +0200
commitaf19722ebd25a7c96b3e3b042e4e48cb690b5e63 (patch)
tree173db741391f4934df06b6c0449e04e63105261b
parentbbe7745ad8ccde3f39f1c1e468fd2d96ca7cb3f5 (diff)
improve moduleonly support
-rw-r--r--tests/projects/c++/modules/packages/my-repo/packages/b/bar2/xmake.lua2
-rw-r--r--xmake/actions/package/remote/main.lua3
-rw-r--r--xmake/core/package/package.lua7
-rw-r--r--xmake/modules/private/action/require/impl/package.lua4
-rw-r--r--xmake/rules/c++/modules/xmake.lua4
5 files changed, 14 insertions, 6 deletions
diff --git a/tests/projects/c++/modules/packages/my-repo/packages/b/bar2/xmake.lua b/tests/projects/c++/modules/packages/my-repo/packages/b/bar2/xmake.lua
index ffa208234..8d7f969bc 100644
--- a/tests/projects/c++/modules/packages/my-repo/packages/b/bar2/xmake.lua
+++ b/tests/projects/c++/modules/packages/my-repo/packages/b/bar2/xmake.lua
@@ -1,5 +1,5 @@
package("bar2")
- set_kind("library")
+ set_kind("library", {moduleonly = true})
set_sourcedir(path.join(os.scriptdir(), "src"))
on_install(function(package)
diff --git a/xmake/actions/package/remote/main.lua b/xmake/actions/package/remote/main.lua
index 028c1f966..f73126618 100644
--- a/xmake/actions/package/remote/main.lua
+++ b/xmake/actions/package/remote/main.lua
@@ -54,6 +54,8 @@ function _package_remote(target)
file:print(" set_kind(\"binary\")")
elseif target:is_headeronly() then
file:print(" set_kind(\"library\", {headeronly = true})")
+ elseif target:is_moduleonly() then
+ file:print(" set_kind(\"library\", {moduleonly = true})")
end
local homepage = option.get("homepage")
if homepage then
@@ -122,6 +124,7 @@ function _package_target(target)
, static = _package_remote
, shared = _package_remote
, headeronly = _package_remote
+ , moduleonly = _package_remote
}
local kind = target:kind()
local script = scripts[kind]
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index b4249c6a0..174e4eb88 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -572,6 +572,11 @@ function _instance:is_headeronly()
return self:is_library() and self:extraconf("kind", "library", "headeronly")
end
+-- is module only?
+function _instance:is_moduleonly()
+ return self:is_library() and self:extraconf("kind", "library", "moduleonly")
+end
+
-- is top level? user top requires in xmake.lua
function _instance:is_toplevel()
local requireinfo = self:requireinfo()
@@ -2399,7 +2404,7 @@ function _instance:_generate_build_configs(configs, opt)
end
-- check links for library
- if self:is_library() and not self:is_headeronly() then
+ if self:is_library() and not self:is_headeronly() and not self:is_moduleonly() then
local links = table.wrap(configs.links)
local ldflags = table.wrap(configs.ldflags)
local frameworks = table.wrap(configs.frameworks)
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 8d64b7891..1c7eaf9e5 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -553,9 +553,9 @@ function _init_requireinfo(requireinfo, package, opt)
requireinfo.configs.asan = project.policy("build.sanitizer.address")
end
end
- -- but we will ignore some configs for buildhash in the headeronly and host/binary package
+ -- but we will ignore some configs for buildhash in the headeronly, moduleonly and host/binary package
-- @note on_test still need these configs, @see https://github.com/xmake-io/xmake/issues/4124
- if package:is_headeronly() or (package:is_binary() and not package:is_cross()) then
+ if package:is_headeronly() or package:is_moduleonly() or (package:is_binary() and not package:is_cross()) then
requireinfo.ignored_configs_for_buildhash = {"runtimes", "toolchains", "lto", "asan", "pic"}
end
end
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index 90ba66c81..2fed09744 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -97,7 +97,7 @@ rule("c++.build.modules.builder")
-- append to sourcebatch
for _, package_module_data in table.orderpairs(package_modules_data) do
table.insert(sourcebatch.sourcefiles, package_module_data.file)
- target:fileconfig_set(package_module_data.file, {external = true, defines = package_module_data.metadata.defines})
+ target:fileconfig_set(package_module_data.file, {external = package_module_data.external, defines = package_module_data.metadata.defines})
end
end
@@ -160,7 +160,7 @@ rule("c++.build.modules.builder")
-- append to sourcebatch
for _, package_module_data in table.orderpairs(package_modules_data) do
table.insert(sourcebatch.sourcefiles, package_module_data.file)
- target:fileconfig_set(package_module_data.file, {external = true, defines = package_module_data.metadata.defines})
+ target:fileconfig_set(package_module_data.file, {external = package_module_data.external, defines = package_module_data.metadata.defines})
end
end