Skip to content

Commit

Permalink
Add //tests/plugin/BUILD.gn
Browse files Browse the repository at this point in the history
  • Loading branch information
ry authored and afinch7 committed Jun 26, 2019
1 parent 1c162f7 commit 49817d0
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 8 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ group("default") {
"cli:deno",
"core:default",
"core/libdeno:libdeno_test",
"tests/plugin:test_plugin",
]
}

Expand Down
9 changes: 8 additions & 1 deletion build_extra/rust/rust.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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, "*")
Expand Down
2 changes: 1 addition & 1 deletion cli/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ main_extern = [
},
]
main_extern_rlib = [
"dlopen",
"ansi_term",
"atty",
"clap",
"dirs",
"dlopen",
"flatbuffers",
"futures",
"fwdansi",
Expand Down
2 changes: 2 additions & 0 deletions js/native_plugins.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions tests/034_native_plugins.test

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions tests/034_plugin.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
args: run --reload --allow-plugins --allow-env tests/034_plugin.ts
output: tests/034_plugin.out
2 changes: 1 addition & 1 deletion tests/034_native_plugins.ts → tests/034_plugin.ts
Original file line number Diff line number Diff line change
@@ -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");

Expand Down
26 changes: 26 additions & 0 deletions tests/plugin/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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"
},
]
}
4 changes: 2 additions & 2 deletions tools/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 49817d0

Please sign in to comment.