Skip to content

Commit

Permalink
fix: android build not working and macos wrong xcframework name
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Apr 22, 2024
1 parent 8056f89 commit 5bc0339
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Extract project name
id: extract
run: |
PROJECT_NAME=$(echo ${{ github.ref_name }} | rev | cut -d '-' -f 2- | rev)
PROJECT_NAME=$(dart cli/main.dart project_name ${{ github.ref_name }})
echo "PROJECT_NAME=$PROJECT_NAME" >> $GITHUB_ENV
shell: bash

Expand Down
4 changes: 0 additions & 4 deletions Cargo.toml

This file was deleted.

2 changes: 1 addition & 1 deletion brick/__brick__/{{name.snakeCase()}}/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {

// Bumping the plugin ndkVersion requires all clients of this plugin to bump
// the version in their app and to download a newer version of the NDK.
ndkVersion "21.4.7075529"
ndkVersion "25.1.8937393"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ release_tag_name = '{{name.snakeCase()}}-v0.0.0' # generated; do not edit

# We cannot distribute the XCFramework alongside the library directly,
# so we have to fetch the correct version here.
framework_name = '{{name.pascalCase()}}-ios.xcframework'
framework_name = '{{name.snakeCase()}}-ios.xcframework'
remote_zip_name = "#{framework_name}.zip"
url = "https://github.com/{{github_user}}/{{repo_name}}/releases/download/#{release_tag_name}/#{remote_zip_name}"
local_zip_name = "#{release_tag_name}.zip"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ release_tag_name = '{{name.snakeCase()}}-v0.0.0' # generated; do not edit

# We cannot distribute the XCFramework alongside the library directly,
# so we have to fetch the correct version here.
framework_name = '{{name.pascalCase()}}-macos.xcframework'
framework_name = '{{name.snakeCase()}}-macos.xcframework'
remote_zip_name = "#{framework_name}.zip"
url = "https://github.com/{{github_user}}/{{repo_name}}/releases/download/#{release_tag_name}/#{remote_zip_name}"
local_zip_name = "#{release_tag_name}.zip"
Expand Down
17 changes: 11 additions & 6 deletions cli/commands/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,31 @@ class AndroidBuildCommand extends Command with BuildConfig {

await ensureBuildDirectoryExists(project);

final shell = Shell(workingDirectory: buildDir);
final shell = Shell(workingDirectory: join(projectDir, "native"));

await shell.run("""
cargo install cargo-ndk
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
""");

final jniDir = join(cwd, "jniLibs");
final jniDir = Directory(join(buildDir, "jniLibs"));

await jniDir.create(recursive: true);

await shell.run("""
cargo ndk -o ${shellArgument(jniDir)} \\
--manifest-path ${shellArgument(join(projectDir, "Cargo.toml"))} \\
cargo ndk -o ${jniDir.path} \\
--manifest-path ${join(projectDir, "Cargo.toml")} \\
-t armeabi-v7a \\
-t arm64-v8a \\
-t x86 \\
-t x86_64 \\
build --release
""");

await shell.cd(jniDir).run("tar -czvf ../android.tar.gz *");
await shell
.cd(jniDir.path)
.run("tar -czvf ../android.tar.gz armeabi-v7a arm64-v8a x86 x86_64");

await Directory(jniDir).delete(recursive: true);
await jniDir.delete(recursive: true);
}
}
26 changes: 26 additions & 0 deletions cli/commands/project_name.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'dart:io';

import 'package:args/command_runner.dart';

class ProjectNameExtractCommand extends Command {
@override
String get name => "project_name";
@override
String get description =>
"Extract the project name from the pubspec.yaml file";

ProjectNameExtractCommand() {
argParser.addOption("path", abbr: "p", mandatory: true);
}

@override
run() async {
final tagName = argResults?.arguments.firstOrNull;
if (tagName == null || tagName.isEmpty) {
stderr.writeln("No tag name provided");
return;
}

stdout.writeln(tagName.split("-v").first.trim());
}
}
2 changes: 2 additions & 0 deletions cli/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'commands/android.dart';
import 'commands/ios.dart';
import 'commands/linux.dart';
import 'commands/macos.dart';
import 'commands/project_name.dart';
import 'commands/version.dart';
import 'commands/windows.dart';

Expand All @@ -17,5 +18,6 @@ void main(List<String> args) {
..addCommand(WindowsBuildCommand())
..addCommand(LinuxBuildCommand())
..addCommand(VersionCommand())
..addCommand(ProjectNameExtractCommand())
..run(args);
}
2 changes: 1 addition & 1 deletion packages/metadata_god/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {

// Bumping the plugin ndkVersion requires all clients of this plugin to bump
// the version in their app and to download a newer version of the NDK.
ndkVersion "21.4.7075529"
ndkVersion "25.1.8937393"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
2 changes: 1 addition & 1 deletion packages/metadata_god/ios/metadata_god.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ release_tag_name = 'metadata_god-v0.5.2' # generated; do not edit

# We cannot distribute the XCFramework alongside the library directly,
# so we have to fetch the correct version here.
framework_name = 'MetadataGod.xcframework'
framework_name = 'metadata_god-ios.xcframework'
remote_zip_name = "#{framework_name}.zip"
url = "https://github.com/KRTirtho/frb_plugins/releases/download/#{release_tag_name}/#{remote_zip_name}"
local_zip_name = "#{release_tag_name}.zip"
Expand Down
2 changes: 1 addition & 1 deletion packages/metadata_god/macos/metadata_god.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ release_tag_name = 'metadata_god-v0.5.2' # generated; do not edit

# We cannot distribute the XCFramework alongside the library directly,
# so we have to fetch the correct version here.
framework_name = 'MetadataGod.xcframework'
framework_name = 'metadata_god-macos.xcframework'
remote_zip_name = "#{framework_name}.zip"
url = "https://github.com/KRTirtho/frb_plugins/releases/download/#{release_tag_name}/#{remote_zip_name}"
local_zip_name = "#{release_tag_name}.zip"
Expand Down

0 comments on commit 5bc0339

Please sign in to comment.