Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to support latest bazel (0.23.0) #78

Merged
merged 4 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ os:
- osx

env:
- V=0.7.0
- V=0.6.1
- V=0.5.4
- V=0.5.3
- V=0.20.0
- V=0.21.0
- V=0.22.0
- V=0.23.2
- V=0.24.0

before_install:
- OS=linux
Expand Down
12 changes: 6 additions & 6 deletions node/internal/mocha_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def mocha_test(
executable with the name of the testable entrypoint module.

"""

node_module(
name = name + "_module",
main = main,
Expand All @@ -45,12 +45,12 @@ def mocha_test(
"%s_modules" % name,
"node_modules"
]
if PACKAGE_NAME:
entrypoint.insert(0, PACKAGE_NAME)
entrypoint.append(PACKAGE_NAME)

if native.package_name():
entrypoint.insert(0, native.package_name())
entrypoint.append(native.package_name())
entrypoint.append("%s_module" % name)

native.sh_test(
name = name,
srcs = [script],
Expand Down
13 changes: 6 additions & 7 deletions node/internal/node_module.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_node_filetype = FileType([".js", ".node"])
_node_filetype = [".js", ".node"]


def _relname(ctx, root_file, file):
Expand All @@ -13,13 +13,13 @@ def _relname(ctx, root_file, file):
rel = file.path[len(root_file.dirname):]
return rel


if not file.short_path.startswith(ctx.label.package):
fail("_relname failed: %s must start with %s" % (file.short_path, ctx.label.package))

# All others, shave off the package label from the file's short
# path.
rel = file.short_path[len(ctx.label.package):]
rel = file.short_path[len(ctx.label.package):]
if rel.startswith('/'):
rel = rel[1:]

Expand Down Expand Up @@ -65,7 +65,7 @@ def _create_package_json(ctx, name, files, executables):

if executables:
json["bin"] = executables

if ctx.attr.main:
json["main"] = ctx.file.main.basename

Expand Down Expand Up @@ -132,7 +132,7 @@ def _node_module_impl(ctx):
files.append(ctx.file.main)

executables = ctx.attr.executables

package_json = ctx.file.package_json

# The presence of an index file suppresses creation of the
Expand Down Expand Up @@ -226,15 +226,14 @@ node_module = rule(
# the module. If not present, one will be generated UNLESS an
# index file is provided.
"package_json": attr.label(
allow_files = FileType(["package.json"]),
allow_files = ["package.json"],
single_file = True,
),

# Additional data files to be included in the module, but
# excluded from the package.json 'files' attribute.
"data": attr.label_list(
allow_files = True,
cfg = "data",
),

# Module dependencies.
Expand Down
12 changes: 6 additions & 6 deletions node/internal/yarn_modules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def _yarn_modules_impl(ctx):
sha256 = "472add7ad141c75811f93dca421e2b7456045504afacec814b0565f092156250",
stripPrefix = "package",
)

# Copy over or create the package.json file
if ctx.attr.package_json:
package_json_file = ctx.path(ctx.attr.package_json)
execute(ctx, ["cp", package_json_file, "package.json"])
else:
ctx.file("package.json", _create_package_json_content(ctx).to_json())


# Copy the parse_yarn_lock script and yarn.js over here.
execute(ctx, ["cp", parse_yarn_lock_js, "internal/parse_yarn_lock.js"])
execute(ctx, ["cp", clean_node_modules_js, "internal/clean_node_modules.js"])
Expand All @@ -64,7 +64,7 @@ def _yarn_modules_impl(ctx):
fail("Required install tool '%s' is not in the PATH" % tool, "install_tools")
install_path.append(tool_path.dirname)
install_path.append("$PATH")

# Build node_modules via 'yarn install'
execute(ctx, [node, yarn_js, "install"], quiet = True, environment = {
"PATH": ":".join(install_path),
Expand All @@ -73,7 +73,7 @@ def _yarn_modules_impl(ctx):
# Sadly, pre-existing BUILD.bazel files located in npm modules can
# screw up package boudaries. Remove these.
execute(ctx, [node, "internal/clean_node_modules.js"], quiet = True)

# Run the script and save the stdout to our BUILD file(s)
parse_args = ["--resolve=%s:%s" % (k, v) for k, v in ctx.attr.resolutions.items()]
result = execute(ctx, [node, "internal/parse_yarn_lock.js"] + parse_args, quiet = True)
Expand Down Expand Up @@ -130,11 +130,11 @@ yarn_modules = repository_rule(
single_file = True,
),
# If specififed, augment the PATH environment variable with these
# tools during 'yarn install'.
# tools during 'yarn install'.
"install_tools": attr.string_list(),
"package_json": attr.label(
mandatory = False,
allow_files = FileType(["package.json"]),
allow_files = ["package.json"],
),
"post_install": attr.string_list(),
"deps": attr.string_dict(mandatory = False),
Expand Down