Skip to content

Commit a9aec42

Browse files
committed
Trying to get runfiles working
1 parent 1a714f1 commit a9aec42

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

gazelle/manifest/generate/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ go_library(
66
srcs = ["generate.go"],
77
importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/generate",
88
visibility = ["//visibility:public"],
9-
deps = ["//manifest"],
9+
deps = [
10+
"//manifest",
11+
"@io_bazel_rules_go//go/runfiles",
12+
],
1013
)
1114

1215
sources_hash(

gazelle/manifest/generate/generate.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"os"
2929
"strings"
3030

31+
"github.com/bazelbuild/rules_go/go/runfiles"
3132
"github.com/bazelbuild/rules_python/gazelle/manifest"
3233
)
3334

@@ -128,7 +129,24 @@ func main() {
128129

129130
// unmarshalJSON returns the parsed mapping from the given JSON file path.
130131
func unmarshalJSON(jsonPath string) (map[string]string, error) {
131-
file, err := os.Open(jsonPath)
132+
133+
r, err := runfiles.New()
134+
if err != nil {
135+
log.Fatalf("runfiles.New: %v", err)
136+
}
137+
138+
// FIXME harding coding this for debugging
139+
path := "modules_mapping.json"
140+
path, err = r.Rlocation(path)
141+
if err != nil {
142+
log.Fatalf("runfiles.Path: %v", err)
143+
}
144+
145+
file, err := r.Open(path)
146+
if err != nil {
147+
log.Fatal(err)
148+
}
149+
132150
if err != nil {
133151
return nil, fmt.Errorf("failed to unmarshal JSON file: %w", err)
134152
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy