diff --git a/.travis.yml b/.travis.yml index 8fae05d073552b..2bb27028464ccc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,7 +72,6 @@ script: - ./tools/lint.py - ./tools/test_format.py - ./tools/build.py -C target/release -- cargo build -p test_plugin --release --locked - DENO_BUILD_MODE=release ./tools/test.py -v jobs: diff --git a/BUILD.gn b/BUILD.gn index 909d04ce590e9e..f5f6b0d5d10c37 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -8,6 +8,7 @@ group("default") { "cli:deno", "core:default", "core/libdeno:libdeno_test", + "tests/plugin:test_plugin", ] } diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index dee8c311c6f41c..9b84648bbabe75 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -122,7 +122,7 @@ template("_rust_crate") { } else if (crate_type == "rlib") { out_file = "lib$crate_name$crate_suffix.rlib" emit_type = "link" - } else if (crate_type == "dylib") { + } else if (crate_type == "dylib" || crate_type == "cdylib") { out_file = "$shared_lib_prefix$crate_name$crate_suffix$shared_lib_suffix" emit_type = "link" } @@ -318,6 +318,13 @@ template("rust_dylib") { } } +template("rust_cdylib") { + _rust_crate(target_name) { + forward_variables_from(invoker, "*") + crate_type = "cdylib" + } +} + template("rust_proc_macro") { _rust_crate(target_name) { forward_variables_from(invoker, "*") diff --git a/cli/BUILD.gn b/cli/BUILD.gn index 9c16f5e9fd4edf..43bb575716662d 100644 --- a/cli/BUILD.gn +++ b/cli/BUILD.gn @@ -20,11 +20,11 @@ main_extern = [ }, ] main_extern_rlib = [ - "dlopen", "ansi_term", "atty", "clap", "dirs", + "dlopen", "flatbuffers", "futures", "fwdansi", diff --git a/js/native_plugins.ts b/js/native_plugins.ts index 54ca352c8cabcc..968b00f20648dc 100644 --- a/js/native_plugins.ts +++ b/js/native_plugins.ts @@ -1,4 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +// TODO rename this file to js/plugins.ts import { sendSync, sendAnySync } from "./dispatch"; import * as msg from "gen/cli/msg_generated"; import * as flatbuffers from "./flatbuffers"; @@ -89,6 +90,7 @@ class PluginOpImpl implements PluginOp { } } +// TODO Rename to pluginOpen function dlOpen(filename: string): number { const builder = flatbuffers.createBuilder(); const filename_ = builder.createString(filename); diff --git a/tests/034_native_plugins.test b/tests/034_native_plugins.test deleted file mode 100644 index d64058d5c1c8a0..00000000000000 --- a/tests/034_native_plugins.test +++ /dev/null @@ -1,2 +0,0 @@ -args: run --reload --allow-plugins --allow-env tests/034_native_plugins.ts -output: tests/034_native_plugins.ts.out \ No newline at end of file diff --git a/tests/034_native_plugins.ts.out b/tests/034_plugin.out similarity index 100% rename from tests/034_native_plugins.ts.out rename to tests/034_plugin.out diff --git a/tests/034_plugin.test b/tests/034_plugin.test new file mode 100644 index 00000000000000..e43037a67c4c4b --- /dev/null +++ b/tests/034_plugin.test @@ -0,0 +1,2 @@ +args: run --reload --allow-plugins --allow-env tests/034_plugin.ts +output: tests/034_plugin.out \ No newline at end of file diff --git a/tests/034_native_plugins.ts b/tests/034_plugin.ts similarity index 94% rename from tests/034_native_plugins.ts rename to tests/034_plugin.ts index 0c75375897cbd3..021c27a729b08b 100644 --- a/tests/034_native_plugins.ts +++ b/tests/034_plugin.ts @@ -1,7 +1,7 @@ const { openPlugin, pluginFilename, env } = Deno; const plugin = openPlugin( - env().DENO_BUILD_PATH + "/" + pluginFilename("test_plugin") + env().DENO_BUILD_PATH + "/rust_crates/" + pluginFilename("test_plugin") ); const testOp = plugin.loadOp("test_op"); diff --git a/tests/plugin/BUILD.gn b/tests/plugin/BUILD.gn new file mode 100644 index 00000000000000..04b0aaf250bc3a --- /dev/null +++ b/tests/plugin/BUILD.gn @@ -0,0 +1,26 @@ +# Users of Deno plugins will not need to provide a BUILD.gn +# this is just to integrate into the build system. +import("//build_extra/rust/rust.gni") + +# TODO(ry) This is placed into (on mac) +# target/debug/rust_crates/libtest_plugin.dylib but the corresponding "cargo +# build" places it in target/debug/libtest_plugin.dylib this discrepancy means +# that tests/034_plugin.test depends on a GN build. +rust_cdylib("test_plugin") { + source_root = "lib.rs" + + # TODO(ry) This should not be necessary, it should come with the extern + # core:deno + args = [ + "-L", + "obj/core/libdeno/", + ] + + extern = [ + { + label = "//core:deno" + crate_name = "deno" + crate_type = "rlib" + }, + ] +} diff --git a/tools/format.py b/tools/format.py index 7f53ff5069bec1..2f8a1e276883d1 100755 --- a/tools/format.py +++ b/tools/format.py @@ -24,8 +24,8 @@ def qrun(cmd, env=None): find_exts(["core"], [".cc", ".h"])) print "gn format" -for fn in ["BUILD.gn", ".gn"] + find_exts(["build_extra", "cli", "core"], - [".gn", ".gni"]): +for fn in ["BUILD.gn", ".gn"] + find_exts( + ["build_extra", "cli", "core", "tests/plugin"], [".gn", ".gni"]): qrun(["third_party/depot_tools/gn", "format", fn], env=google_env()) print "yapf"