summaryrefslogtreecommitdiff
path: root/tools/ts_library_builder/main.ts
blob: e4e2e73edef710ea825be0b228bc77b9a0c40e20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import * as path from "path";
import { main as buildRuntimeLib } from "./build_library";

// this is very simplistic argument parsing, just enough to integrate into
// the build scripts, versus being very robust
let basePath = process.cwd();
let buildPath = path.join(basePath, "target", "debug");
let outFile = path.join(buildPath, "gen", "lib", "lib.d.ts");
let inline: string[] = [];
let debug = false;
let silent = false;

process.argv.forEach((arg, i, argv) => {
  switch (arg) {
    case "--basePath":
      basePath = path.resolve(argv[i + 1]);
      break;
    case "--buildPath":
      buildPath = path.resolve(argv[i + 1]);
      break;
    case "--inline":
      inline = argv[i + 1].split(",").map(filename => {
        return path.resolve(filename);
      });
      break;
    case "--outFile":
      outFile = path.resolve(argv[i + 1]);
      break;
    case "--debug":
      debug = true;
      break;
    case "--silent":
      silent = true;
      break;
  }
});

buildRuntimeLib({
  basePath,
  buildPath,
  debug,
  inline,
  inputs: [
    "node_modules/typescript/lib/lib.esnext.d.ts",
    "js/deno.ts",
    "js/globals.ts"
  ],
  declareAsLet: ["onmessage"],
  outFile,
  silent
});