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

build(xtask): 🔨 Don't build all android targets by default #2277

Merged
merged 1 commit into from
Jul 24, 2024
Merged
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
26 changes: 9 additions & 17 deletions alvr/xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,14 @@ pub fn build_launcher(profile: Profile, enable_messagebox: bool, reproducible: b
.unwrap();
}

fn build_android_lib_impl(dir_name: &str, profile: Profile, link_stdcpp: bool) {
fn build_android_lib_impl(dir_name: &str, profile: Profile, link_stdcpp: bool, all_targets: bool) {
let sh = Shell::new().unwrap();

let ndk_flags = &[
"-t",
"arm64-v8a",
"-t",
"armeabi-v7a",
"-t",
"x86_64",
"-t",
"x86",
"-p",
"26",
"--no-strip",
];
let mut ndk_flags = vec!["--no-strip", "-p", "26", "-t", "arm64-v8a"];

if all_targets {
ndk_flags.extend(["-t", "armeabi-v7a", "-t", "x86_64", "-t", "x86"]);
}

let mut rust_flags = vec![];
match profile {
Expand Down Expand Up @@ -351,12 +343,12 @@ fn build_android_lib_impl(dir_name: &str, profile: Profile, link_stdcpp: bool) {
cmd!(sh, "cbindgen --output {out}").run().unwrap();
}

pub fn build_android_client_core_lib(profile: Profile, link_stdcpp: bool) {
build_android_lib_impl("client_core", profile, link_stdcpp)
pub fn build_android_client_core_lib(profile: Profile, link_stdcpp: bool, all_targets: bool) {
build_android_lib_impl("client_core", profile, link_stdcpp, all_targets)
}

pub fn build_android_client_openxr_lib(profile: Profile, link_stdcpp: bool) {
build_android_lib_impl("client_openxr", profile, link_stdcpp)
build_android_lib_impl("client_openxr", profile, link_stdcpp, false)
}

pub fn build_android_client(profile: Profile) {
Expand Down
22 changes: 12 additions & 10 deletions alvr/xtask/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn get_android_openxr_loaders() {
);
}

pub fn build_android_deps(skip_admin_priv: bool) {
pub fn build_android_deps(skip_admin_priv: bool, all_targets: bool) {
let sh = Shell::new().unwrap();

update_submodules(&sh);
Expand All @@ -357,15 +357,17 @@ pub fn build_android_deps(skip_admin_priv: bool) {
cmd!(sh, "rustup target add aarch64-linux-android")
.run()
.unwrap();
cmd!(sh, "rustup target add armv7-linux-androideabi")
.run()
.unwrap();
cmd!(sh, "rustup target add x86_64-linux-android")
.run()
.unwrap();
cmd!(sh, "rustup target add i686-linux-android")
.run()
.unwrap();
if all_targets {
cmd!(sh, "rustup target add armv7-linux-androideabi")
.run()
.unwrap();
cmd!(sh, "rustup target add x86_64-linux-android")
.run()
.unwrap();
cmd!(sh, "rustup target add i686-linux-android")
.run()
.unwrap();
}
cmd!(sh, "cargo install cargo-ndk cbindgen").run().unwrap();
cmd!(
sh,
Expand Down
12 changes: 8 additions & 4 deletions alvr/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ FLAGS:
--no-rebuild Do not rebuild the streamer with run-streamer
--ci Do some CI related tweaks. Depends on the other flags and subcommand
--no-stdcpp Disable linking to libc++_shared with build-client-lib
--all-targets For prepare-deps and build-client-lib subcommand, will build for all android supported ABI targets

ARGS:
--platform <NAME> Name of the platform (operative system or hardware name). snake_case
Expand Down Expand Up @@ -167,6 +168,7 @@ fn main() {
let appimage = args.contains("--appimage");
let zsync = args.contains("--zsync");
let link_stdcpp = !args.contains("--no-stdcpp");
let all_targets = args.contains("--all-targets");

let platform: Option<String> = args.opt_value_from_str("--platform").unwrap();
let version: Option<String> = args.opt_value_from_str("--version").unwrap();
Expand All @@ -180,7 +182,7 @@ fn main() {
"windows" => dependencies::prepare_windows_deps(for_ci),
"linux" => dependencies::prepare_linux_deps(!no_nvidia),
"macos" => dependencies::prepare_macos_deps(),
"android" => dependencies::build_android_deps(for_ci),
"android" => dependencies::build_android_deps(for_ci, all_targets),
_ => panic!("Unrecognized platform."),
}
} else {
Expand All @@ -190,7 +192,7 @@ fn main() {
dependencies::prepare_linux_deps(!no_nvidia);
}

dependencies::build_android_deps(for_ci);
dependencies::build_android_deps(for_ci, all_targets);
}
}
"build-streamer" => {
Expand All @@ -199,7 +201,9 @@ fn main() {
"build-launcher" => build::build_launcher(profile, true, false),
"build-server-lib" => build::build_server_lib(profile, true, None, false),
"build-client" => build::build_android_client(profile),
"build-client-lib" => build::build_android_client_core_lib(profile, link_stdcpp),
"build-client-lib" => {
build::build_android_client_core_lib(profile, link_stdcpp, all_targets)
}
"build-client-xr-lib" => {
build::build_android_client_openxr_lib(profile, link_stdcpp)
}
Expand All @@ -226,7 +230,7 @@ fn main() {
"package-streamer" => packaging::package_streamer(gpl, root, appimage, zsync),
"package-launcher" => packaging::package_launcher(appimage),
"package-client" => build::build_android_client(Profile::Distribution),
"package-client-lib" => packaging::package_client_lib(link_stdcpp),
"package-client-lib" => packaging::package_client_lib(link_stdcpp, all_targets),
"format" => format::format(),
"check-format" => format::check_format(),
"clean" => clean(),
Expand Down
4 changes: 2 additions & 2 deletions alvr/xtask/src/packaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ pub fn package_launcher(appimage: bool) {
}
}

pub fn package_client_lib(link_stdcpp: bool) {
pub fn package_client_lib(link_stdcpp: bool, all_targets: bool) {
let sh = Shell::new().unwrap();

build::build_android_client_core_lib(Profile::Distribution, link_stdcpp);
build::build_android_client_core_lib(Profile::Distribution, link_stdcpp, all_targets);

command::zip(&sh, &afs::build_dir().join("alvr_client_core")).unwrap();
}
Loading