Skip to content

Commit c00b437

Browse files
committed
yoink legacy
1 parent ba5ad5b commit c00b437

File tree

8 files changed

+246
-1292
lines changed

8 files changed

+246
-1292
lines changed

packages/cli/src/build/assets.rs

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ use anyhow::{bail, Context};
3838
use const_serialize::{deserialize_const, serialize_const, ConstVec};
3939
use dioxus_cli_opt::AssetManifest;
4040
use manganis::{AssetOptions, AssetVariant, BundledAsset, ImageFormat, ImageSize};
41-
use manganis_core::{
42-
AndroidArtifactMetadata, AppleWidgetExtensionMetadata, SwiftPackageMetadata, SymbolData,
43-
};
41+
use manganis_core::{AndroidArtifactMetadata, SwiftPackageMetadata, SymbolData};
4442
use object::{File, Object, ObjectSection, ObjectSymbol, ReadCache, ReadRef, Section, Symbol};
4543
use pdb::FallibleIterator;
4644
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
@@ -707,9 +705,6 @@ pub(crate) struct SymbolExtractionResult {
707705

708706
/// Swift packages discovered in the binary
709707
pub swift_packages: Vec<SwiftPackageMetadata>,
710-
711-
/// Apple Widget Extensions discovered in the binary
712-
pub widget_extensions: Vec<AppleWidgetExtensionMetadata>,
713708
}
714709

715710
/// Find all assets in the given file, hash them, and write them back to the file.
@@ -734,7 +729,6 @@ pub(crate) async fn extract_symbols_from_file(
734729
let mut assets = Vec::new();
735730
let mut android_artifacts = Vec::new();
736731
let mut swift_packages = Vec::new();
737-
let mut widget_extensions = Vec::new();
738732
let mut write_entries = Vec::new();
739733

740734
// Read each symbol from the data section using the offsets
@@ -762,51 +756,37 @@ pub(crate) async fn extract_symbols_from_file(
762756
// The deserialization should work even with padding (zeros) at the end
763757
if let Some(result) = version.deserialize(data_in_range) {
764758
match result {
765-
SymbolDataOrAsset::SymbolData(symbol_data) => {
766-
match *symbol_data {
767-
SymbolData::Asset(asset) => {
768-
tracing::debug!(
769-
"Found asset (via SymbolData) at offset {offset}: {:?}",
770-
asset.absolute_source_path()
771-
);
772-
let asset_index = assets.len();
773-
assets.push(asset);
774-
write_entries.push(AssetWriteEntry::new(
775-
symbol,
776-
asset_index,
777-
AssetRepresentation::SymbolData,
778-
));
779-
}
780-
SymbolData::Permission(_) => {
781-
// Permissions are now configured via Dioxus.toml, not extracted from binary
782-
tracing::trace!(
783-
"Ignoring legacy permission! macro at offset {offset} - use [permissions] in Dioxus.toml instead"
784-
);
785-
}
786-
SymbolData::AndroidArtifact(meta) => {
787-
tracing::debug!(
788-
"Found Android artifact declaration for plugin {}",
789-
meta.plugin_name.as_str()
790-
);
791-
android_artifacts.push(meta);
792-
}
793-
SymbolData::SwiftPackage(meta) => {
794-
tracing::debug!(
795-
"Found Swift package declaration for plugin {}",
796-
meta.plugin_name.as_str()
797-
);
798-
swift_packages.push(meta);
799-
}
800-
SymbolData::AppleWidgetExtension(meta) => {
801-
tracing::debug!(
802-
"Found Apple Widget Extension declaration: {}",
803-
meta.display_name.as_str()
804-
);
805-
widget_extensions.push(meta);
806-
}
807-
_ => {}
759+
SymbolDataOrAsset::SymbolData(symbol_data) => match *symbol_data {
760+
SymbolData::Asset(asset) => {
761+
tracing::debug!(
762+
"Found asset (via SymbolData) at offset {offset}: {:?}",
763+
asset.absolute_source_path()
764+
);
765+
let asset_index = assets.len();
766+
assets.push(asset);
767+
write_entries.push(AssetWriteEntry::new(
768+
symbol,
769+
asset_index,
770+
AssetRepresentation::SymbolData,
771+
));
808772
}
809-
}
773+
774+
SymbolData::AndroidArtifact(meta) => {
775+
tracing::debug!(
776+
"Found Android artifact declaration for plugin {}",
777+
meta.plugin_name.as_str()
778+
);
779+
android_artifacts.push(meta);
780+
}
781+
SymbolData::SwiftPackage(meta) => {
782+
tracing::debug!(
783+
"Found Swift package declaration for plugin {}",
784+
meta.plugin_name.as_str()
785+
);
786+
swift_packages.push(meta);
787+
}
788+
_ => {}
789+
},
810790
SymbolDataOrAsset::Asset(asset) => {
811791
tracing::debug!(
812792
"Found asset (old format) at offset {offset}: {:?}",
@@ -900,7 +880,6 @@ pub(crate) async fn extract_symbols_from_file(
900880
assets,
901881
android_artifacts,
902882
swift_packages,
903-
widget_extensions,
904883
})
905884
}
906885

packages/cli/src/build/request.rs

Lines changed: 86 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ use dioxus_cli_opt::{process_file_to, AssetManifest};
336336
use itertools::Itertools;
337337
use krates::{cm::TargetKind, NodeId};
338338
use manganis::{AssetOptions, BundledAsset, SwiftPackageMetadata};
339-
use manganis_core::{AndroidArtifactMetadata, AppleWidgetExtensionMetadata, AssetVariant};
339+
use manganis_core::{AndroidArtifactMetadata, AssetVariant};
340340
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
341341
use serde::{Deserialize, Serialize};
342342
use std::{borrow::Cow, ffi::OsString};
@@ -456,7 +456,6 @@ pub struct BuildArtifacts {
456456
pub(crate) assets: AssetManifest,
457457
pub(crate) android_artifacts: Vec<AndroidArtifactMetadata>,
458458
pub(crate) swift_sources: Vec<SwiftPackageMetadata>,
459-
pub(crate) widget_extensions: Vec<AppleWidgetExtensionMetadata>,
460459
pub(crate) mode: BuildMode,
461460
pub(crate) patch_cache: Option<Arc<HotpatchModuleCache>>,
462461
pub(crate) depinfo: RustcDepInfo,
@@ -1118,14 +1117,14 @@ impl BuildRequest {
11181117
.context("Failed to embed Swift standard libraries")?;
11191118
}
11201119

1121-
// Compile and install Apple Widget Extensions
1122-
if matches!(self.bundle, BundleFormat::Ios | BundleFormat::MacOS)
1123-
&& !artifacts.widget_extensions.is_empty()
1124-
{
1125-
self.compile_widget_extensions(&artifacts.widget_extensions)
1126-
.await
1127-
.context("Failed to compile widget extensions")?;
1128-
}
1120+
// // Compile and install Apple Widget Extensions
1121+
// if matches!(self.bundle, BundleFormat::Ios | BundleFormat::MacOS)
1122+
// && !artifacts.widget_extensions.is_empty()
1123+
// {
1124+
// self.compile_widget_extensions(&artifacts.widget_extensions)
1125+
// .await
1126+
// .context("Failed to compile widget extensions")?;
1127+
// }
11291128

11301129
self.update_manifests_with_permissions()
11311130
.context("Failed to update manifests with permissions")?;
@@ -1317,7 +1316,7 @@ impl BuildRequest {
13171316
}
13181317

13191318
// Extract all linker metadata (assets, Android/iOS plugins, widget extensions) in a single pass.
1320-
let (assets, android_artifacts, swift_sources, widget_extensions) =
1319+
let (assets, android_artifacts, swift_sources) =
13211320
self.collect_assets_and_metadata(&exe, ctx).await?;
13221321

13231322
let time_end = SystemTime::now();
@@ -1338,7 +1337,6 @@ impl BuildRequest {
13381337
assets,
13391338
android_artifacts,
13401339
swift_sources,
1341-
widget_extensions,
13421340
mode,
13431341
depinfo,
13441342
root_dir: self.root_dir(),
@@ -1359,7 +1357,6 @@ impl BuildRequest {
13591357
AssetManifest,
13601358
Vec<AndroidArtifactMetadata>,
13611359
Vec<SwiftPackageMetadata>,
1362-
Vec<AppleWidgetExtensionMetadata>,
13631360
)> {
13641361
use super::assets::extract_symbols_from_file;
13651362

@@ -1368,15 +1365,14 @@ impl BuildRequest {
13681365
let needs_swift_packages = matches!(self.bundle, BundleFormat::Ios | BundleFormat::MacOS);
13691366

13701367
if skip_assets && !needs_android_artifacts && !needs_swift_packages {
1371-
return Ok((AssetManifest::default(), Vec::new(), Vec::new(), Vec::new()));
1368+
return Ok((AssetManifest::default(), Vec::new(), Vec::new()));
13721369
}
13731370

13741371
ctx.status_extracting_assets();
13751372
let super::assets::SymbolExtractionResult {
13761373
assets: extracted_assets,
13771374
android_artifacts,
13781375
swift_packages,
1379-
widget_extensions,
13801376
} = extract_symbols_from_file(exe).await?;
13811377

13821378
let asset_manifest = if skip_assets {
@@ -1443,27 +1439,7 @@ impl BuildRequest {
14431439
}
14441440
}
14451441

1446-
if !widget_extensions.is_empty() {
1447-
tracing::debug!(
1448-
"Found {} Apple Widget Extension declaration(s)",
1449-
widget_extensions.len()
1450-
);
1451-
for widget in &widget_extensions {
1452-
tracing::debug!(
1453-
" Widget: {} (path={} bundle_id_suffix={})",
1454-
widget.display_name.as_str(),
1455-
widget.package_path.as_str(),
1456-
widget.bundle_id_suffix.as_str()
1457-
);
1458-
}
1459-
}
1460-
1461-
Ok((
1462-
asset_manifest,
1463-
android_artifacts,
1464-
swift_packages,
1465-
widget_extensions,
1466-
))
1442+
Ok((asset_manifest, android_artifacts, swift_packages))
14671443
}
14681444

14691445
/// Install Android plugin artifacts by bundling source folders as Gradle submodules.
@@ -1771,79 +1747,79 @@ impl BuildRequest {
17711747
Ok(())
17721748
}
17731749

1774-
/// Compile and install Apple Widget Extensions from embedded metadata.
1775-
///
1776-
/// This processes widget extensions discovered via the widget!() macro by:
1777-
/// 1. Compiling the Swift package as a Widget Extension executable
1778-
/// 2. Creating the .appex bundle structure with Info.plist
1779-
/// 3. Installing to the app's PlugIns folder
1780-
async fn compile_widget_extensions(
1781-
&self,
1782-
widget_extensions: &[AppleWidgetExtensionMetadata],
1783-
) -> Result<()> {
1784-
tracing::info!(
1785-
"Compiling {} Apple Widget Extension(s)",
1786-
widget_extensions.len()
1787-
);
1788-
1789-
let build_dir = self.target_dir.join("widget-build");
1790-
std::fs::create_dir_all(&build_dir)?;
1791-
1792-
// Get the app bundle identifier for deriving widget bundle IDs
1793-
let app_bundle_id = self.bundle_identifier();
1794-
1795-
let plugins_dir = self.plugins_folder();
1796-
std::fs::create_dir_all(&plugins_dir)?;
1797-
1798-
for meta in widget_extensions {
1799-
let widget_source = super::ios_swift::AppleWidgetSource {
1800-
source_path: PathBuf::from(meta.package_path.as_str()),
1801-
display_name: meta.display_name.as_str().to_string(),
1802-
bundle_id_suffix: meta.bundle_id_suffix.as_str().to_string(),
1803-
deployment_target: meta.deployment_target.as_str().to_string(),
1804-
module_name: meta.module_name.as_str().to_string(),
1805-
};
1806-
1807-
// Compile the widget extension
1808-
let appex_path = super::ios_swift::compile_apple_widget(
1809-
&widget_source,
1810-
&self.triple,
1811-
&build_dir,
1812-
&app_bundle_id,
1813-
self.release,
1814-
)
1815-
.await
1816-
.with_context(|| {
1817-
format!(
1818-
"Failed to compile widget extension '{}'",
1819-
widget_source.display_name
1820-
)
1821-
})?;
1822-
1823-
// Install the .appex bundle to PlugIns/
1824-
let appex_name = appex_path
1825-
.file_name()
1826-
.map(|n| n.to_string_lossy().to_string())
1827-
.unwrap_or_else(|| "Widget.appex".to_string());
1828-
let dest_path = plugins_dir.join(&appex_name);
1829-
1830-
// Remove existing if present
1831-
if dest_path.exists() {
1832-
std::fs::remove_dir_all(&dest_path)?;
1833-
}
1834-
1835-
// Copy the entire .appex bundle
1836-
self.copy_dir_recursive(&appex_path, &dest_path)?;
1837-
1838-
tracing::info!(
1839-
"Installed widget extension '{}' to {}",
1840-
widget_source.display_name,
1841-
dest_path.display()
1842-
);
1843-
}
1844-
1845-
Ok(())
1846-
}
1750+
// /// Compile and install Apple Widget Extensions from embedded metadata.
1751+
// ///
1752+
// /// This processes widget extensions discovered via the widget!() macro by:
1753+
// /// 1. Compiling the Swift package as a Widget Extension executable
1754+
// /// 2. Creating the .appex bundle structure with Info.plist
1755+
// /// 3. Installing to the app's PlugIns folder
1756+
// async fn compile_widget_extensions(
1757+
// &self,
1758+
// widget_extensions: &[AppleWidgetExtensionMetadata],
1759+
// ) -> Result<()> {
1760+
// tracing::info!(
1761+
// "Compiling {} Apple Widget Extension(s)",
1762+
// widget_extensions.len()
1763+
// );
1764+
1765+
// let build_dir = self.target_dir.join("widget-build");
1766+
// std::fs::create_dir_all(&build_dir)?;
1767+
1768+
// // Get the app bundle identifier for deriving widget bundle IDs
1769+
// let app_bundle_id = self.bundle_identifier();
1770+
1771+
// let plugins_dir = self.plugins_folder();
1772+
// std::fs::create_dir_all(&plugins_dir)?;
1773+
1774+
// for meta in widget_extensions {
1775+
// let widget_source = super::ios_swift::AppleWidgetSource {
1776+
// source_path: PathBuf::from(meta.package_path.as_str()),
1777+
// display_name: meta.display_name.as_str().to_string(),
1778+
// bundle_id_suffix: meta.bundle_id_suffix.as_str().to_string(),
1779+
// deployment_target: meta.deployment_target.as_str().to_string(),
1780+
// module_name: meta.module_name.as_str().to_string(),
1781+
// };
1782+
1783+
// // Compile the widget extension
1784+
// let appex_path = super::ios_swift::compile_apple_widget(
1785+
// &widget_source,
1786+
// &self.triple,
1787+
// &build_dir,
1788+
// &app_bundle_id,
1789+
// self.release,
1790+
// )
1791+
// .await
1792+
// .with_context(|| {
1793+
// format!(
1794+
// "Failed to compile widget extension '{}'",
1795+
// widget_source.display_name
1796+
// )
1797+
// })?;
1798+
1799+
// // Install the .appex bundle to PlugIns/
1800+
// let appex_name = appex_path
1801+
// .file_name()
1802+
// .map(|n| n.to_string_lossy().to_string())
1803+
// .unwrap_or_else(|| "Widget.appex".to_string());
1804+
// let dest_path = plugins_dir.join(&appex_name);
1805+
1806+
// // Remove existing if present
1807+
// if dest_path.exists() {
1808+
// std::fs::remove_dir_all(&dest_path)?;
1809+
// }
1810+
1811+
// // Copy the entire .appex bundle
1812+
// self.copy_dir_recursive(&appex_path, &dest_path)?;
1813+
1814+
// tracing::info!(
1815+
// "Installed widget extension '{}' to {}",
1816+
// widget_source.display_name,
1817+
// dest_path.display()
1818+
// );
1819+
// }
1820+
1821+
// Ok(())
1822+
// }
18471823

18481824
/// Update platform manifests with permissions from Dioxus.toml config
18491825
///
@@ -2573,13 +2549,12 @@ impl BuildRequest {
25732549
}
25742550

25752551
// Now extract linker metadata from the fat binary (assets, plugin data)
2576-
let (assets, android_artifacts, swift_sources, widget_extensions) = self
2552+
let (assets, android_artifacts, swift_sources) = self
25772553
.collect_assets_and_metadata(&self.patch_exe(artifacts.time_start), ctx)
25782554
.await?;
25792555
artifacts.assets = assets;
25802556
artifacts.android_artifacts = android_artifacts;
25812557
artifacts.swift_sources = swift_sources;
2582-
artifacts.widget_extensions = widget_extensions;
25832558

25842559
// If this is a web build, reset the index.html file in case it was modified by SSG
25852560
self.write_index_html(&artifacts.assets)

0 commit comments

Comments
 (0)