From 918d22c5a20e579c9c9e32ff41bfdcb11c350d2c Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 13 Feb 2026 23:59:41 +0800 Subject: add haiku ci --- .github/workflows/haiku.yml | 81 +++++++++++++++++++++ core/src/tbox/tbox | 2 +- core/src/xmake/string/lower.c | 162 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/haiku.yml diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml new file mode 100644 index 000000000..f277d263f --- /dev/null +++ b/.github/workflows/haiku.yml @@ -0,0 +1,81 @@ +name: Haiku + +on: + pull_request: + push: + release: + types: [published] + +jobs: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const outputFile = process.env.GITHUB_OUTPUT; + + if (context.eventName === 'release') { + fs.appendFileSync(outputFile, `should-run=true\n`); + core.info('Release event detected. Will run tests.'); + return; + } + + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; + } + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + fs.appendFileSync(outputFile, `should-run=${shouldRun}\n`); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.HAIKU_RUN_PROBABILITY || '0.2' }} + + build: + #needs: check + #if: needs.check.outputs.should-run == 'true' + runs-on: ubuntu-latest + + concurrency: + group: Haiku-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Tests + uses: vmactions/haiku-vm@v1 + with: + usesh: true + mem: 4096 + copyback: false + prepare: | + pkgman install -y git curl unzip make bash perl + run: | + pwd + ./configure --prefix=`pwd`/dist + make -j2 + make install + ls -l ./dist/ + export XMAKE_ROOT=y + export PATH=`pwd`/dist/bin:$PATH + xrepo --version + xmake l os.meminfo + xmake l string.lower "Test 源文件🎆 Message" diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox index ef851bcb6..75c90b4c4 160000 --- a/core/src/tbox/tbox +++ b/core/src/tbox/tbox @@ -1 +1 @@ -Subproject commit ef851bcb6589b6092f5bd3fca4625631237f9bdd +Subproject commit 75c90b4c4313f84f8247867c99721882e390f401 diff --git a/core/src/xmake/string/lower.c b/core/src/xmake/string/lower.c index 71f8408dc..07ae4bff4 100644 --- a/core/src/xmake/string/lower.c +++ b/core/src/xmake/string/lower.c @@ -23,6 +23,166 @@ * includes */ #include "prefix.h" +# include + +static __tb_inline__ tb_bool_t tb_unicode_tolower_try(tb_uint32_t ch, tb_uint32_t* out) +{ + // builtin, locale-independent case mapping for some common unicode ranges: + // - Basic Latin (ASCII) + // - Latin-1 Supplement (partial) + // - Latin Extended-A (partial) + // - Greek (partial) + // - Cyrillic (partial) + if (sizeof(tb_wchar_t) == 2 && ch >= 0xd800 && ch <= 0xdfff) return tb_false; + + // Basic Latin (ASCII) + if (ch <= 0x7f) + { + tb_trace_i("basic: %x", ch); + *out = tb_tolower(ch); + return tb_true; + } + + // Latin-1 Supplement: U+00C0..U+00D6, U+00D8..U+00DE + if ((ch >= 0x00c0 && ch <= 0x00d6) || (ch >= 0x00d8 && ch <= 0x00de)) { *out = ch + 0x20; return tb_true; } + // Latin-1 Supplement: U+00E0..U+00F6, U+00F8..U+00FE + if ((ch >= 0x00e0 && ch <= 0x00f6) || (ch >= 0x00f8 && ch <= 0x00fe)) { *out = ch; return tb_true; } + + // Latin-1 Supplement: U+0178 <-> U+00FF + if (ch == 0x0178) { *out = 0x00ff; return tb_true; } + if (ch == 0x00ff) { *out = ch; return tb_true; } + + // Latin Extended Additional: U+1E9E <-> U+00DF + if (ch == 0x1e9e) { *out = 0x00df; return tb_true; } + if (ch == 0x00df) { *out = ch; return tb_true; } + + // Latin Extended-A: many letters have alternating upper/lower code points + if (ch >= 0x0100 && ch <= 0x012f) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } + if (ch >= 0x0132 && ch <= 0x0137) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } + if (ch >= 0x0139 && ch <= 0x0148) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } + if (ch >= 0x014a && ch <= 0x0177) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } + if (ch >= 0x0179 && ch <= 0x017e) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } + // Latin Extended-A: long s (already lowercase) + if (ch == 0x017f) { *out = ch; return tb_true; } + + // Greek and Coptic (partial): U+0391..U+03A1, U+03A3..U+03AB + if ((ch >= 0x0391 && ch <= 0x03a1) || (ch >= 0x03a3 && ch <= 0x03ab)) { *out = ch + 0x20; return tb_true; } + // Greek and Coptic (partial): U+03B1..U+03C1, U+03C3..U+03CB, and U+03C2 + if ((ch >= 0x03b1 && ch <= 0x03c1) || (ch >= 0x03c3 && ch <= 0x03cb) || ch == 0x03c2) { *out = ch; return tb_true; } + + // Cyrillic (partial): U+0401/U+0451 and U+0410..U+042F + if (ch == 0x0401) { *out = 0x0451; return tb_true; } + if (ch == 0x0451) { *out = ch; return tb_true; } + if (ch >= 0x0402 && ch <= 0x040f) { *out = ch + 0x50; return tb_true; } + if (ch >= 0x0452 && ch <= 0x045f) { *out = ch; return tb_true; } + if (ch >= 0x0410 && ch <= 0x042f) { *out = ch + 0x20; return tb_true; } + + if (ch >= 0x0430 && ch <= 0x044f) { + *out = ch; + return tb_true; + } + + return tb_false; +} + +tb_wchar_t tb_towlower_test(tb_wchar_t c) +{ + tb_trace_i("towlower: %x, wchar: %d", (tb_uint32_t)c, sizeof(tb_wchar_t)); + tb_uint32_t ch = tb_bits_wchar_to_u32_le(c); + tb_uint32_t out; + if (__tb_likely__(tb_unicode_tolower_try(ch, &out))) { + tb_trace_i("towlower: out: %x", out); + return tb_bits_u32_le_to_wchar(out); + } + + tb_trace_i("towlower xxx: %x", (tb_uint32_t)c); + return (tb_wchar_t)towlower((tb_uint32_t)c); +} + +static tb_wchar_t* tb_wcslwr_test(tb_wchar_t* s) +{ + // check + tb_assert_and_check_return_val(s, tb_null); + + // set local locale + tb_setlocale(); + + tb_wchar_t* p = s; + while (*p) + { + *p = tb_towlower_test(*p); + p++; + } + + // set default locale + tb_resetlocale(); + + return s; +} + +static tb_size_t tb_mbstowcs_charset(tb_wchar_t* s1, tb_char_t const* s2, tb_size_t n) +{ + // check + tb_assert_and_check_return_val(s1 && s2, 0); + + // init + tb_size_t e = (sizeof(tb_wchar_t) == 4) ? TB_CHARSET_TYPE_UTF32 : TB_CHARSET_TYPE_UTF16; + tb_long_t r = tb_charset_conv_cstr(TB_CHARSET_TYPE_UTF8, e | TB_CHARSET_TYPE_LE, s2, + (tb_byte_t*)s1, n * sizeof(tb_wchar_t)); + if (r > 0) r /= sizeof(tb_wchar_t); + + // strip + if (r >= 0) s1[r] = L'\0'; + + tb_trace_i("tb_mbstowcs_charset: %ld", r); + // ok? + return r >= 0 ? r : -1; +} + +static tb_long_t tb_charset_utf8_tolower_test(tb_char_t* s, tb_size_t n) +{ + tb_assert_and_check_return_val(s, -1); + + tb_trace_i("s: %s: %d", s, n); + + // try ascii tolower first + tb_char_t* p = s; + tb_char_t* e = s + n; + while (p < e && *p) + { + if ((*p) & 0x80) { + break; + } + tb_trace_i("old: %c -> %x", *p); + *p = tb_tolower(*p); + tb_trace_i("new: %c -> %x", *p); + p++; + } + tb_trace_i("test: %d %d", p == e, !*p); + + if (p == e || !*p) return p - s; + + // convert the suffix to wchar_t + tb_long_t r = -1; + tb_size_t wn = e - p + 1; + tb_wchar_t wb[256]; + tb_wchar_t* w = (wn <= 256)? wb : (tb_wchar_t*)tb_malloc(wn * sizeof(tb_wchar_t)); + if (w) + { + tb_trace_i("tb_mbstowcs 111"); + if (tb_mbstowcs_charset(w, p, wn) != -1) + { + tb_trace_i("tb_wcslwr_test 111"); + tb_wcslwr_test(w); + r = tb_wcstombs(p, w, wn); + if (r != -1) r += (p - s); + } + + tb_trace_i("tb_free 111"); + if (w != wb) tb_free(w); + } + return r; +} /* ////////////////////////////////////////////////////////////////////////////////////// * implementation @@ -58,7 +218,7 @@ tb_int_t xm_string_lower(lua_State *lua) { buffer[size] = '\0'; // to lower - tb_long_t real_size = tb_charset_utf8_tolower(buffer, size); + tb_long_t real_size = tb_charset_utf8_tolower_test(buffer, size); // push result if (real_size >= 0) { -- cgit v1.3.1 From ffc3348ba6cc87402f24b4755ecfd8a505b52787 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 16:34:49 +0800 Subject: enable force-utf8 for haiku --- core/src/tbox/inc/haiku/tbox.config.h | 2 +- core/src/tbox/inc/iphoneos/tbox.config.h | 2 +- core/src/tbox/inc/solaris/tbox.config.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/tbox/inc/haiku/tbox.config.h b/core/src/tbox/inc/haiku/tbox.config.h index 8a9e72ad8..dc61fce45 100644 --- a/core/src/tbox/inc/haiku/tbox.config.h +++ b/core/src/tbox/inc/haiku/tbox.config.h @@ -16,7 +16,7 @@ /*#undef TB_CONFIG_MICRO_ENABLE*/ /*#undef TB_CONFIG_TYPE_HAVE_WCHAR*/ #define TB_CONFIG_TYPE_HAVE_FLOAT 1 -/*#undef TB_CONFIG_FORCE_UTF8*/ +#define TB_CONFIG_FORCE_UTF8 1 /*#undef TB_CONFIG_API_HAVE_DEPRECATED*/ /*#undef TB_CONFIG_EXCEPTION_ENABLE*/ diff --git a/core/src/tbox/inc/iphoneos/tbox.config.h b/core/src/tbox/inc/iphoneos/tbox.config.h index 290786a50..43aa10c8b 100755 --- a/core/src/tbox/inc/iphoneos/tbox.config.h +++ b/core/src/tbox/inc/iphoneos/tbox.config.h @@ -16,7 +16,7 @@ /* #undef TB_CONFIG_MICRO_ENABLE */ /* #undef TB_CONFIG_TYPE_HAVE_WCHAR */ #define TB_CONFIG_TYPE_HAVE_FLOAT 1 -/* #undef TB_CONFIG_FORCE_UTF8 */ +#define TB_CONFIG_FORCE_UTF8 1 /* #undef TB_CONFIG_API_HAVE_DEPRECATED */ /* #undef TB_CONFIG_EXCEPTION_ENABLE */ diff --git a/core/src/tbox/inc/solaris/tbox.config.h b/core/src/tbox/inc/solaris/tbox.config.h index 89bce47bc..25bafd9f6 100644 --- a/core/src/tbox/inc/solaris/tbox.config.h +++ b/core/src/tbox/inc/solaris/tbox.config.h @@ -16,7 +16,7 @@ /*#undef TB_CONFIG_MICRO_ENABLE*/ /*#undef TB_CONFIG_TYPE_HAVE_WCHAR*/ #define TB_CONFIG_TYPE_HAVE_FLOAT 1 -/*#undef TB_CONFIG_FORCE_UTF8*/ +#define TB_CONFIG_FORCE_UTF8 1 /*#undef TB_CONFIG_API_HAVE_DEPRECATED*/ /*#undef TB_CONFIG_EXCEPTION_ENABLE*/ -- cgit v1.3.1 From 947c09b57f3a2bd14dbd05e1cb6f12c3c815e533 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 16:38:02 +0800 Subject: update tbox --- core/src/tbox/tbox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox index 75c90b4c4..ddc363161 160000 --- a/core/src/tbox/tbox +++ b/core/src/tbox/tbox @@ -1 +1 @@ -Subproject commit 75c90b4c4313f84f8247867c99721882e390f401 +Subproject commit ddc363161ce6aed86109dcd665b63fb9a810e3a3 -- cgit v1.3.1 From 021f8144f2686305795b61a90ef040ee98f139ef Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 16:39:19 +0800 Subject: update lower --- core/src/xmake/string/lower.c | 162 +----------------------------------------- 1 file changed, 1 insertion(+), 161 deletions(-) diff --git a/core/src/xmake/string/lower.c b/core/src/xmake/string/lower.c index 07ae4bff4..71f8408dc 100644 --- a/core/src/xmake/string/lower.c +++ b/core/src/xmake/string/lower.c @@ -23,166 +23,6 @@ * includes */ #include "prefix.h" -# include - -static __tb_inline__ tb_bool_t tb_unicode_tolower_try(tb_uint32_t ch, tb_uint32_t* out) -{ - // builtin, locale-independent case mapping for some common unicode ranges: - // - Basic Latin (ASCII) - // - Latin-1 Supplement (partial) - // - Latin Extended-A (partial) - // - Greek (partial) - // - Cyrillic (partial) - if (sizeof(tb_wchar_t) == 2 && ch >= 0xd800 && ch <= 0xdfff) return tb_false; - - // Basic Latin (ASCII) - if (ch <= 0x7f) - { - tb_trace_i("basic: %x", ch); - *out = tb_tolower(ch); - return tb_true; - } - - // Latin-1 Supplement: U+00C0..U+00D6, U+00D8..U+00DE - if ((ch >= 0x00c0 && ch <= 0x00d6) || (ch >= 0x00d8 && ch <= 0x00de)) { *out = ch + 0x20; return tb_true; } - // Latin-1 Supplement: U+00E0..U+00F6, U+00F8..U+00FE - if ((ch >= 0x00e0 && ch <= 0x00f6) || (ch >= 0x00f8 && ch <= 0x00fe)) { *out = ch; return tb_true; } - - // Latin-1 Supplement: U+0178 <-> U+00FF - if (ch == 0x0178) { *out = 0x00ff; return tb_true; } - if (ch == 0x00ff) { *out = ch; return tb_true; } - - // Latin Extended Additional: U+1E9E <-> U+00DF - if (ch == 0x1e9e) { *out = 0x00df; return tb_true; } - if (ch == 0x00df) { *out = ch; return tb_true; } - - // Latin Extended-A: many letters have alternating upper/lower code points - if (ch >= 0x0100 && ch <= 0x012f) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } - if (ch >= 0x0132 && ch <= 0x0137) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } - if (ch >= 0x0139 && ch <= 0x0148) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } - if (ch >= 0x014a && ch <= 0x0177) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } - if (ch >= 0x0179 && ch <= 0x017e) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } - // Latin Extended-A: long s (already lowercase) - if (ch == 0x017f) { *out = ch; return tb_true; } - - // Greek and Coptic (partial): U+0391..U+03A1, U+03A3..U+03AB - if ((ch >= 0x0391 && ch <= 0x03a1) || (ch >= 0x03a3 && ch <= 0x03ab)) { *out = ch + 0x20; return tb_true; } - // Greek and Coptic (partial): U+03B1..U+03C1, U+03C3..U+03CB, and U+03C2 - if ((ch >= 0x03b1 && ch <= 0x03c1) || (ch >= 0x03c3 && ch <= 0x03cb) || ch == 0x03c2) { *out = ch; return tb_true; } - - // Cyrillic (partial): U+0401/U+0451 and U+0410..U+042F - if (ch == 0x0401) { *out = 0x0451; return tb_true; } - if (ch == 0x0451) { *out = ch; return tb_true; } - if (ch >= 0x0402 && ch <= 0x040f) { *out = ch + 0x50; return tb_true; } - if (ch >= 0x0452 && ch <= 0x045f) { *out = ch; return tb_true; } - if (ch >= 0x0410 && ch <= 0x042f) { *out = ch + 0x20; return tb_true; } - - if (ch >= 0x0430 && ch <= 0x044f) { - *out = ch; - return tb_true; - } - - return tb_false; -} - -tb_wchar_t tb_towlower_test(tb_wchar_t c) -{ - tb_trace_i("towlower: %x, wchar: %d", (tb_uint32_t)c, sizeof(tb_wchar_t)); - tb_uint32_t ch = tb_bits_wchar_to_u32_le(c); - tb_uint32_t out; - if (__tb_likely__(tb_unicode_tolower_try(ch, &out))) { - tb_trace_i("towlower: out: %x", out); - return tb_bits_u32_le_to_wchar(out); - } - - tb_trace_i("towlower xxx: %x", (tb_uint32_t)c); - return (tb_wchar_t)towlower((tb_uint32_t)c); -} - -static tb_wchar_t* tb_wcslwr_test(tb_wchar_t* s) -{ - // check - tb_assert_and_check_return_val(s, tb_null); - - // set local locale - tb_setlocale(); - - tb_wchar_t* p = s; - while (*p) - { - *p = tb_towlower_test(*p); - p++; - } - - // set default locale - tb_resetlocale(); - - return s; -} - -static tb_size_t tb_mbstowcs_charset(tb_wchar_t* s1, tb_char_t const* s2, tb_size_t n) -{ - // check - tb_assert_and_check_return_val(s1 && s2, 0); - - // init - tb_size_t e = (sizeof(tb_wchar_t) == 4) ? TB_CHARSET_TYPE_UTF32 : TB_CHARSET_TYPE_UTF16; - tb_long_t r = tb_charset_conv_cstr(TB_CHARSET_TYPE_UTF8, e | TB_CHARSET_TYPE_LE, s2, - (tb_byte_t*)s1, n * sizeof(tb_wchar_t)); - if (r > 0) r /= sizeof(tb_wchar_t); - - // strip - if (r >= 0) s1[r] = L'\0'; - - tb_trace_i("tb_mbstowcs_charset: %ld", r); - // ok? - return r >= 0 ? r : -1; -} - -static tb_long_t tb_charset_utf8_tolower_test(tb_char_t* s, tb_size_t n) -{ - tb_assert_and_check_return_val(s, -1); - - tb_trace_i("s: %s: %d", s, n); - - // try ascii tolower first - tb_char_t* p = s; - tb_char_t* e = s + n; - while (p < e && *p) - { - if ((*p) & 0x80) { - break; - } - tb_trace_i("old: %c -> %x", *p); - *p = tb_tolower(*p); - tb_trace_i("new: %c -> %x", *p); - p++; - } - tb_trace_i("test: %d %d", p == e, !*p); - - if (p == e || !*p) return p - s; - - // convert the suffix to wchar_t - tb_long_t r = -1; - tb_size_t wn = e - p + 1; - tb_wchar_t wb[256]; - tb_wchar_t* w = (wn <= 256)? wb : (tb_wchar_t*)tb_malloc(wn * sizeof(tb_wchar_t)); - if (w) - { - tb_trace_i("tb_mbstowcs 111"); - if (tb_mbstowcs_charset(w, p, wn) != -1) - { - tb_trace_i("tb_wcslwr_test 111"); - tb_wcslwr_test(w); - r = tb_wcstombs(p, w, wn); - if (r != -1) r += (p - s); - } - - tb_trace_i("tb_free 111"); - if (w != wb) tb_free(w); - } - return r; -} /* ////////////////////////////////////////////////////////////////////////////////////// * implementation @@ -218,7 +58,7 @@ tb_int_t xm_string_lower(lua_State *lua) { buffer[size] = '\0'; // to lower - tb_long_t real_size = tb_charset_utf8_tolower_test(buffer, size); + tb_long_t real_size = tb_charset_utf8_tolower(buffer, size); // push result if (real_size >= 0) { -- cgit v1.3.1 From e580c6c06087a4181db1bac5edcb5b0a45da51c9 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:39:50 +0800 Subject: fix ci --- .github/workflows/alpine.yml | 5 ++--- .github/workflows/archlinux.yml | 13 ++++++------- .github/workflows/dragonflybsd.yml | 5 ++--- .github/workflows/fedora.yml | 5 ++--- .github/workflows/haiku.yml | 4 ++-- .github/workflows/linux_luajit.yml | 5 ++--- .github/workflows/netbsd.yml | 5 ++--- .github/workflows/openbsd.yml | 5 ++--- .github/workflows/windows_luajit.yml | 4 ++-- 9 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 5bce09441..ba6d3552c 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -63,8 +63,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Alpine-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Alpine + cancel-in-progress: true steps: - name: Prepare build tools run: | @@ -88,4 +88,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/archlinux.yml b/.github/workflows/archlinux.yml index 7ee73fe47..03118bbb8 100644 --- a/.github/workflows/archlinux.yml +++ b/.github/workflows/archlinux.yml @@ -19,17 +19,17 @@ jobs: script: | const fs = require('fs'); const outputFile = process.env.GITHUB_OUTPUT; - + // Always run for release events if (context.eventName === 'release') { fs.appendFileSync(outputFile, `should-run=true\n`); core.info('Release event detected. Will run tests.'); return; } - + // Execution probability (default 20%, can be overridden via env) const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); - + // Generate deterministic "random" number based on commit SHA, run ID, and current time // Adding time ensures better randomness while keeping same commit/run consistent const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency @@ -43,7 +43,7 @@ jobs: // Normalize to 0-1 range const random = Math.abs(hash) / 2147483647; const shouldRun = random < probability; - + // Use environment file instead of deprecated set-output fs.appendFileSync(outputFile, `should-run=${shouldRun}\n`); if (shouldRun) { @@ -63,8 +63,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Archlinux-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Archlinux + cancel-in-progress: true steps: - name: Prepare build tools run: | @@ -90,4 +90,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/dragonflybsd.yml b/.github/workflows/dragonflybsd.yml index b65a22a88..41be4d83e 100644 --- a/.github/workflows/dragonflybsd.yml +++ b/.github/workflows/dragonflybsd.yml @@ -61,8 +61,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: DragonflyBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-DragonflyBSD + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -84,4 +84,3 @@ jobs: xrepo --version xmake l os.meminfo xmake lua -v -D tests/run.lua - diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index 1b0ec0304..5666ce932 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -63,8 +63,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Fedora-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Fedora + cancel-in-progress: true steps: - name: Prepare build tools run: | @@ -90,4 +90,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index f277d263f..fd1a95eca 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -53,8 +53,8 @@ jobs: runs-on: ubuntu-latest concurrency: - group: Haiku-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Haiku + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/linux_luajit.yml b/.github/workflows/linux_luajit.yml index 36c519245..ccbb96f59 100644 --- a/.github/workflows/linux_luajit.yml +++ b/.github/workflows/linux_luajit.yml @@ -60,8 +60,8 @@ jobs: runs-on: ubuntu-latest concurrency: # Prevent concurrent runs of the same workflow - group: Linux-Luajit-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Linux-Luajit + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -90,4 +90,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/netbsd.yml b/.github/workflows/netbsd.yml index bf704048f..f216f8992 100644 --- a/.github/workflows/netbsd.yml +++ b/.github/workflows/netbsd.yml @@ -61,8 +61,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: NetBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-NetBSD + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -85,4 +85,3 @@ jobs: xrepo --version xmake l os.meminfo xmake lua -v -D tests/run.lua - diff --git a/.github/workflows/openbsd.yml b/.github/workflows/openbsd.yml index 1e3cc912a..8c74bdaf1 100644 --- a/.github/workflows/openbsd.yml +++ b/.github/workflows/openbsd.yml @@ -61,8 +61,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: OpenBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-OpenBSD + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -85,4 +85,3 @@ jobs: xrepo --version xmake l os.meminfo xmake lua -v -D tests/run.lua - diff --git a/.github/workflows/windows_luajit.yml b/.github/workflows/windows_luajit.yml index c86d5e0b5..7a26cabaa 100644 --- a/.github/workflows/windows_luajit.yml +++ b/.github/workflows/windows_luajit.yml @@ -66,8 +66,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Windows-Luajit-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }}-${{ matrix.os }}-${{ matrix.arch }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.arch }}-Windows-Luajit + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: -- cgit v1.3.1 From 66ab9eb3c4a176c4d92acd88d76f99d27b06f632 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:40:04 +0800 Subject: update tbox --- core/src/tbox/tbox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox index ddc363161..de475fef0 160000 --- a/core/src/tbox/tbox +++ b/core/src/tbox/tbox @@ -1 +1 @@ -Subproject commit ddc363161ce6aed86109dcd665b63fb9a810e3a3 +Subproject commit de475fef05346a7603efea54d77afead7a16daca -- cgit v1.3.1 From 0cebadf47e5ee6b24d50a495617ae84608c1b199 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:45:37 +0800 Subject: update haiku ci --- .github/workflows/freebsd.yml | 8 ++++---- .github/workflows/haiku.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 92b91c84e..4f86f346c 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -19,17 +19,17 @@ jobs: script: | const fs = require('fs'); const outputFile = process.env.GITHUB_OUTPUT; - + // Always run for release events if (context.eventName === 'release') { fs.appendFileSync(outputFile, `should-run=true\n`); core.info('Release event detected. Will run tests.'); return; } - + // Execution probability (default 50%, can be overridden via env) const probability = parseFloat(process.env.RUN_PROBABILITY || '0.5'); - + // Generate deterministic "random" number based on commit SHA, run ID, and current time // Adding time ensures better randomness while keeping same commit/run consistent const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency @@ -43,7 +43,7 @@ jobs: // Normalize to 0-1 range const random = Math.abs(hash) / 2147483647; const shouldRun = random < probability; - + // Use environment file instead of deprecated set-output fs.appendFileSync(outputFile, `should-run=${shouldRun}\n`); if (shouldRun) { diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index fd1a95eca..49e12beaf 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -78,4 +78,4 @@ jobs: export PATH=`pwd`/dist/bin:$PATH xrepo --version xmake l os.meminfo - xmake l string.lower "Test 源文件🎆 Message" + xmake lua -v -D tests/run.lua -- cgit v1.3.1 From ffe255c4b65044a833c166904a67b47cf6d14c5e Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:45:49 +0800 Subject: update haiku ci --- .github/workflows/haiku.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index 49e12beaf..136788754 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -69,11 +69,9 @@ jobs: prepare: | pkgman install -y git curl unzip make bash perl run: | - pwd ./configure --prefix=`pwd`/dist make -j2 make install - ls -l ./dist/ export XMAKE_ROOT=y export PATH=`pwd`/dist/bin:$PATH xrepo --version -- cgit v1.3.1 From d83d2400d5c28ec5d6655a930aaa4ec913e873ae Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 20:15:07 +0800 Subject: fix builddir --- xmake/core/project/config.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 93c1ff6af..47d9406a8 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -165,9 +165,13 @@ function config.builddir(opt) builddir = path.absolute(builddir, rootdir) end - -- adjust path for the current directory + -- Adjust path for the current directory, + -- If it's an external directory, use the absolute path directly. if not opt.absolute then - builddir = path.relative(builddir, os.curdir()) + local relativedir = path.relative(builddir, os.curdir()) + if not relativedir:startswith("..") then + builddir = relativedir + end end return builddir end -- cgit v1.3.1 From a7e81f8efefb7d1a621d4a47bfa5208a761d7af4 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 15 Feb 2026 22:53:12 +0800 Subject: improve tests for haiku --- tests/actions/package/localpkg/test.lua | 2 +- tests/apis/namespace/package/test.lua | 2 +- tests/projects/c++/linkorders/test.lua | 3 +-- tests/projects/c++/snippet_runtimes/test.lua | 2 +- tests/projects/c/library_with_cmakelists/test.lua | 2 +- tests/projects/package/basic/test.lua | 2 +- tests/projects/package/compatibility/deps_with_version/test.lua | 2 +- tests/projects/package/compatibility/sync_requires_to_deps/test.lua | 2 +- tests/projects/package/components/test.lua | 2 +- tests/projects/package/depconfigs/test.lua | 2 +- tests/projects/package/inherit_base/test.lua | 2 +- tests/projects/package/multiconfig/test.lua | 2 +- tests/projects/package/package_rule/test.lua | 2 +- tests/projects/package/requires_lock/test.lua | 2 +- tests/projects/package/rootconfigs/test.lua | 2 +- tests/projects/package/schemes/test.lua | 2 +- tests/projects/package/toolchain_muslcc/test.lua | 2 +- tests/projects/package/toolchain_muslcc/xmake.lua | 2 +- 18 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tests/actions/package/localpkg/test.lua b/tests/actions/package/localpkg/test.lua index b3b3106ff..cd8e6f75e 100644 --- a/tests/actions/package/localpkg/test.lua +++ b/tests/actions/package/localpkg/test.lua @@ -1,5 +1,5 @@ function main(t) - if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd", "solaris") then + if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd", "solaris", "haiku") then os.cd("libfoo") os.exec("xmake package -D -o ../bar/build") os.cd("../bar") diff --git a/tests/apis/namespace/package/test.lua b/tests/apis/namespace/package/test.lua index 7b7dabeff..dc9b6d9ab 100644 --- a/tests/apis/namespace/package/test.lua +++ b/tests/apis/namespace/package/test.lua @@ -1,5 +1,5 @@ function main() - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end os.exec("xmake -vD -y") diff --git a/tests/projects/c++/linkorders/test.lua b/tests/projects/c++/linkorders/test.lua index 39898ef97..7728aa73a 100644 --- a/tests/projects/c++/linkorders/test.lua +++ b/tests/projects/c++/linkorders/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end @@ -10,4 +10,3 @@ function main(t) t:build() end end - diff --git a/tests/projects/c++/snippet_runtimes/test.lua b/tests/projects/c++/snippet_runtimes/test.lua index e06f405f7..c20ec10ff 100644 --- a/tests/projects/c++/snippet_runtimes/test.lua +++ b/tests/projects/c++/snippet_runtimes/test.lua @@ -12,7 +12,7 @@ end function main(t) local clang = find_tool("clang") - if clang and not is_subhost("windows") and not is_subhost("bsd", "solaris") then + if clang and not is_subhost("windows") and not is_subhost("bsd", "solaris", "haiku") then os.exec("xmake f --toolchain=clang --runtimes=c++_shared --yes") _build() end diff --git a/tests/projects/c/library_with_cmakelists/test.lua b/tests/projects/c/library_with_cmakelists/test.lua index 53b02d24c..585571628 100644 --- a/tests/projects/c/library_with_cmakelists/test.lua +++ b/tests/projects/c/library_with_cmakelists/test.lua @@ -2,7 +2,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/basic/test.lua b/tests/projects/package/basic/test.lua index 65d2f2335..7728aa73a 100644 --- a/tests/projects/package/basic/test.lua +++ b/tests/projects/package/basic/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/compatibility/deps_with_version/test.lua b/tests/projects/package/compatibility/deps_with_version/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/compatibility/deps_with_version/test.lua +++ b/tests/projects/package/compatibility/deps_with_version/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/compatibility/sync_requires_to_deps/test.lua b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/compatibility/sync_requires_to_deps/test.lua +++ b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/components/test.lua b/tests/projects/package/components/test.lua index a7e71bb89..f1634e485 100644 --- a/tests/projects/package/components/test.lua +++ b/tests/projects/package/components/test.lua @@ -1,5 +1,5 @@ function main(t) - if is_host("bsd", "solaris") or is_subhost("msys") then + if is_host("bsd", "solaris", "haiku") or is_subhost("msys") then return end if is_host("linux") and linuxos.name() == "alpine" then diff --git a/tests/projects/package/depconfigs/test.lua b/tests/projects/package/depconfigs/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/depconfigs/test.lua +++ b/tests/projects/package/depconfigs/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/inherit_base/test.lua b/tests/projects/package/inherit_base/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/inherit_base/test.lua +++ b/tests/projects/package/inherit_base/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/multiconfig/test.lua b/tests/projects/package/multiconfig/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/multiconfig/test.lua +++ b/tests/projects/package/multiconfig/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/package_rule/test.lua b/tests/projects/package/package_rule/test.lua index 65d2f2335..7728aa73a 100644 --- a/tests/projects/package/package_rule/test.lua +++ b/tests/projects/package/package_rule/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/requires_lock/test.lua b/tests/projects/package/requires_lock/test.lua index 213b1ba60..40c0ebf98 100644 --- a/tests/projects/package/requires_lock/test.lua +++ b/tests/projects/package/requires_lock/test.lua @@ -172,7 +172,7 @@ end function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/rootconfigs/test.lua b/tests/projects/package/rootconfigs/test.lua index d98f3385f..ed5c87486 100644 --- a/tests/projects/package/rootconfigs/test.lua +++ b/tests/projects/package/rootconfigs/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/schemes/test.lua b/tests/projects/package/schemes/test.lua index 4c7bad3c2..0c31b696f 100644 --- a/tests/projects/package/schemes/test.lua +++ b/tests/projects/package/schemes/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/toolchain_muslcc/test.lua b/tests/projects/package/toolchain_muslcc/test.lua index 65d2f2335..7728aa73a 100644 --- a/tests/projects/package/toolchain_muslcc/test.lua +++ b/tests/projects/package/toolchain_muslcc/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/toolchain_muslcc/xmake.lua b/tests/projects/package/toolchain_muslcc/xmake.lua index 6c5e8f8b3..0f63fb0d6 100644 --- a/tests/projects/package/toolchain_muslcc/xmake.lua +++ b/tests/projects/package/toolchain_muslcc/xmake.lua @@ -25,7 +25,7 @@ toolchain_end() -- add library packages -- for testing zlib/xmake, libplist/autoconf, libogg/cmake add_requires("zlib", "libogg", {system = false}) -if is_host("macosx", "linux", "bsd", "solaris") then +if is_host("macosx", "linux", "bsd", "solaris", "haiku") then add_requires("libplist", {system = false}) end -- cgit v1.3.1 From 1e15fe7013857315471598237635198d2e1c0c55 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 19:45:00 +0300 Subject: add winos.file_signature function to retrieve file signature information --- core/src/xmake/engine.c | 2 + core/src/xmake/winos/file_signature.c | 244 ++++++++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 core/src/xmake/winos/file_signature.c diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 1a542bc7c..b93b29bb0 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -280,6 +280,7 @@ tb_int_t xm_winos_registry_values(lua_State *lua); tb_int_t xm_winos_short_path(lua_State *lua); tb_int_t xm_winos_processes(lua_State* lua); tb_int_t xm_winos_set_error_mode(lua_State *lua); +tb_int_t xm_winos_file_signature(lua_State *lua); #endif // the utf8 functions @@ -487,6 +488,7 @@ static luaL_Reg const g_winos_functions[] = { { "short_path", xm_winos_short_path }, { "processes", xm_winos_processes }, { "set_error_mode", xm_winos_set_error_mode }, + { "file_signature", xm_winos_file_signature }, { tb_null, tb_null }, }; #endif diff --git a/core/src/xmake/winos/file_signature.c b/core/src/xmake/winos/file_signature.c new file mode 100644 index 000000000..8df13f4f7 --- /dev/null +++ b/core/src/xmake/winos/file_signature.c @@ -0,0 +1,244 @@ +/*!A cross-platform build utility based on Lua + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright (C) 2015-present, Xmake Open Source Community. + * + * @author ruki + * @file file_signature.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "file_signature" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include +#include +#include +#include + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ +/// the file signature info type +typedef struct __tb_file_signature_info_t +{ + /// is the file digitally signed? + tb_bool_t is_signed; + + /// is the signature valid and trusted by the OS? + tb_bool_t is_trusted; + + /// the name of the signer (e.g., "Microsoft Corporation") + /// tbox uses UTF-8 by default for tb_char_t + tb_char_t signer_name[256]; + +}tb_file_signature_info_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * private implementation + */ +static tb_wchar_t* tb_path_to_wchar(tb_char_t const* path, tb_wchar_t* buffer, tb_size_t size) +{ + // check + tb_assert_and_check_return_val(path && buffer && size, tb_null); + + // convert + if (MultiByteToWideChar(CP_UTF8, 0, path, -1, buffer, (int)size) > 0) + return buffer; + + return tb_null; +} + +static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_signature_info_t* info) +{ + // check + tb_assert_and_check_return_val(filepath && info, tb_false); + + // init info + tb_memset(info, 0, sizeof(tb_file_signature_info_t)); + + // convert path + tb_wchar_t wide_path[TB_PATH_MAXN]; + if (!tb_path_to_wchar(filepath, wide_path, TB_PATH_MAXN)) return tb_false; + + // init file info + WINTRUST_FILE_INFO file_data = {0}; + file_data.cbStruct = sizeof(file_data); + file_data.pcwszFilePath = wide_path; + file_data.hFile = NULL; + file_data.pgKnownSubject = NULL; + + // init trust data + WINTRUST_DATA trust_data = {0}; + trust_data.cbStruct = sizeof(trust_data); + trust_data.dwUIChoice = WTD_UI_NONE; + trust_data.fdwRevocationChecks = WTD_REVOKE_NONE; + trust_data.dwUnionChoice = WTD_CHOICE_FILE; + trust_data.dwStateAction = WTD_STATEACTION_VERIFY; + trust_data.hWVTStateData = NULL; + trust_data.pwszURLReference = NULL; + trust_data.dwProvFlags = WTD_SAFER_FLAG; + trust_data.dwUIContext = 0; + trust_data.pFile = &file_data; + + // verify trust + GUID guid_action = WINTRUST_ACTION_GENERIC_VERIFY_V2; + LONG status = WinVerifyTrust(NULL, &guid_action, &trust_data); + + // clean up + trust_data.dwStateAction = WTD_STATEACTION_CLOSE; + WinVerifyTrust(NULL, &guid_action, &trust_data); + + // check status + if (status == ERROR_SUCCESS) + { + info->is_signed = tb_true; + info->is_trusted = tb_true; + } + else if (status == TRUST_E_NOSIGNATURE) + { + return tb_true; + } + else if (status == TRUST_E_EXPLICIT_DISTRUST || status == TRUST_E_SUBJECT_NOT_TRUSTED) + { + info->is_signed = tb_true; + info->is_trusted = tb_false; + } + else + { + return tb_false; + } + + // extract signer name + if (info->is_signed) + { + HCERTSTORE hStore = NULL; + HCRYPTMSG hMsg = NULL; + DWORD dwEncoding = 0; + DWORD dwContentType = 0; + DWORD dwFormatType = 0; + PCMSG_SIGNER_INFO pSignerInfo = NULL; + PCCERT_CONTEXT pCertContext = NULL; + BOOL bResult = FALSE; + + bResult = CryptQueryObject(CERT_QUERY_OBJECT_FILE, + wide_path, + CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED, + CERT_QUERY_FORMAT_FLAG_BINARY, + 0, + &dwEncoding, + &dwContentType, + &dwFormatType, + &hStore, + &hMsg, + NULL); + + if (bResult) + { + DWORD cbSignerInfo = 0; + if (CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &cbSignerInfo)) + { + pSignerInfo = (PCMSG_SIGNER_INFO)tb_malloc(cbSignerInfo); + if (pSignerInfo) + { + if (CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, (void*)pSignerInfo, &cbSignerInfo)) + { + CERT_INFO certInfo; + certInfo.Issuer = pSignerInfo->Issuer; + certInfo.SerialNumber = pSignerInfo->SerialNumber; + + pCertContext = CertFindCertificateInStore(hStore, + (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING), + 0, + CERT_FIND_SUBJECT_CERT, + (PVOID)&certInfo, + NULL); + + if (pCertContext) + { + tb_wchar_t wName[256] = {0}; + if (CertGetNameStringW(pCertContext, + CERT_NAME_SIMPLE_DISPLAY_TYPE, + 0, + NULL, + wName, + 256)) + { + WideCharToMultiByte(CP_UTF8, 0, wName, -1, info->signer_name, sizeof(info->signer_name), NULL, NULL); + } + CertFreeCertificateContext(pCertContext); + } + } + tb_free(pSignerInfo); + } + } + } + + if (hStore) CertCloseStore(hStore, 0); + if (hMsg) CryptMsgClose(hMsg); + } + + return tb_true; +} + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ + +/* get the file signature info + * + * local info = winos.file_signature(filepath) + * { + * is_signed = true, + * is_trusted = true, + * signer_name = "Microsoft Corporation" + * } + */ +tb_int_t xm_winos_file_signature(lua_State *lua) { + + // check + tb_assert_and_check_return_val(lua, 0); + + // get the arguments + tb_char_t const *filepath = luaL_checkstring(lua, 1); + tb_check_return_val(filepath, 0); + + // get signature info + tb_file_signature_info_t info = {0}; + if (tb_file_get_signature_info(filepath, &info)) { + lua_newtable(lua); + lua_pushstring(lua, "is_signed"); + lua_pushboolean(lua, info.is_signed); + lua_settable(lua, -3); + + lua_pushstring(lua, "is_trusted"); + lua_pushboolean(lua, info.is_trusted); + lua_settable(lua, -3); + + if (info.is_signed) { + lua_pushstring(lua, "signer_name"); + lua_pushstring(lua, info.signer_name); + lua_settable(lua, -3); + } + return 1; + } + return 0; +} -- cgit v1.3.1 From 1aa5abae9c4b86715c48ac5137d6411c6517e283 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 20:32:34 +0300 Subject: retry --- core/src/cli/xmake.lua | 2 +- core/xmake.lua | 2 +- xmake/core/sandbox/modules/winos.lua | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/cli/xmake.lua b/core/src/cli/xmake.lua index 2e4b1aea9..98e86b128 100644 --- a/core/src/cli/xmake.lua +++ b/core/src/cli/xmake.lua @@ -29,7 +29,7 @@ target("cli") -- add links if is_plat("windows") then - add_syslinks("ws2_32", "advapi32", "shell32") + add_syslinks("ws2_32", "advapi32", "shell32", "wintrust", "crypt32") add_ldflags("/export:malloc", "/export:free", "/export:memmove") elseif is_plat("android") then add_syslinks("m", "c") diff --git a/core/xmake.lua b/core/xmake.lua index f9e387ad5..114f8bbdb 100644 --- a/core/xmake.lua +++ b/core/xmake.lua @@ -41,7 +41,7 @@ end]] -- for the windows platform (msvc) if is_plat("windows") then set_runtimes("MT") - add_links("kernel32", "user32", "gdi32") + add_links("kernel32", "user32", "gdi32", "wintrust", "crypt32") end -- for mode coverage diff --git a/xmake/core/sandbox/modules/winos.lua b/xmake/core/sandbox/modules/winos.lua index 2ed01245d..65603897b 100644 --- a/xmake/core/sandbox/modules/winos.lua +++ b/xmake/core/sandbox/modules/winos.lua @@ -34,6 +34,7 @@ sandbox_winos.console_output_cp = winos.console_output_cp sandbox_winos.logical_drives = winos.logical_drives sandbox_winos.cmdargv = winos.cmdargv sandbox_winos.processes = winos.processes +sandbox_winos.file_signature = winos.file_signature sandbox_winos.inherit_handles_safely = winos.inherit_handles_safely sandbox_winos.set_error_mode = winos.set_error_mode -- cgit v1.3.1 From 84420e555ff547e04e42cc67a3c2f3fb2bc0580d Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 20:55:52 +0300 Subject: Try filter GCC.exe --- xmake/modules/detect/tools/find_gcc.lua | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index b8c7b71a5..9c2184fe1 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,6 +22,21 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") +import("core.base.option") + +-- check for Gigabyte's GCC.exe +function _check_gigabyte_gcc(program) + if is_host("windows") then + local winos = import("core.base.winos", {try = true}) + if winos and winos.file_signature then + local sig = try { function () return winos.file_signature(program) end } + if sig and sig.signer_name and sig.signer_name:find("GIGA-BYTE", 1, true) then + return false + end + end + end + return true +end -- detect whether the current gcc compiler is clang function check_clang(program, opt) @@ -54,6 +69,25 @@ end function main(opt) opt = opt or {} opt.norunfile = true + + -- select GIGABYTE/GCC.exe? + local check_orig = opt.check + opt.check = function (program) + if not _check_gigabyte_gcc(program) then + return false + end + if check_orig then + if type(check_orig) == "function" then + return check_orig(program) + elseif type(check_orig) == "string" then + return os.runv(program, {check_orig}, {envs = opt.envs, shell = opt.shell}) + elseif type(check_orig) == "table" then + return os.runv(program, check_orig, {envs = opt.envs, shell = opt.shell}) + end + end + return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) + end + local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then -- cgit v1.3.1 From a8a2c629923dd5143297d2acd64b11eb589e94cc Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 20:58:57 +0300 Subject: retry MinGW --- core/src/cli/xmake.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/cli/xmake.lua b/core/src/cli/xmake.lua index 98e86b128..e239776c6 100644 --- a/core/src/cli/xmake.lua +++ b/core/src/cli/xmake.lua @@ -36,6 +36,7 @@ target("cli") elseif is_plat("macosx") and is_config("runtime", "luajit") then add_ldflags("-all_load", "-pagezero_size 10000", "-image_base 100000000") elseif is_plat("mingw") then + add_syslinks("wintrust", "crypt32") add_ldflags("-static-libgcc", {force = true}) elseif is_plat("haiku") then add_syslinks("pthread", "network", "m", "c") -- cgit v1.3.1 From 8d8bceff498ab535dd35db3ad9616d185bd5f909 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 21:16:22 +0300 Subject: retry for mingw --- core/src/cli/xmake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/cli/xmake.sh b/core/src/cli/xmake.sh index 12fffe1af..6ae33ef16 100755 --- a/core/src/cli/xmake.sh +++ b/core/src/cli/xmake.sh @@ -19,7 +19,7 @@ target "cli" if is_plat "macosx" && is_config "runtime" "luajit"; then add_ldflags "-all_load" "-pagezero_size 10000" "-image_base 100000000" elif is_plat "mingw"; then - add_ldflags "-static-libgcc" + add_ldflags "-static-libgcc" "-lwintrust" "-lcrypt32" fi # add install files -- cgit v1.3.1 From 227449f1d972877ce5e734fb16d937d7b534f7a6 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 21:26:21 +0300 Subject: Fix file_signature assignment in winos.lua --- xmake/core/sandbox/modules/winos.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/winos.lua b/xmake/core/sandbox/modules/winos.lua index 65603897b..0466e746b 100644 --- a/xmake/core/sandbox/modules/winos.lua +++ b/xmake/core/sandbox/modules/winos.lua @@ -34,9 +34,9 @@ sandbox_winos.console_output_cp = winos.console_output_cp sandbox_winos.logical_drives = winos.logical_drives sandbox_winos.cmdargv = winos.cmdargv sandbox_winos.processes = winos.processes -sandbox_winos.file_signature = winos.file_signature sandbox_winos.inherit_handles_safely = winos.inherit_handles_safely sandbox_winos.set_error_mode = winos.set_error_mode +sandbox_winos.file_signature = winos.file_signature -- get windows system version function sandbox_winos.version() -- cgit v1.3.1 From b82ccd6f714b59c4dd518d7dc2b07558a72d7a50 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 21:26:52 +0300 Subject: Clear --- core/src/cli/xmake.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/cli/xmake.lua b/core/src/cli/xmake.lua index e239776c6..98e86b128 100644 --- a/core/src/cli/xmake.lua +++ b/core/src/cli/xmake.lua @@ -36,7 +36,6 @@ target("cli") elseif is_plat("macosx") and is_config("runtime", "luajit") then add_ldflags("-all_load", "-pagezero_size 10000", "-image_base 100000000") elseif is_plat("mingw") then - add_syslinks("wintrust", "crypt32") add_ldflags("-static-libgcc", {force = true}) elseif is_plat("haiku") then add_syslinks("pthread", "network", "m", "c") -- cgit v1.3.1 From fc17a30b0ad0642441dcd5d99c298e145abcc765 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 23:45:11 +0300 Subject: revert --- xmake/modules/detect/tools/find_gcc.lua | 34 --------------------------------- 1 file changed, 34 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 9c2184fe1..b8c7b71a5 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,21 +22,6 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") -import("core.base.option") - --- check for Gigabyte's GCC.exe -function _check_gigabyte_gcc(program) - if is_host("windows") then - local winos = import("core.base.winos", {try = true}) - if winos and winos.file_signature then - local sig = try { function () return winos.file_signature(program) end } - if sig and sig.signer_name and sig.signer_name:find("GIGA-BYTE", 1, true) then - return false - end - end - end - return true -end -- detect whether the current gcc compiler is clang function check_clang(program, opt) @@ -69,25 +54,6 @@ end function main(opt) opt = opt or {} opt.norunfile = true - - -- select GIGABYTE/GCC.exe? - local check_orig = opt.check - opt.check = function (program) - if not _check_gigabyte_gcc(program) then - return false - end - if check_orig then - if type(check_orig) == "function" then - return check_orig(program) - elseif type(check_orig) == "string" then - return os.runv(program, {check_orig}, {envs = opt.envs, shell = opt.shell}) - elseif type(check_orig) == "table" then - return os.runv(program, check_orig, {envs = opt.envs, shell = opt.shell}) - end - end - return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) - end - local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then -- cgit v1.3.1 From e7fe0d2de16824d602158e4f7e837a814d95a0a8 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 15 Feb 2026 23:59:25 +0300 Subject: Test for find_program --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 858b413e8..f47e35c02 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -24,7 +24,7 @@ local sandbox_lib_detect_find_program = sandbox_lib_detect_find_program or {} -- load modules local os = require("base/os") local path = require("base/path") -local option = require("base/winos") +local winos = require("base/winos") local table = require("base/table") local utils = require("base/utils") local option = require("base/option") @@ -40,6 +40,14 @@ local scheduler = require("sandbox/modules/import/core/base/scheduler") -- do check function sandbox_lib_detect_find_program._do_check(program, opt) + -- avoid gcc.exe signed by GIGA-BYTE + if winos.file_signature and program:lower():match("gcc%.exe$") then + local signer = winos.file_signature(program) + if signer and signer.signer and signer.signer:find("GIGA-BYTE", 1, true) then + return false + end + end + -- do not attempt to run program? check it fastly if opt.norun then return os.isfile(program) -- cgit v1.3.1 From af2c806cc9a2ea513a61179b86e9a7333c82ae21 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 00:04:40 +0300 Subject: retry --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index f47e35c02..5040802a9 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -41,7 +41,7 @@ local scheduler = require("sandbox/modules/import/core/base/scheduler") function sandbox_lib_detect_find_program._do_check(program, opt) -- avoid gcc.exe signed by GIGA-BYTE - if winos.file_signature and program:lower():match("gcc%.exe$") then + if winos.file_signature and program:lower():match("gcc%.exe") then local signer = winos.file_signature(program) if signer and signer.signer and signer.signer:find("GIGA-BYTE", 1, true) then return false -- cgit v1.3.1 From 0d4a4234f59f92c13b9b63284324b66eef1313c2 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 00:13:28 +0300 Subject: wrap find_program --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 5040802a9..42c1a80d7 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -43,7 +43,7 @@ function sandbox_lib_detect_find_program._do_check(program, opt) -- avoid gcc.exe signed by GIGA-BYTE if winos.file_signature and program:lower():match("gcc%.exe") then local signer = winos.file_signature(program) - if signer and signer.signer and signer.signer:find("GIGA-BYTE", 1, true) then + if signer and signer.signer_name and signer.signer_name:find("GIGA-BYTE", 1, true) then return false end end -- cgit v1.3.1 From 92cbb94be2d3ce0d1a302beaf9e031d9ee47126a Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 00:30:22 +0300 Subject: try improve wrapper. it wont work if we pass just gcc.exe instead of fullpath as file_signature would not work without full path provided --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 42c1a80d7..9f1815f38 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -41,9 +41,9 @@ local scheduler = require("sandbox/modules/import/core/base/scheduler") function sandbox_lib_detect_find_program._do_check(program, opt) -- avoid gcc.exe signed by GIGA-BYTE - if winos.file_signature and program:lower():match("gcc%.exe") then + if winos.file_signature and program:lower():endswith("gcc.exe") then local signer = winos.file_signature(program) - if signer and signer.signer_name and signer.signer_name:find("GIGA-BYTE", 1, true) then + if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then return false end end -- cgit v1.3.1 From caf37bdceca49df8a819859057060ab7db6f3612 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 00:35:32 +0300 Subject: enhance signature check for gcc.exe to handle both absolute and relative paths --- .../modules/import/lib/detect/find_program.lua | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 9f1815f38..6233738f6 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -42,9 +42,29 @@ function sandbox_lib_detect_find_program._do_check(program, opt) -- avoid gcc.exe signed by GIGA-BYTE if winos.file_signature and program:lower():endswith("gcc.exe") then - local signer = winos.file_signature(program) - if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then - return false + local check_signature = function (program) + if os.isfile(program) then + local signer = winos.file_signature(program) + if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then + return true + end + end + end + if path.is_absolute(program) then + if check_signature(program) then + return false + end + else + local paths = path.splitenv(vformat("$(env PATH)")) + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) then + if check_signature(prog) then + return false + end + break + end + end end end -- cgit v1.3.1 From f338f19fdd28f271775fa4c301ec279054981cfe Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 01:55:16 +0300 Subject: Update comment to include issue reference for gcc.exe Added reference to GitHub issue regarding GIGA-BYTE signed gcc.exe. --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 6233738f6..a1eb90c29 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -40,7 +40,7 @@ local scheduler = require("sandbox/modules/import/core/base/scheduler") -- do check function sandbox_lib_detect_find_program._do_check(program, opt) - -- avoid gcc.exe signed by GIGA-BYTE + -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 if winos.file_signature and program:lower():endswith("gcc.exe") then local check_signature = function (program) if os.isfile(program) then -- cgit v1.3.1 From 11cc0a0bb3d6240ca595e0315f07bdbd49677254 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 19:13:32 +0300 Subject: try move into find_gcc --- .../modules/import/lib/detect/find_program.lua | 28 ------------------ xmake/modules/detect/tools/find_gcc.lua | 34 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index a1eb90c29..288a9089e 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -40,34 +40,6 @@ local scheduler = require("sandbox/modules/import/core/base/scheduler") -- do check function sandbox_lib_detect_find_program._do_check(program, opt) - -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if winos.file_signature and program:lower():endswith("gcc.exe") then - local check_signature = function (program) - if os.isfile(program) then - local signer = winos.file_signature(program) - if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then - return true - end - end - end - if path.is_absolute(program) then - if check_signature(program) then - return false - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) then - if check_signature(prog) then - return false - end - break - end - end - end - end - -- do not attempt to run program? check it fastly if opt.norun then return os.isfile(program) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index b8c7b71a5..f2f1d456e 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,6 +22,39 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") +import("core.base.winos") + +-- check gigabyte gcc +function _check_gigabyte_gcc(program) + -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 + if winos.file_signature and program:lower():endswith("gcc.exe") then + local check_signature = function (program) + if os.isfile(program) then + local signer = winos.file_signature(program) + if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then + return true + end + end + end + if path.is_absolute(program) then + if check_signature(program) then + return false + end + else + local paths = path.splitenv(vformat("$(env PATH)")) + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) then + if check_signature(prog) then + return false + end + break + end + end + end + end + return true +end -- detect whether the current gcc compiler is clang function check_clang(program, opt) @@ -54,6 +87,7 @@ end function main(opt) opt = opt or {} opt.norunfile = true + opt.check = _check_gigabyte_gcc local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then -- cgit v1.3.1 From 86b1f8b1211116c718c789146033f70cd14a0c65 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 19:18:02 +0300 Subject: try wrap to style --- core/src/xmake/winos/file_signature.c | 45 +++++++++++------------------------ 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/core/src/xmake/winos/file_signature.c b/core/src/xmake/winos/file_signature.c index 8df13f4f7..3c79d78d4 100644 --- a/core/src/xmake/winos/file_signature.c +++ b/core/src/xmake/winos/file_signature.c @@ -38,8 +38,7 @@ * types */ /// the file signature info type -typedef struct __tb_file_signature_info_t -{ +typedef struct __tb_file_signature_info_t { /// is the file digitally signed? tb_bool_t is_signed; @@ -55,8 +54,7 @@ typedef struct __tb_file_signature_info_t /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ -static tb_wchar_t* tb_path_to_wchar(tb_char_t const* path, tb_wchar_t* buffer, tb_size_t size) -{ +static tb_wchar_t* tb_path_to_wchar(tb_char_t const* path, tb_wchar_t* buffer, tb_size_t size) { // check tb_assert_and_check_return_val(path && buffer && size, tb_null); @@ -67,8 +65,7 @@ static tb_wchar_t* tb_path_to_wchar(tb_char_t const* path, tb_wchar_t* buffer, t return tb_null; } -static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_signature_info_t* info) -{ +static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_signature_info_t* info) { // check tb_assert_and_check_return_val(filepath && info, tb_false); @@ -108,28 +105,20 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s WinVerifyTrust(NULL, &guid_action, &trust_data); // check status - if (status == ERROR_SUCCESS) - { + if (status == ERROR_SUCCESS) { info->is_signed = tb_true; info->is_trusted = tb_true; - } - else if (status == TRUST_E_NOSIGNATURE) - { + } else if (status == TRUST_E_NOSIGNATURE) { return tb_true; - } - else if (status == TRUST_E_EXPLICIT_DISTRUST || status == TRUST_E_SUBJECT_NOT_TRUSTED) - { + } else if (status == TRUST_E_EXPLICIT_DISTRUST || status == TRUST_E_SUBJECT_NOT_TRUSTED) { info->is_signed = tb_true; info->is_trusted = tb_false; - } - else - { + } else { return tb_false; } // extract signer name - if (info->is_signed) - { + if (info->is_signed) { HCERTSTORE hStore = NULL; HCRYPTMSG hMsg = NULL; DWORD dwEncoding = 0; @@ -151,16 +140,12 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s &hMsg, NULL); - if (bResult) - { + if (bResult) { DWORD cbSignerInfo = 0; - if (CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &cbSignerInfo)) - { + if (CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &cbSignerInfo)) { pSignerInfo = (PCMSG_SIGNER_INFO)tb_malloc(cbSignerInfo); - if (pSignerInfo) - { - if (CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, (void*)pSignerInfo, &cbSignerInfo)) - { + if (pSignerInfo) { + if (CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, (void*)pSignerInfo, &cbSignerInfo)) { CERT_INFO certInfo; certInfo.Issuer = pSignerInfo->Issuer; certInfo.SerialNumber = pSignerInfo->SerialNumber; @@ -172,16 +157,14 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s (PVOID)&certInfo, NULL); - if (pCertContext) - { + if (pCertContext) { tb_wchar_t wName[256] = {0}; if (CertGetNameStringW(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, wName, - 256)) - { + 256)) { WideCharToMultiByte(CP_UTF8, 0, wName, -1, info->signer_name, sizeof(info->signer_name), NULL, NULL); } CertFreeCertificateContext(pCertContext); -- cgit v1.3.1 From 1ef8c05c510484e3d7e608c87abcb65efe3a5aba Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 19:30:30 +0300 Subject: retry find_gcc --- xmake/modules/detect/tools/find_gcc.lua | 42 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index f2f1d456e..1a0cf4b78 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,33 +22,35 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") -import("core.base.winos") -- check gigabyte gcc function _check_gigabyte_gcc(program) -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if winos.file_signature and program:lower():endswith("gcc.exe") then - local check_signature = function (program) - if os.isfile(program) then - local signer = winos.file_signature(program) - if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then - return true + if is_plat("windows", "mingw") and program:lower():endswith("gcc.exe") then + import("core.base.winos") + if winos.file_signature then + local check_signature = function (program) + if os.isfile(program) then + local signer = winos.file_signature(program) + if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then + return true + end end end - end - if path.is_absolute(program) then - if check_signature(program) then - return false - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) then - if check_signature(prog) then - return false + if path.is_absolute(program) then + if check_signature(program) then + return false + end + else + local paths = path.splitenv(vformat("$(env PATH)")) + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) then + if check_signature(prog) then + return false + end + break end - break end end end -- cgit v1.3.1 From f024c37ca77bec28ffa7377af56ae8f0b189a4b3 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 19:37:53 +0300 Subject: retry --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 288a9089e..18abf37a2 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -64,7 +64,13 @@ function sandbox_lib_detect_find_program._do_check(program, opt) elseif type(opt.check) == "table" then ok, errors = os.runv(program, opt.check, {envs = opt.envs, shell = opt.shell}) else - ok, errors = sandbox.load(opt.check, program) + local ok_or_errors + ok, ok_or_errors = sandbox.load(opt.check, program) + if ok then + ok = ok_or_errors + else + errors = ok_or_errors + end end -- check failed? print verbose error info -- cgit v1.3.1 From 56581ecfdc1fc6982a03b9575fb66c2821f8aedd Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 19:41:17 +0300 Subject: retry --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 18abf37a2..6bd140b12 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -43,7 +43,7 @@ function sandbox_lib_detect_find_program._do_check(program, opt) -- do not attempt to run program? check it fastly if opt.norun then return os.isfile(program) - elseif opt.norunfile and path.is_absolute(program) and os.isfile(program) then + elseif not opt.check and opt.norunfile and path.is_absolute(program) and os.isfile(program) then return true end -- cgit v1.3.1 From 530d8745ab19cf707ac0a1e729d641325455b24b Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 19:43:16 +0300 Subject: retry --- xmake/modules/detect/tools/find_gcc.lua | 48 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 1a0cf4b78..10e23b797 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -26,34 +26,40 @@ import("core.cache.detectcache") -- check gigabyte gcc function _check_gigabyte_gcc(program) -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if is_plat("windows", "mingw") and program:lower():endswith("gcc.exe") then - import("core.base.winos") - if winos.file_signature then - local check_signature = function (program) - if os.isfile(program) then - local signer = winos.file_signature(program) - if signer and signer.signer_name and signer.signer_name:startswith("GIGA-BYTE") then - return true + if is_host("windows") then -- is_plat("windows", "mingw") + local is_gigabyte = false + if program:lower():endswith("gcc.exe") then + import("core.base.winos") + if winos.file_signature then + local check_signature = function (program) + if os.isfile(program) then + local signer = winos.file_signature(program) + if signer and signer.signer_name and signer.signer_name:find("GIGA-BYTE", 1, true) then + return true + end end end - end - if path.is_absolute(program) then - if check_signature(program) then - return false - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) then - if check_signature(prog) then - return false + if path.is_absolute(program) then + if check_signature(program) then + is_gigabyte = true + end + else + local paths = path.splitenv(vformat("$(env PATH)")) + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) then + if check_signature(prog) then + is_gigabyte = true + end + break end - break end end end end + if is_gigabyte then + return false + end end return true end -- cgit v1.3.1 From 6a89f384f8dc2f837f52cbbab7ea903d34dd6175 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Feb 2026 19:48:38 +0300 Subject: retry --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 6bd140b12..fd8908bdf 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -67,7 +67,9 @@ function sandbox_lib_detect_find_program._do_check(program, opt) local ok_or_errors ok, ok_or_errors = sandbox.load(opt.check, program) if ok then - ok = ok_or_errors + if ok_or_errors ~= nil then + ok = ok_or_errors + end else errors = ok_or_errors end -- cgit v1.3.1 From 994c838e48bfabace4b6deda4d5dc51ee0e101a0 Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 22:55:54 +0300 Subject: todo --- core/src/xmake/winos/file_signature.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/xmake/winos/file_signature.c b/core/src/xmake/winos/file_signature.c index 3c79d78d4..d9d262544 100644 --- a/core/src/xmake/winos/file_signature.c +++ b/core/src/xmake/winos/file_signature.c @@ -37,19 +37,19 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * types */ -/// the file signature info type +// the file signature info type typedef struct __tb_file_signature_info_t { - /// is the file digitally signed? + // is the file digitally signed? tb_bool_t is_signed; - /// is the signature valid and trusted by the OS? + // is the signature valid and trusted by the OS? tb_bool_t is_trusted; - /// the name of the signer (e.g., "Microsoft Corporation") - /// tbox uses UTF-8 by default for tb_char_t + /* the name of the signer (e.g., "Microsoft Corporation") + tbox uses UTF-8 by default for tb_char_t*/ tb_char_t signer_name[256]; -}tb_file_signature_info_t; +} tb_file_signature_info_t; /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation @@ -74,7 +74,7 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s // convert path tb_wchar_t wide_path[TB_PATH_MAXN]; - if (!tb_path_to_wchar(filepath, wide_path, TB_PATH_MAXN)) return tb_false; + if (!tb_path_absolute_w(filepath, wide_path, TB_PATH_MAXN)) return tb_false; // init file info WINTRUST_FILE_INFO file_data = {0}; @@ -87,7 +87,7 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s WINTRUST_DATA trust_data = {0}; trust_data.cbStruct = sizeof(trust_data); trust_data.dwUIChoice = WTD_UI_NONE; - trust_data.fdwRevocationChecks = WTD_REVOKE_NONE; + trust_data.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN; trust_data.dwUnionChoice = WTD_CHOICE_FILE; trust_data.dwStateAction = WTD_STATEACTION_VERIFY; trust_data.hWVTStateData = NULL; -- cgit v1.3.1 From 387e1c258a5c4bef446b6d18fcffd93cc25c1543 Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 22:57:47 +0300 Subject: tb_wtoa --- core/src/xmake/winos/file_signature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/xmake/winos/file_signature.c b/core/src/xmake/winos/file_signature.c index d9d262544..e16cb4949 100644 --- a/core/src/xmake/winos/file_signature.c +++ b/core/src/xmake/winos/file_signature.c @@ -165,7 +165,7 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s NULL, wName, 256)) { - WideCharToMultiByte(CP_UTF8, 0, wName, -1, info->signer_name, sizeof(info->signer_name), NULL, NULL); + tb_wtoa(info->signer_name, wName, sizeof(info->signer_name)); } CertFreeCertificateContext(pCertContext); } -- cgit v1.3.1 From 3774d82b0004a7adca704ab2de70c65270bf92b7 Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 22:59:49 +0300 Subject: clear --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index fd8908bdf..a5909abdd 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -43,7 +43,7 @@ function sandbox_lib_detect_find_program._do_check(program, opt) -- do not attempt to run program? check it fastly if opt.norun then return os.isfile(program) - elseif not opt.check and opt.norunfile and path.is_absolute(program) and os.isfile(program) then + elseif opt.norunfile and path.is_absolute(program) and os.isfile(program) then return true end -- cgit v1.3.1 From 05ebd2e41e28a1ef4cb3184e822a44063fcc63e2 Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:00:28 +0300 Subject: revert ok, errors = sandbox.load(opt.check, program) --- xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index a5909abdd..288a9089e 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -64,15 +64,7 @@ function sandbox_lib_detect_find_program._do_check(program, opt) elseif type(opt.check) == "table" then ok, errors = os.runv(program, opt.check, {envs = opt.envs, shell = opt.shell}) else - local ok_or_errors - ok, ok_or_errors = sandbox.load(opt.check, program) - if ok then - if ok_or_errors ~= nil then - ok = ok_or_errors - end - else - errors = ok_or_errors - end + ok, errors = sandbox.load(opt.check, program) end -- check failed? print verbose error info -- cgit v1.3.1 From 26d3ba66b3625db632d350c1314710264d40546a Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:02:19 +0300 Subject: try fix norunfile = true --- xmake/modules/detect/tools/find_gcc.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 10e23b797..3545daec2 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -26,7 +26,7 @@ import("core.cache.detectcache") -- check gigabyte gcc function _check_gigabyte_gcc(program) -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if is_host("windows") then -- is_plat("windows", "mingw") + if is_host("windows") then local is_gigabyte = false if program:lower():endswith("gcc.exe") then import("core.base.winos") @@ -95,7 +95,11 @@ end function main(opt) opt = opt or {} opt.norunfile = true - opt.check = _check_gigabyte_gcc + if is_host("windows") then + opt.check = _check_gcc + else + opt.norunfile = true + end local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then -- cgit v1.3.1 From 0b9f1b8dc2454a8f4b48b96ffdc9f74ea9fe532e Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:06:18 +0300 Subject: todo --- xmake/modules/detect/tools/find_gcc.lua | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 3545daec2..09b85039e 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,6 +22,7 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") +import("core.base.winos") -- check gigabyte gcc function _check_gigabyte_gcc(program) @@ -29,7 +30,6 @@ function _check_gigabyte_gcc(program) if is_host("windows") then local is_gigabyte = false if program:lower():endswith("gcc.exe") then - import("core.base.winos") if winos.file_signature then local check_signature = function (program) if os.isfile(program) then @@ -43,25 +43,13 @@ function _check_gigabyte_gcc(program) if check_signature(program) then is_gigabyte = true end - else - local paths = path.splitenv(vformat("$(env PATH)")) - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) then - if check_signature(prog) then - is_gigabyte = true - end - break - end - end end end end if is_gigabyte then - return false + raise("gcc.exe signed by GIGA-BYTE is not supported, please use the official gcc.exe instead.") end end - return true end -- detect whether the current gcc compiler is clang -- cgit v1.3.1 From 1e2596cb6983378a8add754901f613d180c644fc Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:15:31 +0300 Subject: refactor: enhance gigabyte gcc check and integrate custom check option --- xmake/modules/detect/tools/find_gcc.lua | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 09b85039e..a4e0782e7 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -25,7 +25,7 @@ import("core.cache.detectcache") import("core.base.winos") -- check gigabyte gcc -function _check_gigabyte_gcc(program) +function _check_gigabyte_gcc(program, opt) -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 if is_host("windows") then local is_gigabyte = false @@ -43,13 +43,30 @@ function _check_gigabyte_gcc(program) if check_signature(program) then is_gigabyte = true end + else + local paths = path.splitenv(vformat("$(env PATH)")) + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) then + if check_signature(prog) then + is_gigabyte = true + end + break + end + end end end end if is_gigabyte then - raise("gcc.exe signed by GIGA-BYTE is not supported, please use the official gcc.exe instead.") + return false end end + + if opt.check_gcc then + return opt.check_gcc(program, opt) + end + + return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end -- detect whether the current gcc compiler is clang @@ -82,12 +99,10 @@ end -- function main(opt) opt = opt or {} + -- save the original check + opt.check_gcc = opt.check + opt.check = _check_gigabyte_gcc opt.norunfile = true - if is_host("windows") then - opt.check = _check_gcc - else - opt.norunfile = true - end local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then -- cgit v1.3.1 From 4879e24c27f481a3b2341f8be0f553030da98e0d Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:18:58 +0300 Subject: retry --- xmake/modules/detect/tools/find_gcc.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index a4e0782e7..e785af2ad 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,7 +22,9 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") -import("core.base.winos") +if is_host("windows") then + import("core.base.winos") +end -- check gigabyte gcc function _check_gigabyte_gcc(program, opt) -- cgit v1.3.1 From ad77b2a47be8dd1809c46bc2406c57aa4e3a8117 Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:30:58 +0300 Subject: retry --- xmake/modules/detect/tools/find_gcc.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index e785af2ad..9a81352b0 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -22,9 +22,6 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") -if is_host("windows") then - import("core.base.winos") -end -- check gigabyte gcc function _check_gigabyte_gcc(program, opt) -- cgit v1.3.1 From 451bdbc8c04327d7b060fc2ffb5db3842a127fb0 Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:39:41 +0300 Subject: retry --- xmake/modules/detect/tools/find_gcc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 9a81352b0..166c45bdc 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -26,7 +26,7 @@ import("core.cache.detectcache") -- check gigabyte gcc function _check_gigabyte_gcc(program, opt) -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if is_host("windows") then + if is_host("windows") or is_subhost("msys", "cygwin") then local is_gigabyte = false if program:lower():endswith("gcc.exe") then if winos.file_signature then @@ -57,7 +57,7 @@ function _check_gigabyte_gcc(program, opt) end end if is_gigabyte then - return false + raise("gcc.exe signed by GIGA-BYTE is not supported, please use the official gcc from https://gcc.gnu.org/") end end -- cgit v1.3.1 From 7d1fb079c4bc57b24cc5696ac04d3fb31571199a Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Feb 2026 23:55:13 +0300 Subject: retry --- xmake/modules/detect/tools/find_gcc.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 166c45bdc..cd52a06d2 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -31,10 +31,13 @@ function _check_gigabyte_gcc(program, opt) if program:lower():endswith("gcc.exe") then if winos.file_signature then local check_signature = function (program) - if os.isfile(program) then - local signer = winos.file_signature(program) - if signer and signer.signer_name and signer.signer_name:find("GIGA-BYTE", 1, true) then - return true + local filepath = path.translate(program) + if os.isfile(filepath) then + local signer = winos.file_signature(filepath) + if signer and signer.signer_name then + if signer.signer_name:find("GIGA-BYTE", 1, true) then + return true + end end end end -- cgit v1.3.1 From 9105a6b957d63c2a623a7e322210902c040d4940 Mon Sep 17 00:00:00 2001 From: Saikari Date: Wed, 18 Feb 2026 00:04:32 +0300 Subject: test --- xmake/modules/detect/tools/find_gcc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index cd52a06d2..576f6aa28 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -104,7 +104,7 @@ function main(opt) -- save the original check opt.check_gcc = opt.check opt.check = _check_gigabyte_gcc - opt.norunfile = true + -- opt.norunfile = true local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then -- cgit v1.3.1 From 39aa24a3192deb910a4b19b67a7e0178eb0f3f4a Mon Sep 17 00:00:00 2001 From: Saikari Date: Wed, 18 Feb 2026 00:11:23 +0300 Subject: sigh --- xmake/modules/detect/tools/find_gcc.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 576f6aa28..296008e3d 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -103,8 +103,11 @@ function main(opt) opt = opt or {} -- save the original check opt.check_gcc = opt.check - opt.check = _check_gigabyte_gcc - -- opt.norunfile = true + if is_host("windows") then + opt.check = _check_gigabyte_gcc + else + opt.norunfile = true + end local program = find_program(opt.program or "gcc", opt) local version = nil if program and opt.version then -- cgit v1.3.1 From 4ab3a066e0777f784eabeb103b4137b0bffcdacf Mon Sep 17 00:00:00 2001 From: Saikari Date: Wed, 18 Feb 2026 00:13:07 +0300 Subject: sigh --- xmake/modules/detect/tools/find_gcc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 296008e3d..2bfe53bc4 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -24,7 +24,7 @@ import("lib.detect.find_programver") import("core.cache.detectcache") -- check gigabyte gcc -function _check_gigabyte_gcc(program, opt) +function _check_gcc(program, opt) -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 if is_host("windows") or is_subhost("msys", "cygwin") then local is_gigabyte = false @@ -104,7 +104,7 @@ function main(opt) -- save the original check opt.check_gcc = opt.check if is_host("windows") then - opt.check = _check_gigabyte_gcc + opt.check = _check_gcc else opt.norunfile = true end -- cgit v1.3.1 From 3b4d1e1faf3183c26d3709a671b4c32ebb93b1b1 Mon Sep 17 00:00:00 2001 From: Saikari Date: Wed, 18 Feb 2026 00:17:18 +0300 Subject: try iterate over path env var --- xmake/modules/detect/tools/find_gcc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 2bfe53bc4..ce9562de6 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -60,7 +60,7 @@ function _check_gcc(program, opt) end end if is_gigabyte then - raise("gcc.exe signed by GIGA-BYTE is not supported, please use the official gcc from https://gcc.gnu.org/") + return false end end -- cgit v1.3.1 From 81cd22950cf68e698a4405209988b35d0a79c5a6 Mon Sep 17 00:00:00 2001 From: Saikari Date: Wed, 18 Feb 2026 00:30:28 +0300 Subject: retry --- xmake/modules/detect/tools/find_gcc.lua | 57 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index ce9562de6..4be9cc775 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -26,42 +26,41 @@ import("core.cache.detectcache") -- check gigabyte gcc function _check_gcc(program, opt) -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if is_host("windows") or is_subhost("msys", "cygwin") then - local is_gigabyte = false - if program:lower():endswith("gcc.exe") then - if winos.file_signature then - local check_signature = function (program) - local filepath = path.translate(program) - if os.isfile(filepath) then - local signer = winos.file_signature(filepath) - if signer and signer.signer_name then - if signer.signer_name:find("GIGA-BYTE", 1, true) then - return true - end - end - end + if is_host("windows") then + local check_signature = function (program) + local filepath = program + if path.is_absolute(filepath) then + filepath = path.translate(filepath) + end + if os.isfile(filepath) then + local signer = nil + if winos.file_signature then + signer = winos.file_signature(filepath) end - if path.is_absolute(program) then - if check_signature(program) then - is_gigabyte = true - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) then - if check_signature(prog) then - is_gigabyte = true - end - break - end + if signer and signer.signer_name then + local signer_name = signer.signer_name:upper() + if signer_name:find("GIGA-BYTE", 1, true) then + return true end end end end - if is_gigabyte then + + if check_signature(program) then return false end + + if not path.is_absolute(program) then + local paths = path.splitenv(vformat("$(env PATH)")) + if paths then + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) and check_signature(prog) then + return false + end + end + end + end end if opt.check_gcc then -- cgit v1.3.1 From 890c96aa26f16189957745329581b7e6c327e1ec Mon Sep 17 00:00:00 2001 From: Saikari Date: Wed, 18 Feb 2026 21:49:28 +0300 Subject: retry? --- xmake/modules/detect/tools/find_gcc.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 4be9cc775..71d7596b6 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -47,7 +47,7 @@ function _check_gcc(program, opt) end if check_signature(program) then - return false + raise("gcc.exe signed by GIGA-BYTE is not allowed!") end if not path.is_absolute(program) then @@ -56,17 +56,13 @@ function _check_gcc(program, opt) for _, p in ipairs(paths) do local prog = path.join(p, program) if os.isfile(prog) and check_signature(prog) then - return false + raise("gcc.exe signed by GIGA-BYTE is not allowed!") end end end end end - if opt.check_gcc then - return opt.check_gcc(program, opt) - end - return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end @@ -100,8 +96,6 @@ end -- function main(opt) opt = opt or {} - -- save the original check - opt.check_gcc = opt.check if is_host("windows") then opt.check = _check_gcc else -- cgit v1.3.1 From 3b5a2eb617b1083ea30153f6b3c4bbdf3b90faad Mon Sep 17 00:00:00 2001 From: Saikari Date: Thu, 19 Feb 2026 00:31:58 +0300 Subject: retry? --- xmake/modules/detect/tools/find_gcc.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 71d7596b6..fc961e65e 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -32,6 +32,10 @@ function _check_gcc(program, opt) if path.is_absolute(filepath) then filepath = path.translate(filepath) end + -- we only check signature for gcc.exe + if not filepath:lower():endswith("gcc.exe") then + return + end if os.isfile(filepath) then local signer = nil if winos.file_signature then @@ -46,11 +50,11 @@ function _check_gcc(program, opt) end end - if check_signature(program) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") - end - - if not path.is_absolute(program) then + if path.is_absolute(program) then + if check_signature(program) then + raise("gcc.exe signed by GIGA-BYTE is not allowed!") + end + else local paths = path.splitenv(vformat("$(env PATH)")) if paths then for _, p in ipairs(paths) do @@ -61,7 +65,6 @@ function _check_gcc(program, opt) end end end - end return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end -- cgit v1.3.1 From d9d08b4544a67699adbe0a4f317430fd045d6f51 Mon Sep 17 00:00:00 2001 From: Saikari Date: Thu, 19 Feb 2026 00:36:01 +0300 Subject: fixup --- xmake/modules/detect/tools/find_gcc.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index fc961e65e..17d548805 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -65,6 +65,7 @@ function _check_gcc(program, opt) end end end + end return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end -- cgit v1.3.1 From 562cd7187775c7b7184cc7da5fffd0dcc77550d3 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 22:39:41 +0800 Subject: fix tmpdir for haiku --- .github/workflows/haiku.yml | 1 - tests/plugins/create/test.lua | 8 ++++---- xmake/core/base/os.lua | 17 +++++++++++++---- xmake/core/project/config.lua | 8 ++------ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index 136788754..c872b678e 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -75,5 +75,4 @@ jobs: export XMAKE_ROOT=y export PATH=`pwd`/dist/bin:$PATH xrepo --version - xmake l os.meminfo xmake lua -v -D tests/run.lua diff --git a/tests/plugins/create/test.lua b/tests/plugins/create/test.lua index 397f846f4..7813c3ee2 100644 --- a/tests/plugins/create/test.lua +++ b/tests/plugins/create/test.lua @@ -1,11 +1,11 @@ function main () os.tryrm("$(tmpdir)/test_create") os.exec("xmake create -P $(tmpdir)/test_create/test") - os.exec("xmake -P $(tmpdir)/test_create/test") + os.exec("xmake -vD -P $(tmpdir)/test_create/test") os.exec("xmake create -l c++ -P $(tmpdir)/test_create/test_cpp") - os.exec("xmake -P $(tmpdir)/test_create/test_cpp") + os.exec("xmake -vD -P $(tmpdir)/test_create/test_cpp") os.exec("xmake create -l c++ -t static -P $(tmpdir)/test_create/test_cpp2") - os.exec("xmake -P $(tmpdir)/test_create/test_cpp2") + os.exec("xmake -vD -P $(tmpdir)/test_create/test_cpp2") os.exec("xmake create -l c++ -t shared -P $(tmpdir)/test_create/test_cpp3") - os.exec("xmake -P $(tmpdir)/test_create/test_cpp3") + os.exec("xmake -vD -P $(tmpdir)/test_create/test_cpp3") end diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index d20cd671a..d50ce19f2 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -768,15 +768,24 @@ function os.tmpdir(opt) -- get root tmpdir local tmpdir_root = nil if opt and opt.ramdisk == false then + tmpdir_root = os._ROOT_TMPDIR if os._ROOT_TMPDIR == nil then - os._ROOT_TMPDIR = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() + tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() + -- TODO + if os.islink(tmpdir_root) then + tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root + end + os._ROOT_TMPDIR = tmpdir_root end - tmpdir_root = os._ROOT_TMPDIR else + tmpdir_root = os._ROOT_TMPDIR_RAM if os._ROOT_TMPDIR_RAM == nil then - os._ROOT_TMPDIR_RAM = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() + tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() + if os.islink(tmpdir_root) then + tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root + end + os._ROOT_TMPDIR_RAM = tmpdir_root end - tmpdir_root = os._ROOT_TMPDIR_RAM end -- make sub-directory name diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 47d9406a8..93c1ff6af 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -165,13 +165,9 @@ function config.builddir(opt) builddir = path.absolute(builddir, rootdir) end - -- Adjust path for the current directory, - -- If it's an external directory, use the absolute path directly. + -- adjust path for the current directory if not opt.absolute then - local relativedir = path.relative(builddir, os.curdir()) - if not relativedir:startswith("..") then - builddir = relativedir - end + builddir = path.relative(builddir, os.curdir()) end return builddir end -- cgit v1.3.1 From 8a0500d1fb9453fc5a8bebf9f859acadc1d8301f Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 22:41:40 +0800 Subject: improve os.tmpdir --- xmake/core/base/os.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index d50ce19f2..b8ce09f68 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -200,6 +200,15 @@ function os._ramdir() return ramdir_root or nil end +-- if tmpdir_root is a symbolic link, os.tmpdir() may return a path that differs +-- from the path style returned by os.curdir() (e.g. on Haiku). +function os._resolve_tmpdir(tmpdir_root) + if os.islink(tmpdir_root) then + tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root + end + return tmpdir_root +end + -- set on change environments callback for scheduler function os._sched_chenvs_set(envs) os._SCHED_CHENVS = envs @@ -771,19 +780,14 @@ function os.tmpdir(opt) tmpdir_root = os._ROOT_TMPDIR if os._ROOT_TMPDIR == nil then tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() - -- TODO - if os.islink(tmpdir_root) then - tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root - end + tmpdir_root = os._resolve_tmpdir(tmpdir_root) os._ROOT_TMPDIR = tmpdir_root end else tmpdir_root = os._ROOT_TMPDIR_RAM if os._ROOT_TMPDIR_RAM == nil then tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() - if os.islink(tmpdir_root) then - tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root - end + tmpdir_root = os._resolve_tmpdir(tmpdir_root) os._ROOT_TMPDIR_RAM = tmpdir_root end end -- cgit v1.3.1 From 104ffb3bc0d4d43f36688ffa778201bed4a71e45 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 22:54:35 +0800 Subject: update comments --- .github/workflows/haiku.yml | 4 ++-- xmake/core/base/os.lua | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index c872b678e..34e51392b 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -48,8 +48,8 @@ jobs: RUN_PROBABILITY: ${{ vars.HAIKU_RUN_PROBABILITY || '0.2' }} build: - #needs: check - #if: needs.check.outputs.should-run == 'true' + needs: check + if: needs.check.outputs.should-run == 'true' runs-on: ubuntu-latest concurrency: diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index b8ce09f68..1766d28f5 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -202,6 +202,12 @@ end -- if tmpdir_root is a symbolic link, os.tmpdir() may return a path that differs -- from the path style returned by os.curdir() (e.g. on Haiku). +-- +-- Using a consistent root path can avoid errors in relative path resolution. +-- +-- e.g. +-- tmpdir: /tmp/.xmake0/260217/ -> /boot/system/cache/tmp/.xmake0/260217 +-- curdir: /boot/system/cache/tmp/.xmake0/260217 function os._resolve_tmpdir(tmpdir_root) if os.islink(tmpdir_root) then tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root -- cgit v1.3.1 From b065878db47435b7ebfa9f29020c927b4eff8f7e Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 23:31:47 +0800 Subject: Update find_gcc.lua --- xmake/modules/detect/tools/find_gcc.lua | 60 +++++++++++---------------------- 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 17d548805..d658ca1ff 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -23,50 +23,30 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("core.cache.detectcache") --- check gigabyte gcc -function _check_gcc(program, opt) - -- avoid gcc.exe signed by GIGA-BYTE ref: https://github.com/xmake-io/xmake/issues/5629 - if is_host("windows") then - local check_signature = function (program) - local filepath = program - if path.is_absolute(filepath) then - filepath = path.translate(filepath) - end - -- we only check signature for gcc.exe - if not filepath:lower():endswith("gcc.exe") then - return - end - if os.isfile(filepath) then - local signer = nil - if winos.file_signature then - signer = winos.file_signature(filepath) - end - if signer and signer.signer_name then - local signer_name = signer.signer_name:upper() - if signer_name:find("GIGA-BYTE", 1, true) then - return true - end - end - end +-- check gcc/gigabyte signature +function check_gcc_gigabyte(program) + if os.isfile(program) then + local signer = nil + if winos.file_signature then + signer = winos.file_signature(program) end - - if path.is_absolute(program) then - if check_signature(program) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - if paths then - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) and check_signature(prog) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") - end - end + if signer and signer.signer_name then + local signer_name = signer.signer_name:upper() + if signer_name:find("GIGA-BYTE", 1, true) then + return true end end end +end +-- check gigabyte gcc +-- avoid gcc.exe signed by GIGA-BYTE +-- @see https://github.com/xmake-io/xmake/issues/5629 +function _check_gcc_on_windows(program, opt) + opt = opt or {} + if check_gcc_gigabyte(program) then + raise("gcc.exe signed by GIGA-BYTE is not allowed!") + end return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end @@ -101,7 +81,7 @@ end function main(opt) opt = opt or {} if is_host("windows") then - opt.check = _check_gcc + opt.check = _check_gcc_on_windows else opt.norunfile = true end -- cgit v1.3.1 From b66b14a6b56e3eab79ebedd51be44fee81be174e Mon Sep 17 00:00:00 2001 From: Saikari Date: Fri, 20 Feb 2026 16:06:09 +0300 Subject: Test --- xmake/modules/detect/tools/find_gcc.lua | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index d658ca1ff..651fbe102 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -25,10 +25,18 @@ import("core.cache.detectcache") -- check gcc/gigabyte signature function check_gcc_gigabyte(program) - if os.isfile(program) then + local filepath = program + if path.is_absolute(filepath) then + filepath = path.translate(filepath) + end + -- we only check signature for gcc.exe + if not filepath:lower():endswith("gcc.exe") then + return + end + if os.isfile(filepath) then local signer = nil if winos.file_signature then - signer = winos.file_signature(program) + signer = winos.file_signature(filepath) end if signer and signer.signer_name then local signer_name = signer.signer_name:upper() @@ -44,8 +52,20 @@ end -- @see https://github.com/xmake-io/xmake/issues/5629 function _check_gcc_on_windows(program, opt) opt = opt or {} - if check_gcc_gigabyte(program) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") + if path.is_absolute(program) then + if check_gcc_gigabyte(program) then + raise("gcc.exe signed by GIGA-BYTE is not allowed!") + end + else + local paths = path.splitenv(vformat("$(env PATH)")) + if paths then + for _, p in ipairs(paths) do + local prog = path.join(p, program) + if os.isfile(prog) and check_gcc_gigabyte(prog) then + raise("gcc.exe signed by GIGA-BYTE is not allowed!") + end + end + end end return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end -- cgit v1.3.1 From c93f82380376dfddc680d39e13606fca9bb13806 Mon Sep 17 00:00:00 2001 From: Saikari Date: Fri, 20 Feb 2026 16:16:28 +0300 Subject: fixup --- xmake/modules/detect/tools/find_gcc.lua | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 651fbe102..83ee0fe59 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -25,18 +25,10 @@ import("core.cache.detectcache") -- check gcc/gigabyte signature function check_gcc_gigabyte(program) - local filepath = program - if path.is_absolute(filepath) then - filepath = path.translate(filepath) - end - -- we only check signature for gcc.exe - if not filepath:lower():endswith("gcc.exe") then - return - end - if os.isfile(filepath) then + if os.isfile(program) then local signer = nil if winos.file_signature then - signer = winos.file_signature(filepath) + signer = winos.file_signature(program) end if signer and signer.signer_name then local signer_name = signer.signer_name:upper() -- cgit v1.3.1 From cc3ccaeefb01d2e4650ff850d74a04bfa2b62a63 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 13 Feb 2026 23:59:41 +0800 Subject: add haiku ci --- .github/workflows/haiku.yml | 81 +++++++++++++++++++++ core/src/tbox/tbox | 2 +- core/src/xmake/string/lower.c | 162 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/haiku.yml diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml new file mode 100644 index 000000000..f277d263f --- /dev/null +++ b/.github/workflows/haiku.yml @@ -0,0 +1,81 @@ +name: Haiku + +on: + pull_request: + push: + release: + types: [published] + +jobs: + check: + runs-on: ubuntu-latest + outputs: + should-run: ${{ steps.check.outputs.should-run }} + steps: + - name: Random execution check + id: check + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const outputFile = process.env.GITHUB_OUTPUT; + + if (context.eventName === 'release') { + fs.appendFileSync(outputFile, `should-run=true\n`); + core.info('Release event detected. Will run tests.'); + return; + } + + const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); + const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); + const seed = context.sha + context.runId + timeSeed; + let hash = 0; + for (let i = 0; i < seed.length; i++) { + const char = seed.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash | 0; + } + const random = Math.abs(hash) / 2147483647; + const shouldRun = random < probability; + + fs.appendFileSync(outputFile, `should-run=${shouldRun}\n`); + if (shouldRun) { + core.info(`Random check passed (${(random * 100).toFixed(2)}% < ${(probability * 100).toFixed(0)}%). Will run tests.`); + } else { + core.info(`Random check failed (${(random * 100).toFixed(2)}% >= ${(probability * 100).toFixed(0)}%). Skipping.`); + } + env: + RUN_PROBABILITY: ${{ vars.HAIKU_RUN_PROBABILITY || '0.2' }} + + build: + #needs: check + #if: needs.check.outputs.should-run == 'true' + runs-on: ubuntu-latest + + concurrency: + group: Haiku-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} + cancel-in-progress: false + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Tests + uses: vmactions/haiku-vm@v1 + with: + usesh: true + mem: 4096 + copyback: false + prepare: | + pkgman install -y git curl unzip make bash perl + run: | + pwd + ./configure --prefix=`pwd`/dist + make -j2 + make install + ls -l ./dist/ + export XMAKE_ROOT=y + export PATH=`pwd`/dist/bin:$PATH + xrepo --version + xmake l os.meminfo + xmake l string.lower "Test 源文件🎆 Message" diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox index ef851bcb6..75c90b4c4 160000 --- a/core/src/tbox/tbox +++ b/core/src/tbox/tbox @@ -1 +1 @@ -Subproject commit ef851bcb6589b6092f5bd3fca4625631237f9bdd +Subproject commit 75c90b4c4313f84f8247867c99721882e390f401 diff --git a/core/src/xmake/string/lower.c b/core/src/xmake/string/lower.c index 71f8408dc..07ae4bff4 100644 --- a/core/src/xmake/string/lower.c +++ b/core/src/xmake/string/lower.c @@ -23,6 +23,166 @@ * includes */ #include "prefix.h" +# include + +static __tb_inline__ tb_bool_t tb_unicode_tolower_try(tb_uint32_t ch, tb_uint32_t* out) +{ + // builtin, locale-independent case mapping for some common unicode ranges: + // - Basic Latin (ASCII) + // - Latin-1 Supplement (partial) + // - Latin Extended-A (partial) + // - Greek (partial) + // - Cyrillic (partial) + if (sizeof(tb_wchar_t) == 2 && ch >= 0xd800 && ch <= 0xdfff) return tb_false; + + // Basic Latin (ASCII) + if (ch <= 0x7f) + { + tb_trace_i("basic: %x", ch); + *out = tb_tolower(ch); + return tb_true; + } + + // Latin-1 Supplement: U+00C0..U+00D6, U+00D8..U+00DE + if ((ch >= 0x00c0 && ch <= 0x00d6) || (ch >= 0x00d8 && ch <= 0x00de)) { *out = ch + 0x20; return tb_true; } + // Latin-1 Supplement: U+00E0..U+00F6, U+00F8..U+00FE + if ((ch >= 0x00e0 && ch <= 0x00f6) || (ch >= 0x00f8 && ch <= 0x00fe)) { *out = ch; return tb_true; } + + // Latin-1 Supplement: U+0178 <-> U+00FF + if (ch == 0x0178) { *out = 0x00ff; return tb_true; } + if (ch == 0x00ff) { *out = ch; return tb_true; } + + // Latin Extended Additional: U+1E9E <-> U+00DF + if (ch == 0x1e9e) { *out = 0x00df; return tb_true; } + if (ch == 0x00df) { *out = ch; return tb_true; } + + // Latin Extended-A: many letters have alternating upper/lower code points + if (ch >= 0x0100 && ch <= 0x012f) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } + if (ch >= 0x0132 && ch <= 0x0137) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } + if (ch >= 0x0139 && ch <= 0x0148) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } + if (ch >= 0x014a && ch <= 0x0177) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } + if (ch >= 0x0179 && ch <= 0x017e) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } + // Latin Extended-A: long s (already lowercase) + if (ch == 0x017f) { *out = ch; return tb_true; } + + // Greek and Coptic (partial): U+0391..U+03A1, U+03A3..U+03AB + if ((ch >= 0x0391 && ch <= 0x03a1) || (ch >= 0x03a3 && ch <= 0x03ab)) { *out = ch + 0x20; return tb_true; } + // Greek and Coptic (partial): U+03B1..U+03C1, U+03C3..U+03CB, and U+03C2 + if ((ch >= 0x03b1 && ch <= 0x03c1) || (ch >= 0x03c3 && ch <= 0x03cb) || ch == 0x03c2) { *out = ch; return tb_true; } + + // Cyrillic (partial): U+0401/U+0451 and U+0410..U+042F + if (ch == 0x0401) { *out = 0x0451; return tb_true; } + if (ch == 0x0451) { *out = ch; return tb_true; } + if (ch >= 0x0402 && ch <= 0x040f) { *out = ch + 0x50; return tb_true; } + if (ch >= 0x0452 && ch <= 0x045f) { *out = ch; return tb_true; } + if (ch >= 0x0410 && ch <= 0x042f) { *out = ch + 0x20; return tb_true; } + + if (ch >= 0x0430 && ch <= 0x044f) { + *out = ch; + return tb_true; + } + + return tb_false; +} + +tb_wchar_t tb_towlower_test(tb_wchar_t c) +{ + tb_trace_i("towlower: %x, wchar: %d", (tb_uint32_t)c, sizeof(tb_wchar_t)); + tb_uint32_t ch = tb_bits_wchar_to_u32_le(c); + tb_uint32_t out; + if (__tb_likely__(tb_unicode_tolower_try(ch, &out))) { + tb_trace_i("towlower: out: %x", out); + return tb_bits_u32_le_to_wchar(out); + } + + tb_trace_i("towlower xxx: %x", (tb_uint32_t)c); + return (tb_wchar_t)towlower((tb_uint32_t)c); +} + +static tb_wchar_t* tb_wcslwr_test(tb_wchar_t* s) +{ + // check + tb_assert_and_check_return_val(s, tb_null); + + // set local locale + tb_setlocale(); + + tb_wchar_t* p = s; + while (*p) + { + *p = tb_towlower_test(*p); + p++; + } + + // set default locale + tb_resetlocale(); + + return s; +} + +static tb_size_t tb_mbstowcs_charset(tb_wchar_t* s1, tb_char_t const* s2, tb_size_t n) +{ + // check + tb_assert_and_check_return_val(s1 && s2, 0); + + // init + tb_size_t e = (sizeof(tb_wchar_t) == 4) ? TB_CHARSET_TYPE_UTF32 : TB_CHARSET_TYPE_UTF16; + tb_long_t r = tb_charset_conv_cstr(TB_CHARSET_TYPE_UTF8, e | TB_CHARSET_TYPE_LE, s2, + (tb_byte_t*)s1, n * sizeof(tb_wchar_t)); + if (r > 0) r /= sizeof(tb_wchar_t); + + // strip + if (r >= 0) s1[r] = L'\0'; + + tb_trace_i("tb_mbstowcs_charset: %ld", r); + // ok? + return r >= 0 ? r : -1; +} + +static tb_long_t tb_charset_utf8_tolower_test(tb_char_t* s, tb_size_t n) +{ + tb_assert_and_check_return_val(s, -1); + + tb_trace_i("s: %s: %d", s, n); + + // try ascii tolower first + tb_char_t* p = s; + tb_char_t* e = s + n; + while (p < e && *p) + { + if ((*p) & 0x80) { + break; + } + tb_trace_i("old: %c -> %x", *p); + *p = tb_tolower(*p); + tb_trace_i("new: %c -> %x", *p); + p++; + } + tb_trace_i("test: %d %d", p == e, !*p); + + if (p == e || !*p) return p - s; + + // convert the suffix to wchar_t + tb_long_t r = -1; + tb_size_t wn = e - p + 1; + tb_wchar_t wb[256]; + tb_wchar_t* w = (wn <= 256)? wb : (tb_wchar_t*)tb_malloc(wn * sizeof(tb_wchar_t)); + if (w) + { + tb_trace_i("tb_mbstowcs 111"); + if (tb_mbstowcs_charset(w, p, wn) != -1) + { + tb_trace_i("tb_wcslwr_test 111"); + tb_wcslwr_test(w); + r = tb_wcstombs(p, w, wn); + if (r != -1) r += (p - s); + } + + tb_trace_i("tb_free 111"); + if (w != wb) tb_free(w); + } + return r; +} /* ////////////////////////////////////////////////////////////////////////////////////// * implementation @@ -58,7 +218,7 @@ tb_int_t xm_string_lower(lua_State *lua) { buffer[size] = '\0'; // to lower - tb_long_t real_size = tb_charset_utf8_tolower(buffer, size); + tb_long_t real_size = tb_charset_utf8_tolower_test(buffer, size); // push result if (real_size >= 0) { -- cgit v1.3.1 From 424000071f5aeabac3e51e7d2640bc625f06f10a Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 16:34:49 +0800 Subject: enable force-utf8 for haiku --- core/src/tbox/inc/haiku/tbox.config.h | 2 +- core/src/tbox/inc/iphoneos/tbox.config.h | 2 +- core/src/tbox/inc/solaris/tbox.config.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/tbox/inc/haiku/tbox.config.h b/core/src/tbox/inc/haiku/tbox.config.h index 8a9e72ad8..dc61fce45 100644 --- a/core/src/tbox/inc/haiku/tbox.config.h +++ b/core/src/tbox/inc/haiku/tbox.config.h @@ -16,7 +16,7 @@ /*#undef TB_CONFIG_MICRO_ENABLE*/ /*#undef TB_CONFIG_TYPE_HAVE_WCHAR*/ #define TB_CONFIG_TYPE_HAVE_FLOAT 1 -/*#undef TB_CONFIG_FORCE_UTF8*/ +#define TB_CONFIG_FORCE_UTF8 1 /*#undef TB_CONFIG_API_HAVE_DEPRECATED*/ /*#undef TB_CONFIG_EXCEPTION_ENABLE*/ diff --git a/core/src/tbox/inc/iphoneos/tbox.config.h b/core/src/tbox/inc/iphoneos/tbox.config.h index 290786a50..43aa10c8b 100755 --- a/core/src/tbox/inc/iphoneos/tbox.config.h +++ b/core/src/tbox/inc/iphoneos/tbox.config.h @@ -16,7 +16,7 @@ /* #undef TB_CONFIG_MICRO_ENABLE */ /* #undef TB_CONFIG_TYPE_HAVE_WCHAR */ #define TB_CONFIG_TYPE_HAVE_FLOAT 1 -/* #undef TB_CONFIG_FORCE_UTF8 */ +#define TB_CONFIG_FORCE_UTF8 1 /* #undef TB_CONFIG_API_HAVE_DEPRECATED */ /* #undef TB_CONFIG_EXCEPTION_ENABLE */ diff --git a/core/src/tbox/inc/solaris/tbox.config.h b/core/src/tbox/inc/solaris/tbox.config.h index 89bce47bc..25bafd9f6 100644 --- a/core/src/tbox/inc/solaris/tbox.config.h +++ b/core/src/tbox/inc/solaris/tbox.config.h @@ -16,7 +16,7 @@ /*#undef TB_CONFIG_MICRO_ENABLE*/ /*#undef TB_CONFIG_TYPE_HAVE_WCHAR*/ #define TB_CONFIG_TYPE_HAVE_FLOAT 1 -/*#undef TB_CONFIG_FORCE_UTF8*/ +#define TB_CONFIG_FORCE_UTF8 1 /*#undef TB_CONFIG_API_HAVE_DEPRECATED*/ /*#undef TB_CONFIG_EXCEPTION_ENABLE*/ -- cgit v1.3.1 From 457b14df41a52d8d123aed13879855affd9a8957 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 16:38:02 +0800 Subject: update tbox --- core/src/tbox/tbox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox index 75c90b4c4..ddc363161 160000 --- a/core/src/tbox/tbox +++ b/core/src/tbox/tbox @@ -1 +1 @@ -Subproject commit 75c90b4c4313f84f8247867c99721882e390f401 +Subproject commit ddc363161ce6aed86109dcd665b63fb9a810e3a3 -- cgit v1.3.1 From 92048d416c4644898e59f0664e7b1df2a2079133 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 16:39:19 +0800 Subject: update lower --- core/src/xmake/string/lower.c | 162 +----------------------------------------- 1 file changed, 1 insertion(+), 161 deletions(-) diff --git a/core/src/xmake/string/lower.c b/core/src/xmake/string/lower.c index 07ae4bff4..71f8408dc 100644 --- a/core/src/xmake/string/lower.c +++ b/core/src/xmake/string/lower.c @@ -23,166 +23,6 @@ * includes */ #include "prefix.h" -# include - -static __tb_inline__ tb_bool_t tb_unicode_tolower_try(tb_uint32_t ch, tb_uint32_t* out) -{ - // builtin, locale-independent case mapping for some common unicode ranges: - // - Basic Latin (ASCII) - // - Latin-1 Supplement (partial) - // - Latin Extended-A (partial) - // - Greek (partial) - // - Cyrillic (partial) - if (sizeof(tb_wchar_t) == 2 && ch >= 0xd800 && ch <= 0xdfff) return tb_false; - - // Basic Latin (ASCII) - if (ch <= 0x7f) - { - tb_trace_i("basic: %x", ch); - *out = tb_tolower(ch); - return tb_true; - } - - // Latin-1 Supplement: U+00C0..U+00D6, U+00D8..U+00DE - if ((ch >= 0x00c0 && ch <= 0x00d6) || (ch >= 0x00d8 && ch <= 0x00de)) { *out = ch + 0x20; return tb_true; } - // Latin-1 Supplement: U+00E0..U+00F6, U+00F8..U+00FE - if ((ch >= 0x00e0 && ch <= 0x00f6) || (ch >= 0x00f8 && ch <= 0x00fe)) { *out = ch; return tb_true; } - - // Latin-1 Supplement: U+0178 <-> U+00FF - if (ch == 0x0178) { *out = 0x00ff; return tb_true; } - if (ch == 0x00ff) { *out = ch; return tb_true; } - - // Latin Extended Additional: U+1E9E <-> U+00DF - if (ch == 0x1e9e) { *out = 0x00df; return tb_true; } - if (ch == 0x00df) { *out = ch; return tb_true; } - - // Latin Extended-A: many letters have alternating upper/lower code points - if (ch >= 0x0100 && ch <= 0x012f) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } - if (ch >= 0x0132 && ch <= 0x0137) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } - if (ch >= 0x0139 && ch <= 0x0148) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } - if (ch >= 0x014a && ch <= 0x0177) { *out = (ch & 0x1) ? ch : (ch + 1); return tb_true; } - if (ch >= 0x0179 && ch <= 0x017e) { *out = (ch & 0x1) ? (ch + 1) : ch; return tb_true; } - // Latin Extended-A: long s (already lowercase) - if (ch == 0x017f) { *out = ch; return tb_true; } - - // Greek and Coptic (partial): U+0391..U+03A1, U+03A3..U+03AB - if ((ch >= 0x0391 && ch <= 0x03a1) || (ch >= 0x03a3 && ch <= 0x03ab)) { *out = ch + 0x20; return tb_true; } - // Greek and Coptic (partial): U+03B1..U+03C1, U+03C3..U+03CB, and U+03C2 - if ((ch >= 0x03b1 && ch <= 0x03c1) || (ch >= 0x03c3 && ch <= 0x03cb) || ch == 0x03c2) { *out = ch; return tb_true; } - - // Cyrillic (partial): U+0401/U+0451 and U+0410..U+042F - if (ch == 0x0401) { *out = 0x0451; return tb_true; } - if (ch == 0x0451) { *out = ch; return tb_true; } - if (ch >= 0x0402 && ch <= 0x040f) { *out = ch + 0x50; return tb_true; } - if (ch >= 0x0452 && ch <= 0x045f) { *out = ch; return tb_true; } - if (ch >= 0x0410 && ch <= 0x042f) { *out = ch + 0x20; return tb_true; } - - if (ch >= 0x0430 && ch <= 0x044f) { - *out = ch; - return tb_true; - } - - return tb_false; -} - -tb_wchar_t tb_towlower_test(tb_wchar_t c) -{ - tb_trace_i("towlower: %x, wchar: %d", (tb_uint32_t)c, sizeof(tb_wchar_t)); - tb_uint32_t ch = tb_bits_wchar_to_u32_le(c); - tb_uint32_t out; - if (__tb_likely__(tb_unicode_tolower_try(ch, &out))) { - tb_trace_i("towlower: out: %x", out); - return tb_bits_u32_le_to_wchar(out); - } - - tb_trace_i("towlower xxx: %x", (tb_uint32_t)c); - return (tb_wchar_t)towlower((tb_uint32_t)c); -} - -static tb_wchar_t* tb_wcslwr_test(tb_wchar_t* s) -{ - // check - tb_assert_and_check_return_val(s, tb_null); - - // set local locale - tb_setlocale(); - - tb_wchar_t* p = s; - while (*p) - { - *p = tb_towlower_test(*p); - p++; - } - - // set default locale - tb_resetlocale(); - - return s; -} - -static tb_size_t tb_mbstowcs_charset(tb_wchar_t* s1, tb_char_t const* s2, tb_size_t n) -{ - // check - tb_assert_and_check_return_val(s1 && s2, 0); - - // init - tb_size_t e = (sizeof(tb_wchar_t) == 4) ? TB_CHARSET_TYPE_UTF32 : TB_CHARSET_TYPE_UTF16; - tb_long_t r = tb_charset_conv_cstr(TB_CHARSET_TYPE_UTF8, e | TB_CHARSET_TYPE_LE, s2, - (tb_byte_t*)s1, n * sizeof(tb_wchar_t)); - if (r > 0) r /= sizeof(tb_wchar_t); - - // strip - if (r >= 0) s1[r] = L'\0'; - - tb_trace_i("tb_mbstowcs_charset: %ld", r); - // ok? - return r >= 0 ? r : -1; -} - -static tb_long_t tb_charset_utf8_tolower_test(tb_char_t* s, tb_size_t n) -{ - tb_assert_and_check_return_val(s, -1); - - tb_trace_i("s: %s: %d", s, n); - - // try ascii tolower first - tb_char_t* p = s; - tb_char_t* e = s + n; - while (p < e && *p) - { - if ((*p) & 0x80) { - break; - } - tb_trace_i("old: %c -> %x", *p); - *p = tb_tolower(*p); - tb_trace_i("new: %c -> %x", *p); - p++; - } - tb_trace_i("test: %d %d", p == e, !*p); - - if (p == e || !*p) return p - s; - - // convert the suffix to wchar_t - tb_long_t r = -1; - tb_size_t wn = e - p + 1; - tb_wchar_t wb[256]; - tb_wchar_t* w = (wn <= 256)? wb : (tb_wchar_t*)tb_malloc(wn * sizeof(tb_wchar_t)); - if (w) - { - tb_trace_i("tb_mbstowcs 111"); - if (tb_mbstowcs_charset(w, p, wn) != -1) - { - tb_trace_i("tb_wcslwr_test 111"); - tb_wcslwr_test(w); - r = tb_wcstombs(p, w, wn); - if (r != -1) r += (p - s); - } - - tb_trace_i("tb_free 111"); - if (w != wb) tb_free(w); - } - return r; -} /* ////////////////////////////////////////////////////////////////////////////////////// * implementation @@ -218,7 +58,7 @@ tb_int_t xm_string_lower(lua_State *lua) { buffer[size] = '\0'; // to lower - tb_long_t real_size = tb_charset_utf8_tolower_test(buffer, size); + tb_long_t real_size = tb_charset_utf8_tolower(buffer, size); // push result if (real_size >= 0) { -- cgit v1.3.1 From e7837a890c43646dae50644f6f120f084687ad09 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:39:50 +0800 Subject: fix ci --- .github/workflows/alpine.yml | 5 ++--- .github/workflows/archlinux.yml | 13 ++++++------- .github/workflows/dragonflybsd.yml | 5 ++--- .github/workflows/fedora.yml | 5 ++--- .github/workflows/haiku.yml | 4 ++-- .github/workflows/linux_luajit.yml | 5 ++--- .github/workflows/netbsd.yml | 5 ++--- .github/workflows/openbsd.yml | 5 ++--- .github/workflows/windows_luajit.yml | 4 ++-- 9 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 5bce09441..ba6d3552c 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -63,8 +63,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Alpine-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Alpine + cancel-in-progress: true steps: - name: Prepare build tools run: | @@ -88,4 +88,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/archlinux.yml b/.github/workflows/archlinux.yml index 7ee73fe47..03118bbb8 100644 --- a/.github/workflows/archlinux.yml +++ b/.github/workflows/archlinux.yml @@ -19,17 +19,17 @@ jobs: script: | const fs = require('fs'); const outputFile = process.env.GITHUB_OUTPUT; - + // Always run for release events if (context.eventName === 'release') { fs.appendFileSync(outputFile, `should-run=true\n`); core.info('Release event detected. Will run tests.'); return; } - + // Execution probability (default 20%, can be overridden via env) const probability = parseFloat(process.env.RUN_PROBABILITY || '0.2'); - + // Generate deterministic "random" number based on commit SHA, run ID, and current time // Adding time ensures better randomness while keeping same commit/run consistent const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency @@ -43,7 +43,7 @@ jobs: // Normalize to 0-1 range const random = Math.abs(hash) / 2147483647; const shouldRun = random < probability; - + // Use environment file instead of deprecated set-output fs.appendFileSync(outputFile, `should-run=${shouldRun}\n`); if (shouldRun) { @@ -63,8 +63,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Archlinux-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Archlinux + cancel-in-progress: true steps: - name: Prepare build tools run: | @@ -90,4 +90,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/dragonflybsd.yml b/.github/workflows/dragonflybsd.yml index b65a22a88..41be4d83e 100644 --- a/.github/workflows/dragonflybsd.yml +++ b/.github/workflows/dragonflybsd.yml @@ -61,8 +61,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: DragonflyBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-DragonflyBSD + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -84,4 +84,3 @@ jobs: xrepo --version xmake l os.meminfo xmake lua -v -D tests/run.lua - diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index 1b0ec0304..5666ce932 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -63,8 +63,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Fedora-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Fedora + cancel-in-progress: true steps: - name: Prepare build tools run: | @@ -90,4 +90,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index f277d263f..fd1a95eca 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -53,8 +53,8 @@ jobs: runs-on: ubuntu-latest concurrency: - group: Haiku-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Haiku + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/linux_luajit.yml b/.github/workflows/linux_luajit.yml index 36c519245..ccbb96f59 100644 --- a/.github/workflows/linux_luajit.yml +++ b/.github/workflows/linux_luajit.yml @@ -60,8 +60,8 @@ jobs: runs-on: ubuntu-latest concurrency: # Prevent concurrent runs of the same workflow - group: Linux-Luajit-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Linux-Luajit + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -90,4 +90,3 @@ jobs: run: | xmake lua -v -D tests/run.lua xrepo --version - diff --git a/.github/workflows/netbsd.yml b/.github/workflows/netbsd.yml index bf704048f..f216f8992 100644 --- a/.github/workflows/netbsd.yml +++ b/.github/workflows/netbsd.yml @@ -61,8 +61,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: NetBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-NetBSD + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -85,4 +85,3 @@ jobs: xrepo --version xmake l os.meminfo xmake lua -v -D tests/run.lua - diff --git a/.github/workflows/openbsd.yml b/.github/workflows/openbsd.yml index 1e3cc912a..8c74bdaf1 100644 --- a/.github/workflows/openbsd.yml +++ b/.github/workflows/openbsd.yml @@ -61,8 +61,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: OpenBSD-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-OpenBSD + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: @@ -85,4 +85,3 @@ jobs: xrepo --version xmake l os.meminfo xmake lua -v -D tests/run.lua - diff --git a/.github/workflows/windows_luajit.yml b/.github/workflows/windows_luajit.yml index c86d5e0b5..7a26cabaa 100644 --- a/.github/workflows/windows_luajit.yml +++ b/.github/workflows/windows_luajit.yml @@ -66,8 +66,8 @@ jobs: concurrency: # Prevent concurrent runs of the same workflow - group: Windows-Luajit-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }}-${{ matrix.os }}-${{ matrix.arch }} - cancel-in-progress: false + group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.arch }}-Windows-Luajit + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: -- cgit v1.3.1 From 9e9906cd7a72e14f28cd172b57ea237192f3661f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:40:04 +0800 Subject: update tbox --- core/src/tbox/tbox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox index ddc363161..de475fef0 160000 --- a/core/src/tbox/tbox +++ b/core/src/tbox/tbox @@ -1 +1 @@ -Subproject commit ddc363161ce6aed86109dcd665b63fb9a810e3a3 +Subproject commit de475fef05346a7603efea54d77afead7a16daca -- cgit v1.3.1 From d7ec0e8f525b88f2184cab499f2636b0c08822ce Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:45:37 +0800 Subject: update haiku ci --- .github/workflows/freebsd.yml | 8 ++++---- .github/workflows/haiku.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 92b91c84e..4f86f346c 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -19,17 +19,17 @@ jobs: script: | const fs = require('fs'); const outputFile = process.env.GITHUB_OUTPUT; - + // Always run for release events if (context.eventName === 'release') { fs.appendFileSync(outputFile, `should-run=true\n`); core.info('Release event detected. Will run tests.'); return; } - + // Execution probability (default 50%, can be overridden via env) const probability = parseFloat(process.env.RUN_PROBABILITY || '0.5'); - + // Generate deterministic "random" number based on commit SHA, run ID, and current time // Adding time ensures better randomness while keeping same commit/run consistent const timeSeed = Math.floor(Date.now() / (1000 * 60 * 60)); // Round to hour for consistency @@ -43,7 +43,7 @@ jobs: // Normalize to 0-1 range const random = Math.abs(hash) / 2147483647; const shouldRun = random < probability; - + // Use environment file instead of deprecated set-output fs.appendFileSync(outputFile, `should-run=${shouldRun}\n`); if (shouldRun) { diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index fd1a95eca..49e12beaf 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -78,4 +78,4 @@ jobs: export PATH=`pwd`/dist/bin:$PATH xrepo --version xmake l os.meminfo - xmake l string.lower "Test 源文件🎆 Message" + xmake lua -v -D tests/run.lua -- cgit v1.3.1 From c05571007a70f58d2d5862c87e0125054d6f4e90 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 17:45:49 +0800 Subject: update haiku ci --- .github/workflows/haiku.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index 49e12beaf..136788754 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -69,11 +69,9 @@ jobs: prepare: | pkgman install -y git curl unzip make bash perl run: | - pwd ./configure --prefix=`pwd`/dist make -j2 make install - ls -l ./dist/ export XMAKE_ROOT=y export PATH=`pwd`/dist/bin:$PATH xrepo --version -- cgit v1.3.1 From 373932b3d1064f5968b286ae9d764d60b008edf6 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Feb 2026 20:15:07 +0800 Subject: fix builddir --- xmake/core/project/config.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 93c1ff6af..47d9406a8 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -165,9 +165,13 @@ function config.builddir(opt) builddir = path.absolute(builddir, rootdir) end - -- adjust path for the current directory + -- Adjust path for the current directory, + -- If it's an external directory, use the absolute path directly. if not opt.absolute then - builddir = path.relative(builddir, os.curdir()) + local relativedir = path.relative(builddir, os.curdir()) + if not relativedir:startswith("..") then + builddir = relativedir + end end return builddir end -- cgit v1.3.1 From 175e26d2075347587a623f64e87f9f5dc7473157 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 15 Feb 2026 22:53:12 +0800 Subject: improve tests for haiku --- tests/actions/package/localpkg/test.lua | 2 +- tests/apis/namespace/package/test.lua | 2 +- tests/projects/c++/linkorders/test.lua | 3 +-- tests/projects/c++/snippet_runtimes/test.lua | 2 +- tests/projects/c/library_with_cmakelists/test.lua | 2 +- tests/projects/package/basic/test.lua | 2 +- tests/projects/package/compatibility/deps_with_version/test.lua | 2 +- tests/projects/package/compatibility/sync_requires_to_deps/test.lua | 2 +- tests/projects/package/components/test.lua | 2 +- tests/projects/package/depconfigs/test.lua | 2 +- tests/projects/package/inherit_base/test.lua | 2 +- tests/projects/package/multiconfig/test.lua | 2 +- tests/projects/package/package_rule/test.lua | 2 +- tests/projects/package/requires_lock/test.lua | 2 +- tests/projects/package/rootconfigs/test.lua | 2 +- tests/projects/package/schemes/test.lua | 2 +- tests/projects/package/toolchain_muslcc/test.lua | 2 +- tests/projects/package/toolchain_muslcc/xmake.lua | 2 +- 18 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tests/actions/package/localpkg/test.lua b/tests/actions/package/localpkg/test.lua index b3b3106ff..cd8e6f75e 100644 --- a/tests/actions/package/localpkg/test.lua +++ b/tests/actions/package/localpkg/test.lua @@ -1,5 +1,5 @@ function main(t) - if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd", "solaris") then + if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd", "solaris", "haiku") then os.cd("libfoo") os.exec("xmake package -D -o ../bar/build") os.cd("../bar") diff --git a/tests/apis/namespace/package/test.lua b/tests/apis/namespace/package/test.lua index 7b7dabeff..dc9b6d9ab 100644 --- a/tests/apis/namespace/package/test.lua +++ b/tests/apis/namespace/package/test.lua @@ -1,5 +1,5 @@ function main() - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end os.exec("xmake -vD -y") diff --git a/tests/projects/c++/linkorders/test.lua b/tests/projects/c++/linkorders/test.lua index 39898ef97..7728aa73a 100644 --- a/tests/projects/c++/linkorders/test.lua +++ b/tests/projects/c++/linkorders/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end @@ -10,4 +10,3 @@ function main(t) t:build() end end - diff --git a/tests/projects/c++/snippet_runtimes/test.lua b/tests/projects/c++/snippet_runtimes/test.lua index e06f405f7..c20ec10ff 100644 --- a/tests/projects/c++/snippet_runtimes/test.lua +++ b/tests/projects/c++/snippet_runtimes/test.lua @@ -12,7 +12,7 @@ end function main(t) local clang = find_tool("clang") - if clang and not is_subhost("windows") and not is_subhost("bsd", "solaris") then + if clang and not is_subhost("windows") and not is_subhost("bsd", "solaris", "haiku") then os.exec("xmake f --toolchain=clang --runtimes=c++_shared --yes") _build() end diff --git a/tests/projects/c/library_with_cmakelists/test.lua b/tests/projects/c/library_with_cmakelists/test.lua index 53b02d24c..585571628 100644 --- a/tests/projects/c/library_with_cmakelists/test.lua +++ b/tests/projects/c/library_with_cmakelists/test.lua @@ -2,7 +2,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/basic/test.lua b/tests/projects/package/basic/test.lua index 65d2f2335..7728aa73a 100644 --- a/tests/projects/package/basic/test.lua +++ b/tests/projects/package/basic/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/compatibility/deps_with_version/test.lua b/tests/projects/package/compatibility/deps_with_version/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/compatibility/deps_with_version/test.lua +++ b/tests/projects/package/compatibility/deps_with_version/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/compatibility/sync_requires_to_deps/test.lua b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/compatibility/sync_requires_to_deps/test.lua +++ b/tests/projects/package/compatibility/sync_requires_to_deps/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/components/test.lua b/tests/projects/package/components/test.lua index a7e71bb89..f1634e485 100644 --- a/tests/projects/package/components/test.lua +++ b/tests/projects/package/components/test.lua @@ -1,5 +1,5 @@ function main(t) - if is_host("bsd", "solaris") or is_subhost("msys") then + if is_host("bsd", "solaris", "haiku") or is_subhost("msys") then return end if is_host("linux") and linuxos.name() == "alpine" then diff --git a/tests/projects/package/depconfigs/test.lua b/tests/projects/package/depconfigs/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/depconfigs/test.lua +++ b/tests/projects/package/depconfigs/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/inherit_base/test.lua b/tests/projects/package/inherit_base/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/inherit_base/test.lua +++ b/tests/projects/package/inherit_base/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/multiconfig/test.lua b/tests/projects/package/multiconfig/test.lua index b9f43bad5..f8321b2f7 100644 --- a/tests/projects/package/multiconfig/test.lua +++ b/tests/projects/package/multiconfig/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/package_rule/test.lua b/tests/projects/package/package_rule/test.lua index 65d2f2335..7728aa73a 100644 --- a/tests/projects/package/package_rule/test.lua +++ b/tests/projects/package/package_rule/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/requires_lock/test.lua b/tests/projects/package/requires_lock/test.lua index 213b1ba60..40c0ebf98 100644 --- a/tests/projects/package/requires_lock/test.lua +++ b/tests/projects/package/requires_lock/test.lua @@ -172,7 +172,7 @@ end function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/rootconfigs/test.lua b/tests/projects/package/rootconfigs/test.lua index d98f3385f..ed5c87486 100644 --- a/tests/projects/package/rootconfigs/test.lua +++ b/tests/projects/package/rootconfigs/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end -- only for x86/x64, because it will take too long time on ci with arm/mips diff --git a/tests/projects/package/schemes/test.lua b/tests/projects/package/schemes/test.lua index 4c7bad3c2..0c31b696f 100644 --- a/tests/projects/package/schemes/test.lua +++ b/tests/projects/package/schemes/test.lua @@ -1,6 +1,6 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/toolchain_muslcc/test.lua b/tests/projects/package/toolchain_muslcc/test.lua index 65d2f2335..7728aa73a 100644 --- a/tests/projects/package/toolchain_muslcc/test.lua +++ b/tests/projects/package/toolchain_muslcc/test.lua @@ -1,7 +1,7 @@ function main(t) -- freebsd ci is slower - if is_host("bsd", "solaris") then + if is_host("bsd", "solaris", "haiku") then return end diff --git a/tests/projects/package/toolchain_muslcc/xmake.lua b/tests/projects/package/toolchain_muslcc/xmake.lua index 6c5e8f8b3..0f63fb0d6 100644 --- a/tests/projects/package/toolchain_muslcc/xmake.lua +++ b/tests/projects/package/toolchain_muslcc/xmake.lua @@ -25,7 +25,7 @@ toolchain_end() -- add library packages -- for testing zlib/xmake, libplist/autoconf, libogg/cmake add_requires("zlib", "libogg", {system = false}) -if is_host("macosx", "linux", "bsd", "solaris") then +if is_host("macosx", "linux", "bsd", "solaris", "haiku") then add_requires("libplist", {system = false}) end -- cgit v1.3.1 From d98330b24d4897430a9f26680dbdc7f910b0e948 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 22:39:41 +0800 Subject: fix tmpdir for haiku --- .github/workflows/haiku.yml | 1 - tests/plugins/create/test.lua | 8 ++++---- xmake/core/base/os.lua | 17 +++++++++++++---- xmake/core/project/config.lua | 8 ++------ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index 136788754..c872b678e 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -75,5 +75,4 @@ jobs: export XMAKE_ROOT=y export PATH=`pwd`/dist/bin:$PATH xrepo --version - xmake l os.meminfo xmake lua -v -D tests/run.lua diff --git a/tests/plugins/create/test.lua b/tests/plugins/create/test.lua index 397f846f4..7813c3ee2 100644 --- a/tests/plugins/create/test.lua +++ b/tests/plugins/create/test.lua @@ -1,11 +1,11 @@ function main () os.tryrm("$(tmpdir)/test_create") os.exec("xmake create -P $(tmpdir)/test_create/test") - os.exec("xmake -P $(tmpdir)/test_create/test") + os.exec("xmake -vD -P $(tmpdir)/test_create/test") os.exec("xmake create -l c++ -P $(tmpdir)/test_create/test_cpp") - os.exec("xmake -P $(tmpdir)/test_create/test_cpp") + os.exec("xmake -vD -P $(tmpdir)/test_create/test_cpp") os.exec("xmake create -l c++ -t static -P $(tmpdir)/test_create/test_cpp2") - os.exec("xmake -P $(tmpdir)/test_create/test_cpp2") + os.exec("xmake -vD -P $(tmpdir)/test_create/test_cpp2") os.exec("xmake create -l c++ -t shared -P $(tmpdir)/test_create/test_cpp3") - os.exec("xmake -P $(tmpdir)/test_create/test_cpp3") + os.exec("xmake -vD -P $(tmpdir)/test_create/test_cpp3") end diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index d20cd671a..d50ce19f2 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -768,15 +768,24 @@ function os.tmpdir(opt) -- get root tmpdir local tmpdir_root = nil if opt and opt.ramdisk == false then + tmpdir_root = os._ROOT_TMPDIR if os._ROOT_TMPDIR == nil then - os._ROOT_TMPDIR = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() + tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() + -- TODO + if os.islink(tmpdir_root) then + tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root + end + os._ROOT_TMPDIR = tmpdir_root end - tmpdir_root = os._ROOT_TMPDIR else + tmpdir_root = os._ROOT_TMPDIR_RAM if os._ROOT_TMPDIR_RAM == nil then - os._ROOT_TMPDIR_RAM = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() + tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() + if os.islink(tmpdir_root) then + tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root + end + os._ROOT_TMPDIR_RAM = tmpdir_root end - tmpdir_root = os._ROOT_TMPDIR_RAM end -- make sub-directory name diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 47d9406a8..93c1ff6af 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -165,13 +165,9 @@ function config.builddir(opt) builddir = path.absolute(builddir, rootdir) end - -- Adjust path for the current directory, - -- If it's an external directory, use the absolute path directly. + -- adjust path for the current directory if not opt.absolute then - local relativedir = path.relative(builddir, os.curdir()) - if not relativedir:startswith("..") then - builddir = relativedir - end + builddir = path.relative(builddir, os.curdir()) end return builddir end -- cgit v1.3.1 From 9f1c3a8e8115a0746a2f7de435fa660a9504978e Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 22:41:40 +0800 Subject: improve os.tmpdir --- xmake/core/base/os.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index d50ce19f2..b8ce09f68 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -200,6 +200,15 @@ function os._ramdir() return ramdir_root or nil end +-- if tmpdir_root is a symbolic link, os.tmpdir() may return a path that differs +-- from the path style returned by os.curdir() (e.g. on Haiku). +function os._resolve_tmpdir(tmpdir_root) + if os.islink(tmpdir_root) then + tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root + end + return tmpdir_root +end + -- set on change environments callback for scheduler function os._sched_chenvs_set(envs) os._SCHED_CHENVS = envs @@ -771,19 +780,14 @@ function os.tmpdir(opt) tmpdir_root = os._ROOT_TMPDIR if os._ROOT_TMPDIR == nil then tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() - -- TODO - if os.islink(tmpdir_root) then - tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root - end + tmpdir_root = os._resolve_tmpdir(tmpdir_root) os._ROOT_TMPDIR = tmpdir_root end else tmpdir_root = os._ROOT_TMPDIR_RAM if os._ROOT_TMPDIR_RAM == nil then tmpdir_root = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() - if os.islink(tmpdir_root) then - tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root - end + tmpdir_root = os._resolve_tmpdir(tmpdir_root) os._ROOT_TMPDIR_RAM = tmpdir_root end end -- cgit v1.3.1 From 0b89554d1bad82154ed65278ca0207de5294d958 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 22:54:35 +0800 Subject: update comments --- .github/workflows/haiku.yml | 4 ++-- xmake/core/base/os.lua | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/haiku.yml b/.github/workflows/haiku.yml index c872b678e..34e51392b 100644 --- a/.github/workflows/haiku.yml +++ b/.github/workflows/haiku.yml @@ -48,8 +48,8 @@ jobs: RUN_PROBABILITY: ${{ vars.HAIKU_RUN_PROBABILITY || '0.2' }} build: - #needs: check - #if: needs.check.outputs.should-run == 'true' + needs: check + if: needs.check.outputs.should-run == 'true' runs-on: ubuntu-latest concurrency: diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index b8ce09f68..1766d28f5 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -202,6 +202,12 @@ end -- if tmpdir_root is a symbolic link, os.tmpdir() may return a path that differs -- from the path style returned by os.curdir() (e.g. on Haiku). +-- +-- Using a consistent root path can avoid errors in relative path resolution. +-- +-- e.g. +-- tmpdir: /tmp/.xmake0/260217/ -> /boot/system/cache/tmp/.xmake0/260217 +-- curdir: /boot/system/cache/tmp/.xmake0/260217 function os._resolve_tmpdir(tmpdir_root) if os.islink(tmpdir_root) then tmpdir_root = os.readlink(tmpdir_root) or tmpdir_root -- cgit v1.3.1 From 97a4ee37a0057c670ba09003dc67ed50bc35fae4 Mon Sep 17 00:00:00 2001 From: Saikari Date: Fri, 20 Feb 2026 17:58:04 +0300 Subject: resolve gemini --- core/src/xmake/winos/file_signature.c | 10 ---------- xmake/modules/detect/tools/find_gcc.lua | 16 ++-------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/core/src/xmake/winos/file_signature.c b/core/src/xmake/winos/file_signature.c index e16cb4949..2efa8bd8c 100644 --- a/core/src/xmake/winos/file_signature.c +++ b/core/src/xmake/winos/file_signature.c @@ -54,16 +54,6 @@ typedef struct __tb_file_signature_info_t { /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ -static tb_wchar_t* tb_path_to_wchar(tb_char_t const* path, tb_wchar_t* buffer, tb_size_t size) { - // check - tb_assert_and_check_return_val(path && buffer && size, tb_null); - - // convert - if (MultiByteToWideChar(CP_UTF8, 0, path, -1, buffer, (int)size) > 0) - return buffer; - - return tb_null; -} static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_signature_info_t* info) { // check diff --git a/xmake/modules/detect/tools/find_gcc.lua b/xmake/modules/detect/tools/find_gcc.lua index 83ee0fe59..d658ca1ff 100644 --- a/xmake/modules/detect/tools/find_gcc.lua +++ b/xmake/modules/detect/tools/find_gcc.lua @@ -44,20 +44,8 @@ end -- @see https://github.com/xmake-io/xmake/issues/5629 function _check_gcc_on_windows(program, opt) opt = opt or {} - if path.is_absolute(program) then - if check_gcc_gigabyte(program) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") - end - else - local paths = path.splitenv(vformat("$(env PATH)")) - if paths then - for _, p in ipairs(paths) do - local prog = path.join(p, program) - if os.isfile(prog) and check_gcc_gigabyte(prog) then - raise("gcc.exe signed by GIGA-BYTE is not allowed!") - end - end - end + if check_gcc_gigabyte(program) then + raise("gcc.exe signed by GIGA-BYTE is not allowed!") end return os.runv(program, {"--version"}, {envs = opt.envs, shell = opt.shell}) end -- cgit v1.3.1 From b59a11005353e771c35d001991ad106d7cb57684 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 20 Feb 2026 23:04:21 +0800 Subject: Update file_signature.c --- core/src/xmake/winos/file_signature.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/xmake/winos/file_signature.c b/core/src/xmake/winos/file_signature.c index 2efa8bd8c..3e617294c 100644 --- a/core/src/xmake/winos/file_signature.c +++ b/core/src/xmake/winos/file_signature.c @@ -37,6 +37,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * types */ + // the file signature info type typedef struct __tb_file_signature_info_t { // is the file digitally signed? @@ -46,9 +47,9 @@ typedef struct __tb_file_signature_info_t { tb_bool_t is_trusted; /* the name of the signer (e.g., "Microsoft Corporation") - tbox uses UTF-8 by default for tb_char_t*/ + tbox uses UTF-8 by default for tb_char_t + */ tb_char_t signer_name[256]; - } tb_file_signature_info_t; /* ////////////////////////////////////////////////////////////////////////////////////// @@ -56,7 +57,6 @@ typedef struct __tb_file_signature_info_t { */ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_signature_info_t* info) { - // check tb_assert_and_check_return_val(filepath && info, tb_false); // init info @@ -64,8 +64,10 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s // convert path tb_wchar_t wide_path[TB_PATH_MAXN]; - if (!tb_path_absolute_w(filepath, wide_path, TB_PATH_MAXN)) return tb_false; - + if (!tb_path_absolute_w(filepath, wide_path, TB_PATH_MAXN)) { + return tb_false; + } + // init file info WINTRUST_FILE_INFO file_data = {0}; file_data.cbStruct = sizeof(file_data); @@ -186,8 +188,6 @@ static tb_bool_t tb_file_get_signature_info(tb_char_t const* filepath, tb_file_s * } */ tb_int_t xm_winos_file_signature(lua_State *lua) { - - // check tb_assert_and_check_return_val(lua, 0); // get the arguments -- cgit v1.3.1 From 30bcf8321661f8bd384eb941ea92e6ad3c7776f3 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sat, 21 Feb 2026 19:30:11 +0300 Subject: Add support for WASI platform in various modules and scripts --- configure | 2 +- xmake/modules/detect/sdks/find_qt.lua | 4 +-- .../package/manager/conan/configurations.lua | 3 +- .../package/manager/conan/v2/install_package.lua | 2 +- xmake/modules/package/tools/cmake.lua | 10 +++---- xmake/modules/package/tools/meson.lua | 4 +-- .../private/action/require/impl/package.lua | 2 +- xmake/modules/private/action/trybuild/cmake.lua | 8 ++++-- xmake/modules/private/action/trybuild/meson.lua | 2 +- xmake/modules/private/detect/find_platform.lua | 2 +- xmake/modules/private/tools/go/goenv.lua | 6 ++-- xmake/platforms/wasi/xmake.lua | 32 ++++++++++++++++++++++ xmake/rules/platform/wasm/installfiles/xmake.lua | 2 +- xmake/rules/platform/wasm/preloadfiles/xmake.lua | 2 +- xmake/rules/qt/config_static.lua | 2 +- xmake/rules/qt/load.lua | 2 +- 16 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 xmake/platforms/wasi/xmake.lua diff --git a/configure b/configure index d5bcbf5a0..466c8101e 100755 --- a/configure +++ b/configure @@ -3591,7 +3591,7 @@ _toolchain_detect() { else toolchains="x86_64_w64_mingw32" fi - elif is_plat "wasm"; then + elif is_plat "wasm" "wasi"; then toolchains="emcc" elif is_plat "linux" && ! is_arch "${os_arch}"; then toolchains="envs" diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua index a7aa8e57c..6c1db309b 100644 --- a/xmake/modules/detect/sdks/find_qt.lua +++ b/xmake/modules/detect/sdks/find_qt.lua @@ -65,7 +65,7 @@ function _find_sdkdir(sdkdir, sdkver) table.insert(subdirs, path.join(sdkver or "*", subdir, "bin")) end table.insert(subdirs, path.join(sdkver or "*", "android", "bin")) - elseif is_plat("wasm") then + elseif is_plat("wasm", "wasi") then table.insert(subdirs, path.join(sdkver or "*", "wasm_*", "bin")) else table.insert(subdirs, path.join(sdkver or "*", "*", "bin")) @@ -126,7 +126,7 @@ function _find_sdkdir(sdkdir, sdkver) -- special case for android on windows, where qmake is a .bat from version 6.3 -- this case also applys to wasm - if is_host("windows") and is_plat("android", "wasm") then + if is_host("windows") and is_plat("android", "wasm", "wasi") then local qmake = find_file("qmake.bat", paths, {suffixes = subdirs}) if qmake then return path.directory(path.directory(qmake)), qmake diff --git a/xmake/modules/package/manager/conan/configurations.lua b/xmake/modules/package/manager/conan/configurations.lua index 178b3dfaa..f4dfcfbee 100644 --- a/xmake/modules/package/manager/conan/configurations.lua +++ b/xmake/modules/package/manager/conan/configurations.lua @@ -33,7 +33,8 @@ function arch(arch) ["arm64-v8a"] = "armv8", -- for android mips = "mips", mips64 = "mips64", - wasm32 = "wasm"} + wasm32 = "wasm", + wasi = "wasm"} return assert(map[arch], "unknown arch(%s)!", arch) end diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index ff834e1b6..e6f4f6632 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -193,7 +193,7 @@ function _conan_generate_compiler_profile(profile, configs, opt) end conf = {} conf["tools.android:ndk_path"] = ndk:config("ndk") - elseif plat == "wasm" then + elseif plat == "wasm" or plat == "wasi" then local emsdk = find_emsdk() assert(emsdk and emsdk.emscripten, "emscripten not found!") local emscripten_cmakefile = find_file("Emscripten.cmake", path.join(emsdk.emscripten, "cmake/Modules/Platform")) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 1557aebeb..fe9c13ffd 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -754,7 +754,7 @@ function _get_configs_for_generator(package, configs, opt) elseif package:is_plat("windows") then table.insert(configs, "-G") table.insert(configs, _get_cmake_generator_for_msvc(package)) - elseif package:is_plat("wasm") and is_subhost("windows") then + elseif package:is_plat("wasm", "wasi") and is_subhost("windows") then table.insert(configs, "-G") table.insert(configs, "MinGW Makefiles") else @@ -894,7 +894,7 @@ function _get_envs_for_flags(package, configs, opt) if package:has_tool("cxx", "clang", "clang_cl") then platform_envs.CMAKE_CXX_FLAGS = _get_cxxflags(package, table.join({cross = true}, opt)) end - elseif package:is_plat("wasm") then + elseif package:is_plat("wasm", "wasi") then -- pass toolchain flags cross-compilation -- @see https://github.com/xmake-io/xmake/issues/6690 opt.cross = true @@ -929,7 +929,7 @@ function _get_configs(package, configs, opt) _get_configs_for_appleos(package, configs, opt) elseif package:is_plat("mingw") then _get_configs_for_mingw(package, configs, opt) - elseif package:is_plat("wasm") then + elseif package:is_plat("wasm", "wasi") then _get_configs_for_wasm(package, configs, opt) elseif package:is_cross() then _get_configs_for_cross(package, configs, opt) @@ -1146,7 +1146,7 @@ function _install_for_make(package, configs, opt) if is_host("bsd") then os.vrunv("gmake", argv) os.vrunv("gmake", {"install"}) - elseif is_subhost("windows") and package:is_plat("mingw", "wasm") then + elseif is_subhost("windows") and package:is_plat("mingw", "wasm", "wasi") then local mingw_make = assert(_get_mingw32_make(package), "mingw32-make.exe not found!") os.vrunv(mingw_make, argv) os.vrunv(mingw_make, {"install"}) @@ -1207,7 +1207,7 @@ function _get_cmake_generator(package, opt) if not cmake_generator then if package:has_tool("cc", "clang_cl") or package:has_tool("cxx", "clang_cl") then cmake_generator = "Ninja" - elseif (is_subhost("windows") and package:is_plat("mingw", "wasm")) + elseif (is_subhost("windows") and package:is_plat("mingw", "wasm", "wasi")) or (package:is_plat("windows") and is_host("linux")) then local ninja = _get_ninja(package) if ninja then diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index fbc6bbe77..4ba4d9bfb 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -174,7 +174,7 @@ function _insert_cross_configs(package, file, opt) file:print("cpu_family = '%s'", cpu_family) file:print("cpu = '%s'", cpu) file:print("endian = 'little'") - elseif package:is_plat("wasm") then + elseif package:is_plat("wasm", "wasi") then file:print("system = 'emscripten'") file:print("cpu_family = '%s'", package:arch()) file:print("cpu = '%s'", package:arch()) @@ -375,7 +375,7 @@ function _get_configs(package, configs, opt) end -- add cross file - if package:is_cross() or package:is_plat("mingw") then + if package:is_cross() or package:is_plat("mingw", "wasm", "wasi") then table.insert(configs, "--cross-file=" .. _get_configs_file(package, opt)) elseif package:config("toolchains") then if _is_toolchain_compatible_with_host(package) then diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 4e2d70e5f..f0b55975c 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -293,7 +293,7 @@ function _add_package_configurations(package) if package:extraconf("configs", "shared", "default") == nil then -- we always use static library if it's for wasm platform local readonly - if package:is_plat("wasm") then + if package:is_plat("wasm", "wasi") then readonly = true end local default = _get_default_config_value_of("shared") diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index c5b807fb9..6be056a81 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -281,6 +281,10 @@ end -- get configs for wasm function _get_configs_for_wasm(configs) + if is_plat("wasi") then + _get_configs_for_cross(configs) + return + end local emsdk = find_emsdk() assert(emsdk and emsdk.emscripten, "emscripten not found!") local emscripten_cmakefile = find_file("Emscripten.cmake", path.join(emsdk.emscripten, "cmake/Modules/Platform")) @@ -419,7 +423,7 @@ function _get_configs_for_generator(configs, opt) elseif is_plat("windows") then table.insert(configs, "-G") table.insert(configs, _get_cmake_generator_for_msvc()) - elseif is_plat("wasm") and is_subhost("windows") then + elseif is_plat("wasm", "wasi") and is_subhost("windows") then table.insert(configs, "-G") table.insert(configs, "MinGW Makefiles") else @@ -452,7 +456,7 @@ function _get_configs(opt) _get_configs_for_appleos(configs) elseif is_plat("mingw") then _get_configs_for_mingw(configs) - elseif is_plat("wasm") then + elseif is_plat("wasm", "wasi") then _get_configs_for_wasm(configs) elseif _is_cross_compilation() then _get_configs_for_cross(configs) diff --git a/xmake/modules/private/action/trybuild/meson.lua b/xmake/modules/private/action/trybuild/meson.lua index e1976c703..9362f0b63 100644 --- a/xmake/modules/private/action/trybuild/meson.lua +++ b/xmake/modules/private/action/trybuild/meson.lua @@ -184,7 +184,7 @@ function _get_cross_file(builddir) file:print("cpu_family = '%s'", cpu_family) file:print("cpu = '%s'", cpu) file:print("endian = 'little'") - elseif is_plat("wasm") then + elseif is_plat("wasm", "wasi") then file:print("system = 'emscripten'") file:print("cpu_family = 'wasm32'") file:print("cpu = 'wasm32'") diff --git a/xmake/modules/private/detect/find_platform.lua b/xmake/modules/private/detect/find_platform.lua index a94b5ade3..0c38fca85 100644 --- a/xmake/modules/private/detect/find_platform.lua +++ b/xmake/modules/private/detect/find_platform.lua @@ -100,7 +100,7 @@ function _find_arch(plat, arch) arch = appledev == "simulator" and os.arch() or "arm64" elseif plat == "watchos" then arch = appledev == "simulator" and os.arch() or "armv7k" - elseif plat == "wasm" then + elseif plat == "wasm" or plat == "wasi" then arch = "wasm32" elseif plat == "mingw" then local mingw_chost = nil diff --git a/xmake/modules/private/tools/go/goenv.lua b/xmake/modules/private/tools/go/goenv.lua index 1a448e6f3..c22401198 100644 --- a/xmake/modules/private/tools/go/goenv.lua +++ b/xmake/modules/private/tools/go/goenv.lua @@ -38,7 +38,8 @@ function GOOS(plat) dragonfly = "dragonfly", solaris = "solaris", aix = "aix", - plan9 = "plan9" + plan9 = "plan9", + wasi = "wasip1" } return goos_map[plat] end @@ -65,7 +66,8 @@ function GOARCH(arch) ppc64le = "ppc64le", riscv64 = "riscv64", s390x = "s390x", - wasm = "wasm" + wasm = "wasm", + wasm32 = "wasm" } -- try direct match first diff --git a/xmake/platforms/wasi/xmake.lua b/xmake/platforms/wasi/xmake.lua new file mode 100644 index 000000000..12c1f4b15 --- /dev/null +++ b/xmake/platforms/wasi/xmake.lua @@ -0,0 +1,32 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @author ruki +-- @file xmake.lua +-- + +platform("wasi") + set_os("wasi") + set_hosts("macosx", "linux", "windows", "bsd") + set_archs("wasm32", "wasm64") + + set_formats("static", "lib$(name).a") + set_formats("object", "$(name).o") + set_formats("shared", "lib$(name).so") + set_formats("binary", "$(name).wasm") + set_formats("symbol", "$(name).sym") + + set_toolchains("wasi") diff --git a/xmake/rules/platform/wasm/installfiles/xmake.lua b/xmake/rules/platform/wasm/installfiles/xmake.lua index f6833ecab..479f93d59 100644 --- a/xmake/rules/platform/wasm/installfiles/xmake.lua +++ b/xmake/rules/platform/wasm/installfiles/xmake.lua @@ -20,7 +20,7 @@ -- copy other files generated by emcc (see https://emscripten.org/docs/tools_reference/emcc.html#emcc-o-target) rule("platform.wasm.installfiles") - on_load("wasm", function (target) + on_load("wasm", "wasi", function (target) if not target:is_binary() then return end diff --git a/xmake/rules/platform/wasm/preloadfiles/xmake.lua b/xmake/rules/platform/wasm/preloadfiles/xmake.lua index 144797f82..1fbb1d7d1 100644 --- a/xmake/rules/platform/wasm/preloadfiles/xmake.lua +++ b/xmake/rules/platform/wasm/preloadfiles/xmake.lua @@ -20,7 +20,7 @@ -- @see https://github.com/xmake-io/xmake/issues/3613 rule("platform.wasm.preloadfiles") - on_load("wasm", function (target) + on_load("wasm", "wasi", function (target) if not target:is_binary() then return end diff --git a/xmake/rules/qt/config_static.lua b/xmake/rules/qt/config_static.lua index 4cf943d13..d72cc2abb 100644 --- a/xmake/rules/qt/config_static.lua +++ b/xmake/rules/qt/config_static.lua @@ -58,7 +58,7 @@ function main(target) if QtPlatformSupport then table.insert(frameworks, QtPlatformSupport) end - elseif target:is_plat("wasm") then + elseif target:is_plat("wasm", "wasi") then plugins.QWasmIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qwasm"}} if qt_sdkver:ge("6.0") then table.join2(frameworks, "QtOpenGL") diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index 1ce0f4fb1..c0fc4c7f4 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -479,7 +479,7 @@ function main(target, opt) fallbackmkspec = "android-clang" target:add("rpathdirs", qt.libdir) target:add("linkdirs", qt.libdir) - elseif target:is_plat("wasm") then + elseif target:is_plat("wasm", "wasi") then target:set("frameworks", nil) _add_includedirs(target, qt.includedir) fallbackmkspec = "wasm-emscripten" -- cgit v1.3.1 From 54fe033757a7f157f181adb0470572f1963a74cc Mon Sep 17 00:00:00 2001 From: Saikari Date: Sat, 21 Feb 2026 20:59:43 +0300 Subject: try implement runner? --- xmake/actions/run/main.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 6ed59f3f1..d11456cb7 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -33,6 +33,24 @@ import("private.detect.check_targetname") import("lib.detect.find_tool") import("private.action.utils", {alias = "action_utils"}) +function _run_wasi_target(targetfile, args, opt) + opt = opt or {} + local rundir = opt.rundir + local addenvs = opt.addenvs + local setenvs = opt.setenvs + local wasmtime = find_tool("wasmtime") + if wasmtime then + local runargs = {targetfile} + if args and #args > 0 then + table.join2(runargs, args) + end + os.execv(wasmtime.program, runargs, { + curdir = rundir, detach = option.get("detach"), addenvs = addenvs, setenvs = setenvs}) + else + raise("wasmtime not found, which is required for running wasi target!") + end +end + function _run_wasm_target_in_browser(targetfile, opt) opt = opt or {} local rundir = opt.rundir @@ -81,6 +99,12 @@ function _do_run_target(target) return end + -- run wasi target via wasmtime + if target:is_plat("wasi") then + _run_wasi_target(targetfile, args, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) + return + end + -- run windows target on non-windows host via wine if not is_host("windows") and target:is_plat("windows") then local wine = assert(find_tool("wine"), "wine not found!") -- cgit v1.3.1 From 733bfe40bb7a210c1d291607ee118b957fe09c29 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 23 Feb 2026 23:06:38 +0800 Subject: update tbox to fix start process on win7 --- core/src/tbox/tbox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox index de475fef0..d0138aad7 160000 --- a/core/src/tbox/tbox +++ b/core/src/tbox/tbox @@ -1 +1 @@ -Subproject commit de475fef05346a7603efea54d77afead7a16daca +Subproject commit d0138aad74d1dda1fffbee2f6fc0a8f869d8481c -- cgit v1.3.1 From b638bcfdaac7082e9d344b869acd822e4e8c2b09 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 19 Feb 2026 00:47:39 +0800 Subject: improve qt deploy for macapp --- xmake/rules/qt/deploy/macosx.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xmake/rules/qt/deploy/macosx.lua b/xmake/rules/qt/deploy/macosx.lua index deeafb11f..ac26bbd7d 100644 --- a/xmake/rules/qt/deploy/macosx.lua +++ b/xmake/rules/qt/deploy/macosx.lua @@ -166,7 +166,10 @@ function main(target, opt) end -- do deploy - local argv = {target_app, "-always-overwrite"} + local argv = {target_app} + if target:is_rebuilt() then + table.insert(argv, "-always-overwrite") + end if option.get("diagnosis") then table.insert(argv, "-verbose=3") elseif option.get("verbose") then -- cgit v1.3.1 From 25f6f0ce529a29611812558fc6e3d1c9f0fdc9b8 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 23 Feb 2026 16:24:27 +0300 Subject: Remove WASI platform references from various modules and scripts --- configure | 2 +- xmake/actions/run/main.lua | 15 +++++----- xmake/modules/detect/sdks/find_qt.lua | 4 +-- .../package/manager/conan/configurations.lua | 3 +- .../package/manager/conan/v2/install_package.lua | 2 +- xmake/modules/package/tools/cmake.lua | 10 +++---- xmake/modules/package/tools/meson.lua | 4 +-- .../private/action/require/impl/package.lua | 2 +- xmake/modules/private/action/trybuild/cmake.lua | 6 ++-- xmake/modules/private/action/trybuild/meson.lua | 2 +- xmake/modules/private/detect/find_platform.lua | 2 +- xmake/modules/private/tools/go/goenv.lua | 3 +- xmake/platforms/wasi/xmake.lua | 32 ---------------------- xmake/rules/platform/wasm/installfiles/xmake.lua | 2 +- xmake/rules/platform/wasm/preloadfiles/xmake.lua | 2 +- xmake/rules/qt/config_static.lua | 2 +- xmake/rules/qt/load.lua | 2 +- 17 files changed, 30 insertions(+), 65 deletions(-) delete mode 100644 xmake/platforms/wasi/xmake.lua diff --git a/configure b/configure index 466c8101e..d5bcbf5a0 100755 --- a/configure +++ b/configure @@ -3591,7 +3591,7 @@ _toolchain_detect() { else toolchains="x86_64_w64_mingw32" fi - elif is_plat "wasm" "wasi"; then + elif is_plat "wasm"; then toolchains="emcc" elif is_plat "linux" && ! is_arch "${os_arch}"; then toolchains="envs" diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index d11456cb7..59d7cbe76 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -93,15 +93,14 @@ function _do_run_target(target) -- get run arguments local args = table.wrap(option.get("arguments") or target:get("runargs")) - -- run wasm target in browser + -- run wasm target if target:is_plat("wasm") then - _run_wasm_target_in_browser(targetfile, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) - return - end - - -- run wasi target via wasmtime - if target:is_plat("wasi") then - _run_wasi_target(targetfile, args, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) + -- run via wasmtime if using the wasi toolchain, otherwise open in browser + if target:toolchain("wasi") then + _run_wasi_target(targetfile, args, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) + else + _run_wasm_target_in_browser(targetfile, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) + end return end diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua index 6c1db309b..a7aa8e57c 100644 --- a/xmake/modules/detect/sdks/find_qt.lua +++ b/xmake/modules/detect/sdks/find_qt.lua @@ -65,7 +65,7 @@ function _find_sdkdir(sdkdir, sdkver) table.insert(subdirs, path.join(sdkver or "*", subdir, "bin")) end table.insert(subdirs, path.join(sdkver or "*", "android", "bin")) - elseif is_plat("wasm", "wasi") then + elseif is_plat("wasm") then table.insert(subdirs, path.join(sdkver or "*", "wasm_*", "bin")) else table.insert(subdirs, path.join(sdkver or "*", "*", "bin")) @@ -126,7 +126,7 @@ function _find_sdkdir(sdkdir, sdkver) -- special case for android on windows, where qmake is a .bat from version 6.3 -- this case also applys to wasm - if is_host("windows") and is_plat("android", "wasm", "wasi") then + if is_host("windows") and is_plat("android", "wasm") then local qmake = find_file("qmake.bat", paths, {suffixes = subdirs}) if qmake then return path.directory(path.directory(qmake)), qmake diff --git a/xmake/modules/package/manager/conan/configurations.lua b/xmake/modules/package/manager/conan/configurations.lua index f4dfcfbee..178b3dfaa 100644 --- a/xmake/modules/package/manager/conan/configurations.lua +++ b/xmake/modules/package/manager/conan/configurations.lua @@ -33,8 +33,7 @@ function arch(arch) ["arm64-v8a"] = "armv8", -- for android mips = "mips", mips64 = "mips64", - wasm32 = "wasm", - wasi = "wasm"} + wasm32 = "wasm"} return assert(map[arch], "unknown arch(%s)!", arch) end diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index e6f4f6632..ff834e1b6 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -193,7 +193,7 @@ function _conan_generate_compiler_profile(profile, configs, opt) end conf = {} conf["tools.android:ndk_path"] = ndk:config("ndk") - elseif plat == "wasm" or plat == "wasi" then + elseif plat == "wasm" then local emsdk = find_emsdk() assert(emsdk and emsdk.emscripten, "emscripten not found!") local emscripten_cmakefile = find_file("Emscripten.cmake", path.join(emsdk.emscripten, "cmake/Modules/Platform")) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index fe9c13ffd..1557aebeb 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -754,7 +754,7 @@ function _get_configs_for_generator(package, configs, opt) elseif package:is_plat("windows") then table.insert(configs, "-G") table.insert(configs, _get_cmake_generator_for_msvc(package)) - elseif package:is_plat("wasm", "wasi") and is_subhost("windows") then + elseif package:is_plat("wasm") and is_subhost("windows") then table.insert(configs, "-G") table.insert(configs, "MinGW Makefiles") else @@ -894,7 +894,7 @@ function _get_envs_for_flags(package, configs, opt) if package:has_tool("cxx", "clang", "clang_cl") then platform_envs.CMAKE_CXX_FLAGS = _get_cxxflags(package, table.join({cross = true}, opt)) end - elseif package:is_plat("wasm", "wasi") then + elseif package:is_plat("wasm") then -- pass toolchain flags cross-compilation -- @see https://github.com/xmake-io/xmake/issues/6690 opt.cross = true @@ -929,7 +929,7 @@ function _get_configs(package, configs, opt) _get_configs_for_appleos(package, configs, opt) elseif package:is_plat("mingw") then _get_configs_for_mingw(package, configs, opt) - elseif package:is_plat("wasm", "wasi") then + elseif package:is_plat("wasm") then _get_configs_for_wasm(package, configs, opt) elseif package:is_cross() then _get_configs_for_cross(package, configs, opt) @@ -1146,7 +1146,7 @@ function _install_for_make(package, configs, opt) if is_host("bsd") then os.vrunv("gmake", argv) os.vrunv("gmake", {"install"}) - elseif is_subhost("windows") and package:is_plat("mingw", "wasm", "wasi") then + elseif is_subhost("windows") and package:is_plat("mingw", "wasm") then local mingw_make = assert(_get_mingw32_make(package), "mingw32-make.exe not found!") os.vrunv(mingw_make, argv) os.vrunv(mingw_make, {"install"}) @@ -1207,7 +1207,7 @@ function _get_cmake_generator(package, opt) if not cmake_generator then if package:has_tool("cc", "clang_cl") or package:has_tool("cxx", "clang_cl") then cmake_generator = "Ninja" - elseif (is_subhost("windows") and package:is_plat("mingw", "wasm", "wasi")) + elseif (is_subhost("windows") and package:is_plat("mingw", "wasm")) or (package:is_plat("windows") and is_host("linux")) then local ninja = _get_ninja(package) if ninja then diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index 4ba4d9bfb..01c12bbe7 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -174,7 +174,7 @@ function _insert_cross_configs(package, file, opt) file:print("cpu_family = '%s'", cpu_family) file:print("cpu = '%s'", cpu) file:print("endian = 'little'") - elseif package:is_plat("wasm", "wasi") then + elseif package:is_plat("wasm") then file:print("system = 'emscripten'") file:print("cpu_family = '%s'", package:arch()) file:print("cpu = '%s'", package:arch()) @@ -375,7 +375,7 @@ function _get_configs(package, configs, opt) end -- add cross file - if package:is_cross() or package:is_plat("mingw", "wasm", "wasi") then + if package:is_cross() or package:is_plat("mingw", "wasm") then table.insert(configs, "--cross-file=" .. _get_configs_file(package, opt)) elseif package:config("toolchains") then if _is_toolchain_compatible_with_host(package) then diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index f0b55975c..4e2d70e5f 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -293,7 +293,7 @@ function _add_package_configurations(package) if package:extraconf("configs", "shared", "default") == nil then -- we always use static library if it's for wasm platform local readonly - if package:is_plat("wasm", "wasi") then + if package:is_plat("wasm") then readonly = true end local default = _get_default_config_value_of("shared") diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index 6be056a81..4243a7ce8 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -281,7 +281,7 @@ end -- get configs for wasm function _get_configs_for_wasm(configs) - if is_plat("wasi") then + if config.get("toolchain") == "wasi" then _get_configs_for_cross(configs) return end @@ -423,7 +423,7 @@ function _get_configs_for_generator(configs, opt) elseif is_plat("windows") then table.insert(configs, "-G") table.insert(configs, _get_cmake_generator_for_msvc()) - elseif is_plat("wasm", "wasi") and is_subhost("windows") then + elseif is_plat("wasm") and is_subhost("windows") then table.insert(configs, "-G") table.insert(configs, "MinGW Makefiles") else @@ -456,7 +456,7 @@ function _get_configs(opt) _get_configs_for_appleos(configs) elseif is_plat("mingw") then _get_configs_for_mingw(configs) - elseif is_plat("wasm", "wasi") then + elseif is_plat("wasm") then _get_configs_for_wasm(configs) elseif _is_cross_compilation() then _get_configs_for_cross(configs) diff --git a/xmake/modules/private/action/trybuild/meson.lua b/xmake/modules/private/action/trybuild/meson.lua index 9362f0b63..e1976c703 100644 --- a/xmake/modules/private/action/trybuild/meson.lua +++ b/xmake/modules/private/action/trybuild/meson.lua @@ -184,7 +184,7 @@ function _get_cross_file(builddir) file:print("cpu_family = '%s'", cpu_family) file:print("cpu = '%s'", cpu) file:print("endian = 'little'") - elseif is_plat("wasm", "wasi") then + elseif is_plat("wasm") then file:print("system = 'emscripten'") file:print("cpu_family = 'wasm32'") file:print("cpu = 'wasm32'") diff --git a/xmake/modules/private/detect/find_platform.lua b/xmake/modules/private/detect/find_platform.lua index 0c38fca85..a94b5ade3 100644 --- a/xmake/modules/private/detect/find_platform.lua +++ b/xmake/modules/private/detect/find_platform.lua @@ -100,7 +100,7 @@ function _find_arch(plat, arch) arch = appledev == "simulator" and os.arch() or "arm64" elseif plat == "watchos" then arch = appledev == "simulator" and os.arch() or "armv7k" - elseif plat == "wasm" or plat == "wasi" then + elseif plat == "wasm" then arch = "wasm32" elseif plat == "mingw" then local mingw_chost = nil diff --git a/xmake/modules/private/tools/go/goenv.lua b/xmake/modules/private/tools/go/goenv.lua index c22401198..37a2c27c3 100644 --- a/xmake/modules/private/tools/go/goenv.lua +++ b/xmake/modules/private/tools/go/goenv.lua @@ -38,8 +38,7 @@ function GOOS(plat) dragonfly = "dragonfly", solaris = "solaris", aix = "aix", - plan9 = "plan9", - wasi = "wasip1" + plan9 = "plan9" } return goos_map[plat] end diff --git a/xmake/platforms/wasi/xmake.lua b/xmake/platforms/wasi/xmake.lua deleted file mode 100644 index 12c1f4b15..000000000 --- a/xmake/platforms/wasi/xmake.lua +++ /dev/null @@ -1,32 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, Xmake Open Source Community. --- --- @author ruki --- @file xmake.lua --- - -platform("wasi") - set_os("wasi") - set_hosts("macosx", "linux", "windows", "bsd") - set_archs("wasm32", "wasm64") - - set_formats("static", "lib$(name).a") - set_formats("object", "$(name).o") - set_formats("shared", "lib$(name).so") - set_formats("binary", "$(name).wasm") - set_formats("symbol", "$(name).sym") - - set_toolchains("wasi") diff --git a/xmake/rules/platform/wasm/installfiles/xmake.lua b/xmake/rules/platform/wasm/installfiles/xmake.lua index 479f93d59..f6833ecab 100644 --- a/xmake/rules/platform/wasm/installfiles/xmake.lua +++ b/xmake/rules/platform/wasm/installfiles/xmake.lua @@ -20,7 +20,7 @@ -- copy other files generated by emcc (see https://emscripten.org/docs/tools_reference/emcc.html#emcc-o-target) rule("platform.wasm.installfiles") - on_load("wasm", "wasi", function (target) + on_load("wasm", function (target) if not target:is_binary() then return end diff --git a/xmake/rules/platform/wasm/preloadfiles/xmake.lua b/xmake/rules/platform/wasm/preloadfiles/xmake.lua index 1fbb1d7d1..144797f82 100644 --- a/xmake/rules/platform/wasm/preloadfiles/xmake.lua +++ b/xmake/rules/platform/wasm/preloadfiles/xmake.lua @@ -20,7 +20,7 @@ -- @see https://github.com/xmake-io/xmake/issues/3613 rule("platform.wasm.preloadfiles") - on_load("wasm", "wasi", function (target) + on_load("wasm", function (target) if not target:is_binary() then return end diff --git a/xmake/rules/qt/config_static.lua b/xmake/rules/qt/config_static.lua index d72cc2abb..4cf943d13 100644 --- a/xmake/rules/qt/config_static.lua +++ b/xmake/rules/qt/config_static.lua @@ -58,7 +58,7 @@ function main(target) if QtPlatformSupport then table.insert(frameworks, QtPlatformSupport) end - elseif target:is_plat("wasm", "wasi") then + elseif target:is_plat("wasm") then plugins.QWasmIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qwasm"}} if qt_sdkver:ge("6.0") then table.join2(frameworks, "QtOpenGL") diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index c0fc4c7f4..1ce0f4fb1 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -479,7 +479,7 @@ function main(target, opt) fallbackmkspec = "android-clang" target:add("rpathdirs", qt.libdir) target:add("linkdirs", qt.libdir) - elseif target:is_plat("wasm", "wasi") then + elseif target:is_plat("wasm") then target:set("frameworks", nil) _add_includedirs(target, qt.includedir) fallbackmkspec = "wasm-emscripten" -- cgit v1.3.1 From f3ab2ca1744900c105e7e789dc099ee4838015d1 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 23 Feb 2026 16:35:05 +0300 Subject: Refactor WASI platform handling and clean up wasm references in various modules --- xmake/actions/run/main.lua | 3 ++- xmake/modules/package/tools/meson.lua | 2 +- xmake/modules/private/tools/go/goenv.lua | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 59d7cbe76..8eaa5672f 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -96,7 +96,8 @@ function _do_run_target(target) -- run wasm target if target:is_plat("wasm") then -- run via wasmtime if using the wasi toolchain, otherwise open in browser - if target:toolchain("wasi") then + local is_wasi = target:toolchain("wasi") or (target:has_tool("cc", "clang") and target:has_tool("ar", "llvm-ar")) + if is_wasi then _run_wasi_target(targetfile, args, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) else _run_wasm_target_in_browser(targetfile, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index 01c12bbe7..fbc6bbe77 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -375,7 +375,7 @@ function _get_configs(package, configs, opt) end -- add cross file - if package:is_cross() or package:is_plat("mingw", "wasm") then + if package:is_cross() or package:is_plat("mingw") then table.insert(configs, "--cross-file=" .. _get_configs_file(package, opt)) elseif package:config("toolchains") then if _is_toolchain_compatible_with_host(package) then diff --git a/xmake/modules/private/tools/go/goenv.lua b/xmake/modules/private/tools/go/goenv.lua index 37a2c27c3..1a448e6f3 100644 --- a/xmake/modules/private/tools/go/goenv.lua +++ b/xmake/modules/private/tools/go/goenv.lua @@ -65,8 +65,7 @@ function GOARCH(arch) ppc64le = "ppc64le", riscv64 = "riscv64", s390x = "s390x", - wasm = "wasm", - wasm32 = "wasm" + wasm = "wasm" } -- try direct match first -- cgit v1.3.1 From 3634d880f8e48d095fe5184ac9a594923e742f10 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 23 Feb 2026 16:55:17 +0300 Subject: optimize --- xmake/actions/run/main.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 8eaa5672f..effa362e5 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -95,12 +95,10 @@ function _do_run_target(target) -- run wasm target if target:is_plat("wasm") then - -- run via wasmtime if using the wasi toolchain, otherwise open in browser - local is_wasi = target:toolchain("wasi") or (target:has_tool("cc", "clang") and target:has_tool("ar", "llvm-ar")) - if is_wasi then - _run_wasi_target(targetfile, args, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) - else + if target:has_tool("cc", "emcc") then _run_wasm_target_in_browser(targetfile, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) + else + _run_wasi_target(targetfile, args, {rundir = rundir, addenvs = addenvs, setenvs = setenvs}) end return end -- cgit v1.3.1