Skip to content

Commit e85e447

Browse files
committed
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
1 parent dbebb1e commit e85e447

3 files changed

Lines changed: 89 additions & 40 deletions

File tree

.github/actions/setup-toolchain/action.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ runs:
1515
mkdir -p "$HOME/.xlings"
1616
tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1
1717
"$HOME/.xlings/bin/xlings" self install
18+
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
1819
env:
1920
GH_TOKEN: ${{ github.token }}
2021

@@ -31,31 +32,33 @@ runs:
3132
tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1
3233
xattr -dr com.apple.quarantine "$HOME/.xlings" 2>/dev/null || true
3334
"$HOME/.xlings/bin/xlings" self install
35+
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
3436
env:
3537
GH_TOKEN: ${{ github.token }}
3638

3739
- name: Setup (windows)
3840
if: runner.os == 'Windows'
3941
shell: pwsh
40-
run: irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex
42+
run: |
43+
irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex
44+
echo "$env:USERPROFILE\.xlings\subos\current\bin" | Out-File -Append -FilePath $env:GITHUB_PATH
4145
4246
- name: Refresh package index (unix)
4347
if: runner.os != 'Windows'
4448
shell: bash
45-
run: |
46-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
47-
xlings update
49+
run: xlings update
4850

4951
- name: Refresh package index (windows)
5052
if: runner.os == 'Windows'
5153
shell: pwsh
52-
run: |
53-
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
54-
xlings update
54+
run: xlings update
5555

5656
- name: Install toolchain (unix)
5757
if: runner.os != 'Windows'
5858
shell: bash
59-
run: |
60-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
61-
xlings install -y
59+
run: xlings install -y
60+
61+
- name: Install toolchain (windows)
62+
if: runner.os == 'Windows'
63+
shell: pwsh
64+
run: xlings install -y

.github/workflows/ci.yml

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ on:
66
paths:
77
- 'packages/**'
88
- 'tests/**'
9-
- '.github/workflows/ci.yml'
9+
- '.github/**'
10+
- '.xlings.json'
1011
pull_request:
1112
branches: [main]
1213
paths:
1314
- 'packages/**'
1415
- 'tests/**'
15-
- '.github/workflows/ci.yml'
16+
- '.github/**'
17+
- '.xlings.json'
1618

1719
env:
1820
XLINGS_NON_INTERACTIVE: 1
@@ -35,23 +37,23 @@ jobs:
3537
templates:
3638
- 'packages/t/templates/**'
3739
- 'tests/t/templates/**'
38-
- '.github/workflows/ci.yml'
40+
- '.github/**'
3941
cmdline:
4042
- 'packages/c/cmdline/**'
4143
- 'tests/c/cmdline/**'
42-
- '.github/workflows/ci.yml'
44+
- '.github/**'
4345
llmapi:
4446
- 'packages/l/llmapi/**'
4547
- 'tests/l/llmapi/**'
46-
- '.github/workflows/ci.yml'
48+
- '.github/**'
4749
lua:
4850
- 'packages/m/mcpplibs-capi-lua/**'
4951
- 'tests/l/lua/**'
50-
- '.github/workflows/ci.yml'
52+
- '.github/**'
5153
xpkg:
5254
- 'packages/m/mcpplibs-xpkg/**'
5355
- 'tests/m/mcpplibs-xpkg/**'
54-
- '.github/workflows/ci.yml'
56+
- '.github/**'
5557
5658
build:
5759
needs: detect-changes
@@ -77,37 +79,29 @@ jobs:
7779
- name: Configure (linux)
7880
if: runner.os == 'Linux'
7981
working-directory: tests
80-
run: |
81-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
82-
xmake f -P . -y
82+
run: xmake f -P . -y
8383

8484
- name: Configure (macos)
8585
if: runner.os == 'macOS'
8686
working-directory: tests
87-
run: |
88-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
89-
xmake f -P . -y --toolchain=llvm
87+
run: xmake f -P . -y --toolchain=llvm
9088

9189
- name: Configure (windows)
9290
if: runner.os == 'Windows'
9391
working-directory: tests
94-
run: |
95-
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
96-
xmake f -P . -y
92+
run: xmake f -P . -y
9793

9894
# templates
9995
- name: templates (unix)
10096
if: runner.os != 'Windows' && needs.detect-changes.outputs.templates == 'true'
10197
working-directory: tests
10298
run: |
103-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
10499
xmake build -P . -y templates_test
105100
xmake run -P . templates_test
106101
- name: templates (windows)
107102
if: runner.os == 'Windows' && needs.detect-changes.outputs.templates == 'true'
108103
working-directory: tests
109104
run: |
110-
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
111105
xmake build -P . -y templates_test
112106
xmake run -P . templates_test
113107
@@ -116,44 +110,36 @@ jobs:
116110
if: runner.os != 'Windows' && needs.detect-changes.outputs.cmdline == 'true'
117111
working-directory: tests
118112
run: |
119-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
120113
xmake build -P . -y cmdline_test
121114
xmake run -P . cmdline_test test_input
122115
- name: cmdline (windows)
123116
if: runner.os == 'Windows' && needs.detect-changes.outputs.cmdline == 'true'
124117
working-directory: tests
125118
run: |
126-
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
127119
xmake build -P . -y cmdline_test
128120
xmake run -P . cmdline_test test_input
129121
130122
# llmapi (build only, needs API key to run)
131123
- name: llmapi (unix)
132124
if: runner.os != 'Windows' && needs.detect-changes.outputs.llmapi == 'true'
133125
working-directory: tests
134-
run: |
135-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
136-
xmake build -P . -y llmapi_test
126+
run: xmake build -P . -y llmapi_test
137127
- name: llmapi (windows)
138128
if: runner.os == 'Windows' && needs.detect-changes.outputs.llmapi == 'true'
139129
working-directory: tests
140-
run: |
141-
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
142-
xmake build -P . -y llmapi_test
130+
run: xmake build -P . -y llmapi_test
143131

144132
# lua
145133
- name: lua (unix)
146134
if: runner.os != 'Windows' && needs.detect-changes.outputs.lua == 'true'
147135
working-directory: tests
148136
run: |
149-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
150137
xmake build -P . -y lua_test
151138
xmake run -P . lua_test
152139
- name: lua (windows)
153140
if: runner.os == 'Windows' && needs.detect-changes.outputs.lua == 'true'
154141
working-directory: tests
155142
run: |
156-
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
157143
xmake build -P . -y lua_test
158144
xmake run -P . lua_test
159145
@@ -162,13 +148,11 @@ jobs:
162148
if: runner.os != 'Windows' && needs.detect-changes.outputs.xpkg == 'true'
163149
working-directory: tests
164150
run: |
165-
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
166151
xmake build -P . -y mcpplibs-xpkg_test
167152
xmake run -P . mcpplibs-xpkg_test
168153
- name: mcpplibs-xpkg (windows)
169154
if: runner.os == 'Windows' && needs.detect-changes.outputs.xpkg == 'true'
170155
working-directory: tests
171156
run: |
172-
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
173157
xmake build -P . -y mcpplibs-xpkg_test
174158
xmake run -P . mcpplibs-xpkg_test

packages/m/mbedtls/xmake.lua

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package("mbedtls")
2+
set_homepage("https://tls.mbed.org")
3+
set_description("An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API")
4+
set_license("Apache-2.0")
5+
6+
add_urls("https://github.com/Mbed-TLS/mbedtls/releases/download/$(version).tar.bz2", {version = function (version)
7+
return string.format("mbedtls-%s/mbedtls-%s", version:sub(2), version:sub(2))
8+
end})
9+
add_urls("https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/$(version).zip")
10+
add_urls("https://github.com/Mbed-TLS/mbedtls.git")
11+
12+
add_versions("v3.6.1", "fc8bef0991b43629b7e5319de6f34f13359011105e08e3e16eed3a9fe6ffd3a3")
13+
14+
add_deps("cmake")
15+
16+
add_links("mbedtls", "mbedx509", "mbedcrypto")
17+
18+
if is_plat("windows", "mingw") then
19+
add_syslinks("ws2_32", "advapi32", "bcrypt")
20+
elseif is_plat("linux", "bsd") then
21+
add_syslinks("pthread")
22+
end
23+
24+
on_install(function (package)
25+
if package:config("shared") and package:is_plat("windows") then
26+
io.replace("library/constant_time_impl.h", "extern volatile", "__declspec(dllimport) volatile", {plain = true})
27+
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})
28+
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})
29+
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})
30+
end
31+
32+
local configs = {"-DENABLE_TESTING=OFF", "-DENABLE_PROGRAMS=OFF", "-DMBEDTLS_FATAL_WARNINGS=OFF"}
33+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
34+
if package:config("shared") then
35+
table.insert(configs, "-DUSE_SHARED_MBEDTLS_LIBRARY=ON")
36+
table.insert(configs, "-DUSE_STATIC_MBEDTLS_LIBRARY=OFF")
37+
if package:is_plat("windows") then
38+
table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
39+
end
40+
else
41+
table.insert(configs, "-DUSE_SHARED_MBEDTLS_LIBRARY=OFF")
42+
table.insert(configs, "-DUSE_STATIC_MBEDTLS_LIBRARY=ON")
43+
end
44+
45+
local cxflags
46+
if package:is_plat("mingw") and package:is_arch("i386") then
47+
cxflags = {"-maes", "-msse2", "-mpclmul"}
48+
end
49+
import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
50+
end)
51+
52+
on_test(function (package)
53+
assert(package:has_cfuncs("mbedtls_ssl_init", {includes = "mbedtls/ssl.h"}))
54+
assert(package:check_cxxsnippets({test = [[
55+
void test() {
56+
mbedtls_aes_context ctx;
57+
58+
unsigned char key[32];
59+
mbedtls_aes_setkey_enc(&ctx, key, 256);
60+
}
61+
]]}, {includes = "mbedtls/aes.h"}))
62+
end)

0 commit comments

Comments
 (0)