0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-30 11:15:13 -05:00
denoland-deno/src/main.rs

81 lines
1.6 KiB
Rust
Raw Normal View History

// Copyright 2018 the Deno authors. All rights reserved. MIT license.
extern crate flatbuffers;
extern crate futures;
extern crate hyper;
2018-07-26 17:54:22 -04:00
extern crate libc;
2018-09-09 19:21:22 -04:00
extern crate msg_rs as msg;
2018-08-24 00:36:45 +02:00
extern crate rand;
2018-07-24 01:45:23 -04:00
extern crate tempfile;
extern crate tokio;
extern crate url;
2018-07-26 17:54:22 -04:00
#[macro_use]
extern crate log;
extern crate dirs;
extern crate hyper_rustls;
extern crate remove_dir_all;
extern crate ring;
2018-07-26 17:54:22 -04:00
mod deno_dir;
mod errors;
mod flags;
2018-07-26 17:54:22 -04:00
mod fs;
pub mod handlers;
mod isolate;
mod libdeno;
mod net;
mod version;
2018-07-04 14:50:28 -04:00
use isolate::Isolate;
2018-07-25 18:27:27 -07:00
use std::env;
static LOGGER: Logger = Logger;
struct Logger;
impl log::Log for Logger {
fn enabled(&self, metadata: &log::Metadata) -> bool {
2018-08-07 13:33:36 -04:00
metadata.level() <= log::max_level()
}
fn log(&self, record: &log::Record) {
if self.enabled(record.metadata()) {
println!("{} RS - {}", record.level(), record.args());
}
}
fn flush(&self) {}
}
2018-06-16 01:43:23 +02:00
fn main() {
log::set_logger(&LOGGER).unwrap();
2018-07-16 23:25:50 -04:00
let js_args = flags::v8_set_flags(env::args().collect());
2018-06-22 23:19:43 +02:00
let mut isolate = Isolate::new(js_args);
2018-06-22 23:19:43 +02:00
if isolate.flags.help {
flags::print_usage();
std::process::exit(0);
}
if isolate.flags.version {
version::print_version();
std::process::exit(0);
}
let mut log_level = log::LevelFilter::Info;
if isolate.flags.log_debug {
2018-09-03 00:04:44 +09:00
log_level = log::LevelFilter::Debug;
}
log::set_max_level(log_level);
isolate
.execute("deno_main.js", "denoMain();")
.unwrap_or_else(|err| {
error!("{}", err);
std::process::exit(1);
});
// Start the Tokio event loop
isolate.rt.run().expect("err");
2018-06-16 01:43:23 +02:00
}