Skip to content
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

WIP debug android daita build #6725

Closed
wants to merge 11 commits into from
Closed
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
165 changes: 165 additions & 0 deletions .github/workflows/android-app-multiple.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
name: Android - Multibuild
on:
workflow_dispatch:
inputs:
override_container_image:
description: Override container image
type: string
required: false
pull_request:

permissions: {}

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use custom container image if specified
if: ${{ github.event.inputs.override_container_image != '' }}
run:
echo "inner_container_image=${{ github.event.inputs.override_container_image }}"
>> $GITHUB_ENV

- name: Use default container image and resolve digest
if: ${{ github.event.inputs.override_container_image == '' }}
run: |
echo "inner_container_image=$(cat ./building/android-container-image.txt)" >> $GITHUB_ENV
outputs:
container_image: ${{ env.inner_container_image }}

build-app:
name: Build app (multiple)
needs: prepare
runs-on: ubuntu-latest
container:
image: ${{ needs.prepare.outputs.container_image }}
strategy:
fail-fast: false
matrix:
attempt:
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,

Check failure on line 145 in .github/workflows/android-app-multiple.yml

View workflow job for this annotation

GitHub Actions / check-formatting

145:12 [indentation] wrong indentation: expected 12 but found 11
]
steps:
# Fix for HOME path overridden by GH runners when building in containers, see:
# https://github.com/actions/runner/issues/863
- name: Fix HOME path
run: echo "HOME=/root" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Checkout wireguard-go-rs recursively
run: |
git config --global --add safe.directory '*'
git submodule update --init --recursive --depth=1 wireguard-go-rs

- name: Run build script
shell: bash
run: ./build-apk.sh --dev-build
32 changes: 32 additions & 0 deletions .github/workflows/android-app-wrapper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Android - Wrapper build
on:

Check warning on line 3 in .github/workflows/android-app-wrapper.yml

View workflow job for this annotation

GitHub Actions / check-formatting

3:1 [truthy] truthy value should be one of [false, true]
workflow_dispatch:
pull_request:

permissions: {}

jobs:
build-app:
name: Build app (using wrapper)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Checkout wireguard-go-rs recursively
run: |
git config --global --add safe.directory '*'
git submodule update --init --recursive --depth=1 wireguard-go-rs

- name: Install podman
shell: bash
run: |
sudo apt-get update
sudo apt-get install podman

- name: Run build script
shell: bash
run: ./building/containerized-build.sh android --dev-build
8 changes: 7 additions & 1 deletion build-apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ mkdir -p "app/build/extraAssets"
mkdir -p "app/build/extraJni"
popd

for ARCHITECTURE in ${ARCHITECTURES:-aarch64 armv7 x86_64 i686}; do
#cargo install --force cbindgen

for ARCHITECTURE in ${ARCHITECTURES:-x86_64}; do
case "$ARCHITECTURE" in
"x86_64")
TARGET="x86_64-linux-android"
Expand Down Expand Up @@ -111,6 +113,10 @@ for ARCHITECTURE in ${ARCHITECTURES:-aarch64 armv7 x86_64 i686}; do
fi
done

echo "DAEMON BUILT!"

exit 0

echo "Updating relays.json..."
cargo run --bin relay_list "${CARGO_ARGS[@]}" > android/app/build/extraAssets/relays.json

Expand Down
4 changes: 0 additions & 4 deletions building/container-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,4 @@ fi
set -x
exec "$CONTAINER_RUNNER" run --rm -it \
-v "$REPO_DIR:$REPO_MOUNT_TARGET:Z" \
-v "$CARGO_TARGET_VOLUME_NAME:/cargo-target:Z" \
-v "$CARGO_REGISTRY_VOLUME_NAME:/root/.cargo/registry:Z" \
"${optional_gradle_cache_volume[@]}" \
"${optional_android_credentials_volume[@]}" \
"$container_image_name" bash -c "$optional_mold $*"
7 changes: 2 additions & 5 deletions mullvad-daemon/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ fn main() {
}
res.compile().expect("Unable to generate windows resources");
}
let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");

// Enable DAITA by default on desktop
// Enable DAITA by default on desktop and android
println!("cargo::rustc-check-cfg=cfg(daita)");
if let "linux" | "windows" | "macos" = target_os.as_str() {
println!(r#"cargo::rustc-cfg=daita"#);
}
println!(r#"cargo::rustc-cfg=daita"#);
}

fn commit_date() -> String {
Expand Down
8 changes: 2 additions & 6 deletions mullvad-management-interface/build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
fn main() {
tonic_build::compile_protos("proto/management_interface.proto").unwrap();

let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");

// Enable DAITA by default on desktop
// Enable DAITA by default on desktop and android
println!("cargo::rustc-check-cfg=cfg(daita)");
if let "linux" | "windows" | "macos" = target_os.as_str() {
println!(r#"cargo::rustc-cfg=daita"#);
}
println!(r#"cargo::rustc-cfg=daita"#);
}
2 changes: 1 addition & 1 deletion mullvad-management-interface/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::types;
#[cfg(not(target_os = "android"))]
use futures::{Stream, StreamExt};
#[cfg(daita)]
#[cfg(all(daita, not(target_os = "android")))]
use mullvad_types::wireguard::DaitaSettings;
use mullvad_types::{
access_method::AccessMethodSetting,
Expand Down
8 changes: 2 additions & 6 deletions mullvad-relay-selector/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
fn main() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");

// Enable DAITA by default on desktop
// Enable DAITA by default on desktop and android
println!("cargo::rustc-check-cfg=cfg(daita)");
if let "linux" | "windows" | "macos" = target_os.as_str() {
println!(r#"cargo::rustc-cfg=daita"#);
}
println!(r#"cargo::rustc-cfg=daita"#);
}
8 changes: 2 additions & 6 deletions mullvad-types/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
fn main() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");

// Enable DAITA by default on desktop
// Enable DAITA by default on desktop and android
println!("cargo::rustc-check-cfg=cfg(daita)");
if let "linux" | "windows" | "macos" = target_os.as_str() {
println!(r#"cargo::rustc-cfg=daita"#);
}
println!(r#"cargo::rustc-cfg=daita"#);
}
8 changes: 2 additions & 6 deletions talpid-types/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
fn main() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");

// Enable DAITA by default on desktop
// Enable DAITA by default on desktop and android
println!("cargo::rustc-check-cfg=cfg(daita)");
if let "linux" | "windows" | "macos" = target_os.as_str() {
println!(r#"cargo::rustc-cfg=daita"#);
}
println!(r#"cargo::rustc-cfg=daita"#);
}
6 changes: 2 additions & 4 deletions talpid-wireguard/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ fn add_wireguard_go_cfg(target_os: &str) {
println!("cargo::rustc-cfg=wireguard_go");
}

// Enable DAITA by default on desktop
// Enable DAITA by default on desktop and android
println!("cargo::rustc-check-cfg=cfg(daita)");
if matches!(target_os, "linux" | "macos" | "windows") {
println!(r#"cargo::rustc-cfg=daita"#);
}
println!(r#"cargo::rustc-cfg=daita"#);
}

fn declare_libs_dir(base: &str) {
Expand Down
2 changes: 1 addition & 1 deletion wireguard-go-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ thiserror.workspace = true
log.workspace = true
zeroize = "1.8.1"

[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
[target.'cfg(not(target_os = "windows"))'.dependencies]
# The app does not depend on maybenot-ffi itself, but adds it as a dependency to expose FFI symbols to wireguard-go.
# This is done, instead of using the makefile in wireguard-go to build maybenot-ffi into its archive, to prevent
# name clashes induced by link-time optimization.
Expand Down
9 changes: 7 additions & 2 deletions wireguard-go-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> anyhow::Result<()> {
match target_os.as_str() {
"linux" => build_static_lib(Os::Linux, true)?,
"macos" => build_static_lib(Os::MacOs, true)?,
"android" => build_android_dynamic_lib(false)?,
"android" => build_android_dynamic_lib(true)?,
// building wireguard-go-rs for windows is not implemented
_ => {}
}
Expand Down Expand Up @@ -192,7 +192,12 @@ fn build_android_dynamic_lib(daita: bool) -> anyhow::Result<()> {
.env("ANDROID_ARCH_NAME", android_arch_name(target))
.env("GOPATH", &go_path)
// Note: -w -s results in a stripped binary
.env("LDFLAGS", format!("-L{out_dir} -w -s"));
.env("LDFLAGS", format!("-L{out_dir} -w -s"))
// Note: the build container overrides CARGO_TARGET_DIR, which will cause problems
// since we will spawn another cargo process as part of building maybenot (which we
// link into libwg). A work around is to simply override the overridden value, and we
// do this by pointing to a target folder in our temporary build folder.
.env("CARGO_TARGET_DIR", tmp_build_dir.join("target"));

exec(build_command)?;

Expand Down
8 changes: 6 additions & 2 deletions wireguard-go-rs/libwg/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ GOBUILDVERSION := 1.21.3
GOBUILDTARBALL := https://go.dev/dl/go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)


$(DESTDIR)/libwg.so:
mkdir -p $(DESTDIR)
go get -tags "linux android"
# Build libmaybenot
make --directory wireguard-go libmaybenot.a LIBDEST="$(DESTDIR)" TARGET="$(TARGET)" CARGO_TARGET_DIR="$(CARGO_TARGET_DIR)"
# Build wireguard-go
go get -tags "linux android daita"
chmod -fR +w "$(GOPATH)/pkg/mod"
go build -tags "linux android" -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o "$@" -buildmode c-shared
go build -tags "linux android daita" -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o "$@" -buildmode c-shared
rm -f $(DESTDIR)/libwg.h


Expand Down
2 changes: 1 addition & 1 deletion wireguard-go-rs/libwg/wireguard-go
Submodule wireguard-go updated 2 files
+1 −1 Makefile
+1 −1 maybenot
Loading