summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/compiler.lua16
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/linker.lua16
-rw-r--r--xmake/core/tool/compiler.lua21
-rw-r--r--xmake/core/tool/linker.lua29
4 files changed, 70 insertions, 12 deletions
diff --git a/xmake/core/sandbox/modules/import/core/tool/compiler.lua b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
index bf231f7b4..71059ad16 100644
--- a/xmake/core/sandbox/modules/import/core/tool/compiler.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
@@ -41,5 +41,21 @@ function sandbox_core_tool_compiler.compcmd(sourcefile, objectfile, target)
return instance:compcmd(sourcefile, objectfile, target)
end
+-- compile source file
+function sandbox_core_tool_compiler.compile(sourcefile, objectfile, target, multitasking)
+
+ -- get the compiler instance
+ local instance, errors = compiler.load(compiler.kind_of_file(sourcefile))
+ if not instance then
+ raise(errors)
+ end
+
+ -- compile it
+ local ok, errors = instance:compile(sourcefile, objectfile, target, multitasking)
+ if not ok then
+ raise(errors)
+ end
+end
+
-- return module
return sandbox_core_tool_compiler
diff --git a/xmake/core/sandbox/modules/import/core/tool/linker.lua b/xmake/core/sandbox/modules/import/core/tool/linker.lua
index 9f42a04e7..5f9a32f96 100644
--- a/xmake/core/sandbox/modules/import/core/tool/linker.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/linker.lua
@@ -41,5 +41,21 @@ function sandbox_core_tool_linker.linkcmd(objectfiles, targetfile, target)
return instance:linkcmd(objectfiles, targetfile, target)
end
+-- link target file
+function sandbox_core_tool_linker.link(objectfiles, targetfile, target)
+
+ -- get the linker instance
+ local instance, errors = linker.load(target:get("kind"))
+ if not instance then
+ raise(errors)
+ end
+
+ -- link it
+ local ok, errors = instance:link(objectfiles, targetfile, target)
+ if not ok then
+ raise(errors)
+ end
+end
+
-- return module
return sandbox_core_tool_linker
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index 7d867a6d2..da4e284fd 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -308,10 +308,10 @@ function compiler:_addflags_from_compiler(flags, kind)
end
-- get the compiler kind of the source file
-function compiler.kind_of_file(srcfile)
+function compiler.kind_of_file(sourcefile)
-- get the source file type
- local filetype = path.extension(srcfile)
+ local filetype = path.extension(sourcefile)
if not filetype then
return nil
end
@@ -398,8 +398,21 @@ function compiler:get(name)
return self:_tool().get(name)
end
+-- compile the source file
+function compiler:compile(sourcefile, objectfile, target, multitasking)
+
+ -- get flags
+ local flags = nil
+ if target then
+ flags = self:_flags(target)
+ end
+
+ -- compile it
+ return sandbox.load(self:_tool().compile, sourcefile, objectfile, flags or "", multitasking)
+end
+
-- get the compile command
-function compiler:compcmd(srcfile, objfile, target)
+function compiler:compcmd(sourcefile, objectfile, target)
-- get flags
local flags = nil
@@ -408,7 +421,7 @@ function compiler:compcmd(srcfile, objfile, target)
end
-- get it
- return self:_tool().compcmd(srcfile, objfile, flags or "")
+ return self:_tool().compcmd(sourcefile, objectfile, flags or "")
end
-- make the define flag
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index e0959702c..41ce9bfd3 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -195,7 +195,7 @@ function linker:_addflags_from_target(flags, target)
-- add the links flags
for _, link in ipairs(table.wrap(target:get("links"))) do
- table.join2(flags, self:link(link))
+ table.join2(flags, self:linklib(link))
end
-- for target options?
@@ -214,7 +214,7 @@ function linker:_addflags_from_target(flags, target)
-- add the links flags from the option
for _, link in ipairs(table.wrap(opt:get("links"))) do
- table.join2(flags, self:link(link))
+ table.join2(flags, self:linklib(link))
end
end
end
@@ -238,7 +238,7 @@ function linker:_addflags_from_platform(flags)
-- add the links flags
for _, link in ipairs(table.wrap(platform.get("links"))) do
- table.join2(flags, self:link(link))
+ table.join2(flags, self:linklib(link))
end
end
@@ -332,8 +332,21 @@ function linker:get(name)
return self:_tool().get(name)
end
+-- link the target file
+function linker:link(objectfiles, targetfile, target)
+
+ -- get flags
+ local flags = nil
+ if target then
+ flags = self:_flags(target)
+ end
+
+ -- get it
+ return sandbox.load(self:_tool().link, table.concat(table.wrap(objectfiles), " "), targetfile, flags or "")
+end
+
-- get the link command
-function linker:linkcmd(objfiles, targetfile, target)
+function linker:linkcmd(objectfiles, targetfile, target)
-- get flags
local flags = nil
@@ -342,14 +355,14 @@ function linker:linkcmd(objfiles, targetfile, target)
end
-- get it
- return self:_tool().linkcmd(table.concat(table.wrap(objfiles), " "), targetfile, flags or "")
+ return self:_tool().linkcmd(table.concat(table.wrap(objectfiles), " "), targetfile, flags or "")
end
--- make the link flag
-function linker:link(lib)
+-- make the linklib flag
+function linker:linklib(lib)
-- make it
- return self:_tool().link(lib)
+ return self:_tool().linklib(lib)
end
-- make the linkdir flag