summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-24 20:54:11 +0800
committerruki <[email protected]>2016-05-24 20:54:11 +0800
commitc5606b9bc54e3630898554f61fc191073506591b (patch)
tree0a0bc9d4c1807d2282ea61489d3c999d7513a178
parent487eda865797da4fc81ba8ba8ec932dc2fb64cec (diff)
modify merge static library test
-rwxr-xr-xtests/merge_static_library/src/add.c (renamed from tests/merge_static_library/src/interface.c)2
-rwxr-xr-xtests/merge_static_library/src/interface.h8
-rwxr-xr-xtests/merge_static_library/src/mul.c4
-rwxr-xr-xtests/merge_static_library/src/sub.c4
-rwxr-xr-xtests/merge_static_library/src/test.c8
-rwxr-xr-xtests/merge_static_library/xmake.lua26
-rwxr-xr-xtests/tests2
-rw-r--r--xmake/core/tool/tool.lua9
8 files changed, 32 insertions, 31 deletions
diff --git a/tests/merge_static_library/src/interface.c b/tests/merge_static_library/src/add.c
index 598d07560..be1e084fc 100755
--- a/tests/merge_static_library/src/interface.c
+++ b/tests/merge_static_library/src/add.c
@@ -1,5 +1,3 @@
-#include "interface.h"
-
int add(int a, int b)
{
return a + b;
diff --git a/tests/merge_static_library/src/interface.h b/tests/merge_static_library/src/interface.h
deleted file mode 100755
index 10ec0f856..000000000
--- a/tests/merge_static_library/src/interface.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*! calculate add(a, b)
- *
- * @param a the first argument
- * @param b the second argument
- *
- * @return the result
- */
-int add(int a, int b);
diff --git a/tests/merge_static_library/src/mul.c b/tests/merge_static_library/src/mul.c
new file mode 100755
index 000000000..c4292f9aa
--- /dev/null
+++ b/tests/merge_static_library/src/mul.c
@@ -0,0 +1,4 @@
+int mul(int a, int b)
+{
+ return a * b;
+}
diff --git a/tests/merge_static_library/src/sub.c b/tests/merge_static_library/src/sub.c
new file mode 100755
index 000000000..b151ec4bc
--- /dev/null
+++ b/tests/merge_static_library/src/sub.c
@@ -0,0 +1,4 @@
+int sub(int a, int b)
+{
+ return a - b;
+}
diff --git a/tests/merge_static_library/src/test.c b/tests/merge_static_library/src/test.c
deleted file mode 100755
index 9505a2f75..000000000
--- a/tests/merge_static_library/src/test.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "interface.h"
-#include <stdio.h>
-
-int main(int argc, char** argv)
-{
- printf("add(1, 2) = %d\n", add(1, 2));
- return 0;
-}
diff --git a/tests/merge_static_library/xmake.lua b/tests/merge_static_library/xmake.lua
index d51e3c6ef..bd36a983a 100755
--- a/tests/merge_static_library/xmake.lua
+++ b/tests/merge_static_library/xmake.lua
@@ -22,28 +22,36 @@ if is_mode("release") then
end
-- add target
-target("merge_static_library")
+target("add")
-- set kind
set_kind("static")
-- add files
- add_files("../static_library_c/build/static_library_c.pkg/lib/release/$(plat)/$(arch)/*.a")
+ add_files("src/add.c")
-- add target
-target("test")
+target("sub")
-- set kind
- set_kind("binary")
+ set_kind("static")
+
+ -- add files
+ add_files("src/sub.c")
+
+-- add target
+target("mul")
+
+ -- set kind
+ set_kind("static")
-- add deps
- add_deps("merge_static_library")
+ add_deps("add", "sub")
-- add files
- add_files("src/test.c")
-
- -- add links
- add_links("merge_static_library")
+ add_files("src/mul.c")
+ add_files("build/libadd.a")
+ add_files("build/libsub.a")
-- add link directory
add_linkdirs("$(buildir)")
diff --git a/tests/tests b/tests/tests
index d731cccc9..c938d712c 100755
--- a/tests/tests
+++ b/tests/tests
@@ -61,7 +61,7 @@ build "./tests/shared_library_c++"
build "./tests/merge_object"
# merge static library
-#build "./tests/merge_static_library"
+build "./tests/merge_static_library"
# build for macosx
if [ $host = "macosx" ]; then
diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua
index 3846dc499..d16d27a7b 100644
--- a/xmake/core/tool/tool.lua
+++ b/xmake/core/tool/tool.lua
@@ -124,10 +124,13 @@ end
-- load the given tool from the given shell name
function tool._load(shellname, kind)
+ -- calculate the cache key
+ local key = shellname .. (kind or "")
+
-- get it directly from cache dirst
tool._TOOLS = tool._TOOLS or {}
- if tool._TOOLS[shellname] then
- return tool._TOOLS[shellname]
+ if tool._TOOLS[key] then
+ return tool._TOOLS[key]
end
-- find the tool script path
@@ -170,7 +173,7 @@ function tool._load(shellname, kind)
end
-- save tool to the cache
- tool._TOOLS[shellname] = module
+ tool._TOOLS[key] = module
-- ok?
return module