Skip to content

Commit 2d00862

Browse files
authored
Merge pull request #60 from Foundation-Devices/support_16k_page_size
android: support 16K page size and use latest flutter SDK
2 parents 440a2d2 + c089d8b commit 2d00862

File tree

27 files changed

+346
-298
lines changed

27 files changed

+346
-298
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- uses: subosito/flutter-action@v2
2929
with:
3030
channel: 'stable'
31-
flutter-version: '3.16.3'
31+
flutter-version: '3.35.1'
3232

3333
- name: Install dependencies
3434
run: flutter pub get

.reuse/dep5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Files: example/windows/flutter/generated*
2323
Copyright: 2024 Foundation Devices Inc.
2424
License: MIT
2525

26+
Files: example/android/*
27+
Copyright: 2024 Foundation Devices Inc.
28+
License: MIT
29+
2630
Files: rust/target/*
2731
Copyright: 2024 Foundation Devices Inc.
2832
License: MIT

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ buildscript {
1515

1616
dependencies {
1717
// The Android Gradle Plugin knows how to build native code with the NDK.
18-
classpath 'com.android.tools.build:gradle:7.3.0'
18+
classpath 'com.android.tools.build:gradle:8.12.1'
1919
}
2020
}
2121

@@ -34,7 +34,7 @@ android {
3434
}
3535
// Bumping the plugin compileSdkVersion requires all clients of this plugin
3636
// to bump the version in their app.
37-
compileSdkVersion 33
37+
compileSdkVersion 36
3838

3939
compileOptions {
4040
sourceCompatibility JavaVersion.VERSION_1_8

cargokit/build_tool/lib/src/android_environment.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,17 @@ class AndroidEnvironment {
190190
if (rustFlags.isNotEmpty) {
191191
rustFlags = '$rustFlags\x1f';
192192
}
193-
rustFlags = '$rustFlags-L\x1f$workaroundDir';
193+
rustFlags = '$rustFlags-L\x1f$workaroundDir\x1f';
194+
195+
const pageSizeArgs = [
196+
"-C",
197+
"link-arg=-Wl,--hash-style=both",
198+
"-C",
199+
"link-arg=-Wl,-z,max-page-size=16384"
200+
];
201+
final pageSizeArgsString = pageSizeArgs.join("\x1f");
202+
203+
rustFlags = '$rustFlags$pageSizeArgsString';
194204
return rustFlags;
195205
}
196206
}

cargokit/gradle/plugin.gradle

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2024 Foundation Devices Inc.
2-
//
3-
// SPDX-License-Identifier: MIT
4-
51
import java.nio.file.Paths
62
import org.apache.tools.ant.taskdefs.condition.Os
73

@@ -87,10 +83,10 @@ class CargoKitPlugin implements Plugin<Project> {
8783
_findFlutterPlugin(rootProject.childProjects)
8884
}
8985

90-
private Plugin _findFlutterPlugin(Map projects) {
86+
private Plugin _findFlutterPlugin(Map projects) {
9187
for (project in projects) {
9288
for (plugin in project.value.getPlugins()) {
93-
if (plugin.class.name == "FlutterPlugin") {
89+
if (plugin.class.name == "com.flutter.gradle.FlutterPlugin") {
9490
return plugin;
9591
}
9692
}
@@ -123,7 +119,7 @@ class CargoKitPlugin implements Plugin<Project> {
123119
def jniLibs = project.android.sourceSets.maybeCreate(buildType).jniLibs;
124120
jniLibs.srcDir(new File(cargoOutputDir))
125121

126-
def platforms = plugin.getTargetPlatforms().collect()
122+
def platforms = com.flutter.gradle.FlutterPluginUtils.getTargetPlatforms(project).collect()
127123

128124
// Same thing addFlutterDependencies does in flutter.gradle
129125
if (buildType == "debug") {
@@ -145,7 +141,7 @@ class CargoKitPlugin implements Plugin<Project> {
145141
}
146142

147143
def task = project.tasks.create(taskName, CargoKitBuildTask.class) {
148-
buildMode = variant.name
144+
buildMode = variant.buildType.name
149145
buildDir = cargoBuildDir
150146
outputDir = cargoOutputDir
151147
ndkVersion = plugin.project.android.ndkVersion
@@ -167,4 +163,4 @@ class CargoKitPlugin implements Plugin<Project> {
167163
}
168164
}
169165
}
170-
}
166+
}

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
*.swp
1010
.DS_Store
1111
.atom/
12+
.build/
1213
.buildlog/
1314
.history
1415
.svn/
16+
.swiftpm/
1517
migrate_working_dir/
1618

1719
# IntelliJ related

example/android/app/build.gradle

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// SPDX-FileCopyrightText: 2024 Foundation Devices Inc.
22
//
33
// SPDX-License-Identifier: MIT
4-
4+
plugins {
5+
id "com.android.application"
6+
id "kotlin-android"
7+
id "dev.flutter.flutter-gradle-plugin"
8+
}
59
def localProperties = new Properties()
610
def localPropertiesFile = rootProject.file('local.properties')
711
if (localPropertiesFile.exists()) {
@@ -10,10 +14,6 @@ if (localPropertiesFile.exists()) {
1014
}
1115
}
1216

13-
def flutterRoot = localProperties.getProperty('flutter.sdk')
14-
if (flutterRoot == null) {
15-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
16-
}
1717

1818
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1919
if (flutterVersionCode == null) {
@@ -25,10 +25,6 @@ if (flutterVersionName == null) {
2525
flutterVersionName = '1.0'
2626
}
2727

28-
apply plugin: 'com.android.application'
29-
apply plugin: 'kotlin-android'
30-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
31-
3228
android {
3329
namespace "com.foundationdevices.tor_example"
3430
compileSdkVersion flutter.compileSdkVersion
@@ -72,5 +68,4 @@ flutter {
7268
}
7369

7470
dependencies {
75-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
7671
}

example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png.license

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png.license

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png.license

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)