summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/nim.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-21 22:42:59 +0800
committerruki <[email protected]>2021-10-21 22:42:59 +0800
commitc03c36da556816137e18916dcca4517a8a10c6b7 (patch)
tree77c297320f32c80c0194009982c7a796c2b78e93 /xmake/modules/core/tools/nim.lua
parent7251eee6ab7ec54f5a052860ac28f46a02371eb9 (diff)
add nim lang
Diffstat (limited to 'xmake/modules/core/tools/nim.lua')
-rw-r--r--xmake/modules/core/tools/nim.lua89
1 files changed, 89 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/nim.lua b/xmake/modules/core/tools/nim.lua
new file mode 100644
index 000000000..4cee95c95
--- /dev/null
+++ b/xmake/modules/core/tools/nim.lua
@@ -0,0 +1,89 @@
+--!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 nim.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("core.project.project")
+
+-- init it
+function init(self)
+
+ -- init arflags
+ self:set("ncarflags", "--app:staticlib")
+
+ -- init shflags
+ self:set("ncshflags", "--app:lib")
+end
+
+-- make the define flag
+function nf_define(self, macro)
+ return "--define:" .. macro
+end
+
+-- make the undefine flag
+function nf_undefine(self, macro)
+ return "--undef:" .. macro
+end
+
+-- make the optimize flag
+function nf_optimize(self, level)
+ local maps =
+ {
+ none = "--opt:none"
+ , fast = "--opt:speed"
+ , faster = "--opt:speed"
+ , fastest = "--opt:speed"
+ , smallest = "--opt:size"
+ , aggressive = "--opt:speed"
+ }
+ return maps[level]
+end
+
+-- make the symbol flag
+function nf_symbol(self, level)
+ local maps =
+ {
+ debug = "--stackTrace:on"
+ }
+ return maps[level]
+end
+
+-- make the link flag
+function nf_link(self, lib)
+ return "--passL:" .. lib
+end
+
+-- make the linkdir flag
+function nf_linkdir(self, dir)
+ return {"-L" .. dir}
+end
+
+-- make the build arguments list
+function buildargv(self, sourcefiles, targetkind, targetfile, flags)
+ return self:program(), table.join(flags, "c", "-o:" .. targetfile, sourcefiles)
+end
+
+-- build the target file
+function build(self, sourcefiles, targetkind, targetfile, flags)
+ os.mkdir(path.directory(targetfile))
+ os.runv(buildargv(self, sourcefiles, targetkind, targetfile, flags))
+end
+