// execute the public API with libalpm headers forbidden and check its ELF dependencies. module main import nspkg.tests.tooling import os fn main() { run() or { eprintln(err) exit(1) } } fn run() ! { args := tooling.options(false)! base := tooling.temporary('alpm-native-api')! defer { os.rmdir_all(base) or { eprintln(err) } } for name in ['alpm.h', 'alpm_list.h'] { os.write_file(os.join_path(base, name), '#error "production must not include libalpm headers"\n')! } executable := os.join_path(base, 'public-api') // Resolve this checkout by its import name without using installed modules. os.symlink(@VMODROOT, os.join_path(base, 'nspkg'))! mut flags := ['-path', '${base}|@vlib', '-cflags', '-I${base}'] $if nspkg_libcurl ? { flags << ['-d', 'nspkg_libcurl'] } $else { os.mkdir(os.join_path(base, 'curl'))! os.write_file(os.join_path(base, 'curl', 'curl.h'), '#error "default build included curl.h"\n')! } flags << ['-o', executable, os.join_path(@VMODROOT, 'native_api_test.v')] tooling.command(args.compiler, flags)! tooling.command(executable, [])! tooling.require_no_libalpm(executable)! needed := tooling.command('readelf', ['-d', executable])! uses_curl := needed.split_into_lines().any(it.contains('(NEEDED)') && it.contains('[libcurl.so')) $if nspkg_libcurl ? { assert uses_curl } $else { assert !uses_curl } println('Native public API passed with the expected downloader linkage') }