diff options
| author | ruki <[email protected]> | 2022-01-25 15:20:51 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-25 15:20:51 +0800 |
| commit | e219035a8e884bc3bbae0c57c122cefa4cd66b28 (patch) | |
| tree | 89d5cd2228816892edc12176fadabbea84634b11 | |
| parent | db60a26fa1334c1175c8a2a549a67b827a01978a (diff) | |
| parent | a314a9b8d4131701a4dcd6140765836d092d3bc3 (diff) | |
Merge pull request #2010 from xmake-io/basepkg
Support base package
| -rw-r--r-- | tests/projects/package/depconfigs/xmake.lua | 2 | ||||
| -rwxr-xr-x | tests/projects/package/inherit_base/src/main.c | 7 | ||||
| -rw-r--r-- | tests/projects/package/inherit_base/test.lua | 10 | ||||
| -rw-r--r-- | tests/projects/package/inherit_base/xmake.lua | 11 | ||||
| -rw-r--r-- | tests/projects/package/multiconfig/xmake-requires.lock | 88 | ||||
| -rw-r--r-- | tests/projects/package/toolchain_muslcc/xmake-requires.lock | 40 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 19 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 17 |
8 files changed, 138 insertions, 56 deletions
diff --git a/tests/projects/package/depconfigs/xmake.lua b/tests/projects/package/depconfigs/xmake.lua index c76e92df5..3580841f5 100644 --- a/tests/projects/package/depconfigs/xmake.lua +++ b/tests/projects/package/depconfigs/xmake.lua @@ -14,7 +14,7 @@ target("test") if target:pkg("libpng") then local found for _, linkdir in ipairs(target:pkg("libpng"):get("linkdirs")) do - if linkdir:find("zlib[/\\]1%.2%.10") then + if linkdir:find("zlib[/\\]v1%.2%.10") then found = true end end diff --git a/tests/projects/package/inherit_base/src/main.c b/tests/projects/package/inherit_base/src/main.c new file mode 100755 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/inherit_base/src/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char** argv) +{ + printf("hello world!\n"); + return 0; +} diff --git a/tests/projects/package/inherit_base/test.lua b/tests/projects/package/inherit_base/test.lua new file mode 100644 index 000000000..a6690754b --- /dev/null +++ b/tests/projects/package/inherit_base/test.lua @@ -0,0 +1,10 @@ +function main(t) + -- freebsd ci is slower + if is_host("bsd") then + return + end + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end +end diff --git a/tests/projects/package/inherit_base/xmake.lua b/tests/projects/package/inherit_base/xmake.lua new file mode 100644 index 000000000..3eea30f03 --- /dev/null +++ b/tests/projects/package/inherit_base/xmake.lua @@ -0,0 +1,11 @@ +package("myzlib") + set_base("zlib") + set_urls("https://github.com/madler/zlib.git") +package_end() + +add_requires("myzlib", {system = false, alias = "zlib"}) + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("zlib") diff --git a/tests/projects/package/multiconfig/xmake-requires.lock b/tests/projects/package/multiconfig/xmake-requires.lock index 359015a18..362eebba4 100644 --- a/tests/projects/package/multiconfig/xmake-requires.lock +++ b/tests/projects/package/multiconfig/xmake-requires.lock @@ -1,31 +1,57 @@ -{ - __meta__ = { - version = "1.0" - }, - ["macosx|x86_64"] = { - ["zlib#31fecfc4"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://github.com/xmake-io/xmake-repo.git" - }, - version = "1.2.11" - }, - ["zlib~debug#55833b12"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://github.com/xmake-io/xmake-repo.git" - }, - version = "1.2.11" - }, - ["zlib~shared#b6ab42cb"] = { - repo = { - branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", - url = "https://github.com/xmake-io/xmake-repo.git" - }, - version = "1.2.11" - } - } -} +{
+ __meta__ = {
+ version = "1.0"
+ },
+ ["macosx|x86_64"] = {
+ ["zlib#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87",
+ url = "https://github.com/xmake-io/xmake-repo.git"
+ },
+ version = "v1.2.11"
+ },
+ ["zlib~debug#55833b12"] = {
+ repo = {
+ branch = "master",
+ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87",
+ url = "https://github.com/xmake-io/xmake-repo.git"
+ },
+ version = "v1.2.11"
+ },
+ ["zlib~shared#b6ab42cb"] = {
+ repo = {
+ branch = "master",
+ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87",
+ url = "https://github.com/xmake-io/xmake-repo.git"
+ },
+ version = "v1.2.11"
+ }
+ },
+ ["windows|x64"] = {
+ ["zlib#31fecfc4"] = {
+ repo = {
+ branch = "master",
+ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87",
+ url = "https://github.com/xmake-io/xmake-repo.git"
+ },
+ version = "v1.2.11"
+ },
+ ["zlib~debug#55833b12"] = {
+ repo = {
+ branch = "master",
+ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87",
+ url = "https://github.com/xmake-io/xmake-repo.git"
+ },
+ version = "v1.2.11"
+ },
+ ["zlib~shared#b6ab42cb"] = {
+ repo = {
+ branch = "master",
+ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87",
+ url = "https://github.com/xmake-io/xmake-repo.git"
+ },
+ version = "v1.2.11"
+ }
+ }
+}
diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock index 05f143646..00f23d026 100644 --- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock +++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock @@ -6,7 +6,7 @@ ["autoconf#31fecfc4"] = { repo = { branch = "master", - commit = "4498f11267de5112199152ab030ed139c985ad5a", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "2.71" @@ -14,7 +14,7 @@ ["automake#31fecfc4"] = { repo = { branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "1.16.4" @@ -22,15 +22,15 @@ ["cmake#31fecfc4"] = { repo = { branch = "master", - commit = "4498f11267de5112199152ab030ed139c985ad5a", + commit = "d3260ca0867f8b26aa2a72818bca3e6113a4fc42", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "3.21.0" + version = "3.22.1" }, ["gmp#31fecfc4"] = { repo = { branch = "master", - commit = "89ac4c1e2d360bc3a8c3f4cdedf4ee683701de74", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "6.2.1" @@ -38,7 +38,7 @@ ["libisl 0.22#67114504"] = { repo = { branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "0.22" @@ -46,7 +46,7 @@ ["libogg#31fecfc4"] = { repo = { branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "v1.3.4" @@ -54,7 +54,7 @@ ["libplist#31fecfc4"] = { repo = { branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "2.2.0" @@ -62,7 +62,7 @@ ["libtool#31fecfc4"] = { repo = { branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + commit = "dd4abbd658b9897c9e1dcacf2e4bdeeb02d05860", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "2.4.6" @@ -70,7 +70,7 @@ ["m4#31fecfc4"] = { repo = { branch = "master", - commit = "89ac4c1e2d360bc3a8c3f4cdedf4ee683701de74", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "1.4.19" @@ -78,7 +78,7 @@ ["muslcc#31fecfc4"] = { repo = { branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "20210202" @@ -86,7 +86,7 @@ ["pkg-config#31fecfc4"] = { repo = { branch = "master", - commit = "89ac4c1e2d360bc3a8c3f4cdedf4ee683701de74", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "0.29.2" @@ -94,20 +94,20 @@ ["zlib#31fecfc4"] = { repo = { branch = "master", - commit = "eda7adee81bac151f87c507030cc0dd8ab299462", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "1.2.11" + version = "v1.2.11" } }, ["windows|x64"] = { ["cmake#31fecfc4"] = { repo = { branch = "master", - commit = "8e8c5e4d1c7e8b047b23333594d23b4b85163aed", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "3.21.0" + version = "3.22.1" }, ["libogg#31fecfc4"] = { repo = { @@ -120,7 +120,7 @@ ["make#31fecfc4"] = { repo = { branch = "master", - commit = "2b1cb74b289ae3221241985db4401a495c42fde3", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "4.3" @@ -128,7 +128,7 @@ ["muslcc#31fecfc4"] = { repo = { branch = "master", - commit = "2b1cb74b289ae3221241985db4401a495c42fde3", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "20210202" @@ -136,10 +136,10 @@ ["zlib#31fecfc4"] = { repo = { branch = "master", - commit = "2b1cb74b289ae3221241985db4401a495c42fde3", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "1.2.11" + version = "v1.2.11" } } } diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 379d1ddea..73b2731dd 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -68,11 +68,17 @@ function _instance:type() return "package" end --- get the package configure -function _instance:get(name) +-- get the base package +function _instance:base() + return self._BASE +end - -- get it from info first +-- get the package configuration +function _instance:get(name) local value = self._INFO:get(name) + if value == nil and self:base() then + value = self:base():get(name) + end if value ~= nil then return value end @@ -90,7 +96,11 @@ end -- get the extra configuration function _instance:extraconf(name, item, key) - return self._INFO: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 @@ -1811,6 +1821,7 @@ function package.apis() , "package.set_kind" , "package.set_plat" -- deprecated , "package.set_arch" -- deprecated + , "package.set_base" , "package.set_license" , "package.set_homepage" , "package.set_description" diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 07e2abc34..3534723d2 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -217,6 +217,17 @@ function _load_package_from_repository(packagename, opt) end end +-- load package package from base +function _load_package_from_base(package, basename, opt) + local package_base = _load_package_from_project(basename) + if not package_base then + package_base = _load_package_from_repository(basename, opt) + end + if package_base then + package._BASE = package_base + end +end + -- has locked requires? function _has_locked_requires(opt) opt = opt or {} @@ -700,6 +711,12 @@ function _load_package(packagename, requireinfo, opt) end end + -- load base package + if package and package:get("base") then + _load_package_from_base(package, package:get("base", { + name = requireinfo.reponame, locked_repo = locked_requireinfo and locked_requireinfo.repo})) + end + -- load package from system local system = requireinfo.system if system == nil then |
