Changed generate.dart script to dynamically look for needed files on linux with newest version
This commit is contained in:
parent
31c3173bb5
commit
ab63301de6
2 changed files with 97 additions and 23 deletions
32
pubspec.lock
32
pubspec.lock
|
|
@ -587,10 +587,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: idb_shim
|
||||
sha256: d46b09e116508e817f5ea2d8e1f6f55fb98bf7966175152809fd29791bfba3b8
|
||||
sha256: "48be1c95f06c4b059d0f5b9888dc5d7384e4a9e4d71824ae2deeb1e1546c6c07"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.9.1"
|
||||
version: "2.9.2"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -836,10 +836,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.0"
|
||||
version: "1.18.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1321,26 +1321,26 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: test
|
||||
sha256: "280d6d890011ca966ad08df7e8a4ddfab0fb3aa49f96ed6de56e3521347a9ae7"
|
||||
sha256: "8d9ceddbab833f180fbefed08afa76d7c03513dfdba87ffcec2718b02bbcbf20"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.30.0"
|
||||
version: "1.31.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
||||
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.10"
|
||||
version: "0.7.11"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
sha256: "0381bd1585d1a924763c308100f2138205252fb90c9d4eeaf28489ee65ccde51"
|
||||
sha256: "1991d4cfe85d5043241acac92962c3977c8d2f2add1ee73130c7b286417d1d34"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.16"
|
||||
version: "0.6.17"
|
||||
timeago:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -1401,10 +1401,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: "3bb000251e55d4a209aa0e2e563309dc9bb2befea2295fd0cec1f51760aac572"
|
||||
sha256: "17bc677f0b301615530dd1d67e0a9828cafa2d0b6b6eae4cd3679b7eac4a273c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.29"
|
||||
version: "6.3.30"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1465,10 +1465,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics
|
||||
sha256: "4d35a36400983c3457c289d4d553b5308f506ea84f7e51c7a564651b5525209a"
|
||||
sha256: "2306c03da2ba81724afeb589c351ebbc0aa7d86005925be8f8735856dbe5e42d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
version: "1.2.2"
|
||||
vector_graphics_codec:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1481,10 +1481,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics_compiler
|
||||
sha256: "98e7e94de127b46a86ef46197fff84ff99f3d3b80a708390d717ad731efef598"
|
||||
sha256: b9b3f391857781aa96acacef96066f2f49b4cd03cf9fce3ca4d8da2ef5ea129e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.2"
|
||||
version: "1.2.3"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,26 +1,100 @@
|
|||
import "dart:io";
|
||||
import "package:ffigen/ffigen.dart";
|
||||
import "package:path/path.dart";
|
||||
import "package:path/path.dart" as path;
|
||||
|
||||
void main(List<String> args) async {
|
||||
final repoDir = Directory.fromUri(Platform.script.resolve("../gomuks"));
|
||||
final Directory repoDir = Directory.fromUri(Platform.script.resolve("../gomuks"));
|
||||
|
||||
print("Generating FFI Bindings...");
|
||||
|
||||
final libclangPath = Platform.environment["LIBCLANG_PATH"];
|
||||
int? parseVersion(String name) {
|
||||
final RegExpMatch? match = RegExp(r"^(\d+)(?:\.(\d+))?(?:\.(\d+))?$").firstMatch(name);
|
||||
|
||||
if (match == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int major = int.tryParse(match.group(1)!) ?? 0;
|
||||
final int minor = int.tryParse(match.group(2) ?? "0") ?? 0;
|
||||
final int patch = int.tryParse(match.group(3) ?? "0") ?? 0;
|
||||
return major * 10000 + minor * 100 + patch; //Single number to compare versions based on integer math
|
||||
}
|
||||
|
||||
final Directory gccBaseDir = Directory("/usr/lib/gcc/x86_64-pc-linux-gnu");
|
||||
String? latestGccIncludePath;
|
||||
|
||||
if (await gccBaseDir.exists()) {
|
||||
final Iterable<Directory> entries = gccBaseDir.listSync().whereType<Directory>();
|
||||
|
||||
final List<Directory> versionDirs = entries.where((dir) {
|
||||
final String name = path.basename(dir.path);
|
||||
return parseVersion(name) != null;
|
||||
}).toList();
|
||||
|
||||
if (versionDirs.isNotEmpty) {
|
||||
versionDirs.sort((a, b) {
|
||||
final int verA = parseVersion(path.basename(a.path))!;
|
||||
final int verB = parseVersion(path.basename(b.path))!;
|
||||
return verB.compareTo(verA); // Descending
|
||||
});
|
||||
|
||||
final Directory latestDir = versionDirs.first;
|
||||
latestGccIncludePath = path.join(latestDir.path, "include");
|
||||
print("Successfully detected GCC version: ${path.basename(latestDir.path)} -> Using: $latestGccIncludePath");
|
||||
} else {
|
||||
print("!Warning!: No GCC version directories found in ${gccBaseDir.path}");
|
||||
}
|
||||
} else {
|
||||
print("!Warning!: GCC base directory not found at ${gccBaseDir.path}");
|
||||
}
|
||||
|
||||
final List<String> systemIncludePaths = <String>[];
|
||||
|
||||
if (latestGccIncludePath != null) {
|
||||
systemIncludePaths.add(latestGccIncludePath);
|
||||
systemIncludePaths.add(path.dirname(latestGccIncludePath));
|
||||
}
|
||||
|
||||
final Directory clangDir = Directory("/usr/lib/clang");
|
||||
if (await clangDir.exists()) {
|
||||
final List<Directory> clangEntries = clangDir.listSync().whereType<Directory>().toList();
|
||||
if (clangEntries.isNotEmpty) {
|
||||
clangEntries.sort((a, b) {
|
||||
final verA = parseVersion(path.basename(a.path)) ?? 0;
|
||||
final verB = parseVersion(path.basename(b.path)) ?? 0;
|
||||
return verB.compareTo(verA);
|
||||
});
|
||||
systemIncludePaths.add(path.join(clangEntries.first.path, "include"));
|
||||
}
|
||||
}
|
||||
|
||||
//Standard Paths
|
||||
systemIncludePaths.addAll([
|
||||
"/usr/include",
|
||||
"/usr/include/x86_64-linux-gnu",
|
||||
"/usr/local/include",
|
||||
]);
|
||||
|
||||
final String? 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"],
|
||||
entryPoints: [File(path.join(repoDir.path, "pkg", "ffi", "gomuksffi.h")).uri],
|
||||
compilerOptions: [
|
||||
"--no-warnings",
|
||||
"-target", "x86_64-pc-linux-gnu",
|
||||
...systemIncludePaths.map((path) => "-I$path"),
|
||||
],
|
||||
),
|
||||
functions: Functions.includeAll,
|
||||
).generate(
|
||||
libclangDylib: libclangPath == null
|
||||
? null
|
||||
: Uri.file(join(libclangPath, "libclang.so")),
|
||||
: Uri.file(path.join(libclangPath, "libclang.so")),
|
||||
);
|
||||
|
||||
print("Done!");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue