MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / run_wasix_initdb_template

Function run_wasix_initdb_template

xtask/src/main.rs:8358–8483  ·  view source on GitHub ↗
(
    _manifest: &SourcesManifest,
    _outputs: &BuildOutputs,
    runtime_stage: &Path,
    work_root: &Path,
)

Source from the content-addressed store, hash-verified

8356
8357#[cfg(feature = "template-runner")]
8358fn run_wasix_initdb_template(
8359 _manifest: &SourcesManifest,
8360 _outputs: &BuildOutputs,
8361 runtime_stage: &Path,
8362 work_root: &Path,
8363) -> Result<()> {
8364 use std::sync::Arc;
8365
8366 use wasmer::Engine;
8367 use wasmer_wasix::bin_factory::BinaryPackage;
8368 use wasmer_wasix::runners::wasi::{RuntimeOrEngine, WasiRunner};
8369 use wasmer_wasix::runtime::task_manager::tokio::TokioTaskManager;
8370 use wasmer_wasix::runtime::{PluggableRuntime, Runtime};
8371 use wasmer_wasix::virtual_fs;
8372 use wasmer_wasix::virtual_fs::null_file::NullFile;
8373
8374 let package_dir = work_root.join("package");
8375 let package_root = work_root.join("root");
8376 let pgdata_root = work_root.join("pgdata");
8377 fs::create_dir_all(package_dir.join("modules"))
8378 .with_context(|| format!("create {}", package_dir.join("modules").display()))?;
8379 fs::create_dir_all(&pgdata_root)
8380 .with_context(|| format!("create {}", pgdata_root.display()))?;
8381 copy_tree_filtered(runtime_stage, &package_root, None)?;
8382 copy_file(
8383 &runtime_stage.join("bin/initdb"),
8384 &package_dir.join("modules/initdb.wasm"),
8385 )?;
8386 copy_file(
8387 &runtime_stage.join("bin/pglite"),
8388 &package_dir.join("modules/postgres.wasm"),
8389 )?;
8390 let wasmer_toml = r#"
8391[package]
8392name = "pglite-oxide/initdb-template"
8393version = "0.0.0"
8394description = "pglite-oxide generated PGDATA template builder"
8395
8396[[module]]
8397name = "initdb"
8398source = "modules/initdb.wasm"
8399abi = "wasi"
8400
8401[[module]]
8402name = "postgres"
8403source = "modules/postgres.wasm"
8404abi = "wasi"
8405
8406[[command]]
8407name = "initdb"
8408module = "initdb"
8409
8410[[command]]
8411name = "postgres"
8412module = "postgres"
8413"#;
8414 fs::write(package_dir.join("wasmer.toml"), wasmer_toml)
8415 .with_context(|| format!("write {}", package_dir.join("wasmer.toml").display()))?;

Calls 7

copy_tree_filteredFunction · 0.85
copy_fileFunction · 0.85
default_initdb_argsFunction · 0.85
buildMethod · 0.80
joinMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected