Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric05 committed Oct 12, 2018
2 parents a777795 + c9f95d5 commit 548ee9d
Show file tree
Hide file tree
Showing 58 changed files with 2,408 additions and 258 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ cache:
- third_party/v8/build/linux/debian_sid_amd64-sysroot/
- third_party/v8/third_party/llvm-build/
install:
- nvm install v8
- nvm use --delete-prefix v8
- node -v
- |-
# OS X: install a private copy of homebrew.
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
Expand Down
29 changes: 18 additions & 11 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ts_sources = [
"js/libdeno.ts",
"js/main.ts",
"js/make_temp_dir.ts",
"js/metrics.ts",
"js/mkdir.ts",
"js/mock_builtin.js",
"js/net.ts",
Expand All @@ -107,7 +108,6 @@ ts_sources = [
"js/v8_source_maps.ts",
"js/write_file.ts",

"js/tsconfig.declarations.json",
"tsconfig.json",

# Listing package.json and yarn.lock as sources ensures the bundle is rebuilt
Expand Down Expand Up @@ -246,26 +246,33 @@ executable("snapshot_creator") {
configs += [ ":deno_config" ]
}

# Generates type declarations for files that need to be included
# in the runtime bundle
run_node("gen_declarations") {
# Generates the core TypeScript type library for deno that will be
# included in the runtime bundle
run_node("deno_runtime_declaration") {
out_dir = target_gen_dir
sources = ts_sources
outputs = [
"$out_dir/types/globals.d.ts",
"$out_dir/lib/lib.deno_runtime.d.ts",
]
deps = [
":msg_ts",
]
args = [
"./node_modules/typescript/bin/tsc",
"-p",
rebase_path("js/tsconfig.declarations.json", root_build_dir),
"--baseUrl",
rebase_path("node_modules/.bin/ts-node", root_build_dir),
"--project",
rebase_path("tools/ts_library_builder/tsconfig.json"),
rebase_path("tools/ts_library_builder/main.ts", root_build_dir),
"--basePath",
rebase_path(".", root_build_dir),
"--buildPath",
rebase_path(root_build_dir, root_build_dir),
"--outFile",
rebase_path("$out_dir/types/globals.js", root_build_dir),
rebase_path("$out_dir/lib/lib.deno_runtime.d.ts", root_build_dir),
"--silent",
]
if (is_debug) {
args += [ "--debug" ]
}
}

run_node("bundle") {
Expand All @@ -276,7 +283,7 @@ run_node("bundle") {
out_dir + "main.js.map",
]
deps = [
":gen_declarations",
":deno_runtime_declaration",
":msg_ts",
]
args = [
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ dirs = "1.0.3"
flatbuffers = { path = "third_party/flatbuffers/rust/flatbuffers/" }
futures = "0.1.23"
hyper = "0.12.9"
hyper-rustls = "0.14.0"
# The current version of hyper-rustls, 0.14.0, depends on tokio-core, which is
# deprecated.
hyper-rustls = { git = "https://github.com/ctz/hyper-rustls.git" }
libc = "0.2.42"
log = "0.4.4"
rand = "0.4.3"
Expand Down
8 changes: 4 additions & 4 deletions Roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ API and Feature requests should be submitted as PRs to this document.

### Implementation of `cat`

#721
[#721](https://github.com/denoland/deno/issues/721)

```ts
import * as deno from "deno";
Expand All @@ -20,7 +20,7 @@ for (let i = 1; i < deno.argv.length; i++) {

### TCP Server

#725
[#725](https://github.com/denoland/deno/issues/725)

```ts
import * as deno from "deno";
Expand Down Expand Up @@ -199,13 +199,13 @@ compatibility with Node.

#### Top-level Await (Not Implemented)

#471
[#471](https://github.com/denoland/deno/issues/471)

This will be put off until at least deno2 Milestone1 is complete. One of the
major problems is that top-level await calls are not syntactically valid
TypeScript.

#### I/O (Not Implemented) #721
#### I/O (Not Implemented) [#721](https://github.com/denoland/deno/issues/721)

There are many OS constructs that perform I/O: files, sockets, pipes. Deno aims
to provide a unified lowest common denominator interface to work with these
Expand Down
21 changes: 2 additions & 19 deletions build_extra/rust/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -476,23 +476,6 @@ rust_crate("hyper") {
]
}

rust_crate("tokio_core") {
source_root = "$registry_github/tokio-core-0.1.17/src/lib.rs"
extern = [
":mio",
":futures",
":tokio",
":tokio_executor",
":tokio_reactor",
":tokio_timer",
":tokio_io",
":log",
":iovec",
":bytes",
":scoped_tls",
]
}

rust_crate("h2") {
source_root = "$registry_github/h2-0.1.12/src/lib.rs"
extern = [
Expand Down Expand Up @@ -709,14 +692,14 @@ rust_crate("tokio_current_thread") {
}

rust_crate("hyper_rustls") {
source_root = "$registry_github/hyper-rustls-0.14.0/src/lib.rs"
source_root =
"$crates/git/checkouts/hyper-rustls-d4ca51501db57c63/2c536d5/src/lib.rs"
extern = [
":ct_logs",
":futures",
":http",
":hyper",
":rustls",
":tokio_core",
":tokio_io",
":tokio_rustls",
":tokio_tcp",
Expand Down
6 changes: 2 additions & 4 deletions js/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// tslint:disable:max-line-length

// Generated default library
import globalsDts from "gen/types/globals.d.ts!string";
import libDts from "gen/lib/lib.deno_runtime.d.ts!string";

// Static libraries
import libEs2015Dts from "/third_party/node_modules/typescript/lib/lib.es2015.d.ts!string";
Expand Down Expand Up @@ -40,15 +40,14 @@ import libEsnextIntlDts from "/third_party/node_modules/typescript/lib/lib.esnex
import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esnext.symbol.d.ts!string";

// Static definitions
import flatbuffersDts from "/third_party/node_modules/@types/flatbuffers/index.d.ts!string";
import textEncodingDts from "/third_party/node_modules/@types/text-encoding/index.d.ts!string";
import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d.ts!string";
// tslint:enable:max-line-length

// @internal
export const assetSourceCode: { [key: string]: string } = {
// Generated library
"globals.d.ts": globalsDts,
"lib.deno_runtime.d.ts": libDts,

// Static libraries
"lib.es2015.collection.d.ts": libEs2015CollectionDts,
Expand Down Expand Up @@ -81,7 +80,6 @@ export const assetSourceCode: { [key: string]: string } = {
"lib.esnext.symbol.d.ts": libEsnextSymbolDts,

// Static definitions
"flatbuffers.d.ts": flatbuffersDts,
"text-encoding.d.ts": textEncodingDts,
"typescript.d.ts": typescriptDts
};
7 changes: 4 additions & 3 deletions js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as sourceMaps from "./v8_source_maps";

const EOL = "\n";
const ASSETS = "$asset$";
const LIB_RUNTIME = "lib.deno_runtime.d.ts";

// tslint:disable:no-any
type AmdCallback = (...args: any[]) => void;
Expand Down Expand Up @@ -619,7 +620,7 @@ export class DenoCompiler

getDefaultLibFileName(): string {
this._log("getDefaultLibFileName()");
const moduleSpecifier = "globals.d.ts";
const moduleSpecifier = LIB_RUNTIME;
const moduleMetaData = this.resolveModule(moduleSpecifier, ASSETS);
return moduleMetaData.fileName;
}
Expand Down Expand Up @@ -649,8 +650,8 @@ export class DenoCompiler
return moduleNames.map(name => {
let resolvedFileName;
if (name === "deno") {
// builtin modules are part of `globals.d.ts`
resolvedFileName = this._resolveModuleName("globals.d.ts", ASSETS);
// builtin modules are part of the runtime lib
resolvedFileName = this._resolveModuleName(LIB_RUNTIME, ASSETS);
} else if (name === "typescript") {
resolvedFileName = this._resolveModuleName("typescript.d.ts", ASSETS);
} else {
Expand Down
9 changes: 6 additions & 3 deletions js/compiler_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,10 @@ test(function compilerGetCurrentDirectory() {

test(function compilerGetDefaultLibFileName() {
setup();
assertEqual(compilerInstance.getDefaultLibFileName(), "$asset$/globals.d.ts");
assertEqual(
compilerInstance.getDefaultLibFileName(),
"$asset$/lib.deno_runtime.d.ts"
);
teardown();
});

Expand All @@ -572,7 +575,7 @@ test(function compilerFileExists() {
"/root/project"
);
assert(compilerInstance.fileExists(moduleMetaData.fileName));
assert(compilerInstance.fileExists("$asset$/globals.d.ts"));
assert(compilerInstance.fileExists("$asset$/lib.deno_runtime.d.ts"));
assertEqual(
compilerInstance.fileExists("/root/project/unknown-module.ts"),
false
Expand All @@ -590,7 +593,7 @@ test(function compilerResolveModuleNames() {
const fixtures: Array<[string, boolean]> = [
["/root/project/foo/bar.ts", false],
["/root/project/foo/baz.ts", false],
["$asset$/globals.d.ts", true]
["$asset$/lib.deno_runtime.d.ts", true]
];
for (let i = 0; i < results.length; i++) {
const result = results[i];
Expand Down
1 change: 1 addition & 0 deletions js/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export { trace } from "./trace";
export { truncateSync, truncate } from "./truncate";
export { FileInfo } from "./file_info";
export { connect, dial, listen, Listener, Conn } from "./net";
export { metrics } from "./metrics";
export const args: string[] = [];

// Provide the compiler API in an obfuscated way
Expand Down
24 changes: 12 additions & 12 deletions js/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import { assert } from "./util";
import { flatbuffers } from "flatbuffers";

export class File implements Reader, Writer, Closer {
constructor(readonly fd: number) {}
constructor(readonly rid: number) {}

write(p: ArrayBufferView): Promise<number> {
return write(this.fd, p);
return write(this.rid, p);
}

read(p: ArrayBufferView): Promise<ReadResult> {
return read(this.fd, p);
return read(this.rid, p);
}

close(): void {
close(this.fd);
close(this.rid);
}
}

Expand Down Expand Up @@ -47,17 +47,17 @@ export async function open(
assert(msg.Any.OpenRes === baseRes!.innerType());
const res = new msg.OpenRes();
assert(baseRes!.inner(res) != null);
const fd = res.rid();
return new File(fd);
const rid = res.rid();
return new File(rid);
}

export async function read(
fd: number,
rid: number,
p: ArrayBufferView
): Promise<ReadResult> {
const builder = new flatbuffers.Builder();
msg.Read.startRead(builder);
msg.Read.addRid(builder, fd);
msg.Read.addRid(builder, rid);
const inner = msg.Read.endRead(builder);
const baseRes = await dispatch.sendAsync(builder, msg.Any.Read, inner, p);
assert(baseRes != null);
Expand All @@ -67,10 +67,10 @@ export async function read(
return { nread: res.nread(), eof: res.eof() };
}

export async function write(fd: number, p: ArrayBufferView): Promise<number> {
export async function write(rid: number, p: ArrayBufferView): Promise<number> {
const builder = new flatbuffers.Builder();
msg.Write.startWrite(builder);
msg.Write.addRid(builder, fd);
msg.Write.addRid(builder, rid);
const inner = msg.Write.endWrite(builder);
const baseRes = await dispatch.sendAsync(builder, msg.Any.Write, inner, p);
assert(baseRes != null);
Expand All @@ -80,10 +80,10 @@ export async function write(fd: number, p: ArrayBufferView): Promise<number> {
return res.nbyte();
}

export function close(fd: number): void {
export function close(rid: number): void {
const builder = new flatbuffers.Builder();
msg.Close.startClose(builder);
msg.Close.addRid(builder, fd);
msg.Close.addRid(builder, rid);
const inner = msg.Close.endClose(builder);
dispatch.sendSync(builder, msg.Any.Close, inner);
}
8 changes: 4 additions & 4 deletions js/files_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import * as deno from "deno";
import { test, assert, assertEqual } from "./test_util.ts";

test(function filesStdioFileDescriptors() {
assertEqual(deno.stdin.fd, 0);
assertEqual(deno.stdout.fd, 1);
assertEqual(deno.stderr.fd, 2);
assertEqual(deno.stdin.rid, 0);
assertEqual(deno.stdout.rid, 1);
assertEqual(deno.stderr.rid, 2);
});

test(async function filesCopyToStdout() {
const filename = "package.json";
const file = await deno.open(filename);
assert(file.fd > 2);
assert(file.rid > 2);
const bytesWritten = await deno.copy(deno.stdout, file);
const fileSize = deno.statSync(filename).len;
assertEqual(bytesWritten, fileSize);
Expand Down
Loading

0 comments on commit 548ee9d

Please sign in to comment.