style(c_compiler) Make compile_c_file and compile_titan more consistent
Now both only receive the input file names and the output is always implicit.
@@ -16,7 +16,10 @@ else
c_compiler.CFLAGS_SHARED = "-fPIC -shared"
end
-function c_compiler.compile_c_file(c_filename, so_filename)
+function c_compiler.compile_c_file(c_filename)
+ local name, ext = util.split_ext(c_filename)
+ assert(ext == "c")
+ local so_filename = name .. ".so"
local args = {
c_compiler.CC,
c_compiler.CFLAGS_BASE,
@@ -42,7 +45,6 @@ function c_compiler.compile_titan(filename, input)
local name, ext = util.split_ext(filename)
assert(ext == "titan")
local c_filename = name .. ".c"
- local so_filename = name .. ".so"
local modname = string.gsub(name, "/", "_")
local code, errors = coder.generate(filename, input, modname)
@@ -51,7 +53,7 @@ function c_compiler.compile_titan(filename, input)
local ok, err = util.set_file_contents(c_filename, code)
if not ok then return nil, {err} end
- return c_compiler.compile_c_file(c_filename, so_filename)
+ return c_compiler.compile_c_file(c_filename)
end
return c_compiler
