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

wrong embedsrcs are added when embedsrcs is coming from a rule #1968

Open
Links2004 opened this issue Oct 28, 2024 · 0 comments
Open

wrong embedsrcs are added when embedsrcs is coming from a rule #1968

Links2004 opened this issue Oct 28, 2024 · 0 comments

Comments

@Links2004
Copy link

What version of gazelle are you using?

0.39.1

What version of rules_go are you using?

0.50.1

What version of Bazel are you using?

7.4.0

Does this issue reproduce with the latest releases of all the above?

yes

What operating system and processor architecture are you using?

linux amd64

What did you do?

MODULE.bazel:

...
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
http_file(
    name = "jfrog-cli",
    sha256 = "b3c92f70b75e7b05948ef70f015511928b986bd04ed60d90bb2fedcc62f1ea02",
    url = "https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/2.66.0/jfrog-cli-linux-amd64/jf",
)

BUILD.bazel:

load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@rules_go//go:def.bzl", "go_binary", "go_library")

copy_file(
    name = "jf",
    src = "@jfrog-cli//file:file",
    out = "jf",
)

go_library(
    name = "download_test_lib",
    srcs = ["main.go"],
    embedsrcs = [
        ":jf",  #keep
    ],
    importpath = "local.test/download_test",
    visibility = ["//visibility:private"],
    deps = ["@com_github_rs_zerolog//log"],
)

go_binary(
    name = "download_test",
    embed = [":download_test_lib"],
    visibility = ["//visibility:public"],
)

main.go:

package main

import (
	_ "embed"
)

//go:embed jf
var test_data []byte

func main() {
	fmt.Printf("len: %d\n", len(test_data))
}

What did you expect to see?

running bazel run //:gazelle will not modify the embedsrcs.

What did you see instead?

running bazel run //:gazelle will modify the embedsrcs which breaks the build.

go_library(
    name = "download_test_lib",
    srcs = ["main.go"],
    embedsrcs = [
        ":jf",  #keep
        "jf",
    ],
    importpath = "local.test/download_test",
    visibility = ["//visibility:private"],
    deps = ["@com_github_rs_zerolog//log"],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant