175bd31489
Implement autobuild for(this libs in [`programs/develop/ktcc/bin/lib/`](https://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/develop/ktcc/bin/lib)): + `crt0.o` + `libtcc1.a` + `tiny.o` + `libshell.a` + `libcryptal.a` + `libsound.a` it autobuild for kolibrios image and programs build. `link_tcc` automatically add this libs to `extra_inputs` roots of this grow from #311 --------- Co-authored-by: Burer <burer@kolibrios.org> Reviewed-on: #339 Reviewed-by: Burer <burer@kolibrios.org> Reviewed-by: Mikhail Frolov <mixa.frolov2003@gmail.com> Co-authored-by: Егор <y.yarin@inbox.ru> Co-committed-by: Егор <y.yarin@inbox.ru>
71 lines
2.0 KiB
Lua
71 lines
2.0 KiB
Lua
KTCC_TRUNK = tup.getcwd() .. "/develop/ktcc/"
|
|
|
|
TCC = "kos32-tcc -B" .. tup.getvariantdir() .. "/develop/ktcc/bin"
|
|
|
|
CFLAGS = "-I" .. KTCC_TRUNK .. "libc.obj/include -L" .. KTCC_TRUNK .. "bin/lib"
|
|
LFLAGS = ""
|
|
LIBS = ""
|
|
|
|
OBJS = {}
|
|
|
|
-- Mandatory libs: every TCC-linked program transitively depends on these
|
|
-- (kos32-tcc looks them up automatically from -B<bin>/lib/).
|
|
LIST_OF_LIBS = {}
|
|
|
|
-- Optional libs: requested by individual programs via the third argument
|
|
-- of link_tcc, e.g. link_tcc(src, out, {"cryptal"}). Only entries that the
|
|
-- current toolchain configuration can actually produce are exposed here.
|
|
OPTIONAL_LIBS = {}
|
|
|
|
if tup.getconfig("NO_FASM") == "" then
|
|
tup.append_table(LIST_OF_LIBS, { "crt0.o", "tiny.o" })
|
|
OPTIONAL_LIBS.sound = "libsound.a"
|
|
end
|
|
|
|
if tup.getconfig("NO_TCC") == "" then
|
|
OPTIONAL_LIBS.cryptal = "libcryptal.a"
|
|
OPTIONAL_LIBS.shell = "libshell.a"
|
|
end
|
|
|
|
if tup.getconfig("NO_FASM") == "" and tup.getconfig("NO_TCC") == "" then
|
|
tup.append_table(LIST_OF_LIBS, { "libtcc1.a" })
|
|
end
|
|
|
|
function compile_tcc(input, output)
|
|
if not output then output = '%B.o' end
|
|
tup.append_table(OBJS,
|
|
tup.foreach_rule(input, TCC .. " -c " .. CFLAGS .. " %f -o %o", output)
|
|
)
|
|
end
|
|
|
|
function link_tcc(input, output, libs)
|
|
if not output then input, output = OBJS, input end
|
|
|
|
if type(input) ~= "table" then
|
|
input = { input }
|
|
end
|
|
|
|
if not input.extra_inputs then
|
|
input.extra_inputs = {}
|
|
end
|
|
|
|
for _, lib in pairs(LIST_OF_LIBS) do
|
|
table.insert(input.extra_inputs, KTCC_TRUNK .. "<" .. lib .. ">")
|
|
end
|
|
|
|
if libs then
|
|
for _, name in pairs(libs) do
|
|
local libfile = OPTIONAL_LIBS[name]
|
|
if libfile then
|
|
table.insert(input.extra_inputs, KTCC_TRUNK .. "<" .. libfile .. ">")
|
|
end
|
|
end
|
|
end
|
|
|
|
table.insert(input.extra_inputs, KTCC_TRUNK .. "bin/lib/*.def")
|
|
|
|
tup.rule(input,
|
|
TCC .. " " .. CFLAGS .. " " .. LFLAGS .. " " .. "%f -o %o " .. LIBS .. " " .. tup.getconfig("KPACK_CMD"),
|
|
output)
|
|
end
|