Files
windmill/backend/windmill-worker/build.rs
Ruben Fiszel c669e9940b feat: native fetch + native postgresql jobs (#1796)
* push

* test

* test

* done

* fix

* modify script lang enum

* fix tests

* update wasm

* fix tests
2023-07-04 19:39:59 +02:00

72 lines
2.0 KiB
Rust

use deno_core::OpState;
use deno_fetch::FetchPermissions;
use deno_web::{BlobStore, TimersPermission};
use std::env;
use std::path::PathBuf;
pub struct PermissionsContainer;
impl FetchPermissions for PermissionsContainer {
fn check_net_url(
&mut self,
_url: &deno_core::url::Url,
_api_name: &str,
) -> Result<(), deno_core::error::AnyError> {
Ok(())
}
fn check_read(
&mut self,
_p: &std::path::Path,
_api_name: &str,
) -> Result<(), deno_core::error::AnyError> {
Ok(())
}
}
impl TimersPermission for PermissionsContainer {
fn allow_hrtime(&mut self) -> bool {
true
}
fn check_unstable(&self, _state: &OpState, _api_name: &'static str) {
()
}
}
deno_core::extension!(
fetch,
esm_entry_point = "ext:fetch/src/runtime.js",
esm = ["src/runtime.js"],
);
fn main() {
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
let exts = vec![
deno_webidl::deno_webidl::init_ops_and_esm(),
deno_url::deno_url::init_ops_and_esm(),
deno_console::deno_console::init_ops_and_esm(),
deno_web::deno_web::init_ops_and_esm::<PermissionsContainer>(BlobStore::default(), None),
deno_fetch::deno_fetch::init_ops_and_esm::<PermissionsContainer>(Default::default()),
fetch::init_ops_and_esm(),
];
// Build the file path to the snapshot.
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let snapshot_path = o.join("FETCH_SNAPSHOT.bin");
// Create the snapshot.
let _ = deno_core::snapshot_util::create_snapshot(
deno_core::snapshot_util::CreateSnapshotOptions {
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
snapshot_path: snapshot_path,
startup_snapshot: None,
extensions: exts,
compression_cb: None,
snapshot_module_load_cb: None,
},
);
}