nexus/scripts/generate.dart

44 lines
1.3 KiB
Dart
Raw Permalink Normal View History

2026-01-24 11:10:39 +00:00
import "dart:io";
2026-01-24 11:10:39 +00:00
import "package:ffigen/ffigen.dart";
import "package:path/path.dart";
2026-07-07 18:51:27 -04:00
import "package:nexus/helpers/extensions/get_xcode_sdk.dart";
2026-01-24 11:10:39 +00:00
void main(List<String> args) async {
2026-03-24 12:37:00 -04:00
final repoDir = Directory.fromUri(Platform.script.resolve("../gomuks"));
2026-03-23 23:04:59 -04:00
print("Generating FFI bindings...");
2026-02-06 19:12:07 -05:00
final libclangPath = Platform.environment["LIBCLANG_PATH"];
2026-01-24 11:10:39 +00:00
FfiGenerator(
output: .new(
dart: .new(
path: Platform.script.resolve("../lib/src/third_party/gomuks.g.dart"),
),
2026-01-24 11:10:39 +00:00
),
visitors: [.new(func: (node) => node.isIncluded = true)],
input: .new(
2026-01-25 13:02:40 +00:00
entryPoints: [File(join(repoDir.path, "pkg", "ffi", "gomuksffi.h")).uri],
2026-07-07 18:51:27 -04:00
compilerOptions: [
"--no-warnings",
if (Platform.isMacOS) "-I${await getXCodeTool()}/usr/include",
2026-07-07 18:51:27 -04:00
],
2026-01-24 11:10:39 +00:00
),
2026-02-06 19:12:07 -05:00
).generate(
libclangDylib: libclangPath == null
? null
2026-07-28 15:57:39 -04:00
: Uri.file(
join(
libclangPath,
"libclang.${(Platform.isLinux || Platform.isAndroid)
? "so"
: Platform.isMacOS
? "dylib"
: Platform.isWindows
? "dll"
: throw UnsupportedError("Unsupported Platform")}",
),
),
2026-02-06 19:12:07 -05:00
);
print("FFI bindings generated!");
2026-01-24 11:10:39 +00:00
}