Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .github/actions/setup-toolchain/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
44 changes: 14 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -116,44 +110,36 @@ 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

# llmapi (build only, needs API key to run)
- 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

Expand All @@ -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
15 changes: 14 additions & 1 deletion packages/l/llmapi/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
62 changes: 62 additions & 0 deletions packages/m/mbedtls/xmake.lua
Original file line number Diff line number Diff line change
@@ -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)
15 changes: 12 additions & 3 deletions packages/m/mcpplibs-tinyhttps/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/l/llmapi/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_requires("llmapi 0.2.5")
add_requires("llmapi 0.2.6")

target("llmapi_test")
set_kind("binary")
Expand Down
Loading