Skip to content

Commit a53eaa2

Browse files
committed
diag(connector): write hook trace to a findable build log
xlings swallows install-hook stdout/log.error, so the previous stdout diagnostics never reached the Actions log. Write every step (including a descriptor-load marker) to $HOME/.mcpp/registry/data/mcpp_mysql_connector_cpp_build.log, which validate.yml's 'find ... -name mcpp_*_build.log' dump tail-prints.
1 parent 9c687bd commit a53eaa2

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

pkgs/c/compat.mysql-connector-cpp.lua

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ package = {
5353

5454
import("xim.libxpkg.pkginfo")
5555
import("xim.libxpkg.log")
56+
-- [diag] file-based diagnostics: written under $HOME/.mcpp/registry so the
57+
-- validate.yml `find ... -name 'mcpp_*_build.log'` dump surfaces it even when
58+
-- the hook's stdout/stderr are swallowed by xlings. Strip before finalizing.
59+
local diagf = path.join(os.getenv("HOME") or "/tmp", ".mcpp/registry/data/mcpp_mysql_connector_cpp_build.log")
60+
local function diag(msg)
61+
local f = io.open(diagf, "a")
62+
if f then
63+
f:write(os.date("%H:%M:%S") .. " " .. tostring(msg) .. "\n")
64+
f:close()
65+
end
66+
end
67+
diag("descriptor loaded; cwd=" .. tostring(os.getcwd and os.getcwd()))
68+
5669

5770
local function sh_quote(value)
5871
return "'" .. tostring(value):gsub("'", "'\\''") .. "'"
@@ -88,7 +101,6 @@ local function run(step, logf, command)
88101
.. tostring(err) .. ")\n--- last 40 lines of " .. logf .. " ---\n"
89102
.. tail_lines(logf, 40)
90103
log.error("%s", msg)
91-
print(msg) -- [diag] surface to Actions stdout
92104
return false
93105
end
94106

@@ -131,25 +143,22 @@ local function patch_internal_compression_helper(srcroot)
131143
end
132144

133145
function install()
134-
-- [diag] diagnostics to stdout; strip before finalizing
135-
print("compat.mysql-connector-cpp: install() start pkg_name=" .. tostring(pkginfo.name())
136-
.. " version=" .. tostring(pkginfo.version())
137-
.. " install_file=" .. tostring(pkginfo.install_file())
138-
.. " install_dir=" .. tostring(pkginfo.install_dir())
139-
.. " deps=" .. tostring(pkginfo.deps_list()))
146+
diag("install() called; install_file=" .. tostring(pkginfo.install_file())
147+
.. " install_dir=" .. tostring(pkginfo.install_dir())
148+
.. " deps=" .. tostring(pkginfo.deps_list()))
140149
local ok, result = pcall(function()
141150
local srcroot = find_source_root()
142151
local mysql = pkginfo.install_dir("compat:libmysqlclient", "8.4.6")
143152
local openssl = pkginfo.install_dir("compat:openssl", "3.5.1")
144-
print("compat.mysql-connector-cpp: [diag] srcroot=" .. tostring(srcroot)
145-
.. " mysql=" .. tostring(mysql) .. " openssl=" .. tostring(openssl))
153+
diag("step1 srcroot=" .. tostring(srcroot) .. " mysql=" .. tostring(mysql)
154+
.. " openssl=" .. tostring(openssl))
146155
if not srcroot or not mysql or not openssl then
147156
log.error("compat.mysql-connector-cpp: source/dependency prefix not found")
148157
return false
149158
end
150159

151160
local mysql_src = find_mysql_source_root(mysql)
152-
print("compat.mysql-connector-cpp: [diag] mysql_src=" .. tostring(mysql_src))
161+
diag("step2 mysql_src=" .. tostring(mysql_src))
153162
if not mysql_src then
154163
log.error("compat.mysql-connector-cpp: libmysqlclient Form A source root not found")
155164
return false
@@ -158,8 +167,8 @@ function install()
158167
local prefix = pkginfo.install_dir()
159168
local builddir = path.join(srcroot, "mcpp-build")
160169
local logf = path.join(prefix, "mcpp_mysql_connector_cpp_build.log")
161-
print("compat.mysql-connector-cpp: [diag] prefix=" .. tostring(prefix)
162-
.. " builddir=" .. tostring(builddir) .. " logf=" .. tostring(logf))
170+
diag("step3 prefix=" .. tostring(prefix) .. " builddir=" .. tostring(builddir)
171+
.. " logf=" .. tostring(logf))
163172
os.tryrm(prefix)
164173
os.mkdir(prefix)
165174
os.tryrm(builddir)
@@ -251,9 +260,9 @@ function install()
251260
"int mcpp_compat_mysql_connector_cpp_anchor(void) { return 0; }\n")
252261
end)
253262
if not ok then
254-
print("compat.mysql-connector-cpp: UNCAUGHT Lua error: " .. tostring(result))
263+
diag("UNCAUGHT Lua error: " .. tostring(result))
255264
return false
256265
end
257-
print("compat.mysql-connector-cpp: install() result=" .. tostring(result))
266+
diag("install() result=" .. tostring(result))
258267
return result
259268
end

0 commit comments

Comments
 (0)