This repository has been archived by the owner on Oct 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Fix proto dependency conflicts for prysm, issues building go_path. #13
Open
gnattishness
wants to merge
1
commit into
prysmaticlabs:dv5
Choose a base branch
from
gnattishness:fix_bazel_proto_conflicts
base: dv5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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,39 @@ | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
||
cc_library( | ||
name = "secp256k1", | ||
srcs = [":srcs"], | ||
# TODO also asm files? | ||
hdrs = [":hdrs"], | ||
visibility = ["//crypto/secp256k1:__pkg__"], | ||
# TODO strip include prefix? supposed to be relative to workspace | ||
# TODO actually doesn't matter much if we have c opts | ||
local_defines = [ | ||
"USE_NUM_NONE", | ||
"USE_FIELD_10X26", | ||
"USE_FIELD_INV_BUILTIN", | ||
"USE_SCALAR_8X32", | ||
"USE_SCALAR_INV_BUILTIN", | ||
"NDEBUG", | ||
] | ||
) | ||
|
||
filegroup( | ||
name = "headers", | ||
srcs = glob(["include/**/*.h"]) + [ | ||
"src/secp256k1.h", | ||
"src/modules/recovery/main_impl.h", | ||
], | ||
visibility = ["//crypto/secp256k1:__pkg__"], | ||
) | ||
|
||
filegroup( | ||
name = "srcs", | ||
# NOTE: secp256k1.c is copied into secp256k1.h in this fork, so don't need to touch src/secp256k1.c | ||
# Can also use version before fork, with include prefixes | ||
srcs = glob( | ||
["src/*.h"], exclude=["src/test*.h", "src/bench*.h", "src/secp256k1.h"] | ||
), | ||
visibility = ["//crypto/secp256k1:__pkg__"], | ||
) |
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 @@ | ||
exports_files(glob(["*.patch"])) |
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,83 @@ | ||
diff --git a/go/private/tools/path.bzl b/go/private/tools/path.bzl | ||
index 261b9696..27007a21 100644 | ||
--- a/go/private/tools/path.bzl | ||
+++ b/go/private/tools/path.bzl | ||
@@ -12,6 +12,14 @@ | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
+load( | ||
+ "@bazel_skylib//lib:paths.bzl", | ||
+ "paths", | ||
+) | ||
+load( | ||
+ "@bazel_skylib//lib:new_sets.bzl", | ||
+ "sets", | ||
+) | ||
load( | ||
"@io_bazel_rules_go//go/private:context.bzl", | ||
"go_context", | ||
@@ -58,6 +66,7 @@ def _go_path_impl(ctx): | ||
srcs = as_list(archive.orig_srcs), | ||
data = as_list(archive.data_files), | ||
pkgs = {mode: archive.file}, | ||
+ labels = [archive.label], | ||
) | ||
if pkgpath in pkg_map: | ||
_merge_pkg(pkg_map[pkgpath], pkg) | ||
@@ -70,7 +79,14 @@ def _go_path_impl(ctx): | ||
manifest_entry_map = {} | ||
for pkg in pkg_map.values(): | ||
for f in pkg.srcs: | ||
- dst = pkg.dir + "/" + f.basename | ||
+ if f.extension in ("c", "h", "s", "S") and _is_in_pkg_subdir(pkg, f): | ||
+ # NOTE assumes cgo=true for the pkg | ||
+ # Maintain position of C files relative to package, | ||
+ # if contained in a subdirectory of the pkg | ||
+ dst = paths.normalize(paths.join(pkg.dir, _path_rel_to_pkg(pkg, f))) | ||
+ else: | ||
+ # Flatten into the package | ||
+ dst = paths.join(pkg.dir, f.basename) | ||
_add_manifest_entry(manifest_entries, manifest_entry_map, inputs, f, dst) | ||
if ctx.attr.include_pkg: | ||
for pkg in pkg_map.values(): | ||
@@ -85,8 +101,12 @@ def _go_path_impl(ctx): | ||
parts = f.path.split("/") | ||
if "testdata" in parts: | ||
i = parts.index("testdata") | ||
- dst = pkg.dir + "/" + "/".join(parts[i:]) | ||
+ dst = paths.join(pkg.dir, *parts[i:]) | ||
+ elif _is_in_pkg_subdir(pkg, f): | ||
+ # Maintain relative position for data "inside" the package. | ||
+ dst = paths.normalize(paths.join(pkg.dir, _path_rel_to_pkg(pkg, f))) | ||
else: | ||
+ # Flatten for data outside the package dir | ||
dst = pkg.dir + "/" + f.basename | ||
_add_manifest_entry(manifest_entries, manifest_entry_map, inputs, f, dst) | ||
for f in ctx.files.data: | ||
@@ -181,6 +201,8 @@ def _merge_pkg(x, y): | ||
x.srcs.extend([f for f in y.srcs if f.path not in x_srcs]) | ||
x.data.extend([f for f in y.data if f.path not in x_srcs]) | ||
x.pkgs.update(y.pkgs) | ||
+ x_labels = sets.make(x.labels) | ||
+ x.labels.extend([l for l in y.labels if not sets.contains(x_labels, l)]) | ||
|
||
def _add_manifest_entry(entries, entry_map, inputs, src, dst): | ||
if dst in entry_map: | ||
@@ -190,3 +212,16 @@ def _add_manifest_entry(entries, entry_map, inputs, src, dst): | ||
entries.append(struct(src = src.path, dst = dst)) | ||
entry_map[dst] = src.path | ||
inputs.append(src) | ||
+ | ||
+def _path_rel_to_pkg(pkg, f): | ||
+ # if f is "contained in" a pkg, return its path | ||
+ # relative to the pkg root | ||
+ # otherwise return None | ||
+ for l in pkg.labels: | ||
+ full_pkg_path = paths.join(l.workspace_root, l.package) | ||
+ if f.path.startswith(full_pkg_path): | ||
+ return paths.relativize(f.path, full_pkg_path) | ||
+ return None | ||
+ | ||
+def _is_in_pkg_subdir(pkg, f): | ||
+ return _path_rel_to_pkg(pkg, f) != None |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets block this until this PR is merged in
rules_go
, other than that looks good to me