@@ -4,8 +4,6 @@ use std::env;
4
4
use std:: path:: PathBuf ;
5
5
6
6
use deno_core:: snapshot_util:: * ;
7
- use deno_core:: ExtensionFileSource ;
8
- use deno_core:: ExtensionFileSourceCode ;
9
7
use deno_runtime:: * ;
10
8
11
9
mod ts {
@@ -318,36 +316,9 @@ mod ts {
318
316
}
319
317
}
320
318
321
- // Duplicated in `ops/mod.rs`. Keep in sync!
322
- deno_core:: extension!(
323
- cli,
324
- deps = [ runtime] ,
325
- esm_entry_point = "ext:cli/99_main.js" ,
326
- esm = [
327
- dir "js" ,
328
- "99_main.js"
329
- ] ,
330
- customizer = |ext: & mut deno_core:: Extension | {
331
- ext. esm_files. to_mut( ) . push( ExtensionFileSource {
332
- specifier: "ext:cli/runtime/js/99_main.js" ,
333
- code: ExtensionFileSourceCode :: LoadedFromFsDuringSnapshot (
334
- deno_runtime:: js:: PATH_FOR_99_MAIN_JS ,
335
- ) ,
336
- } ) ;
337
- }
338
- ) ;
339
-
340
319
#[ cfg( not( feature = "__runtime_js_sources" ) ) ]
341
- #[ must_use = "The files listed by create_cli_snapshot should be printed as 'cargo:rerun-if-changed' lines" ]
342
- fn create_cli_snapshot ( snapshot_path : PathBuf ) -> CreateSnapshotOutput {
343
- use deno_core:: Extension ;
344
- use deno_runtime:: deno_cache:: SqliteBackedCache ;
345
- use deno_runtime:: deno_cron:: local:: LocalCronHandler ;
346
- use deno_runtime:: deno_http:: DefaultHttpPropertyExtractor ;
347
- use deno_runtime:: deno_kv:: sqlite:: SqliteDbHandler ;
320
+ fn create_cli_snapshot ( snapshot_path : PathBuf ) {
348
321
use deno_runtime:: ops:: bootstrap:: SnapshotOptions ;
349
- use deno_runtime:: permissions:: PermissionsContainer ;
350
- use std:: sync:: Arc ;
351
322
352
323
// NOTE(bartlomieju): keep in sync with `cli/version.rs`.
353
324
// Ideally we could deduplicate that code.
@@ -359,76 +330,17 @@ fn create_cli_snapshot(snapshot_path: PathBuf) -> CreateSnapshotOutput {
359
330
}
360
331
}
361
332
362
- // NOTE(bartlomieju): ordering is important here, keep it in sync with
363
- // `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/build.rs`!
364
- let fs = Arc :: new ( deno_fs:: RealFs ) ;
365
- let extensions: Vec < Extension > = vec ! [
366
- deno_webidl:: deno_webidl:: init_ops( ) ,
367
- deno_console:: deno_console:: init_ops( ) ,
368
- deno_url:: deno_url:: init_ops( ) ,
369
- deno_web:: deno_web:: init_ops:: <PermissionsContainer >(
370
- Default :: default ( ) ,
371
- Default :: default ( ) ,
372
- ) ,
373
- deno_fetch:: deno_fetch:: init_ops:: <PermissionsContainer >( Default :: default ( ) ) ,
374
- deno_cache:: deno_cache:: init_ops:: <SqliteBackedCache >( None ) ,
375
- deno_websocket:: deno_websocket:: init_ops:: <PermissionsContainer >(
376
- "" . to_owned( ) ,
377
- None ,
378
- None ,
379
- ) ,
380
- deno_webstorage:: deno_webstorage:: init_ops( None ) ,
381
- deno_crypto:: deno_crypto:: init_ops( None ) ,
382
- deno_broadcast_channel:: deno_broadcast_channel:: init_ops(
383
- deno_broadcast_channel:: InMemoryBroadcastChannel :: default ( ) ,
384
- ) ,
385
- deno_ffi:: deno_ffi:: init_ops:: <PermissionsContainer >( ) ,
386
- deno_net:: deno_net:: init_ops:: <PermissionsContainer >( None , None ) ,
387
- deno_tls:: deno_tls:: init_ops( ) ,
388
- deno_kv:: deno_kv:: init_ops( SqliteDbHandler :: <PermissionsContainer >:: new(
389
- None , None ,
390
- ) ) ,
391
- deno_cron:: deno_cron:: init_ops( LocalCronHandler :: new( ) ) ,
392
- deno_napi:: deno_napi:: init_ops:: <PermissionsContainer >( ) ,
393
- deno_http:: deno_http:: init_ops:: <DefaultHttpPropertyExtractor >( ) ,
394
- deno_io:: deno_io:: init_ops( Default :: default ( ) ) ,
395
- deno_fs:: deno_fs:: init_ops:: <PermissionsContainer >( fs. clone( ) ) ,
396
- deno_node:: deno_node:: init_ops:: <PermissionsContainer >( None , fs) ,
397
- deno_runtime:: runtime:: init_ops( ) ,
398
- deno_runtime:: ops:: runtime:: deno_runtime:: init_ops(
399
- "deno:runtime" . parse( ) . unwrap( ) ,
400
- ) ,
401
- deno_runtime:: ops:: worker_host:: deno_worker_host:: init_ops(
402
- Arc :: new( |_| unreachable!( "not used in snapshot." ) ) ,
403
- None ,
404
- ) ,
405
- deno_runtime:: ops:: fs_events:: deno_fs_events:: init_ops( ) ,
406
- deno_runtime:: ops:: os:: deno_os:: init_ops( Default :: default ( ) ) ,
407
- deno_runtime:: ops:: permissions:: deno_permissions:: init_ops( ) ,
408
- deno_runtime:: ops:: process:: deno_process:: init_ops( ) ,
409
- deno_runtime:: ops:: signal:: deno_signal:: init_ops( ) ,
410
- deno_runtime:: ops:: tty:: deno_tty:: init_ops( ) ,
411
- deno_runtime:: ops:: http:: deno_http_runtime:: init_ops( ) ,
412
- deno_runtime:: ops:: bootstrap:: deno_bootstrap:: init_ops( Some (
413
- SnapshotOptions {
414
- deno_version: deno_version( ) ,
415
- ts_version: ts:: version( ) ,
416
- v8_version: deno_core:: v8_version( ) ,
417
- target: std:: env:: var( "TARGET" ) . unwrap( ) ,
418
- } ,
419
- ) ) ,
420
- cli:: init_ops_and_esm( ) , // NOTE: This needs to be init_ops_and_esm!
421
- ] ;
422
-
423
- create_snapshot ( CreateSnapshotOptions {
424
- cargo_manifest_dir : env ! ( "CARGO_MANIFEST_DIR" ) ,
333
+ let snapshot_options = SnapshotOptions {
334
+ deno_version : deno_version ( ) ,
335
+ ts_version : ts:: version ( ) ,
336
+ v8_version : deno_core:: v8_version ( ) ,
337
+ target : std:: env:: var ( "TARGET" ) . unwrap ( ) ,
338
+ } ;
339
+
340
+ deno_runtime:: snapshot:: create_runtime_snapshot (
425
341
snapshot_path,
426
- startup_snapshot : deno_runtime:: js:: deno_isolate_init ( ) ,
427
- extensions,
428
- compression_cb : None ,
429
- with_runtime_cb : None ,
430
- skip_op_registration : false ,
431
- } )
342
+ snapshot_options,
343
+ ) ;
432
344
}
433
345
434
346
fn git_commit_hash ( ) -> String {
@@ -539,10 +451,7 @@ fn main() {
539
451
#[ cfg( not( feature = "__runtime_js_sources" ) ) ]
540
452
{
541
453
let cli_snapshot_path = o. join ( "CLI_SNAPSHOT.bin" ) ;
542
- let output = create_cli_snapshot ( cli_snapshot_path) ;
543
- for path in output. files_loaded_during_snapshot {
544
- println ! ( "cargo:rerun-if-changed={}" , path. display( ) )
545
- }
454
+ create_cli_snapshot ( cli_snapshot_path) ;
546
455
}
547
456
548
457
#[ cfg( target_os = "windows" ) ]
0 commit comments