summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-26 23:13:56 +0800
committerruki <[email protected]>2021-10-26 23:13:56 +0800
commit8654ee65203a6ed670bc671a73bf8f704510bf80 (patch)
tree2f01c941f6e20952cba2258db677ab62857f6f99
parentccfb92f406dbd1535db64cfdb0e4a80d031805e9 (diff)
add mdk.console
-rw-r--r--tests/projects/mdk/hello/xmake.lua6
-rw-r--r--xmake/modules/detect/tools/armcc/has_flags.lua23
-rw-r--r--xmake/modules/detect/tools/armclang/has_flags.lua23
-rw-r--r--xmake/rules/mdk/xmake.lua38
-rw-r--r--xmake/toolchains/armcc/xmake.lua5
5 files changed, 41 insertions, 54 deletions
diff --git a/tests/projects/mdk/hello/xmake.lua b/tests/projects/mdk/hello/xmake.lua
index d5a0429e4..2d375a05f 100644
--- a/tests/projects/mdk/hello/xmake.lua
+++ b/tests/projects/mdk/hello/xmake.lua
@@ -1,7 +1,7 @@
add_rules("mode.debug", "mode.release")
target("hello")
- set_kind("binary")
- set_extension(".axf")
- add_files("src/**.c", "src/**.s")
+ add_rules("mdk.console")
+ add_values("mdk.cpu", "Cortex-M3")
+ add_files("src/*.c", "src/*.s")
add_defines("__EVAL", "__MICROLIB")
add_includedirs("src/lib/cmsis")
diff --git a/xmake/modules/detect/tools/armcc/has_flags.lua b/xmake/modules/detect/tools/armcc/has_flags.lua
deleted file mode 100644
index 6464e10b6..000000000
--- a/xmake/modules/detect/tools/armcc/has_flags.lua
+++ /dev/null
@@ -1,23 +0,0 @@
---!A cross-platform build utility based on Lua
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
--- Copyright (C) 2015-present, TBOOX Open Source Group.
---
--- @author ruki
--- @file has_flags.lua
---
-
--- imports
-inherit("detect.tools.gcc.has_flags")
-
diff --git a/xmake/modules/detect/tools/armclang/has_flags.lua b/xmake/modules/detect/tools/armclang/has_flags.lua
deleted file mode 100644
index 6464e10b6..000000000
--- a/xmake/modules/detect/tools/armclang/has_flags.lua
+++ /dev/null
@@ -1,23 +0,0 @@
---!A cross-platform build utility based on Lua
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
--- Copyright (C) 2015-present, TBOOX Open Source Group.
---
--- @author ruki
--- @file has_flags.lua
---
-
--- imports
-inherit("detect.tools.gcc.has_flags")
-
diff --git a/xmake/rules/mdk/xmake.lua b/xmake/rules/mdk/xmake.lua
new file mode 100644
index 000000000..452d8a4d3
--- /dev/null
+++ b/xmake/rules/mdk/xmake.lua
@@ -0,0 +1,38 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+rule("mdk.console")
+ 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", "binary")
+ if not target:get("extension") then
+ target:set("extension", ".axf")
+ end
+
+ -- set cpu
+ local cpu = assert(target:values("mdk.cpu"), "unknown cpu, please use `add_values(\"mdk.cpu\", \"\")` to set it!")
+ target:add("cxflags", "--cpu " .. cpu)
+ target:add("asflags", "--cpu " .. cpu)
+ target:add("ldflags", "--cpu " .. cpu)
+ end)
diff --git a/xmake/toolchains/armcc/xmake.lua b/xmake/toolchains/armcc/xmake.lua
index d280d0344..487b33604 100644
--- a/xmake/toolchains/armcc/xmake.lua
+++ b/xmake/toolchains/armcc/xmake.lua
@@ -36,8 +36,3 @@ toolchain("armcc")
return import("lib.detect.find_tool")("armcc")
end)
- on_load(function (toolchain)
- toolchain:add("cxflags", "--cpu Cortex-M3", {force = true})
- toolchain:add("asflags", "--cpu Cortex-M3", {force = true})
- toolchain:add("ldflags", "--cpu Cortex-M3", {force = true})
- end)