Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/mobile-apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Mobile Apps

on:
pull_request:
paths:
- ".github/workflows/mobile-apps.yml"
- "barretenberg/mobile-app/**"
workflow_dispatch:

permissions:
contents: read

jobs:
android:
name: Android APK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.10.2"
- run: ./barretenberg/mobile-app/scripts/build-android.sh
- uses: actions/upload-artifact@v4
with:
name: bb-mobile-bench-android-debug-apk
path: barretenberg/mobile-app/android/app/build/outputs/apk/debug/app-debug.apk
if-no-files-found: error

ios:
name: iOS Device App
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- run: ./barretenberg/mobile-app/scripts/build-ios.sh
- uses: actions/upload-artifact@v4
with:
name: bb-mobile-bench-ios-unsigned-ipa
path: barretenberg/mobile-app/ios/build/BBMobileBench.ipa
if-no-files-found: error
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ endef
# PHONY TARGETS - List every target that has a file/dir of the same name.
#==============================================================================

.PHONY: noir barretenberg noir-projects l1-contracts release-image boxes playground docs aztec-up spartan
.PHONY: noir barretenberg noir-projects l1-contracts release-image boxes playground docs aztec-up spartan bb-mobile-app-android bb-mobile-app-ios bb-mobile-apps

#==============================================================================
# BOOTSTRAP TARGETS
Expand Down Expand Up @@ -210,6 +210,14 @@ bb-cpp-release-dir: bb-cpp-native bb-cpp-cross

bb-cpp-full: bb-cpp bb-cpp-gcc bb-cpp-fuzzing bb-cpp-asan bb-cpp-smt bb-cpp-cross-arm64-macos bb-cpp-cross-arm64-ios bb-cpp-cross-arm64-android

bb-mobile-app-android:
$(call run_command,$@,$(ROOT)/barretenberg/mobile-app,bash scripts/build-android.sh)

bb-mobile-app-ios:
$(call run_command,$@,$(ROOT)/barretenberg/mobile-app,bash scripts/build-ios.sh)

bb-mobile-apps: bb-mobile-app-android bb-mobile-app-ios

# BB TypeScript - TypeScript bindings
bb-ts: bb-cpp-wasm bb-cpp-wasm-threads bb-cpp-native
$(call build,$@,barretenberg/ts)
Expand Down
5 changes: 5 additions & 0 deletions barretenberg/mobile-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
android/.gradle/
android/build/
android/app/build/
ios/build/
ios/DerivedData/
42 changes: 42 additions & 0 deletions barretenberg/mobile-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Barretenberg Mobile App

This directory contains the first native mobile app shells for running
barretenberg on real phones. The apps share a small C++ bridge under
`shared/` so Android and iOS exercise the same native entry point before the
benchmark path is wired into `libbb-external.a`.

The current CI contract is intentionally small:

- Android builds a debug APK with Gradle and the Android NDK.
- iOS builds an unsigned device app/IPA with Xcode and code signing disabled.

The barretenberg static libraries already have root Makefile targets:

```bash
make bb-cpp-cross-arm64-ios
make bb-cpp-cross-arm64-ios-sim
make bb-cpp-cross-arm64-android
make bb-cpp-cross-x86_64-android
```

The app shells are separate so CI can prove the mobile projects themselves are
healthy without forcing every pull request to rebuild the heavy proving
archives.

## Local Builds

Android:

```bash
barretenberg/mobile-app/scripts/build-android.sh
```

iOS, on macOS with Xcode:

```bash
barretenberg/mobile-app/scripts/build-ios.sh
```

The default iOS output is `barretenberg/mobile-app/ios/build/BBMobileBench.ipa`.
It is unsigned and intended to prove the app target builds in CI. Real
BrowserStack App Automate device runs still need a properly signed `.ipa`.
33 changes: 33 additions & 0 deletions barretenberg/mobile-app/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id("com.android.application")
}

android {
namespace = "com.aztec.barretenberg.mobilebench"
compileSdk = 35

defaultConfig {
applicationId = namespace
minSdk = 26
targetSdk = 35
versionCode = 1
versionName = "0.1"

externalNativeBuild {
cmake {
cppFlags += "-std=c++20"
}
}

ndk {
abiFilters += listOf("arm64-v8a", "x86_64")
}
}

externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
version = "3.22.1"
}
}
}
17 changes: 17 additions & 0 deletions barretenberg/mobile-app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="false"
android:extractNativeLibs="true"
android:label="BB Mobile Bench"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
18 changes: 18 additions & 0 deletions barretenberg/mobile-app/android/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.22.1)

project(bbmobilebench LANGUAGES CXX)

add_library(
bbmobilebench
SHARED
mobile_bench_jni.cpp
../../../../../shared/src/bb_mobile.cpp
)

target_include_directories(
bbmobilebench
PRIVATE
../../../../../shared/include
)

target_compile_features(bbmobilebench PRIVATE cxx_std_20)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "bb_mobile.h"

#include <jni.h>

extern "C" JNIEXPORT jstring JNICALL
Java_com_aztec_barretenberg_mobilebench_MainActivity_nativeStatus(JNIEnv* env, jclass)
{
return env->NewStringUTF(bb_mobile_status());
}

extern "C" JNIEXPORT jint JNICALL
Java_com_aztec_barretenberg_mobilebench_MainActivity_nativeAbiVersion(JNIEnv*, jclass)
{
return bb_mobile_abi_version();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.aztec.barretenberg.mobilebench;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;

public final class MainActivity extends Activity {
static {
System.loadLibrary("bbmobilebench");
}

private static native String nativeStatus();
private static native int nativeAbiVersion();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

LinearLayout root = new LinearLayout(this);
root.setGravity(Gravity.CENTER);
root.setOrientation(LinearLayout.VERTICAL);
root.setPadding(48, 48, 48, 48);

TextView title = new TextView(this);
title.setText("Barretenberg Mobile Bench");
title.setTextSize(24);

TextView status = new TextView(this);
status.setText(nativeStatus() + " (ABI " + nativeAbiVersion() + ")");
status.setTextSize(16);

root.addView(title);
root.addView(status);
setContentView(root);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<resources>
<style name="AppTheme" parent="android:style/Theme.Material.Light.NoActionBar">
<item name="android:fontFamily">sans</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:colorAccent">#2F6FED</item>
</style>
</resources>
3 changes: 3 additions & 0 deletions barretenberg/mobile-app/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("com.android.application") version "8.8.2" apply false
}
2 changes: 2 additions & 0 deletions barretenberg/mobile-app/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.useAndroidX=false
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
18 changes: 18 additions & 0 deletions barretenberg/mobile-app/android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = "BarretenbergMobileBench"
include(":app")
Loading
Loading