From bf0bdbaff7a2b5fb5fc4e0b5ab201fe764ea84d0 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 3 May 2022 23:06:36 +0800 Subject: improve nasm --- tests/projects/asm/nasm/xmake.lua | 2 ++ xmake/modules/core/tools/nasm.lua | 46 +++++++++++++++------------------------ 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/tests/projects/asm/nasm/xmake.lua b/tests/projects/asm/nasm/xmake.lua index f728b2ca1..d7cafaa54 100644 --- a/tests/projects/asm/nasm/xmake.lua +++ b/tests/projects/asm/nasm/xmake.lua @@ -1,3 +1,5 @@ +add_rules("mode.debug", "mode.release") + target("test") set_kind("binary") add_files("src/*.S") diff --git a/xmake/modules/core/tools/nasm.lua b/xmake/modules/core/tools/nasm.lua index 8297e21bc..b4b623b61 100644 --- a/xmake/modules/core/tools/nasm.lua +++ b/xmake/modules/core/tools/nasm.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.language.language") -- init it function init(self) @@ -45,16 +46,23 @@ function init(self) }) end +-- make the symbol flag +function nf_symbol(self, level) + -- only for source kind + local kind = self:kind() + if language.sourcekinds()[kind] then + local maps = { + debug = "-g" + } + return maps[level] + end +end + -- make the warning flag function nf_warning(self, level) - - -- the maps - local maps = - { + local maps = { none = "-w" } - - -- make it return maps[level] end @@ -79,12 +87,12 @@ function nf_sysincludedir(self, dir) end -- make the compile arguments list -function _compargv1(self, sourcefile, objectfile, flags) +function compargv(self, sourcefile, objectfile, flags) return self:program(), table.join(flags, "-o", objectfile, sourcefile) end -- compile the source file -function _compile1(self, sourcefile, objectfile, dependinfo, flags) +function compile(self, sourcefile, objectfile, dependinfo, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) @@ -93,7 +101,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) local outdata, errdata = try { function () - return os.iorunv(_compargv1(self, sourcefile, objectfile, flags)) + return os.iorunv(compargv(self, sourcefile, objectfile, flags)) end, catch { @@ -122,23 +130,3 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) } end --- make the compile arguments list -function compargv(self, sourcefiles, objectfile, flags) - - -- only support single source file now - assert(type(sourcefiles) ~= "table", "'object:sources' not support!") - - -- for only single source file - return _compargv1(self, sourcefiles, objectfile, flags) -end - --- compile the source file -function compile(self, sourcefiles, objectfile, dependinfo, flags) - - -- only support single source file now - assert(type(sourcefiles) ~= "table", "'object:sources' not support!") - - -- for only single source file - _compile1(self, sourcefiles, objectfile, dependinfo, flags) -end - -- cgit v1.3.1