add skip param

This commit is contained in:
Henry Hiles 2026-01-24 11:56:03 +00:00
commit ede26c9a27
No known key found for this signature in database

View file

@ -3,7 +3,6 @@ import "package:ffigen/ffigen.dart";
import "package:path/path.dart"; import "package:path/path.dart";
void main(List<String> args) async { void main(List<String> args) async {
// Where we put the Gomuks repo and compiled library
final buildDir = Directory.fromUri( final buildDir = Directory.fromUri(
Platform.script.resolve(join("..", "build", "gomuks")), Platform.script.resolve(join("..", "build", "gomuks")),
); );
@ -11,7 +10,7 @@ void main(List<String> args) async {
final repoDir = Directory(join(buildDir.path, "source")); final repoDir = Directory(join(buildDir.path, "source"));
bool skipBuild = false; var skipBuild = args.contains("--skip");
final generatedSourcePath = join("src", "third_party", "gomuks.g.dart"); final generatedSourcePath = join("src", "third_party", "gomuks.g.dart");
final generatedLibPath = Platform.script.resolve( final generatedLibPath = Platform.script.resolve(
@ -19,9 +18,7 @@ void main(List<String> args) async {
); );
final bindingsFile = File(generatedLibPath.toFilePath()); final bindingsFile = File(generatedLibPath.toFilePath());
if (await bindingsFile.exists() && if (await bindingsFile.exists() && await repoDir.exists()) {
await repoDir.exists() &&
!args.contains("--rebuild")) {
final result = await Process.run("git", [ final result = await Process.run("git", [
"fetch", "fetch",
"--dry-run", "--dry-run",
@ -32,12 +29,7 @@ void main(List<String> args) async {
} }
} }
if (skipBuild) { if (!skipBuild) {
return print(
"Gomuks build skipped: bindings and library exist and repo is up to date.",
);
}
if (await repoDir.exists()) await repoDir.delete(recursive: true); if (await repoDir.exists()) await repoDir.delete(recursive: true);
print("Cloning Gomuks repository..."); print("Cloning Gomuks repository...");
@ -50,6 +42,7 @@ void main(List<String> args) async {
"https://mau.dev/gomuks/gomuks", "https://mau.dev/gomuks/gomuks",
repoDir.path, repoDir.path,
]); ]);
if (cloneResult.exitCode != 0) { if (cloneResult.exitCode != 0) {
throw Exception( throw Exception(
"Failed to clone Gomuks repository: \n${cloneResult.stderr}", "Failed to clone Gomuks repository: \n${cloneResult.stderr}",
@ -73,6 +66,7 @@ void main(List<String> args) async {
); );
} }
} }
}
print("Generating FFI Bindings..."); print("Generating FFI Bindings...");
final packageRoot = Platform.script.resolve("../"); final packageRoot = Platform.script.resolve("../");
@ -82,7 +76,7 @@ void main(List<String> args) async {
), ),
headers: Headers( headers: Headers(
entryPoints: [File(join(buildDir.path, "libgomuks.h")).uri], entryPoints: [File(join(buildDir.path, "libgomuks.h")).uri],
compilerOptions: ["-I${String.fromEnvironment("CPATH")}"], // compilerOptions: ["-I${String.fromEnvironment("CPATH")}"],
), ),
functions: Functions.includeAll, functions: Functions.includeAll,
).generate(); ).generate();