summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-30 22:59:25 +0800
committerruki <[email protected]>2026-01-30 22:59:25 +0800
commite836941e029a2999a0d904b77df2196ec8f8eac6 (patch)
tree04d98e3944a7386c754233f4a0fbf06b2add6494
parent6894de1efe19f04301bdbb3068ea746e1b26378b (diff)
improve errors
-rw-r--r--core/src/xmake/binutils/format.c6
-rw-r--r--tests/modules/binutils/test.lua2
-rw-r--r--xmake/core/base/binutils.lua24
3 files changed, 16 insertions, 16 deletions
diff --git a/core/src/xmake/binutils/format.c b/core/src/xmake/binutils/format.c
index 240449f85..1a12d8742 100644
--- a/core/src/xmake/binutils/format.c
+++ b/core/src/xmake/binutils/format.c
@@ -213,7 +213,7 @@ tb_int_t xm_binutils_format(lua_State *lua) {
tb_stream_ref_t istream = tb_stream_init_from_file(binaryfile, TB_FILE_MODE_RO);
if (!istream) {
lua_pushnil(lua);
- lua_pushfstring(lua, "format: open %s failed", binaryfile);
+ lua_pushfstring(lua, "open %s failed", binaryfile);
return 2;
}
@@ -221,14 +221,14 @@ tb_int_t xm_binutils_format(lua_State *lua) {
do {
if (!tb_stream_open(istream)) {
lua_pushnil(lua);
- lua_pushfstring(lua, "format: open %s failed", binaryfile);
+ lua_pushfstring(lua, "open %s failed", binaryfile);
break;
}
tb_int_t format = xm_binutils_format_detect(istream);
if (format < 0) {
lua_pushnil(lua);
- lua_pushliteral(lua, "format: cannot detect file format");
+ lua_pushliteral(lua, "cannot detect file format");
break;
}
diff --git a/tests/modules/binutils/test.lua b/tests/modules/binutils/test.lua
index b9c50b190..da8030558 100644
--- a/tests/modules/binutils/test.lua
+++ b/tests/modules/binutils/test.lua
@@ -34,7 +34,7 @@ function test_format(t)
elseif is_host("macosx", "iphoneos", "watchos", "appletvos") then
expected = "macho"
end
- t:are_equal(binutils.format(programfile), expected)
+ t:are_equal(binutils.format(path.absolute(programfile)), expected)
end
local ar = path.join(tempdir, "a.a")
diff --git a/xmake/core/base/binutils.lua b/xmake/core/base/binutils.lua
index 00c64dfec..7e08ac317 100644
--- a/xmake/core/base/binutils.lua
+++ b/xmake/core/base/binutils.lua
@@ -43,7 +43,7 @@ function binutils.bin2c(binaryfile, outputfile, opt)
return binutils._bin2c(binaryfile, outputfile, opt.linewidth or 32, opt.nozeroend or false)
else
-- fallback to old implementation if C implementation not available
- return nil, "bin2c: C implementation not available"
+ return nil, "C implementation not available"
end
end
@@ -77,21 +77,21 @@ function binutils.bin2obj(binaryfile, outputfile, opt)
if format == "coff" then
if not binutils._bin2coff then
- return nil, "bin2obj: binutils._bin2coff not available (C implementation not compiled)"
+ return nil, "binutils._bin2coff not available (C implementation not compiled)"
end
return binutils._bin2coff(binaryfile, outputfile, opt.symbol_prefix or "_binary_", opt.arch or "x86_64", opt.basename, opt.zeroend or false)
elseif format == "macho" then
if not binutils._bin2macho then
- return nil, "bin2obj: binutils._bin2macho not available (C implementation not compiled)"
+ return nil, "binutils._bin2macho not available (C implementation not compiled)"
end
return binutils._bin2macho(binaryfile, outputfile, opt.symbol_prefix or "_binary_", opt.plat or "macosx", opt.arch or "x86_64", opt.basename, opt.target_minver, opt.xcode_sdkver, opt.zeroend or false)
elseif format == "elf" then
if not binutils._bin2elf then
- return nil, "bin2obj: binutils._bin2elf not available (C implementation not compiled)"
+ return nil, "binutils._bin2elf not available (C implementation not compiled)"
end
return binutils._bin2elf(binaryfile, outputfile, opt.symbol_prefix or "_binary_", opt.arch or "x86_64", opt.basename, opt.zeroend or false)
else
- return nil, string.format("bin2obj: unsupported format '%s' (supported: coff, elf, macho)", format)
+ return nil, string.format("unsupported format '%s' (supported: coff, elf, macho)", format)
end
end
@@ -100,7 +100,7 @@ function binutils.format(binaryfile)
if binutils._format then
return binutils._format(binaryfile)
else
- return nil, "format: C implementation not available"
+ return nil, "C implementation not available"
end
end
@@ -110,7 +110,7 @@ function binutils.readsyms(binaryfile)
if binutils._readsyms then
return binutils._readsyms(binaryfile)
else
- return nil, "readsyms: C implementation not available"
+ return nil, "C implementation not available"
end
end
@@ -119,7 +119,7 @@ function binutils.deplibs(binaryfile)
if binutils._deplibs then
return binutils._deplibs(binaryfile)
else
- return nil, "deplibs: C implementation not available"
+ return nil, "C implementation not available"
end
end
@@ -128,7 +128,7 @@ function binutils.rpath_list(binaryfile)
if binutils._rpath_list then
return binutils._rpath_list(binaryfile)
else
- return nil, "binutils: internal rpath_list not supported!"
+ return nil, "internal rpath_list not supported!"
end
end
@@ -139,7 +139,7 @@ function binutils.rpath_clean(binaryfile)
if binutils._rpath_clean then
return binutils._rpath_clean(binaryfile)
else
- return false, "binutils: internal rpath_clean not supported!"
+ return false, "internal rpath_clean not supported!"
end
end
@@ -156,10 +156,10 @@ function binutils.extractlib(libraryfile, outputdir, opt)
if ok then
return true
else
- return false, errors or "extractlib: unknown error"
+ return false, errors or "unknown error"
end
else
- return false, "extractlib: C implementation not available"
+ return false, "C implementation not available"
end
end