Use a submodule for gomuks source
This commit is contained in:
parent
d3e6340b28
commit
fe845e6cd6
6 changed files with 31 additions and 67 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -36,7 +36,6 @@ key.properties
|
||||||
# Generated Files
|
# Generated Files
|
||||||
*.g.dart
|
*.g.dart
|
||||||
*.freezed.dart
|
*.freezed.dart
|
||||||
src/
|
|
||||||
|
|
||||||
# Devel Password
|
# Devel Password
|
||||||
password.txt
|
password.txt
|
||||||
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[submodule "gomuks"]
|
||||||
|
path = gomuks
|
||||||
|
url = https://github.com/zachatrocity/gomuks
|
||||||
|
branch = init-root-dir
|
||||||
10
README.md
10
README.md
|
|
@ -130,7 +130,7 @@ A simple and user-friendly Matrix client made with Flutter and a Gomuks backend.
|
||||||
First, clone and open the repo:
|
First, clone and open the repo:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://git.federated.nexus/Henry-Hiles/nexus
|
git clone --recurse-submodules https://git.federated.nexus/Henry-Hiles/nexus
|
||||||
cd nexus
|
cd nexus
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -153,13 +153,7 @@ Get dependencies:
|
||||||
flutter pub get
|
flutter pub get
|
||||||
```
|
```
|
||||||
|
|
||||||
Get dependencies:
|
Generate Gomuks bindings:
|
||||||
|
|
||||||
```sh
|
|
||||||
flutter pub get
|
|
||||||
```
|
|
||||||
|
|
||||||
Clone Gomuks and generate bindings:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
scripts/generate.sh
|
scripts/generate.sh
|
||||||
|
|
|
||||||
1
gomuks
Submodule
1
gomuks
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit daa0ba028e7d89ba9fc7580fc8099348e6145cb3
|
||||||
|
|
@ -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("src/");
|
final buildDir = input.packageRoot.resolve("build/");
|
||||||
if (await File(buildDir.resolve("lock").toFilePath()).exists()) return;
|
if (await File(buildDir.resolve("lock").toFilePath()).exists()) return;
|
||||||
|
|
||||||
final codeConfig = input.config.code;
|
final codeConfig = input.config.code;
|
||||||
|
|
@ -27,10 +27,11 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
|
||||||
|
|
||||||
final targetNdkApi = codeConfig.android.targetNdkApi;
|
final targetNdkApi = codeConfig.android.targetNdkApi;
|
||||||
|
|
||||||
final ndkHome = Platform.environment["ANDROID_NDK_HOME"]
|
final ndkHome =
|
||||||
?? Platform.environment["ANDROID_NDK_ROOT"]
|
Platform.environment["ANDROID_NDK_HOME"] ??
|
||||||
?? Platform.environment["NDK_HOME"]
|
Platform.environment["ANDROID_NDK_ROOT"] ??
|
||||||
?? await _findNdkFromSdk();
|
Platform.environment["NDK_HOME"] ??
|
||||||
|
await _findNdkFromSdk();
|
||||||
if (ndkHome == null) {
|
if (ndkHome == null) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
"Could not find Android NDK. Set ANDROID_NDK_HOME or install via sdkmanager.",
|
"Could not find Android NDK. Set ANDROID_NDK_HOME or install via sdkmanager.",
|
||||||
|
|
@ -39,34 +40,30 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
|
||||||
|
|
||||||
final hostTag = _ndkHostTag();
|
final hostTag = _ndkHostTag();
|
||||||
final (goArch, ccTriple) = _androidArch(targetArch);
|
final (goArch, ccTriple) = _androidArch(targetArch);
|
||||||
final cc = "$ndkHome/toolchains/llvm/prebuilt/$hostTag/bin/$ccTriple$targetNdkApi-clang";
|
final cc =
|
||||||
|
"$ndkHome/toolchains/llvm/prebuilt/$hostTag/bin/$ccTriple$targetNdkApi-clang";
|
||||||
|
|
||||||
env = {
|
env = {"CGO_ENABLED": "1", "GOOS": "android", "GOARCH": goArch, "CC": cc};
|
||||||
"CGO_ENABLED": "1",
|
|
||||||
"GOOS": "android",
|
|
||||||
"GOARCH": goArch,
|
|
||||||
"CC": cc,
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw UnsupportedError("Unsupported OS: $targetOS");
|
throw UnsupportedError("Unsupported OS: $targetOS");
|
||||||
}
|
}
|
||||||
|
|
||||||
final gomuksBuildDir = buildDir.resolve("gomuks/");
|
final gomuksBuildDir = input.packageRoot.resolve("gomuks/");
|
||||||
final libFile = gomuksBuildDir.resolve("${targetArch.name}/$libFileName");
|
final libFile = buildDir.resolve("${targetArch.name}/$libFileName");
|
||||||
|
|
||||||
// goheif/dav1d supported on Android would need to fix upstream
|
// goheif/dav1d supported on Android would need to fix upstream
|
||||||
final tags = targetOS == OS.android ? "goolm,noheic" : "goolm";
|
final tags = targetOS == OS.android ? "goolm,noheic" : "goolm";
|
||||||
|
|
||||||
print("Building Gomuks shared library $libFileName (${targetOS.name}/${targetArch.name}) from source...");
|
print(
|
||||||
final result = await Process.run("go", [
|
"Building Gomuks shared library $libFileName (${targetOS.name}/${targetArch.name}) from source...",
|
||||||
"build",
|
);
|
||||||
"-tags", tags,
|
final result = await Process.run(
|
||||||
"-o",
|
"go",
|
||||||
libFile.path,
|
["build", "-tags", tags, "-o", libFile.path, "-buildmode=c-shared"],
|
||||||
"-buildmode=c-shared",
|
workingDirectory: gomuksBuildDir.resolve("pkg/ffi/").toFilePath(),
|
||||||
], workingDirectory: gomuksBuildDir.resolve("source/pkg/ffi/").toFilePath(),
|
environment: env.isNotEmpty ? env : null,
|
||||||
environment: env.isNotEmpty ? env : null);
|
);
|
||||||
|
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
throw Exception("Failed to build Gomuks shared library\n${result.stderr}");
|
throw Exception("Failed to build Gomuks shared library\n${result.stderr}");
|
||||||
|
|
@ -90,8 +87,9 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
|
||||||
|
|
||||||
Future<String?> _findNdkFromSdk() async {
|
Future<String?> _findNdkFromSdk() async {
|
||||||
// pretty sure this wont be needed with nix, i'll get this removed
|
// pretty sure this wont be needed with nix, i'll get this removed
|
||||||
final androidHome = Platform.environment["ANDROID_HOME"]
|
final androidHome =
|
||||||
?? Platform.environment["ANDROID_SDK_ROOT"];
|
Platform.environment["ANDROID_HOME"] ??
|
||||||
|
Platform.environment["ANDROID_SDK_ROOT"];
|
||||||
if (androidHome == null) return null;
|
if (androidHome == null) return null;
|
||||||
final ndkDir = Directory("$androidHome/ndk");
|
final ndkDir = Directory("$androidHome/ndk");
|
||||||
if (!await ndkDir.exists()) return null;
|
if (!await ndkDir.exists()) return null;
|
||||||
|
|
|
||||||
|
|
@ -3,39 +3,7 @@ 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 {
|
||||||
final repoDir = Directory.fromUri(
|
final repoDir = Directory.fromUri(Platform.script.resolve("../gomuks"));
|
||||||
Platform.script.resolve("../src/gomuks/source"),
|
|
||||||
);
|
|
||||||
if (await repoDir.exists()) await repoDir.delete(recursive: true);
|
|
||||||
await repoDir.create(recursive: true);
|
|
||||||
|
|
||||||
print("Cloning Gomuks repository...");
|
|
||||||
final cloneResult = await Process.run("git", [
|
|
||||||
"clone",
|
|
||||||
"https://github.com/zachatrocity/gomuks",
|
|
||||||
repoDir.path,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (cloneResult.exitCode != 0) {
|
|
||||||
throw Exception(
|
|
||||||
"Failed to clone Gomuks repository: \n${cloneResult.stderr}",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final commit = await File.fromUri(
|
|
||||||
Platform.script.resolve("../gomuks.lock"),
|
|
||||||
).readAsString();
|
|
||||||
|
|
||||||
final checkoutResult = await Process.run("git", [
|
|
||||||
"checkout",
|
|
||||||
commit,
|
|
||||||
], workingDirectory: repoDir.path);
|
|
||||||
|
|
||||||
if (checkoutResult.exitCode != 0) {
|
|
||||||
throw Exception(
|
|
||||||
"Failed to check out locked commit: \n${checkoutResult.stderr}",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
print("Generating FFI Bindings...");
|
print("Generating FFI Bindings...");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue