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