v / vlib / net / mbedtls / mbedtls_tcc_arm64_compiles_test.v
25 lines · 23 sloc · 810 bytes · 2b4831c8d65f1d8699c55733f231465bff846aa3
Raw
1import os
2import rand
3
4const vexe = @VEXE
5
6fn test_mbedtls_compiles_with_tcc_on_arm64_macos() {
7 $if !(macos && arm64) {
8 return
9 }
10 workdir := os.join_path(os.vtmp_dir(), 'v_mbedtls_tcc_arm64_${rand.ulid()}')
11 os.mkdir_all(workdir) or { panic(err) }
12 defer {
13 os.rmdir_all(workdir) or {}
14 }
15 vcache := os.join_path(workdir, 'vcache')
16 os.mkdir_all(vcache) or { panic(err) }
17 src := os.join_path(workdir, 'main.v')
18 out := os.join_path(workdir, 'main')
19 os.write_file(src, 'import net.mbedtls as _\n\nfn main() {}\n') or { panic(err) }
20 cmd := 'env VCACHE=${os.quoted_path(vcache)} ${os.quoted_path(vexe)} -nocache -cc tcc -gc none -no-retry-compilation -o ${os.quoted_path(out)} ${os.quoted_path(src)}'
21 res := os.execute(cmd)
22 if res.exit_code != 0 {
23 panic('command failed:\n${cmd}\n${res.output}')
24 }
25}
26