summaryrefslogtreecommitdiff
path: root/cli/BUILD.gn
blob: ce18eb2974e2a52f12679060b977fda88f36fcfd (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import("//build/toolchain/cc_wrapper.gni")
import("//build_extra/rust/rust.gni")

main_extern = [
  {
    label = "../core:deno"
    crate_name = "deno"
    crate_type = "rlib"
  },
  {
    label = "../cli_snapshots:deno_cli_snapshots"
    crate_name = "deno_cli_snapshots"
    crate_type = "rlib"
  },
  {
    label = "../deno_typescript:deno_typescript"
    crate_name = "deno_typescript"
    crate_type = "rlib"
  },
  {
    label = "$rust_build:serde_derive"
    crate_name = "serde_derive"
    crate_type = "proc_macro"
  },
]
main_extern_rlib = [
  "ansi_term",
  "atty",
  "clap",
  "dirs",
  "futures",
  "http",
  "hyper",
  "hyper_rustls",
  "indexmap",
  "lazy_static",
  "libc",
  "log",
  "rand",
  "regex",
  "remove_dir_all",
  "reqwest",
  "ring",
  "rustyline",
  "serde",
  "serde_json",
  "source_map_mappings",
  "tempfile",
  "termcolor",
  "tokio",
  "tokio_executor",
  "tokio_fs",
  "tokio_io",
  "tokio_process",
  "tokio_rustls",
  "tokio_threadpool",
  "url",
  "utime",
]
if (is_win) {
  main_extern_rlib += [
    "fwdansi",
    "winapi",
  ]
}
if (is_posix) {
  main_extern_rlib += [ "nix" ]
}

# Reads the cargo info from Cargo.toml
deno_cargo_info = exec_script("../build_extra/rust/get_cargo_info.py",
                              [ rebase_path("Cargo.toml", root_build_dir) ],
                              "json")

rust_executable("deno") {
  source_root = "main.rs"
  extern = main_extern
  extern_rlib = main_extern_rlib

  # Extract version from Cargo.toml
  # TODO integrate this into rust.gni by allowing the rust_executable template
  # to specify a cargo.toml from which it will extract a version.
  inputs = [
    "Cargo.toml",
  ]
  env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
}

rust_test("cli_test") {
  source_root = "main.rs"
  extern = main_extern
  extern_rlib = main_extern_rlib

  # Extract version from Cargo.toml
  inputs = [
    "Cargo.toml",
  ]
  env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
}