pub fn from_tree_env(f: &mut impl FuchsiaPaths) -> Result<Self> {
        Ok(Self {
            // prebuilt binaries that can be optionally fetched from cipd.
            aemu: match read_env_path("PREBUILT_AEMU_DIR") {
                Ok(val) => val.join("emulator"),
                _ => {
                    let fuchsia_root = f.find_fuchsia_root()?;
                    WalkDir::new(fuchsia_root.join("prebuilt/third_party/android/aemu/release"))
                        .into_iter()
                        .filter_map(|e| e.ok())
                        .find(|e| e.file_name() == "emulator")
                        .ok_or(anyhow!(
                            "Cannot find emulator executable from {:?}",
                            fuchsia_root
                                .join("prebuilt/third_party/android/aemu/release")
                                .display()
                        ))?
                        .path()
                        .to_path_buf()
                }
            },
            grpcwebproxy: match read_env_path("PREBUILT_GRPCWEBPROXY_DIR") {
                Ok(val) => val.join("grpcwebproxy"),
                _ => {
                    let fuchsia_root = f.find_fuchsia_root()?;
                    WalkDir::new(fuchsia_root.join("prebuilt/third_party/grpcwebproxy"))
                        .into_iter()
                        .filter_map(|e| e.ok())
                        .find(|e| e.file_name() == "grpcwebproxy" && e.file_type().is_file())
                        .ok_or(anyhow!(
                            "Cannot find grpcwebproxy executable from {:?}",
                            fuchsia_root.join("prebuilt/third_party/grpcwebproxy").display()
                        ))?
                        .path()
                        .to_path_buf()
                }
            },
            vdl: match read_env_path("PREBUILT_VDL_DIR") {
                Ok(val) => val.join("device_launcher"),
                _ => f.find_fuchsia_root()?.join("prebuilt/vdl/device_launcher"),
            },
            far: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("far")),
                _ => f.get_tool_path("far").ok(),
            },
            ffx: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("ffx")),
                _ => f.get_tool_path("ffx").ok(),
            },
            fvm: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("fvm")),
                _ => f.get_tool_path("fvm").ok(),
            },
            pm: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("pm")),
                _ => f.get_tool_path("pm").ok(),
            },
            zbi: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => val.join("zbi"),
                _ => f.get_tool_path("zbi")?,
            },
            is_sdk: false,
        })
    }
/// Initialize host tools for in-tree usage via fx vdl.
///
/// Environment variable HOST_OUT_DIR, PREBUILT_AEMU_DIR,
/// REBUILT_GRPCWEBPROXY_DIR, and PREBUILT_VDL_DIR are optional.
Initialize host tools for in-tree usage via fx vdl.
Initialize host tools for in - tree usage via fx vdl .
pub fn from_tree_env(f: &mut impl FuchsiaPaths) -> Result<Self> {
        Ok(Self {
            // prebuilt binaries that can be optionally fetched from cipd.
            aemu: match read_env_path("PREBUILT_AEMU_DIR") {
                Ok(val) => val.join("emulator"),
                _ => {
                    let fuchsia_root = f.find_fuchsia_root()?;
                    WalkDir::new(fuchsia_root.join("prebuilt/third_party/android/aemu/release"))
                        .into_iter()
                        .filter_map(|e| e.ok())
                        .find(|e| e.file_name() == "emulator")
                        .ok_or(anyhow!(
                            "Cannot find emulator executable from {:?}",
                            fuchsia_root
                                .join("prebuilt/third_party/android/aemu/release")
                                .display()
                        ))?
                        .path()
                        .to_path_buf()
                }
            },
            grpcwebproxy: match read_env_path("PREBUILT_GRPCWEBPROXY_DIR") {
                Ok(val) => val.join("grpcwebproxy"),
                _ => {
                    let fuchsia_root = f.find_fuchsia_root()?;
                    WalkDir::new(fuchsia_root.join("prebuilt/third_party/grpcwebproxy"))
                        .into_iter()
                        .filter_map(|e| e.ok())
                        .find(|e| e.file_name() == "grpcwebproxy" && e.file_type().is_file())
                        .ok_or(anyhow!(
                            "Cannot find grpcwebproxy executable from {:?}",
                            fuchsia_root.join("prebuilt/third_party/grpcwebproxy").display()
                        ))?
                        .path()
                        .to_path_buf()
                }
            },
            vdl: match read_env_path("PREBUILT_VDL_DIR") {
                Ok(val) => val.join("device_launcher"),
                _ => f.find_fuchsia_root()?.join("prebuilt/vdl/device_launcher"),
            },
            far: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("far")),
                _ => f.get_tool_path("far").ok(),
            },
            ffx: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("ffx")),
                _ => f.get_tool_path("ffx").ok(),
            },
            fvm: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("fvm")),
                _ => f.get_tool_path("fvm").ok(),
            },
            pm: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => Some(val.join("pm")),
                _ => f.get_tool_path("pm").ok(),
            },
            zbi: match read_env_path("HOST_OUT_DIR") {
                Ok(val) => val.join("zbi"),
                _ => f.get_tool_path("zbi")?,
            },
            is_sdk: false,
        })
    }
pub fn from_tree_env ( f : & mut impl FuchsiaPaths ) -> Result < Self > { Ok ( Self { // prebuilt binaries that can be optionally fetched from cipd. aemu : match read_env_path ( " " ) { Ok ( val ) => val . join ( " " ) , _ => { let fuchsia_root = f . find_fuchsia_root ( ) ? ; WalkDir :: new ( fuchsia_root . join ( " " ) ) . into_iter ( ) . filter_map ( | e | e . ok ( ) ) . find ( | e | e . file_name ( ) == " " ) . ok_or ( anyhow ! ( " " fuchsia_root join ( " " ) display ( ) ) ) ? . path ( ) . to_path_buf ( ) } } , grpcwebproxy : match read_env_path ( " " ) { Ok ( val ) => val . join ( " " ) , _ => { let fuchsia_root = f . find_fuchsia_root ( ) ? ; WalkDir :: new ( fuchsia_root . join ( " " ) ) . into_iter ( ) . filter_map ( | e | e . ok ( ) ) . find ( | e | e . file_name ( ) == " " && e . file_type ( ) . is_file ( ) ) . ok_or ( anyhow ! ( " " fuchsia_root join ( " " ) display ( ) ) ) ? . path ( ) . to_path_buf ( ) } } , vdl : match read_env_path ( " " ) { Ok ( val ) => val . join ( " " ) , _ => f . find_fuchsia_root ( ) ? . join ( " " ) , } , far : match read_env_path ( " " ) { Ok ( val ) => Some ( val . join ( " " ) ) , _ => f . get_tool_path ( " " ) . ok ( ) , } , ffx : match read_env_path ( " " ) { Ok ( val ) => Some ( val . join ( " " ) ) , _ => f . get_tool_path ( " " ) . ok ( ) , } , fvm : match read_env_path ( " " ) { Ok ( val ) => Some ( val . join ( " " ) ) , _ => f . get_tool_path ( " " ) . ok ( ) , } , pm : match read_env_path ( " " ) { Ok ( val ) => Some ( val . join ( " " ) ) , _ => f . get_tool_path ( " " ) . ok ( ) , } , zbi : match read_env_path ( " " ) { Ok ( val ) => val . join ( " " ) , _ => f . get_tool_path ( " " ) ? , } , is_sdk : false , } ) }
Initialize host tools for in-tree usage via fx vdl.
Initialize host tools for in - tree usage via fx vdl .
f
&mut impl FuchsiaPaths
f
&mut impl FuchsiaPaths