-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement gradle rust plugin #7319
base: main
Are you sure you want to change the base?
Conversation
This should no longer be needed when #7158 is merged 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 16 files reviewed, 1 unresolved discussion (waiting on @Pururun)
android/.gitignore
line 6 at r2 (raw file):
local.properties # We want to generate relays.json not store it app/src/main/assets/relays.json
This seems applicable to all platforms! Should we move the ignore to the root .gitignore
? 😊
Code quote:
# We want to generate relays.json not store it
app/src/main/assets/relays.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 16 files reviewed, 5 unresolved discussions (waiting on @Pururun)
wireguard-go-rs/build.rs
line 236 at r2 (raw file):
let mut move_command = Command::new("cp"); move_command .arg("-p")
⛏️ move_command
should probably be renamed now that cp
is used instead of mv
😉
Also, could we document why the -p
flag is important? 🙏
Code quote:
let mut move_command = Command::new("cp");
move_command
.arg("-p")
android/build-apk.sh
line 21 at r2 (raw file):
RUN_PLAY_PUBLISH_TASKS="no" PLAY_PUBLISH_TASKS=() SKIP_STRIPPING=${SKIP_STRIPPING:-"no"}
⛏️ This seems to be unused (🎉)
Code quote:
SKIP_STRIPPING=${SKIP_STRIPPING:-"no"}
android/build-apk.sh
line 56 at r2 (raw file):
elif [[ "$PRODUCT_VERSION" == *"-alpha"* ]]; then echo "Removing old Rust build artifacts" cargo clean
Is the intention to get rid of all explicit invocations of cargo
in this script? Is cargo clean
run when invoking gradlew clean
? 😊
Code quote:
echo "Removing old Rust build artifacts"
cargo clean
android/build-apk.sh
line 61 at r2 (raw file):
PLAY_PUBLISH_TASKS=(publishPlayStagemoleReleaseBundle) else cargo clean
dito
Code quote:
cargo clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is great. :)
Reviewable status: 0 of 16 files reviewed, 3 unresolved discussions (waiting on @MarkusPettersson98)
wireguard-go-rs/build.rs
line 236 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
⛏️
move_command
should probably be renamed now thatcp
is used instead ofmv
😉Also, could we document why the
-p
flag is important? 🙏
Done
android/build-apk.sh
line 21 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
⛏️ This seems to be unused (🎉)
Nice catch!. Removed.
android/build-apk.sh
line 56 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
Is the intention to get rid of all explicit invocations of
cargo
in this script? Iscargo clean
run when invokinggradlew clean
? 😊
Cargo clean
is not invoked when running gradle clean
. Maybe we want to do it, I'll add it to the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 17 files reviewed, 3 unresolved discussions (waiting on @MarkusPettersson98)
android/.gitignore
line 6 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
This seems applicable to all platforms! Should we move the ignore to the root
.gitignore
? 😊
We decided to move the file back into build so it will be ignored.
d096cde
to
1b940e2
Compare
06ebd1d
to
e18506b
Compare
a2cd891
to
6786224
Compare
2702f7d
to
cdea054
Compare
cdea054
to
eded09b
Compare
6509729
to
5c4a2cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 16 files at r1, 2 of 4 files at r3, 2 of 4 files at r7, 2 of 5 files at r8, 2 of 5 files at r9, 2 of 3 files at r10, 1 of 1 files at r11, all commit messages.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @MarkusPettersson98 and @Pururun)
android/app/build.gradle.kts
line 298 at r11 (raw file):
} } exec = { spec, _ -> println(spec.commandLine) }
Should maybe remove?
android/app/build.gradle.kts
line 315 at r11 (raw file):
val output = standardOutput as ByteArrayOutputStream // Create file if needed File("$extraAssetsDirectory").mkdirs()
Should we reference parent of relayListPath
maybe?
android/app/build.gradle.kts
line 317 at r11 (raw file):
File("$extraAssetsDirectory").mkdirs() File("$extraAssetsDirectory/relays.json").createNewFile() FileOutputStream("$extraAssetsDirectory/relays.json").use { it.write(output.toByteArray()) }
We should reuse the relayListPath
here, right now we seem to construct it multiple times.
android/app/build.gradle.kts
line 320 at r11 (raw file):
// Old ensure exists tasks if (!relayListPath.exists()) {
Does this serve any purpose? Shouldn't it exist if the thing above successfully ran?
android/app/build.gradle.kts
line 327 at r11 (raw file):
fun isReleaseBuild() = gradle.startParameter.getTaskNames().any { it.contains("release", ignoreCase = true) }
We probably should add a comment and DROID-X issue link to something in our backlog to address this at some point, or what do you think?
android/build.gradle.kts
line 21 at r11 (raw file):
alias(libs.plugins.detekt) apply true alias(libs.plugins.dependency.versions) apply true
Nit: remove whitespace
android/build.gradle.kts
line 74 at r11 (raw file):
classpath("$prebuilt:[email protected]") classpath("org.mozilla.rust-android-gradle:plugin:${libs.versions.rust.android.gradle}")
Should this also be extracted to some toml file??
wireguard-go-rs/build.rs
line 174 at r11 (raw file):
// or if the libwg.so file has been changed. The latter is required since the // libwg.so file could be deleted. It however means that this build will need // to run two times before it is properly cached.
We should probably add some issue to track this post merging this. Unless we have any idea on how we can make this work for real.
.github/workflows/android-app.yml
line 171 at r11 (raw file):
- arch: "armv7" abi: "armeabi-v7a" taskVariant: "Arm"
Generally we seem to name the keys with dashes instead of camelCase, should we change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 14 unresolved discussions (waiting on @MarkusPettersson98 and @Pururun)
android/build-apk.sh
line 64 at r11 (raw file):
fi pushd "$SCRIPT_DIR"
We should already be in the correct folder I believe so we should be able to remove this pushd
& popd
below,
android/app/build.gradle.kts
line 332 at r11 (raw file):
val localProperties = gradleLocalProperties(rootProject.projectDir, providers) val versionName = generateVersionName(localProperties) return versionName.contains("dev", ignoreCase = true) ||
Does it make sense to ignore case? Or would it better to safeg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 16 files at r1, 1 of 4 files at r3, 1 of 4 files at r7, all commit messages.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @Pururun and @Rawa)
wireguard-go-rs/build.rs
line 236 at r2 (raw file):
Previously, Pururun (Jonatan Rhodin) wrote…
Done
⛏️ It should say -p
, not P
. p
and P
are different flags in cp
Also, it would be nice if the comment would mention that we use cp -p
because we want to preserve ownership & timestamp to not re-trigger cargo
accidentally :)
wireguard-go-rs/build.rs
line 174 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
We should probably add some issue to track this post merging this. Unless we have any idea on how we can make this work for real.
I agree. Also, I think this deserves to be prefixed with "FIXME" to stand out more / increase grep-ability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 17 of 18 files reviewed, 10 unresolved discussions (waiting on @Rawa)
.github/workflows/android-app.yml
line 171 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
Generally we seem to name the keys with dashes instead of camelCase, should we change?
Good catch, fixed.
android/app/build.gradle.kts
line 298 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
Should maybe remove?
Indeed, we could add it again if we need for testing purposes
android/app/build.gradle.kts
line 317 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
We should reuse the
relayListPath
here, right now we seem to construct it multiple times.
Yes fixed!
android/app/build.gradle.kts
line 320 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
Does this serve any purpose? Shouldn't it exist if the thing above successfully ran?
Yeah I'll remove it.
android/app/build.gradle.kts
line 327 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
We probably should add a comment and DROID-X issue link to something in our backlog to address this at some point, or what do you think?
Yes will create an issue.
android/app/build.gradle.kts
line 332 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
Does it make sense to ignore case? Or would it better to safeg
Was a copy paste from the releaes build check, will remove the ignore case.
wireguard-go-rs/build.rs
line 236 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
⛏️ It should say
-p
, notP
.p
andP
are different flags incp
Also, it would be nice if the comment would mention that we use
cp -p
because we want to preserve ownership & timestamp to not re-triggercargo
accidentally :)
Updated text!
wireguard-go-rs/build.rs
line 174 at r11 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
I agree. Also, I think this deserves to be prefixed with "FIXME" to stand out more / increase grep-ability.
Created issue and added FIXME.
android/build-apk.sh
line 61 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
dito
Removed! It will now always clean cargo.
android/build-apk.sh
line 64 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
We should already be in the correct folder I believe so we should be able to remove this
pushd
&popd
below,
Removed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 13 of 18 files reviewed, 10 unresolved discussions (waiting on @MarkusPettersson98 and @Rawa)
android/build.gradle.kts
line 74 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
Should this also be extracted to some toml file??
Probably, could not really find a good way to do this?
android/app/build.gradle.kts
line 315 at r11 (raw file):
Previously, Rawa (David Göransson) wrote…
Should we reference parent of
relayListPath
maybe?
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 5 files at r13.
Reviewable status: 14 of 18 files reviewed, 10 unresolved discussions (waiting on @Rawa)
android/build-apk.sh
line 61 at r2 (raw file):
Previously, Pururun (Jonatan Rhodin) wrote…
Removed! It will now always clean cargo.
🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 5 files at r13.
Reviewable status: 17 of 18 files reviewed, 2 unresolved discussions (waiting on @Pururun)
android/app/build.gradle.kts
line 315 at r11 (raw file):
Previously, Pururun (Jonatan Rhodin) wrote…
Done
Seems like we set it toextraAssetsDirectory
not relayListPath.parent()
. This has the implicit dependency of relayListPath being a direct child of extraAssetsDirectory
.
android/app/build.gradle.kts
line 322 at r13 (raw file):
tasks.register<Exec>("cargoClean") { workingDir = File(repoRootPath) commandLine("cargo", "clean")
🌟
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 17 of 18 files reviewed, 3 unresolved discussions (waiting on @Pururun and @Rawa)
a discussion (no related file):
Can we rename android/build-apk.sh
to android/build.sh
?
862cfb9
to
e55f598
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 16 files at r1, 2 of 4 files at r7, 1 of 5 files at r8, 3 of 7 files at r14, 3 of 5 files at r15.
Reviewable status: 14 of 19 files reviewed, 3 unresolved discussions (waiting on @Pururun and @Rawa)
e55f598
to
d2dcf05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 5 files at r13, 3 of 7 files at r14, 5 of 5 files at r15, 1 of 1 files at r16, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Pururun)
d2dcf05
to
99f37a3
Compare
99f37a3
to
4e04ac2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r20, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Pururun)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r10, 2 of 5 files at r13, 1 of 7 files at r14, 1 of 5 files at r15, 1 of 1 files at r16, 1 of 1 files at r20, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Pururun)
wireguard-go-rs/build.rs
line 235 at r20 (raw file):
std::fs::create_dir_all(parent_of_output)?; let mut copy_command = Command::new("cp");
Is there any way we could avoid the copy? Asking since a copy is usually much more experience.
wireguard-go-rs/build.rs
line 237 at r20 (raw file):
let mut copy_command = Command::new("cp"); // -p command is required to preserve ownership and timestamp of the file to prevent a // rebuild of this module everytime.
nit: every time
Code quote:
everytime
.github/workflows/android-app.yml
line 132 at r19 (raw file):
- name: Generate if: steps.cache-relay-list.outputs.cache-hit != 'true' uses: burrunan/gradle-cache-action@v1
I suggest we skip using the cache action here unless we see a lot of value in keeping it. The relay list will be cached on a daily basis (see cache-relay-list
) so this should only run once a day unless the caching mechnaism is broken.
.github/workflows/android-app.yml
line 158 at r19 (raw file):
image: "${{ needs.prepare.outputs.container_image }}" strategy: matrix:
Can this matrix be simplified a bit or are all values needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 5 files at r15.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @Pururun)
android/app/build.gradle.kts
line 270 at r20 (raw file):
// https://github.com/mozilla/rust-android-gradle/tree/master?tab=readme-ov-file#targets targets = gradleLocalProperties(rootProject.projectDir, providers)
I believe we want to avoid local.properties
: https://linear.app/mullvad/issue/DROID-1430/rework-localproperties-and-e2eproperties
I guess it's fine to not address now if too much work
android/app/build.gradle.kts
line 300 at r20 (raw file):
// Set this if you get a cargo not found error // environment =
Can we elaborate a bit here? What would we set it to and are there any relevant internal or external issues we can link to?
Code quote:
// Set this if you get a cargo not found error
// environment =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @albin-mullvad)
.github/workflows/android-app.yml
line 158 at r19 (raw file):
Previously, albin-mullvad wrote…
Can this matrix be simplified a bit or are all values needed?
Removed arch as it is no longer needed.
android/app/build.gradle.kts
line 270 at r20 (raw file):
Previously, albin-mullvad wrote…
I believe we want to avoid
local.properties
: https://linear.app/mullvad/issue/DROID-1430/rework-localproperties-and-e2epropertiesI guess it's fine to not address now if too much work
We decided to keep using local.properties
as the plugin is still using it and it would make more sense to have them at the same place. We should probably have some kind issue for moving them in the future though.
android/app/build.gradle.kts
line 300 at r20 (raw file):
Previously, albin-mullvad wrote…
Can we elaborate a bit here? What would we set it to and are there any relevant internal or external issues we can link to?
There is a potential issue with Android Studio and environment variables, but that should not be documented here. Removed.
wireguard-go-rs/build.rs
line 237 at r20 (raw file):
Previously, albin-mullvad wrote…
nit:
every time
Done
32aeeaa
to
ab3d61f
Compare
PR to implement gradle rust plugin. This enables the android app to essentially do all required steps for building the app within the gradle scope. The implementation mostly relies on the rust gradle plugin to achieve this, but some rust related things are run as standalone gradle tasks.
Details:
build-apk.sh
script.build-apk.sh
script to the android folder.This change is