2018-09-17 17:41:13 -07:00
|
|
|
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
2018-07-23 14:13:12 -04:00
|
|
|
extern crate flatbuffers;
|
2018-08-09 12:17:08 -07:00
|
|
|
extern crate futures;
|
2018-08-15 20:57:36 -04:00
|
|
|
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;
|
2018-08-09 12:17:08 -07:00
|
|
|
extern crate tokio;
|
2018-07-23 14:13:12 -04:00
|
|
|
extern crate url;
|
2018-07-26 17:54:22 -04:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2018-09-13 23:04:02 -07:00
|
|
|
extern crate dirs;
|
2018-08-28 13:49:19 -04:00
|
|
|
extern crate hyper_rustls;
|
2018-09-10 20:40:03 -07:00
|
|
|
extern crate remove_dir_all;
|
2018-08-28 13:49:19 -04:00
|
|
|
extern crate ring;
|
2018-07-26 17:54:22 -04:00
|
|
|
|
|
|
|
mod deno_dir;
|
2018-08-15 23:36:48 -04:00
|
|
|
mod errors;
|
2018-08-17 16:34:30 -04:00
|
|
|
mod flags;
|
2018-07-26 17:54:22 -04:00
|
|
|
mod fs;
|
|
|
|
pub mod handlers;
|
2018-09-17 17:41:13 -07:00
|
|
|
mod isolate;
|
2018-09-04 18:56:12 -04:00
|
|
|
mod libdeno;
|
2018-08-14 16:50:53 -04:00
|
|
|
mod net;
|
2018-08-17 16:34:30 -04:00
|
|
|
mod version;
|
2018-07-04 14:50:28 -04:00
|
|
|
|
2018-09-17 17:41:13 -07:00
|
|
|
use isolate::Isolate;
|
2018-07-25 18:27:27 -07:00
|
|
|
use std::env;
|
2018-07-26 17:37:09 -04:00
|
|
|
|
|
|
|
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()
|
2018-07-26 17:37:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn log(&self, record: &log::Record) {
|
|
|
|
if self.enabled(record.metadata()) {
|
2018-08-17 16:34:30 -04:00
|
|
|
println!("{} RS - {}", record.level(), record.args());
|
2018-07-26 17:37:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fn flush(&self) {}
|
|
|
|
}
|
|
|
|
|
2018-06-16 01:43:23 +02:00
|
|
|
fn main() {
|
2018-07-26 17:37:09 -04:00
|
|
|
log::set_logger(&LOGGER).unwrap();
|
2018-07-16 23:25:50 -04:00
|
|
|
|
2018-08-17 16:34:30 -04:00
|
|
|
let js_args = flags::v8_set_flags(env::args().collect());
|
2018-06-22 23:19:43 +02:00
|
|
|
|
2018-09-17 17:41:13 -07:00
|
|
|
let mut isolate = Isolate::new(js_args);
|
2018-06-22 23:19:43 +02:00
|
|
|
|
2018-09-17 17:41:13 -07:00
|
|
|
if isolate.flags.help {
|
2018-08-17 16:34:30 -04:00
|
|
|
flags::print_usage();
|
|
|
|
std::process::exit(0);
|
|
|
|
}
|
|
|
|
|
2018-09-17 17:41:13 -07:00
|
|
|
if isolate.flags.version {
|
2018-08-17 16:34:30 -04:00
|
|
|
version::print_version();
|
|
|
|
std::process::exit(0);
|
|
|
|
}
|
|
|
|
|
2018-09-17 17:41:13 -07:00
|
|
|
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);
|
2018-08-17 16:34:30 -04:00
|
|
|
|
2018-09-17 17:41:13 -07:00
|
|
|
isolate
|
|
|
|
.execute("deno_main.js", "denoMain();")
|
2018-07-19 21:14:32 -04:00
|
|
|
.unwrap_or_else(|err| {
|
|
|
|
error!("{}", err);
|
|
|
|
std::process::exit(1);
|
|
|
|
});
|
2018-08-09 12:17:08 -07:00
|
|
|
|
|
|
|
// Start the Tokio event loop
|
2018-09-17 17:41:13 -07:00
|
|
|
isolate.rt.run().expect("err");
|
2018-06-16 01:43:23 +02:00
|
|
|
}
|