summaryrefslogtreecommitdiff
path: root/libdeno/BUILD.gn
blob: 39a024c41c492d000a4a9e8bcde88d671ba36933 (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
101
102
103
104
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
import("//third_party/v8/gni/v8.gni")
import("./deno.gni")

config("deno_config") {
  include_dirs = [ "//third_party/v8" ]  # This allows us to v8/src/base/ libraries.
  configs = [ "//third_party/v8:external_config" ]
  cflags = []

  if (is_debug) {
    defines = [ "DEBUG" ]
  }

  if (is_clang) {
    cflags += [
      "-fcolor-diagnostics",
      "-fansi-escape-codes",
    ]
    if (is_debug) {
      cflags += [ "-glldb" ]
    }
  }

  if (is_win) {
    # The `/Zl` ("omit default library name") flag makes the compiler produce
    # object files that can link with both the static and dynamic CRT.
    cflags += [ "/Zl" ]
  }
}

v8_source_set("v8") {
  deps = [
    "//third_party/v8:v8",
    "//third_party/v8:v8_libbase",
    "//third_party/v8:v8_libplatform",
    "//third_party/v8:v8_libsampler",
  ]
  configs = [ ":deno_config" ]
}

# Only functionality needed for libdeno_test and snapshot_creator
# In particular no flatbuffers, no assets, no rust, no msg handlers.
# Because snapshots are slow, it's important that snapshot_creator's
# dependencies are minimal.
v8_source_set("libdeno") {
  sources = [
    "api.cc",
    "binding.cc",
    "deno.h",
    "file_util.cc",
    "file_util.h",
    "internal.h",
  ]
  deps = [
    ":v8",
  ]
  configs = [ ":deno_config" ]
}

# The cargo-driven build links with libdeno to pull in all non-rust code.
v8_static_library("libdeno_static_lib") {
  output_name = "libdeno"
  deps = [
    ":libdeno",
    "//build/config:shared_library_deps",
  ]
  configs = [ ":deno_config" ]
}

v8_executable("snapshot_creator") {
  sources = [
    "snapshot_creator.cc",
  ]
  deps = [
    ":libdeno",
  ]
  configs = [ ":deno_config" ]
}

v8_executable("test_cc") {
  testonly = true
  sources = [
    "file_util_test.cc",
    "libdeno_test.cc",
    "test.cc",
  ]
  deps = [
    ":libdeno",
    ":snapshot_test",
    "//testing/gtest:gtest",
  ]
  data = [
    "$target_gen_dir/snapshot_test.bin",
  ]
  snapshot_path = rebase_path(data[0], root_build_dir)
  defines = [ "SNAPSHOT_PATH=\"$snapshot_path\"" ]
  configs = [ ":deno_config" ]
}

# Generates $target_gen_dir/snapshot_test.bin
snapshot("snapshot_test") {
  testonly = true
  source_root = "libdeno_test.js"
}