From dbebb1ed939d6e67fc40c673e8ca1998e5f48a06 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Wed, 13 May 2026 15:12:55 +0800 Subject: [PATCH 1/2] fix: improve llmapi + tinyhttps package definitions llmapi: - Move deps to on_load with version check (tinyhttps only for >=0.2.0) - Remove global add_deps that applied to all versions including 0.0.x - Add on_test for install verification - Update test to 0.2.6 tinyhttps: - Move deps to on_load (mbedtls >=3.6.1) - Remove global add_deps - Add target="tinyhttps" to install (only install lib, not tests) - Add on_test for install verification --- packages/l/llmapi/xmake.lua | 15 ++++++++++++++- packages/m/mcpplibs-tinyhttps/xmake.lua | 15 ++++++++++++--- tests/l/llmapi/xmake.lua | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/l/llmapi/xmake.lua b/packages/l/llmapi/xmake.lua index 8b3bcae..f589e14 100644 --- a/packages/l/llmapi/xmake.lua +++ b/packages/l/llmapi/xmake.lua @@ -19,13 +19,26 @@ package("llmapi") add_versions("0.0.1", "174f86d3afdf48a57ad1cc9688718d1f1100a78a7e56686c823c573c3ccf99f4") add_includedirs("include") - add_deps("mcpplibs-tinyhttps 0.2.2") on_load(function (package) package:add("links", "llmapi") + -- tinyhttps dependency only for 0.2.0+ (earlier versions used libcurl) + if package:version():ge("0.2.0") then + package:add("deps", "mcpplibs-tinyhttps >=0.2.0") + end end) on_install(function (package) local configs = {} import("package.tools.xmake").install(package, configs, {target = "llmapi"}) end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + import llmapi; + void test() { + llmapi::Config cfg; + cfg.model = "test"; + } + ]]}, {configs = {languages = "c++23"}})) + end) diff --git a/packages/m/mcpplibs-tinyhttps/xmake.lua b/packages/m/mcpplibs-tinyhttps/xmake.lua index f8155b9..0e56a74 100644 --- a/packages/m/mcpplibs-tinyhttps/xmake.lua +++ b/packages/m/mcpplibs-tinyhttps/xmake.lua @@ -14,13 +14,22 @@ package("mcpplibs-tinyhttps") add_versions("0.2.0", "81dab607227f353fa83068d4fee47b6877ceff891719a60a9cd75eaf827fab44") add_versions("0.1.0", "af7daa6a63f264070a1ac8fe42725713ba7ea54e58f1e8b8e190d1b4c58a0896") - add_deps("mbedtls 3.6.1") - on_load(function (package) package:add("links", "tinyhttps") + package:add("deps", "mbedtls >=3.6.1") end) on_install(function (package) local configs = {} - import("package.tools.xmake").install(package, configs) + import("package.tools.xmake").install(package, configs, {target = "tinyhttps"}) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + import tinyhttps; + void test() { + tinyhttps::HttpRequest req; + req.url = "https://example.com"; + } + ]]}, {configs = {languages = "c++23"}})) end) diff --git a/tests/l/llmapi/xmake.lua b/tests/l/llmapi/xmake.lua index 8e1dfac..d9ca87a 100644 --- a/tests/l/llmapi/xmake.lua +++ b/tests/l/llmapi/xmake.lua @@ -1,4 +1,4 @@ -add_requires("llmapi 0.2.5") +add_requires("llmapi 0.2.6") target("llmapi_test") set_kind("binary") From e85e447d7991c6b350f58c9f8dab48f3a4794b4c Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Wed, 13 May 2026 15:16:34 +0800 Subject: [PATCH 2/2] fix: setup-toolchain uses GITHUB_PATH + clean up CI - action.yml: persist PATH via $GITHUB_PATH instead of per-step export - action.yml: add Windows xlings install step (was missing) - ci.yml: remove all manual PATH exports (now handled by action) - ci.yml: trigger on .github/** and .xlings.json changes --- .github/actions/setup-toolchain/action.yml | 23 ++++---- .github/workflows/ci.yml | 44 +++++---------- packages/m/mbedtls/xmake.lua | 62 ++++++++++++++++++++++ 3 files changed, 89 insertions(+), 40 deletions(-) create mode 100644 packages/m/mbedtls/xmake.lua diff --git a/.github/actions/setup-toolchain/action.yml b/.github/actions/setup-toolchain/action.yml index ac56262..7d8a234 100644 --- a/.github/actions/setup-toolchain/action.yml +++ b/.github/actions/setup-toolchain/action.yml @@ -15,6 +15,7 @@ runs: mkdir -p "$HOME/.xlings" tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1 "$HOME/.xlings/bin/xlings" self install + echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" env: GH_TOKEN: ${{ github.token }} @@ -31,31 +32,33 @@ runs: tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1 xattr -dr com.apple.quarantine "$HOME/.xlings" 2>/dev/null || true "$HOME/.xlings/bin/xlings" self install + echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" env: GH_TOKEN: ${{ github.token }} - name: Setup (windows) if: runner.os == 'Windows' shell: pwsh - run: irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex + run: | + irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex + echo "$env:USERPROFILE\.xlings\subos\current\bin" | Out-File -Append -FilePath $env:GITHUB_PATH - name: Refresh package index (unix) if: runner.os != 'Windows' shell: bash - run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" - xlings update + run: xlings update - name: Refresh package index (windows) if: runner.os == 'Windows' shell: pwsh - run: | - $env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH" - xlings update + run: xlings update - name: Install toolchain (unix) if: runner.os != 'Windows' shell: bash - run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" - xlings install -y + run: xlings install -y + + - name: Install toolchain (windows) + if: runner.os == 'Windows' + shell: pwsh + run: xlings install -y diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b771e17..0f1da98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,15 @@ on: paths: - 'packages/**' - 'tests/**' - - '.github/workflows/ci.yml' + - '.github/**' + - '.xlings.json' pull_request: branches: [main] paths: - 'packages/**' - 'tests/**' - - '.github/workflows/ci.yml' + - '.github/**' + - '.xlings.json' env: XLINGS_NON_INTERACTIVE: 1 @@ -35,23 +37,23 @@ jobs: templates: - 'packages/t/templates/**' - 'tests/t/templates/**' - - '.github/workflows/ci.yml' + - '.github/**' cmdline: - 'packages/c/cmdline/**' - 'tests/c/cmdline/**' - - '.github/workflows/ci.yml' + - '.github/**' llmapi: - 'packages/l/llmapi/**' - 'tests/l/llmapi/**' - - '.github/workflows/ci.yml' + - '.github/**' lua: - 'packages/m/mcpplibs-capi-lua/**' - 'tests/l/lua/**' - - '.github/workflows/ci.yml' + - '.github/**' xpkg: - 'packages/m/mcpplibs-xpkg/**' - 'tests/m/mcpplibs-xpkg/**' - - '.github/workflows/ci.yml' + - '.github/**' build: needs: detect-changes @@ -77,37 +79,29 @@ jobs: - name: Configure (linux) if: runner.os == 'Linux' working-directory: tests - run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" - xmake f -P . -y + run: xmake f -P . -y - name: Configure (macos) if: runner.os == 'macOS' working-directory: tests - run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" - xmake f -P . -y --toolchain=llvm + run: xmake f -P . -y --toolchain=llvm - name: Configure (windows) if: runner.os == 'Windows' working-directory: tests - run: | - $env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH" - xmake f -P . -y + run: xmake f -P . -y # templates - name: templates (unix) if: runner.os != 'Windows' && needs.detect-changes.outputs.templates == 'true' working-directory: tests run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" xmake build -P . -y templates_test xmake run -P . templates_test - name: templates (windows) if: runner.os == 'Windows' && needs.detect-changes.outputs.templates == 'true' working-directory: tests run: | - $env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH" xmake build -P . -y templates_test xmake run -P . templates_test @@ -116,14 +110,12 @@ jobs: if: runner.os != 'Windows' && needs.detect-changes.outputs.cmdline == 'true' working-directory: tests run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" xmake build -P . -y cmdline_test xmake run -P . cmdline_test test_input - name: cmdline (windows) if: runner.os == 'Windows' && needs.detect-changes.outputs.cmdline == 'true' working-directory: tests run: | - $env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH" xmake build -P . -y cmdline_test xmake run -P . cmdline_test test_input @@ -131,29 +123,23 @@ jobs: - name: llmapi (unix) if: runner.os != 'Windows' && needs.detect-changes.outputs.llmapi == 'true' working-directory: tests - run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" - xmake build -P . -y llmapi_test + run: xmake build -P . -y llmapi_test - name: llmapi (windows) if: runner.os == 'Windows' && needs.detect-changes.outputs.llmapi == 'true' working-directory: tests - run: | - $env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH" - xmake build -P . -y llmapi_test + run: xmake build -P . -y llmapi_test # lua - name: lua (unix) if: runner.os != 'Windows' && needs.detect-changes.outputs.lua == 'true' working-directory: tests run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" xmake build -P . -y lua_test xmake run -P . lua_test - name: lua (windows) if: runner.os == 'Windows' && needs.detect-changes.outputs.lua == 'true' working-directory: tests run: | - $env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH" xmake build -P . -y lua_test xmake run -P . lua_test @@ -162,13 +148,11 @@ jobs: if: runner.os != 'Windows' && needs.detect-changes.outputs.xpkg == 'true' working-directory: tests run: | - export PATH="$HOME/.xlings/subos/current/bin:$PATH" xmake build -P . -y mcpplibs-xpkg_test xmake run -P . mcpplibs-xpkg_test - name: mcpplibs-xpkg (windows) if: runner.os == 'Windows' && needs.detect-changes.outputs.xpkg == 'true' working-directory: tests run: | - $env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH" xmake build -P . -y mcpplibs-xpkg_test xmake run -P . mcpplibs-xpkg_test diff --git a/packages/m/mbedtls/xmake.lua b/packages/m/mbedtls/xmake.lua new file mode 100644 index 0000000..4f214cc --- /dev/null +++ b/packages/m/mbedtls/xmake.lua @@ -0,0 +1,62 @@ +package("mbedtls") + set_homepage("https://tls.mbed.org") + set_description("An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API") + set_license("Apache-2.0") + + add_urls("https://github.com/Mbed-TLS/mbedtls/releases/download/$(version).tar.bz2", {version = function (version) + return string.format("mbedtls-%s/mbedtls-%s", version:sub(2), version:sub(2)) + end}) + add_urls("https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/$(version).zip") + add_urls("https://github.com/Mbed-TLS/mbedtls.git") + + add_versions("v3.6.1", "fc8bef0991b43629b7e5319de6f34f13359011105e08e3e16eed3a9fe6ffd3a3") + + add_deps("cmake") + + add_links("mbedtls", "mbedx509", "mbedcrypto") + + if is_plat("windows", "mingw") then + add_syslinks("ws2_32", "advapi32", "bcrypt") + elseif is_plat("linux", "bsd") then + add_syslinks("pthread") + end + + on_install(function (package) + if package:config("shared") and package:is_plat("windows") then + io.replace("library/constant_time_impl.h", "extern volatile", "__declspec(dllimport) volatile", {plain = true}) + io.replace("include/mbedtls/x509_crt.h", "extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb;", "__declspec(dllimport) const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb;", {plain = true}) + io.replace("include/mbedtls/x509_crt.h", "extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default;", "__declspec(dllimport) const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default;", {plain = true}) + io.replace("library/psa_util_internal.h", "extern const mbedtls_error_pair_t psa_to_ssl_errors[7];", "__declspec(dllimport) const mbedtls_error_pair_t psa_to_ssl_errors[7];", {plain = true}) + end + + local configs = {"-DENABLE_TESTING=OFF", "-DENABLE_PROGRAMS=OFF", "-DMBEDTLS_FATAL_WARNINGS=OFF"} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + if package:config("shared") then + table.insert(configs, "-DUSE_SHARED_MBEDTLS_LIBRARY=ON") + table.insert(configs, "-DUSE_STATIC_MBEDTLS_LIBRARY=OFF") + if package:is_plat("windows") then + table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") + end + else + table.insert(configs, "-DUSE_SHARED_MBEDTLS_LIBRARY=OFF") + table.insert(configs, "-DUSE_STATIC_MBEDTLS_LIBRARY=ON") + end + + local cxflags + if package:is_plat("mingw") and package:is_arch("i386") then + cxflags = {"-maes", "-msse2", "-mpclmul"} + end + import("package.tools.cmake").install(package, configs, {cxflags = cxflags}) + end) + + on_test(function (package) + assert(package:has_cfuncs("mbedtls_ssl_init", {includes = "mbedtls/ssl.h"})) + assert(package:check_cxxsnippets({test = [[ + void test() { + mbedtls_aes_context ctx; + + unsigned char key[32]; + mbedtls_aes_setkey_enc(&ctx, key, 256); + } + ]]}, {includes = "mbedtls/aes.h"})) + end)