summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-06-02 22:48:05 +0800
committerruki <[email protected]>2021-06-02 22:48:05 +0800
commiteee121636be554cdeef8907bd0d2fac6a23304a6 (patch)
tree1fe24ca4d7fe8740bc222c75aa28ad03b978da63
parent4223c60a70bf0220f15c18fe3ec4a5dda24b317a (diff)
add localpkg test
-rw-r--r--tests/actions/package/localpkg/bar/.gitignore8
-rw-r--r--tests/actions/package/localpkg/bar/src/main.cpp10
-rw-r--r--tests/actions/package/localpkg/bar/xmake.lua11
-rw-r--r--tests/actions/package/localpkg/libfoo/.gitignore8
-rw-r--r--tests/actions/package/localpkg/libfoo/src/interface.cpp6
-rw-r--r--tests/actions/package/localpkg/libfoo/src/interface.h16
-rw-r--r--tests/actions/package/localpkg/libfoo/xmake.lua8
-rw-r--r--tests/actions/package/localpkg/test.lua8
-rw-r--r--xmake/actions/package/local/main.lua3
-rw-r--r--xmake/modules/net/proxy.lua8
10 files changed, 82 insertions, 4 deletions
diff --git a/tests/actions/package/localpkg/bar/.gitignore b/tests/actions/package/localpkg/bar/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/tests/actions/package/localpkg/bar/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/tests/actions/package/localpkg/bar/src/main.cpp b/tests/actions/package/localpkg/bar/src/main.cpp
new file mode 100644
index 000000000..1bee1b2ad
--- /dev/null
+++ b/tests/actions/package/localpkg/bar/src/main.cpp
@@ -0,0 +1,10 @@
+#include "interface.h"
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "add(1, 2) = " << add(1, 2) << endl;
+ return 0;
+}
diff --git a/tests/actions/package/localpkg/bar/xmake.lua b/tests/actions/package/localpkg/bar/xmake.lua
new file mode 100644
index 000000000..9024b2065
--- /dev/null
+++ b/tests/actions/package/localpkg/bar/xmake.lua
@@ -0,0 +1,11 @@
+add_rules("mode.debug", "mode.release")
+
+add_repositories("local-repo build")
+add_requires("foo")
+
+target("bar")
+ set_kind("binary")
+ add_files("src/*.cpp")
+ add_packages("foo")
+
+
diff --git a/tests/actions/package/localpkg/libfoo/.gitignore b/tests/actions/package/localpkg/libfoo/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/tests/actions/package/localpkg/libfoo/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/tests/actions/package/localpkg/libfoo/src/interface.cpp b/tests/actions/package/localpkg/libfoo/src/interface.cpp
new file mode 100644
index 000000000..598d07560
--- /dev/null
+++ b/tests/actions/package/localpkg/libfoo/src/interface.cpp
@@ -0,0 +1,6 @@
+#include "interface.h"
+
+int add(int a, int b)
+{
+ return a + b;
+}
diff --git a/tests/actions/package/localpkg/libfoo/src/interface.h b/tests/actions/package/localpkg/libfoo/src/interface.h
new file mode 100644
index 000000000..62a39427c
--- /dev/null
+++ b/tests/actions/package/localpkg/libfoo/src/interface.h
@@ -0,0 +1,16 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! calculate add(a, b)
+ *
+ * @param a the first argument
+ * @param b the second argument
+ *
+ * @return the result
+ */
+int add(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/actions/package/localpkg/libfoo/xmake.lua b/tests/actions/package/localpkg/libfoo/xmake.lua
new file mode 100644
index 000000000..01419c241
--- /dev/null
+++ b/tests/actions/package/localpkg/libfoo/xmake.lua
@@ -0,0 +1,8 @@
+add_rules("mode.debug", "mode.release")
+
+target("foo")
+ set_kind("static")
+ add_files("src/interface.cpp")
+ add_headerfiles("src/*.h")
+
+
diff --git a/tests/actions/package/localpkg/test.lua b/tests/actions/package/localpkg/test.lua
new file mode 100644
index 000000000..ae685d928
--- /dev/null
+++ b/tests/actions/package/localpkg/test.lua
@@ -0,0 +1,8 @@
+function main(t)
+ os.cd("libfoo")
+ os.exec("xmake package -vD -o ../bar/build")
+ os.cd("../bar")
+ os.exec("xmake f -c -vD")
+ os.exec("xmake -vD")
+ os.exec("xmake run")
+end
diff --git a/xmake/actions/package/local/main.lua b/xmake/actions/package/local/main.lua
index d4b776a00..c2b3c556c 100644
--- a/xmake/actions/package/local/main.lua
+++ b/xmake/actions/package/local/main.lua
@@ -67,6 +67,7 @@ function _package_library(target)
local packagedir = path.join(outputdir, "packages", packagename:sub(1, 1), packagename)
local binarydir = path.join(packagedir, target:plat(), target:arch(), config.mode(), "bin")
local librarydir = path.join(packagedir, target:plat(), target:arch(), config.mode(), "lib")
+ local headerdir = path.join(packagedir, target:plat(), target:arch(), config.mode(), "include")
-- copy the library file to the output directory
local targetfile = target:targetfile()
@@ -86,7 +87,7 @@ function _package_library(target)
end
-- copy headers
- local srcheaders, dstheaders = target:headerfiles(path.join(packagedir, "include"))
+ local srcheaders, dstheaders = target:headerfiles(headerdir)
if srcheaders and dstheaders then
local i = 1
for _, srcheader in ipairs(srcheaders) do
diff --git a/xmake/modules/net/proxy.lua b/xmake/modules/net/proxy.lua
index 8259a07c9..6aac4af4c 100644
--- a/xmake/modules/net/proxy.lua
+++ b/xmake/modules/net/proxy.lua
@@ -108,7 +108,7 @@ function config(url)
-- enable proxy for the given url and configuration pattern
if url then
- -- get proxy from the given hosts pattern
+ -- filter proxy host from the given hosts pattern
local host = url:match("://(.-)/") or url:match("@(.-):")
local proxy_hosts = _proxy_hosts()
if host and proxy_hosts then
@@ -121,11 +121,13 @@ function config(url)
end
end
- -- get proxy from the pac file
+ -- filter proxy host from the pac file
local proxy_pac = _proxy_pac()
- if proxy_pac and _is_callable(proxy_pac) and proxy_pac(url, host) then
+ if proxy_pac and host and _is_callable(proxy_pac) and proxy_pac(url, host) then
return global.get("proxy")
end
+
+ -- use global proxy
if not proxy_pac and not proxy_hosts then
return global.get("proxy")
end