working build
This commit is contained in:
parent
058f68cffb
commit
20f69ca0aa
7 changed files with 55 additions and 35 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -36,7 +36,7 @@ key.properties
|
|||
# Generated Files
|
||||
*.g.dart
|
||||
*.freezed.dart
|
||||
/rust/
|
||||
/src/
|
||||
|
||||
# Devel Password
|
||||
password.txt
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
pkgs.lib.makeLibraryPath ([
|
||||
pkgs.sqlite
|
||||
])
|
||||
}:./.dart_tool/hooks_runner/shared/nexus/build/gomuks";
|
||||
}:./build/native_assets/linux";
|
||||
CPATH = lib.makeSearchPath "include" [ pkgs.glibc.dev ];
|
||||
|
||||
# ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import "package:hooks/hooks.dart";
|
|||
import "package:code_assets/code_assets.dart";
|
||||
|
||||
Future<void> main(List<String> args) => build(args, (input, output) async {
|
||||
final buildDir = input.packageRoot.resolve("build/");
|
||||
final buildDir = input.packageRoot.resolve("src/");
|
||||
if (await File(buildDir.resolve("lock").toFilePath()).exists()) return;
|
||||
|
||||
final targetOS = input.config.code.targetOS;
|
||||
|
|
@ -38,13 +38,16 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
|
|||
}
|
||||
|
||||
final generatedFile = "src/third_party/gomuks.g.dart";
|
||||
output.assets.code.add(
|
||||
print("Adding $libFileName as asset...");
|
||||
output
|
||||
..assets.code.add(
|
||||
CodeAsset(
|
||||
package: "nexus",
|
||||
name: generatedFile,
|
||||
linkMode: DynamicLoadingBundled(),
|
||||
file: libFile,
|
||||
),
|
||||
);
|
||||
output.dependencies.add(input.packageRoot.resolve("lib/$generatedFile"));
|
||||
)
|
||||
..dependencies.add(libFile);
|
||||
print("Done!");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import "dart:convert";
|
||||
import "dart:ffi";
|
||||
import "package:ffi/ffi.dart";
|
||||
import "package:flutter/foundation.dart";
|
||||
|
|
@ -46,14 +45,14 @@ class ClientController extends Notifier<int> {
|
|||
return handle;
|
||||
}
|
||||
|
||||
void sendCommand(String command, Map<String, dynamic> data) {
|
||||
// final response = GomuksSubmitCommand(
|
||||
// state,
|
||||
// command.toNativeUtf8().cast<Char>(),
|
||||
// data.toGomuksBuffer(),
|
||||
// );
|
||||
Map<String, dynamic> sendCommand(String command, Map<String, dynamic> data) {
|
||||
final response = GomuksSubmitCommand(
|
||||
state,
|
||||
command.toNativeUtf8().cast<Char>(),
|
||||
data.toGomuksBuffer(),
|
||||
);
|
||||
|
||||
// return response.buf; TODO
|
||||
return response.buf.toJson();
|
||||
}
|
||||
|
||||
static final provider = NotifierProvider<ClientController, int>(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import "dart:typed_data";
|
|||
import "package:ffi/ffi.dart";
|
||||
import "package:nexus/src/third_party/gomuks.g.dart";
|
||||
|
||||
extension GomuksBufferToJson on GomuksBorrowedBuffer {
|
||||
extension GomuksBorrowedBufferToJson on GomuksBorrowedBuffer {
|
||||
Uint8List toBytes() {
|
||||
if (base == nullptr || length <= 0) return Uint8List(0);
|
||||
return base.asTypedList(length);
|
||||
|
|
@ -18,22 +18,39 @@ extension GomuksBufferToJson on GomuksBorrowedBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
extension JsonToGomuksBuffer on Map<String, dynamic> {
|
||||
// GomuksBorrowedBuffer toGomuksBuffer() {
|
||||
// final jsonString = json.encode(this);
|
||||
// final bytes = utf8.encode(jsonString);
|
||||
|
||||
// final dataPtr = calloc<Uint8>(bytes.length);
|
||||
// dataPtr.asTypedList(bytes.length).setAll(0, bytes);
|
||||
|
||||
// final bufPtr = calloc<GomuksBuffer>();
|
||||
// bufPtr.ref.base = dataPtr;
|
||||
// bufPtr.ref.length = bytes.length;
|
||||
|
||||
// final bufByValue = bufPtr.ref;
|
||||
|
||||
// calloc.free(bufPtr);
|
||||
|
||||
// return bufByValue;
|
||||
// }
|
||||
extension GomuksOwnedBufferToJson on GomuksOwnedBuffer {
|
||||
Uint8List toBytes() {
|
||||
try {
|
||||
if (base == nullptr || length <= 0) return Uint8List(0);
|
||||
return Uint8List.fromList(base.asTypedList(length));
|
||||
} finally {
|
||||
calloc.free(base);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final bytes = toBytes();
|
||||
if (bytes.isEmpty) return {};
|
||||
return jsonDecode(utf8.decode(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
extension JsonToGomuksBuffer on Map<String, dynamic> {
|
||||
GomuksBorrowedBuffer toGomuksBuffer() {
|
||||
final jsonString = json.encode(this);
|
||||
final bytes = utf8.encode(jsonString);
|
||||
|
||||
final dataPtr = calloc<Uint8>(bytes.length);
|
||||
dataPtr.asTypedList(bytes.length).setAll(0, bytes);
|
||||
|
||||
final bufPtr = calloc<GomuksBorrowedBuffer>();
|
||||
bufPtr.ref.base = dataPtr;
|
||||
bufPtr.ref.length = bytes.length;
|
||||
|
||||
final bufByValue = bufPtr.ref;
|
||||
|
||||
calloc.free(bufPtr);
|
||||
|
||||
return bufByValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ class App extends ConsumerWidget {
|
|||
"username": "quadradical",
|
||||
"password": "Quadmarad1!",
|
||||
});
|
||||
return Placeholder();
|
||||
|
||||
return Text(response.toString());
|
||||
},
|
||||
// .betterWhen(
|
||||
// data: (client) =>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import "package:path/path.dart";
|
|||
|
||||
void main(List<String> args) async {
|
||||
final repoDir = Directory.fromUri(
|
||||
Platform.script.resolve("../build/gomuks/source"),
|
||||
Platform.script.resolve("../src/gomuks/source"),
|
||||
);
|
||||
if (await repoDir.exists()) await repoDir.delete(recursive: true);
|
||||
await repoDir.create(recursive: true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue