-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b5f8047
Showing
4 changed files
with
436 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
licenses(["notice"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
workspace(name = "pesto") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2019 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
def _resolver_rule_impl(repository_ctx): | ||
"""Repository rule implementation that invokes dependency resolver.""" | ||
spec_path = repository_ctx.path(repository_ctx.attr._main_spec_file) | ||
resolver_path = repository_ctx.path(repository_ctx.attr._resolver_script) | ||
|
||
# Create a BUILD file next to where the bzl files are created, to | ||
# create a Bazel package through which to load the bzl files. | ||
repository_ctx.file("BUILD", "# I am a teapot, short and stout. Don't touch me") | ||
|
||
result = repository_ctx.execute([resolver_path, spec_path]) | ||
if result.return_code != 0: | ||
fail("Error while running pesto:\nstdout: {stdout}\nstderr: {stderr}".format( | ||
stdout = result.stdout, | ||
stderr = result.stderr, | ||
)) | ||
|
||
_resolver_rule = repository_rule( | ||
implementation = _resolver_rule_impl, | ||
attrs = { | ||
"_main_spec_file": attr.label( | ||
allow_single_file = True, | ||
default = Label("@//:bazel_spec.json") | ||
), | ||
"_resolver_script": attr.label( | ||
allow_single_file = True, | ||
default = Label("@pesto//:pesto.py"), | ||
), | ||
}, | ||
) | ||
|
||
def pesto_setup(): | ||
"""Macro to hide the declaration of the repository rule.""" | ||
_resolver_rule(name = "pesto_generated") |
Oops, something went wrong.