ktcc autobuild: fix gating, dependency wiring, and packaging
Address several blockers in the TCC autobuild PR so it does not break non-default toolchain configurations and so that build-time deps line up with the new policy "TCC programs require FASM": * programs/demos/kmatrix/Tupfile.lua: skip-guard used `and` instead of `or`, which would attempt the build with NO_FASM=full and fail at link time. Aligned with the rest of the TCC programs. * programs/develop/ktcc/libc.obj/source/Tupfile.lua: FASM_SRC was declared inside the NO_TCC block, so NO_TCC=full + NO_FASM="" errored on a nil reference instead of building crt0.o. Hoisted the declaration above both blocks. * programs/develop/ktcc/Tupfile.lua, programs/use_tcc.lua: stop routing libsound.a through tup.getvariantdir()-based cross-tree paths in use_tcc.lua. libsound.a is now copied into bin/lib/ via a dedicated tup.rule that references the contrib group through extra_inputs (matching the cross-tree convention used elsewhere in the tree, e.g. minizip and fridge). Cleaned up the now-dead libPath/lib-table case in link_tcc together with the double-negation conditionals. * programs/use_tcc.lua: split LIST_OF_LIBS (mandatory crt0/tiny/libtcc1) from OPTIONAL_LIBS (sound/cryptal/shell). link_tcc accepts an optional third argument naming requested libraries, so programs no longer transitively depend on libsound/libcryptal/libshell unless they actually need them. * programs/other/TinyHashView/Tupfile.lua: declares the cryptal dependency explicitly through the new link_tcc signature. * programs/develop/ktcc/lib/libshell/Tupfile.lua: missing shell_api.h added to extra_inputs so libshell is rebuilt when its public header changes (matches the pattern already used for the other headers). * data/Tupfile.lua: libsound.a now sourced from programs/develop/ktcc/bin/lib/<libsound.a> for consistency with the other libs. The TCC packaging block was gated only on NO_TCC; under the new policy executables also require FASM, so the executable entries are nested under an additional NO_FASM gate while LIBC.OBJ, libshell.a, libcryptal.a and the static data files stay outside the inner gate. * .gitignore: replaced build-en_US/ + en_US.config with the more general /build-*/ + /*.config (root-anchored so they cannot shadow tracked files in subdirectories).
This commit is contained in:
+2
-3
@@ -12,7 +12,6 @@ programs/cmm/menu/.gitignore
|
||||
|
||||
.tup/
|
||||
|
||||
build-en_US/
|
||||
|
||||
en_US.config
|
||||
/build-*/
|
||||
/*.config
|
||||
|
||||
|
||||
+16
-6
@@ -638,7 +638,7 @@ tup.append_table(extra_files, {
|
||||
{"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_CONTRIB .. "/sdk/sources/sound/libsound.a", group = "../contrib/sdk/sources/sound/<libsound.a>"}
|
||||
{"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, {
|
||||
@@ -723,28 +723,38 @@ 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>"}
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if tup.getconfig("NO_TCC") ~= "" and tup.getconfig("NO_FASM") ~= "" 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,25 +1,36 @@
|
||||
local LIBS = {}
|
||||
|
||||
if not (tup.getconfig("NO_FASM") ~= "") then
|
||||
if tup.getconfig("NO_FASM") == "" then
|
||||
tup.append_table(LIBS, {
|
||||
tup.getcwd() .. "/libc.obj/source/crt0.o",
|
||||
tup.getcwd() .. "/lib/tiny/tiny.o"
|
||||
tup.getcwd() .. "/lib/tiny/tiny.o",
|
||||
})
|
||||
end
|
||||
|
||||
if not (tup.getconfig("NO_TCC") ~= "") then
|
||||
if tup.getconfig("NO_TCC") == "" then
|
||||
tup.append_table(LIBS, {
|
||||
tup.getcwd() .. "/lib/libcryptal/libcryptal.a",
|
||||
tup.getcwd() .. "/lib/libshell/libshell.a",
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
if (not (tup.getconfig("NO_FASM") ~= "")) and
|
||||
(not (tup.getconfig("NO_TCC") ~= "")) then
|
||||
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
|
||||
|
||||
@@ -11,6 +11,7 @@ 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",
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
if not (tup.getconfig("NO_TCC") ~= "") then
|
||||
FASM_SRC = {
|
||||
"crt/crt0.asm",
|
||||
}
|
||||
|
||||
if tup.getconfig("NO_TCC") == "" then
|
||||
|
||||
CFLAGS = " -r -nostdinc -nostdlib -DGNUC -D_BUILD_LIBC "
|
||||
INCLUDES = " -I../include"
|
||||
@@ -32,10 +36,6 @@ GAS_SRC = {
|
||||
"string/memmove.s"
|
||||
}
|
||||
|
||||
FASM_SRC = {
|
||||
"crt/crt0.asm",
|
||||
}
|
||||
|
||||
OBJS = { "libc.c" }
|
||||
|
||||
tup.append_table(OBJS, tup.foreach_rule(GAS_SRC, "as --32 %f -o %o", "%B.o"))
|
||||
@@ -45,7 +45,7 @@ tup.rule("libc.o", "objconv -fcoff32 %f %o " .. tup.getconfig("KPACK_CMD"), "%B.
|
||||
|
||||
end
|
||||
|
||||
if not (tup.getconfig("NO_FASM") ~= "") then
|
||||
if tup.getconfig("NO_FASM") == "" then
|
||||
|
||||
tup.rule(FASM_SRC, "fasm %f %o", "%B.o")
|
||||
|
||||
|
||||
@@ -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"});
|
||||
|
||||
+24
-32
@@ -8,29 +8,27 @@ 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 = {}
|
||||
|
||||
if not (tup.getconfig("NO_FASM") ~= "") then
|
||||
tup.append_table(LIST_OF_LIBS, {
|
||||
"crt0.o",
|
||||
"tiny.o",
|
||||
{ lib = "libsound.a", libPath = tup.getvariantdir() .. "/../contrib/sdk/sources/sound/" },
|
||||
})
|
||||
-- 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 not (tup.getconfig("NO_TCC") ~= "") then
|
||||
tup.append_table(LIST_OF_LIBS, {
|
||||
"libcryptal.a",
|
||||
"libshell.a",
|
||||
})
|
||||
if tup.getconfig("NO_TCC") == "" then
|
||||
OPTIONAL_LIBS.cryptal = "libcryptal.a"
|
||||
OPTIONAL_LIBS.shell = "libshell.a"
|
||||
end
|
||||
|
||||
if (not (tup.getconfig("NO_FASM") ~= "")) and
|
||||
(not (tup.getconfig("NO_TCC") ~= ""))
|
||||
then
|
||||
tup.append_table(LIST_OF_LIBS, {
|
||||
"libtcc1.a",
|
||||
})
|
||||
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)
|
||||
@@ -40,7 +38,7 @@ function compile_tcc(input, output)
|
||||
)
|
||||
end
|
||||
|
||||
function link_tcc(input, output)
|
||||
function link_tcc(input, output, libs)
|
||||
if not output then input, output = OBJS, input end
|
||||
|
||||
if type(input) ~= "table" then
|
||||
@@ -51,22 +49,16 @@ function link_tcc(input, output)
|
||||
input.extra_inputs = {}
|
||||
end
|
||||
|
||||
for _, v in pairs(LIST_OF_LIBS) do
|
||||
local lib
|
||||
for _, lib in pairs(LIST_OF_LIBS) do
|
||||
table.insert(input.extra_inputs, KTCC_TRUNK .. "<" .. lib .. ">")
|
||||
end
|
||||
|
||||
if type(v) == "string" then
|
||||
lib = v
|
||||
elseif type(v) == "table" then
|
||||
if v.libPath then
|
||||
LIBS = " -L" .. v.libPath .. " " .. LIBS
|
||||
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
|
||||
if v.lib then
|
||||
lib = v.lib
|
||||
end
|
||||
end
|
||||
|
||||
if lib then
|
||||
table.insert(input.extra_inputs, (v.libPath or KTCC_TRUNK) .. "<" .. lib .. ">")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user