summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-20 22:59:51 +0800
committerruki <[email protected]>2021-12-20 22:59:51 +0800
commit4b139c33e84d6f2261bea3ec07ec889b44cebd96 (patch)
tree8889ca853f71429464e6222e25a7002eeef1daa6
parentfde9f472906c2b7061afa5afed4128817ffd15c1 (diff)
add vcpkg tests for manifest
-rw-r--r--tests/projects/package/vcpkg_manifest/.gitignore8
-rw-r--r--tests/projects/package/vcpkg_manifest/src/main.cpp9
-rw-r--r--tests/projects/package/vcpkg_manifest/xmake.lua8
-rw-r--r--xmake/modules/package/manager/vcpkg/install_package.lua44
-rw-r--r--xmake/modules/private/action/require/impl/install_packages.lua1
5 files changed, 56 insertions, 14 deletions
diff --git a/tests/projects/package/vcpkg_manifest/.gitignore b/tests/projects/package/vcpkg_manifest/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/tests/projects/package/vcpkg_manifest/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/tests/projects/package/vcpkg_manifest/src/main.cpp b/tests/projects/package/vcpkg_manifest/src/main.cpp
new file mode 100644
index 000000000..7c435d251
--- /dev/null
+++ b/tests/projects/package/vcpkg_manifest/src/main.cpp
@@ -0,0 +1,9 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "hello world!" << endl;
+ return 0;
+}
diff --git a/tests/projects/package/vcpkg_manifest/xmake.lua b/tests/projects/package/vcpkg_manifest/xmake.lua
new file mode 100644
index 000000000..a10ec2347
--- /dev/null
+++ b/tests/projects/package/vcpkg_manifest/xmake.lua
@@ -0,0 +1,8 @@
+add_requires("vcpkg::zlib 1.2.11", "vcpkg::fmt >=8.0.1")
+--add_requires("vcpkg::boost", {alias = "boost", {configs = {}}})
+
+target("test")
+ set_kind("binary")
+ add_files("src/*.cpp")
+ add_packages("vcpkg::zlib", "vcpkg::fmt", "boost")
+
diff --git a/xmake/modules/package/manager/vcpkg/install_package.lua b/xmake/modules/package/manager/vcpkg/install_package.lua
index eaf28710e..071eec03b 100644
--- a/xmake/modules/package/manager/vcpkg/install_package.lua
+++ b/xmake/modules/package/manager/vcpkg/install_package.lua
@@ -22,20 +22,13 @@
import("core.base.option")
import("lib.detect.find_tool")
--- install package
---
--- @param name the package name, e.g. pcre2, pcre2/libpcre2-8
--- @param opt the options, e.g. {verbose = true}
---
--- @return true or false
---
-function main(name, opt)
+-- need manifest mode?
+function _need_manifest(opt)
+-- print("_need_manifest", opt)
+end
- -- attempt to find vcpkg
- local vcpkg = find_tool("vcpkg")
- if not vcpkg then
- raise("vcpkg not found!")
- end
+-- install for classic mode
+function _install_for_classic(vcpkg, name, opt)
-- get arch, plat and mode
local arch = opt.arch
@@ -81,5 +74,28 @@ function main(name, opt)
end
-- install package
- os.vrunv(vcpkg.program, argv)
+ os.vrunv(vcpkg, argv)
+end
+
+-- install package
+--
+-- @param name the package name, e.g. pcre2, pcre2/libpcre2-8
+-- @param opt the options, e.g. {verbose = true}
+--
+-- @return true or false
+--
+function main(name, opt)
+
+ -- attempt to find vcpkg
+ local vcpkg = find_tool("vcpkg")
+ if not vcpkg then
+ raise("vcpkg not found!")
+ end
+
+ -- do install
+ if _need_manifest(opt) then
+ _install_for_manifest(vcpkg.program, name, opt)
+ else
+ _install_for_classic(vcpkg.program, name, opt)
+ end
end
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua
index f62a0fb52..c1d9b4791 100644
--- a/xmake/modules/private/action/require/impl/install_packages.lua
+++ b/xmake/modules/private/action/require/impl/install_packages.lua
@@ -285,6 +285,7 @@ function _install_packages(packages_install, packages_download, installdeps)
-- fetch a new package
local instance = nil
while instance == nil and #packages_pending > 0 do
+ print("packages_pending", #packages_pending)
for idx, pkg in ipairs(packages_pending) do
-- all dependences has been installed? we install it now