diff options
| author | ruki <[email protected]> | 2021-10-26 23:27:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-10-26 23:27:19 +0800 |
| commit | dea09f243e33b43c8c8be40d8a471b4580db1de7 (patch) | |
| tree | 86b3b01f70fb6285cbbec3f5b457a04235dd7f78 | |
| parent | 80dd8e90c0eea596298463e521e64b27c4995a4d (diff) | |
improve armlink
| -rw-r--r-- | tests/projects/mdk/hello/src/foo/foo.c | 4 | ||||
| -rw-r--r-- | tests/projects/mdk/hello/src/main.c | 4 | ||||
| -rw-r--r-- | tests/projects/mdk/hello/xmake.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/core/tools/armlink.lua | 33 | ||||
| -rw-r--r-- | xmake/rules/mdk/xmake.lua | 10 |
5 files changed, 54 insertions, 3 deletions
diff --git a/tests/projects/mdk/hello/src/foo/foo.c b/tests/projects/mdk/hello/src/foo/foo.c new file mode 100644 index 000000000..e51afb553 --- /dev/null +++ b/tests/projects/mdk/hello/src/foo/foo.c @@ -0,0 +1,4 @@ +int foo(int x)
+{
+ return x;
+}
diff --git a/tests/projects/mdk/hello/src/main.c b/tests/projects/mdk/hello/src/main.c index a6e46accc..28d909a18 100644 --- a/tests/projects/mdk/hello/src/main.c +++ b/tests/projects/mdk/hello/src/main.c @@ -1,4 +1,6 @@ +int foo(int x);
+
int main()
{
- return 0;
+ return foo(1);
}
diff --git a/tests/projects/mdk/hello/xmake.lua b/tests/projects/mdk/hello/xmake.lua index 710e29bcf..97d640297 100644 --- a/tests/projects/mdk/hello/xmake.lua +++ b/tests/projects/mdk/hello/xmake.lua @@ -1,5 +1,11 @@ add_rules("mode.debug", "mode.release") + +target("foo") + add_rules("mdk.static") + add_files("src/foo/*.c") + target("hello") + add_deps("foo") add_rules("mdk.console") add_files("src/*.c", "src/*.s") add_defines("__EVAL", "__MICROLIB") diff --git a/xmake/modules/core/tools/armlink.lua b/xmake/modules/core/tools/armlink.lua index 34895be6c..02c2b4800 100644 --- a/xmake/modules/core/tools/armlink.lua +++ b/xmake/modules/core/tools/armlink.lua @@ -18,8 +18,37 @@ -- @file armlink.lua -- -inherit("gcc") +-- imports +import("core.base.option") +import("core.base.global") +import("utils.progress") function init(self) - _super.init(self) end + +-- make the link flag +function nf_link(self, lib) + return "lib" .. lib .. ".a" +end + +-- make the syslink flag +function nf_syslink(self, lib) + return nf_link(self, lib) +end + +-- make the linkdir flag +function nf_linkdir(self, dir) + return {"--userlibpath", dir} +end + +-- make the link arguments list +function linkargv(self, objectfiles, targetkind, targetfile, flags) + return self:program(), table.join("-o", targetfile, objectfiles, flags) +end + +-- link the target file +function link(self, objectfiles, targetkind, targetfile, flags) + os.mkdir(path.directory(targetfile)) + os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) +end + diff --git a/xmake/rules/mdk/xmake.lua b/xmake/rules/mdk/xmake.lua index 640d40aee..f45e04c6e 100644 --- a/xmake/rules/mdk/xmake.lua +++ b/xmake/rules/mdk/xmake.lua @@ -30,3 +30,13 @@ rule("mdk.console") target:set("extension", ".axf") end end) + +rule("mdk.static") + on_load(function (target) + -- we disable checking flags for cross toolchain automatically + target:set("policy", "check.auto_ignore_flags", false) + target:set("policy", "check.auto_map_flags", false) + + -- set default output binary + target:set("kind", "static") + end) |
