add autobuild of some tcc libs (#339)

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>
This commit was merged in pull request #339.
This commit is contained in:
2026-05-16 08:30:18 +00:00
committed by Burer
parent e1a30a4f14
commit 175bd31489
30 changed files with 275 additions and 46 deletions
+6
View File
@@ -9,3 +9,9 @@ ehthumbs_vista.db
._*
programs/cmm/cmm.code-workspace
programs/cmm/menu/.gitignore
.tup/
/build-*/
/*.config
+18
View File
@@ -0,0 +1,18 @@
if tup.getconfig("NO_FASM") ~= "" then return end
SOURCES = {
"src/*.asm",
extra_inputs = {
"src/*.inc"
}
}
OBJS = {
extra_inputs = {
"symbols"
}
}
tup.append_table(OBJS, tup.foreach_rule(SOURCES, "fasm %f %o", "%B.o"))
tup.rule(OBJS, "ar -cvrs %o %f && objcopy -O elf32-i386 --redefine-syms=symbols %o", {"libsound.a", "<libsound.a>"})
+30 -7
View File
@@ -184,7 +184,8 @@ extra_files = {
{"kolibrios/develop/oberon07/lib/KolibriOS/", SRC_PROGS .. "/develop/oberon07/lib/KolibriOS/*"},
{"kolibrios/develop/oberon07/lib/Math/", SRC_PROGS .. "/develop/oberon07/lib/Math/*"},
{"kolibrios/develop/oberon07/samples/", SRC_PROGS .. "/develop/oberon07/samples/KolibriOS/*"},
{"kolibrios/develop/tcc/lib/", SRC_PROGS .. "/develop/ktcc/bin/lib/*"},
{"kolibrios/develop/tcc/lib/", SRC_PROGS .. "/develop/ktcc/bin/lib/*.def"},
{"kolibrios/develop/tcc/lib/libSDL.a", SRC_PROGS .. "/develop/ktcc/bin/lib/libSDL.a"},
{"kolibrios/develop/tcc/include/", SRC_PROGS .. "/develop/ktcc/libc.obj/include/*"},
{"kolibrios/develop/tcc/include/clayer/", SRC_PROGS .. "/develop/ktcc/libc.obj/include/clayer/*"},
{"kolibrios/develop/tcc/include/cryptal/", SRC_PROGS .. "/develop/ktcc/libc.obj/include/cryptal/*"},
@@ -634,7 +635,10 @@ tup.append_table(extra_files, {
{"kolibrios/utils/AMDtemp", VAR_PROGS .. "/system/amd_temp_view/AMDtemp"},
{"kolibrios/utils/kfm/kfm", VAR_PROGS .. "/fs/kfm/kfm"},
{"kolibrios/utils/tedit/t_edit", VAR_PROGS .. "/other/t_edit/t_edit"},
{"kolibrios/3D/blocks/block.bin", VAR_PROGS .. "/bcc32/games/blocks/block.bin"}
{"kolibrios/3D/blocks/block.bin", VAR_PROGS .. "/bcc32/games/blocks/block.bin"},
{"kolibrios/develop/tcc/lib/crt0.o", VAR_PROGS .. "/develop/ktcc/bin/lib/crt0.o", group = "../programs/develop/ktcc/<crt0.o>"},
{"kolibrios/develop/tcc/lib/tiny.o", VAR_PROGS .. "/develop/ktcc/bin/lib/tiny.o", group = "../programs/develop/ktcc/<tiny.o>"},
{"kolibrios/develop/tcc/lib/libsound.a", VAR_PROGS .. "/develop/ktcc/bin/lib/libsound.a", group = "../programs/develop/ktcc/<libsound.a>"}
})
-- For russian build, add russian-only programs.
if build_type == "ru_RU" then tup.append_table(img_files, {
@@ -719,29 +723,41 @@ tup.append_table(extra_files, {
})
end -- tup.getconfig('NO_MSVC') ~= 'full'
-- Programs that require TCC to compile.
-- Programs that require TCC to compile. TCC programs that link executables
-- additionally need FASM (for crt0.o, tiny.o, libtcc1.a). LIBC.OBJ is a
-- relocatable TCC translation unit and does not require FASM.
if tup.getconfig('NO_TCC') ~= 'full' then
if tup.getconfig('NO_FASM') ~= 'full' then
tup.append_table(img_files, {
{"NETWORK/WHOIS", VAR_PROGS .. "/network/whois/whois"},
{"SHELL", VAR_PROGS .. "/system/shell/shell"},
{"GAMES/DINO", VAR_PROGS .. "/games/dino/dino"},
{"GAMES/FLPYBIRD", VAR_PROGS .. "/games/flpybird/flpybird"},
})
end -- tup.getconfig('NO_FASM') ~= 'full'
tup.append_table(img_files, {
{"LIB/LIBC.OBJ", VAR_PROGS .. "/develop/ktcc/libc.obj/source/libc.obj"},
})
if tup.getconfig('NO_FASM') ~= 'full' then
tup.append_table(extra_files, {
{"kolibrios/utils/thashview", VAR_PROGS .. "/other/TinyHashView/thashview"},
{"kolibrios/demos/kmatrix", VAR_PROGS .. "/demos/kmatrix/kmatrix"},
{"kolibrios/utils/graph", VAR_PROGS .. "/other/graph/branches/tcc_current/graph"},
{"kolibrios/develop/TinyBasic/TinyBasic", VAR_PROGS .. "/develop/tinybasic-1.0.4/tinybasic"},
{"kolibrios/develop/TinyBasic/bas/", SRC_PROGS .. "/develop/tinybasic-1.0.4/bas/*"},
{"kolibrios/develop/TinyBasic/TinyBasic.man", SRC_PROGS .. "/develop/tinybasic-1.0.4/doc/tinybasic.man"},
{"kolibrios/utils/passwordgen", VAR_PROGS .. "/other/PasswordGen/passwordgen"},
{"kolibrios/utils/kruler", VAR_PROGS .. "/other/kruler/kruler"},
{"kolibrios/media/qr_tool", SRC_PROGS .. "/media/qr_tool/qr_tool"},
{"kolibrios/utils/weather", VAR_PROGS .. "/other/Weather/weather"},
{"kolibrios/settings/weather.json", SRC_PROGS .. "/other/Weather/weather.json"},
{"kolibrios/utils/man2html", VAR_PROGS .."/other/man2html/man2html"},
})
end -- tup.getconfig('NO_FASM') ~= 'full'
tup.append_table(extra_files, {
{"kolibrios/develop/TinyBasic/bas/", SRC_PROGS .. "/develop/tinybasic-1.0.4/bas/*"},
{"kolibrios/develop/TinyBasic/TinyBasic.man", SRC_PROGS .. "/develop/tinybasic-1.0.4/doc/tinybasic.man"},
{"kolibrios/media/qr_tool", SRC_PROGS .. "/media/qr_tool/qr_tool"},
{"kolibrios/settings/weather.json", SRC_PROGS .. "/other/Weather/weather.json"},
{"kolibrios/develop/tcc/lib/libshell.a", VAR_PROGS .. "/develop/ktcc/bin/lib/libshell.a", group="../programs/develop/ktcc/<libshell.a>"},
{"kolibrios/develop/tcc/lib/libcryptal.a", VAR_PROGS .. "/develop/ktcc/bin/lib/libcryptal.a", group="../programs/develop/ktcc/<libcryptal.a>"}
})
end -- tup.getconfig('NO_TCC') ~= 'full'
-- Programs that require oberon07 compiler.
@@ -808,6 +824,13 @@ if tup.getconfig('NO_NASM') ~= 'full' then
{"kolibrios/emul/dgen/dgenrc.html", SRC_PROGS .. "/emulator/dgen-sdl-1.33/dgenrc.html"},
})
end
if tup.getconfig("NO_FASM") ~= "full" and tup.getconfig("NO_TCC") ~= "full" then
tup.append_table(extra_files, {
{"kolibrios/develop/tcc/lib/libtcc1.a", VAR_PROGS .. "/develop/ktcc/bin/lib/libtcc1.a", group="../programs/develop/ktcc/<libtcc1.a>"}
})
end
-- For russian build, add russian-only programs.
if build_type == "ru_RU" then tup.append_table(extra_files, {
{"kolibrios/games/21days", VAR_PROGS .. "/games/21days/21days"},
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_tcc.lua")
+36
View File
@@ -0,0 +1,36 @@
local LIBS = {}
if tup.getconfig("NO_FASM") == "" then
tup.append_table(LIBS, {
tup.getcwd() .. "/libc.obj/source/crt0.o",
tup.getcwd() .. "/lib/tiny/tiny.o",
})
end
if tup.getconfig("NO_TCC") == "" then
tup.append_table(LIBS, {
tup.getcwd() .. "/lib/libcryptal/libcryptal.a",
tup.getcwd() .. "/lib/libshell/libshell.a",
})
end
if tup.getconfig("NO_FASM") == "" and tup.getconfig("NO_TCC") == "" then
tup.append_table(LIBS, {
tup.getcwd() .. "/libc.obj/source/libtcc1/libtcc1.a",
})
end
tup.foreach_rule(LIBS, "cp %f %o", { tup.getcwd() .. "/bin/lib/%b", "<%b>" })
-- libsound.a lives in another subtree (contrib/), so reference its group
-- explicitly via extra_inputs to keep Tup ordering correct across trees.
if tup.getconfig("NO_FASM") == "" then
tup.rule(
{
"../../../contrib/sdk/sources/sound/libsound.a",
extra_inputs = { "../../../contrib/sdk/sources/sound/<libsound.a>" },
},
"cp %f %o",
{ tup.getcwd() .. "/bin/lib/libsound.a", "<libsound.a>" }
)
end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,23 @@
if tup.getconfig("NO_TCC") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_tcc.lua")
LIBC_INCLUDE = "../../libc.obj/include"
CFLAGS += "-c -I. -I" .. LIBC_INCLUDE
SOURCES = {
"*.c",
extra_inputs = {
"memory.h",
LIBC_INCLUDE .. "/cryptal/*",
LIBC_INCLUDE .. "/string.h",
LIBC_INCLUDE .. "/stdlib.h",
LIBC_INCLUDE .. "/stdio.h",
}
}
compile_tcc(SOURCES)
tup.rule(OBJS, "ar -rcs %o %f", "libcryptal.a")
@@ -0,0 +1,24 @@
if tup.getconfig("NO_TCC") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_tcc.lua")
LIBC_INCLUDE = "../../libc.obj/include"
CFLAGS += "-c -I. -I" .. LIBC_INCLUDE
SOURCES = {
"*.c",
extra_inputs = {
LIBC_INCLUDE .. "/shell_api.h",
LIBC_INCLUDE .. "/sys/ksys.h",
LIBC_INCLUDE .. "/string.h",
LIBC_INCLUDE .. "/stdlib.h",
LIBC_INCLUDE .. "/stdio.h"
}
}
compile_tcc(SOURCES)
tup.rule(OBJS, "ar -rcs %o %f", "libshell.a")
@@ -0,0 +1,10 @@
if tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_fasm.lua")
FASM_SOURCES = {
"tiny.asm",
}
tup.rule(FASM_SOURCES, FASM .. " %f %o", "%B.o")
@@ -0,0 +1,4 @@
.tup
*.o
*.obj
*.kex
Binary file not shown.
@@ -1,4 +1,8 @@
if tup.getconfig("NO_TCC") ~= "" then return end
FASM_SRC = {
"crt/crt0.asm",
}
if tup.getconfig("NO_TCC") == "" then
CFLAGS = " -r -nostdinc -nostdlib -DGNUC -D_BUILD_LIBC "
INCLUDES = " -I../include"
@@ -32,11 +36,17 @@ GAS_SRC = {
"string/memmove.s"
}
OBJS = {"libc.c"}
OBJS = { "libc.c" }
tup.append_table(OBJS,
tup.foreach_rule(GAS_SRC, "as --32 %f -o %o", "%B.o")
)
tup.append_table(OBJS, tup.foreach_rule(GAS_SRC, "as --32 %f -o %o", "%B.o"))
tup.rule(OBJS, "kos32-tcc" .. CFLAGS .. INCLUDES .. " %f -o %o " .. " && strip %o --strip-unneeded " , "libc.o")
tup.rule(OBJS, "kos32-tcc" .. CFLAGS .. INCLUDES .. " %f -o %o " .. " && strip %o --strip-unneeded ", "libc.o")
tup.rule("libc.o", "objconv -fcoff32 %f %o " .. tup.getconfig("KPACK_CMD"), "%B.obj")
end
if tup.getconfig("NO_FASM") == "" then
tup.rule(FASM_SRC, "fasm %f %o", "%B.o")
end
@@ -0,0 +1,25 @@
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
local helperPath = "../../../../.."
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and helperPath or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_tcc.lua")
tup.include(HELPERDIR .. "/use_fasm.lua")
TCC_SOURCES = {
"libtcc1.c",
}
FASM_SOURCES = {
"memcpy.asm",
"memmove.asm",
"memset.asm",
extra_inputs = {
helperPath .. "/proc32.inc"
}
}
compile_tcc(TCC_SOURCES)
tup.append_table(OBJS, tup.foreach_rule(FASM_SOURCES, FASM .. " %f %o", "%B.o"))
tup.rule(OBJS, "ar -rcs %o %f", "libtcc1.a")
@@ -1,5 +1,4 @@
if tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_FASM") ~= "" or tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../../../"
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
+2 -2
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
@@ -7,4 +7,4 @@ tup.include(HELPERDIR .. "/use_tcc.lua")
LIBS = "-lcryptal -lbox_lib -ldialog"
link_tcc({"thashview.c"}, "thashview");
link_tcc({"thashview.c"}, "thashview", {"cryptal"});
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_tcc.lua")
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("HELPERDIR") == ""
then
HELPERDIR = "../../../programs"
+1 -1
View File
@@ -1,4 +1,4 @@
if tup.getconfig("NO_TCC") ~= "" then return end
if tup.getconfig("NO_TCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_tcc.lua")
+70 -19
View File
@@ -1,19 +1,70 @@
TCC = "kos32-tcc -B" .. tup.getcwd().. "/develop/ktcc/bin"
CFLAGS = "-I" .. tup.getcwd().. "/develop/ktcc/libc.obj/include "
LFLAGS = ""
LIBS = ""
OBJS = {}
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)
if not output then input,output = OBJS,input end
tup.rule(input, TCC .. " " .. CFLAGS .. " " .. LFLAGS .. " %f -o %o " .. LIBS .. " " .. tup.getconfig("KPACK_CMD"), output)
end
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