budget-app/docs/MAKEPAD_PACKAGER_COMPILE_FIX.patch

300 lines
13 KiB
Diff

diff --git a/tools/cargo_makepad/src/android/mod.rs b/tools/cargo_makepad/src/android/mod.rs
index f9b4cc7..f939e66 100644
--- a/tools/cargo_makepad/src/android/mod.rs
+++ b/tools/cargo_makepad/src/android/mod.rs
@@ -735,7 +735,7 @@ pub fn handle_android(mut args: &[String]) -> Result<(), String> {
let mut version_name: Option<String> = None;
let mut min_sdk_version: Option<usize> = None;
- let urls = sdk::ANDROID_SDK_URLS_33;
+ let urls = sdk::ANDROID_SDK_URLS_35;
// pull out options
for i in 0..args.len() {
diff --git a/tools/cargo_makepad/src/android/sdk.rs b/tools/cargo_makepad/src/android/sdk.rs
index fe753e1..478e9f1 100644
--- a/tools/cargo_makepad/src/android/sdk.rs
+++ b/tools/cargo_makepad/src/android/sdk.rs
@@ -46,7 +46,7 @@ pub struct AndroidSDKUrls {
pub const BUILD_TOOLS_DIR: &str = "build-tools";
pub const PLATFORMS_DIR: &str = "platforms";
-pub const ANDROID_SDK_URLS_33: AndroidSDKUrls = AndroidSDKUrls {
+pub const ANDROID_SDK_URLS_35: AndroidSDKUrls = AndroidSDKUrls {
// NDK clang triple targets API 26 (Android 8.0 Oreo). The compiled .so will
// load on API 26+ devices, ~96-97% of the active Android population. The
// NDK r28 toolchain still supports compiling for API 21+ on arm64; we pick
@@ -62,19 +62,19 @@ pub struct AndroidSDKUrls {
// Store floor for new submissions. Independent of `sdk_version`: target
// controls runtime-behavior compat, not what the binary links against.
target_sdk_version: 35,
- // Build-tools and platform stay at API 33 — that's our *compile* SDK, used
- // for `android.jar` (Java compile classpath) and aapt2. Java code can call
- // API 33 classes at compile time; runtime version checks keep older devices
- // from actually executing those paths.
- build_tools_version: "33.0.1",
- sdk_extension: "ext4",
- platform: "android-33-ext4",
+ // Compile against API 35 so aapt can encode API 34+ foreground-service
+ // types such as specialUse. This does NOT raise the native/API 26 floor.
+ // Matching build tools can read API 35 resource tables. Retain the NDK
+ // and runtime API guards.
+ build_tools_version: "35.0.1",
+ sdk_extension: "",
+ platform: "android-35",
ndk_version_full: "28.2.13676358",
- platform_dl: "https://dl.google.com/android/repository/platform-33-ext4_r01.zip",
- build_tools_macos: "https://dl.google.com/android/repository/build-tools_r33.0.1-macosx.zip",
- build_tools_linux: "https://dl.google.com/android/repository/build-tools_r33.0.1-linux.zip",
- build_tools_windows: "https://dl.google.com/android/repository/build-tools_r33.0.1-windows.zip",
+ platform_dl: "https://dl.google.com/android/repository/platform-35_r02.zip",
+ build_tools_macos: "https://dl.google.com/android/repository/build-tools_r35.0.1_macosx.zip",
+ build_tools_linux: "https://dl.google.com/android/repository/build-tools_r35.0.1_linux.zip",
+ build_tools_windows: "https://dl.google.com/android/repository/build-tools_r35.0.1_windows.zip",
platform_tools_macos:
"https://dl.google.com/android/repository/platform-tools_r33.0.3-darwin.zip",
platform_tools_linux:
@@ -489,7 +489,7 @@ fn separator(base: &str) -> &str {
&[
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"aapt.exe",
),
@@ -497,7 +497,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"aapt2.exe",
),
@@ -505,7 +505,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"zipalign.exe",
),
@@ -513,7 +513,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"lib/apksigner.jar",
),
@@ -521,7 +521,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"lib/d8.jar",
),
@@ -832,9 +832,18 @@ fn separator(base: &str) -> &str {
sdk_dir,
urls.build_tools_macos,
&[
+ // SDK 35 aapt/zipalign load this universal dylib via @rpath.
(
&copy_map(
- "android-13",
+ "android-15",
+ &format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
+ "lib64/libc++.dylib",
+ ),
+ false,
+ ),
+ (
+ &copy_map(
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"aapt",
),
@@ -842,7 +851,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"aapt2",
),
@@ -850,7 +859,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"zipalign",
),
@@ -858,7 +867,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"lib/apksigner.jar",
),
@@ -866,7 +875,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"lib/d8.jar",
),
@@ -1041,7 +1050,7 @@ fn separator(base: &str) -> &str {
&[
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"aapt",
),
@@ -1049,7 +1058,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"aapt2",
),
@@ -1057,7 +1066,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"lib64/libc++.so",
),
@@ -1065,7 +1074,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"zipalign",
),
@@ -1073,7 +1082,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"lib/apksigner.jar",
),
@@ -1081,7 +1090,7 @@ fn separator(base: &str) -> &str {
),
(
&copy_map(
- "android-13",
+ "android-15",
&format!("{BUILD_TOOLS_DIR}/{ANDROID_BUILD_TOOLS_VERSION}"),
"lib/d8.jar",
),
@@ -1260,3 +1269,18 @@ fn separator(base: &str) -> &str {
}
Ok(())
}
+
+#[cfg(test)]
+mod compile_sdk_tests {
+ use super::*;
+ #[test]
+ fn modern_manifest_symbols_do_not_raise_the_device_floor() {
+ let sdk = ANDROID_SDK_URLS_35;
+ assert_eq!(sdk.sdk_version, 26);
+ assert_eq!(sdk.target_sdk_version, 35);
+ assert_eq!(sdk.platform, "android-35");
+ assert_eq!(sdk.build_tools_version, "35.0.1");
+ assert_eq!(sdk.sdk_extension, "");
+ assert!(sdk.platform_dl.ends_with("platform-35_r02.zip"));
+ }
+}
diff --git a/tools/cargo_makepad/src/desktop.rs b/tools/cargo_makepad/src/desktop.rs
index 8dd9953..58e6b11 100644
--- a/tools/cargo_makepad/src/desktop.rs
+++ b/tools/cargo_makepad/src/desktop.rs
@@ -100,36 +100,6 @@ fn write_windows_icon_resource(
Ok(Some(path))
}
-fn add_windows_icon_link_arg(
- cmd: &mut Command,
- args: &[String],
- icon_env: &AppIconEnv,
- build_crate: &str,
-) -> Result<(), String> {
- if !is_windows_target(args) {
- return Ok(());
- }
- let Some(res) = write_windows_icon_resource(args, icon_env, build_crate)? else {
- return Ok(());
- };
-
- let icns = get_crate_dir(build_crate)?.join("resources/icon.icns");
- let source = if icns.is_file() {
- icns
- } else {
- PathBuf::from(&icon_env[APP_ICON_IDX_1024])
- };
- let bytes = fs::read(&source).map_err(|e| format!("failed to read {:?}: {e}", source))?;
- let input = app_link_input(format, Some(&bytes), None)
- .map_err(|e| format!("Windows icon from {:?}: {e}", source))?;
-
- let out_dir = PathBuf::from("target/makepad-desktop/windows-res").join(build_crate);
- fs::create_dir_all(&out_dir).map_err(|e| format!("failed to create {:?}: {e}", out_dir))?;
- let path = out_dir.join(format!("app_icon.{}", format.extension()));
- fs::write(&path, input).map_err(|e| format!("failed to write {:?}: {e}", path))?;
- Ok(Some(path))
-}
-
/// The Windows app's own binary, with its icon linked in. The icon goes to
/// that one target's final link as a `cargo rustc` argument, never through
/// RUSTFLAGS: those are in every crate's fingerprint, so alternating with a
diff --git a/tools/cargo_makepad/src/utils.rs b/tools/cargo_makepad/src/utils.rs
index 388bc2c..43636df 100644
--- a/tools/cargo_makepad/src/utils.rs
+++ b/tools/cargo_makepad/src/utils.rs
@@ -426,6 +426,7 @@ struct CargoMetadata {
#[derive(DeJson)]
struct CargoMetadataPackage {
name: String,
+ manifest_path: Option<String>,
default_run: Option<String>,
targets: Vec<CargoMetadataTarget>,
}
@@ -777,3 +778,15 @@ pub fn resolve_app_icon_env(build_crate: &str) -> Result<Option<AppIconEnv>, Str
required_paths[3].to_string_lossy().to_string(),
]))
}
+
+#[cfg(test)]
+mod metadata_directory_tests {
+ use super::*;
+ #[test]
+ fn extracts_manifest_directory_and_tolerates_missing_path() {
+ let json = r#"{"packages":[{"name":"capture","manifest_path":"/tmp/capture/Cargo.toml","targets":[]},{"name":"unknown","targets":[]}]}"#;
+ let dirs = crate_dirs_from_metadata_json(json);
+ assert_eq!(dirs.get("capture"), Some(&PathBuf::from("/tmp/capture")));
+ assert!(!dirs.contains_key("unknown"));
+ }
+}