Skip to content

Commit

Permalink
examples: add example and test
Browse files Browse the repository at this point in the history
  • Loading branch information
mgred committed Dec 30, 2023
1 parent dee9789 commit fa22b8f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("//quickjs:qjs.bzl", "qjs_binary")
load(":generate.bzl", "generate_message")

qjs_binary(
name = "hello_world",
entry_point = ":hello_world.js",
)

generate_message(
name = "msg",
message = "Hello, World",
)

diff_test(
name = "generate_message_test",
file1 = ":msg",
file2 = ":generate_message.txt",
)
10 changes: 10 additions & 0 deletions examples/generate.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"Example using @bzlparty_quickjs//:qjs in `genrule`"

def generate_message(name, message):
"Generate a file with a given message"
native.genrule(
name = name,
outs = ["%s.out" % name],
cmd = "$(locations @bzlparty_quickjs//:qjs) --eval 'console.log(\"%s\")' > $(OUTS)" % message,
tools = ["@bzlparty_quickjs//:qjs"],
)
1 change: 1 addition & 0 deletions examples/generate_message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World

0 comments on commit fa22b8f

Please sign in to comment.