CLI fixes for hotpatching the playground (#4715)

* add component subcommand

* add dx component add, remove and list commands

* handle rust dependencies

* handle component dependencies

* fetch remote registries

* sort components before listing them

* remove local dependency

* move te component manifest into the dioxus workspace

* add additional instalation instructions the first time the component
module is created

* fix mod name

* fix clippy

* improve docs and move to the main branch of components

* fix typos

* more typos

* undo const-serialize changes

* remove a few unwraps

* Allow adding multiple components at once and add a `--all` flag

* add options to the config for the base path, global asset path and
default registry

* component_path -> component_dir

* component_dir is always relative to the crate root

* fix clippy

* fix hot patching with a base path

* read the hot patch file from stdin instead of a CLI arg to allow for longer inputs

* fix request imports

* wip: code style changes

* rename to "components" instead of "component"

* bump lock

* move to method on request

* read until eof in the case of pretty json

* strip is now copy

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2025-10-20 17:50:27 -04:00
1 parent 79613f9db9
commit 987e41de16
6 files changed
+1715 -1739

No files matched your search

+44 -1
View File
@@ -349,6 +349,7 @@ use std::{
},
time::{SystemTime, UNIX_EPOCH},
};
use subsecond_types::JumpTable;
use target_lexicon::{Architecture, OperatingSystem, Triple};
use tempfile::TempDir;
use tokio::{io::AsyncBufReadExt, process::Command};
@@ -2334,6 +2335,48 @@ impl BuildRequest {
Ok(())
}
pub(crate) fn create_jump_table(
&self,
patch: &Path,
cache: &HotpatchModuleCache,
) -> Result<JumpTable> {
use crate::build::patch::{
create_native_jump_table, create_wasm_jump_table, create_windows_jump_table,
};
let root_dir = self.root_dir();
let base_path = self.base_path();
let triple = &self.triple;
// Symbols are stored differently based on the platform, so we need to handle them differently.
// - Wasm requires the walrus crate and actually modifies the patch file
// - windows requires the pdb crate and pdb files
// - nix requires the object crate
let mut jump_table = match triple.operating_system {
OperatingSystem::Windows => create_windows_jump_table(patch, cache)?,
_ if triple.architecture == Architecture::Wasm32 => {
create_wasm_jump_table(patch, cache)?
}
_ => create_native_jump_table(patch, triple, cache)?,
};
// root_dir: &Path,
// base_path: Option<&str>,
// Rebase the wasm binary to be relocatable once the jump table is generated
if triple.architecture == target_lexicon::Architecture::Wasm32 {
// Make sure we use the dir relative to the public dir, so the web can load it as a proper URL
//
// ie we would've shipped `/Users/foo/Projects/dioxus/target/dx/project/debug/web/public/wasm/lib.wasm`
// but we want to ship `/wasm/lib.wasm`
jump_table.lib = PathBuf::from(
"/".to_string() + base_path.unwrap_or_default().trim_start_matches('/'),
)
.join(jump_table.lib.strip_prefix(root_dir).unwrap())
}
Ok(jump_table)
}
/// Automatically detect the linker flavor based on the target triple and any custom linkers.
///
/// This tries to replicate what rustc does when selecting the linker flavor based on the linker
@@ -3567,7 +3610,7 @@ impl BuildRequest {
// Get the strip setting from the profile or the profile it inherits from
fn get_strip(profile: &Profile, profiles: &Profiles) -> Option<StripSetting> {
profile.strip.clone().or_else(|| {
profile.strip.or_else(|| {
// If we can't find the strip setting, check if we inherit from another profile
profile.inherits.as_ref().and_then(|inherits| {
let profile = match inherits.as_str() {