nexus/scripts/generate.dart
Erwan Leboucher 7bb4d87638 feat: Add iOS platform support (#60)
Co-authored-by: Henry-Hiles <henry@henryhiles.com>
Reviewed-on: Nexus/nexus#60
2026-08-08 16:35:56 -04:00

41 lines
1.2 KiB
Dart

import "dart:io";
import "package:ffigen/ffigen.dart";
import "package:path/path.dart";
import "package:nexus/helpers/extensions/get_xcode_sdk.dart";
void main(List<String> args) async {
final repoDir = Directory.fromUri(Platform.script.resolve("../gomuks"));
print("Generating FFI Bindings...");
final libclangPath = Platform.environment["LIBCLANG_PATH"];
FfiGenerator(
output: Output(
dartFile: Platform.script.resolve("../lib/src/third_party/gomuks.g.dart"),
),
headers: Headers(
entryPoints: [File(join(repoDir.path, "pkg", "ffi", "gomuksffi.h")).uri],
compilerOptions: [
"--no-warnings",
if (Platform.isMacOS) "-I${await getXCodeTool()}/usr/include",
],
),
functions: Functions.includeAll,
).generate(
libclangDylib: libclangPath == null
? null
: Uri.file(
join(
libclangPath,
"libclang.${(Platform.isLinux || Platform.isAndroid)
? "so"
: Platform.isMacOS
? "dylib"
: Platform.isWindows
? "dll"
: throw UnsupportedError("Unsupported Platform")}",
),
),
);
print("Done!");
}