diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-11-25 13:56:04 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-11-29 17:46:09 -0800 |
commit | 84a1b4d7935c69c3d12aa74b90c7dfb7931b825a (patch) | |
tree | 6fe870ca01e34efb3c35160a59a4f4743ad6caaa /libdeno | |
parent | ea4580f3371c1ef6c3f909e5c28d7f04f01659b8 (diff) |
Move libdeno build config to libdeno/BUILD.gn
Diffstat (limited to 'libdeno')
-rw-r--r-- | libdeno/BUILD.gn | 98 | ||||
-rw-r--r-- | libdeno/deno.gni | 52 |
2 files changed, 150 insertions, 0 deletions
diff --git a/libdeno/BUILD.gn b/libdeno/BUILD.gn new file mode 100644 index 000000000..5cd774eaa --- /dev/null +++ b/libdeno/BUILD.gn @@ -0,0 +1,98 @@ +# Copyright 2018 the Deno authors. All rights reserved. MIT license. +import("./deno.gni") +import("//third_party/v8/gni/v8.gni") + +config("deno_config") { + include_dirs = [ "//third_party/v8" ] # This allows us to v8/src/base/ libraries. + configs = [ "//third_party/v8:external_config" ] + if (is_debug) { + defines = [ "DEBUG" ] + } + if (is_clang) { + cflags = [ + "-fcolor-diagnostics", + "-fansi-escape-codes", + ] + } +} + +v8_static_library("v8") { + public_deps = [ + "//build/win:default_exe_manifest", + "//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_static_library("libdeno") { + configs = [ ":deno_config" ] + sources = [ + "api.cc", + "binding.cc", + "deno.h", + "file_util.cc", + "file_util.h", + "internal.h", + ] + if (!use_prebuilt_v8) { + public_deps = [ + ":v8", + ] + } else { + # TODO(ry) It would be nice to have a standalone target for the prebuilt + # library that could simply be added to the deps here, but it wasn't + # obvious how to accomplish that in gn. + if (is_mac) { + libs = [ "//prebuilt/mac/libv8.a" ] + } else if (is_linux) { + libs = [ "//prebuilt/linux64/libv8.a" ] + } else if (is_win) { + libs = [ "//prebuilt/win/v8.lib" ] + } else { + assert(false, "We don't have prebuilt binaries for this platform yet.") + } + } +} + +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 = [ + ":create_snapshot_libdeno_test", + ":libdeno", + "//testing/gtest:gtest", + ] + data = [ + "$target_gen_dir/snapshot_libdeno_test.bin", + ] + snapshot_path = rebase_path(data[0], root_build_dir) + defines = [ "SNAPSHOT_PATH=\"$snapshot_path\"" ] + configs = [ ":deno_config" ] +} + +# Generates $target_gen_dir/snapshot_libdeno_test.bin +create_snapshot("libdeno_test") { + testonly = true + js = "libdeno_test.js" +} diff --git a/libdeno/deno.gni b/libdeno/deno.gni new file mode 100644 index 000000000..55662145f --- /dev/null +++ b/libdeno/deno.gni @@ -0,0 +1,52 @@ +# Copyright 2018 the Deno authors. All rights reserved. MIT license. +import("//build/compiled_action.gni") + +declare_args() { + # Use prebuilt V8 libraries from //prebuilt/ + use_prebuilt_v8 = true +} + +template("run_node") { + action(target_name) { + forward_variables_from(invoker, "*") + script = "//tools/run_node.py" + } +} + +# Template to generate different V8 snapshots based on different runtime flags. +# Can be invoked with run_mksnapshot(<name>). The target will resolve to +# run_mksnapshot_<name>. If <name> is "default", no file suffixes will be used. +# Otherwise files are suffixed, e.g. embedded_<name>.cc and +# snapshot_blob_<name>.bin. +# +# The template exposes the variables: +# args: additional flags for mksnapshots +# embedded_suffix: a camel case suffix for method names in the embedded +# snapshot. +template("create_snapshot") { + name = target_name + compiled_action("create_snapshot_" + name) { + forward_variables_from(invoker, + [ + "testonly", + "deps", + ]) + tool = "//libdeno:snapshot_creator" + visibility = [ ":*" ] # Only targets in this file can depend on this. + snapshot_out_bin = "$target_gen_dir/snapshot_$name.bin" + inputs = [ + invoker.js, + ] + if (defined(invoker.source_map)) { + inputs += [ invoker.source_map ] + } + outputs = [ + snapshot_out_bin, + ] + args = rebase_path(outputs, root_build_dir) + + rebase_path(inputs, root_build_dir) + + # To debug snapshotting problems: + # args += ["--trace-serializer"] + } +} |