please-build / go-rules

Golang rules for the Please build system
Apache License 2.0
7 stars 18 forks source link

Unbuildable: github.com/wailsapp/wails/v2/cmd/wails #174

Open mibzman opened 10 months ago

mibzman commented 10 months ago

I'm working on a wails project, and I haven't been able to get the package building as a repo in please.

Wails has a lot going on, here's my attempt at making a repo:

go_repo(
    name = "wails",
    module = "github.com/wailsapp/wails/v2",
    version="latest",
    install = [
        "cmd/wails",
        "cmd/wails/internal",
        "cmd/wails/internal/template",
        "cmd/wails/internal/template/base",
        "cmd/wails/flags",
    ],
)

my source with inferred wails deps

When I try to build I get this: CRITICAL: glob(include=[base], exclude=[]) in plz-out/subrepos/third_party/go/github.com_wailsapp_wails_v2/cmd/wails/internal/template/BUILD returned no files. If this is intended, set allow_empty=True on the glob.

Tatskaari commented 10 months ago

Ah I can see what's happening here. They're trying to embed an example Go app, but go_repo has generated a BUILD file for that directory because it found a Go file in there. This means the glob for the embed pattern isn't working, because you can't glob files that are owned by a different package...

https://github.com/wailsapp/wails/tree/master/v2/cmd/wails/internal/template

This is going to require a little thought but I think we can probably fix this. We might need to generate a filegroup for glob patterns if the folder ends up being a please package.

A workaround would be to use go_module to compile this library like so:

go_module(
    name = "wails",
    module = "github.com/wailsapp/wails/v2",
    version = "v2.6.0",
    install = ["cmd/wails"],
    binary = True,
    deps = [
        "///third_party/go/github.com_samber_lo//:lo",
        "///third_party/go/github.com_leaanthony_slicer//:slicer",
        "///third_party/go/golang.org_x_tools//go/packages",
        "///third_party/go/github.com_leaanthony_gosod//:gosod",
        "///third_party/go/github.com_wzshiming_ctc//:ctc",
        "///third_party/go/github.com_pterm_pterm//:pterm",
        "///third_party/go/github.com_pkg_errors//:errors",
        "///third_party/go/github.com_google_shlex//:shlex",
        "///third_party/go/github.com_leaanthony_winicon//:winicon",
        "///third_party/go/github.com_tc-hib_winres//:winres",
        "///third_party/go/github.com_tc-hib_winres//version",
        "///third_party/go/github.com_jackmordaunt_icns//:icns",
        "///third_party/go/github.com_Masterminds_semver//:semver",
        "///third_party/go/golang.org_x_mod//modfile",
        "///third_party/go/github.com_pkg_browser//:browser",
        "///third_party/go/github.com_fsnotify_fsnotify//:fsnotify",
        "///third_party/go/github.com_acarl005_stripansi//:stripansi",
        "///third_party/go/github.com_sabhiram_go-gitignore//:go-gitignore",
        "///third_party/go/github.com_charmbracelet_glamour//:glamour",
        "///third_party/go/github.com_go-git_go-git_v5//:v5",
        "///third_party/go/github.com_go-git_go-git_v5//plumbing",
        "///third_party/go/github.com_leaanthony_debme//:debme",
        "///third_party/go/github.com_tidwall_sjson//:sjson",
        "///third_party/go/github.com_flytam_filenamify//:filenamify",
        "///third_party/go/github.com_leaanthony_clir//:clir",
        "///third_party/go/github.com_labstack_gommon//color",
    ]
)

It looks like they have app.tmpl.go and main.go.tmpl, so maybe they would be willing to rename app.tmpl.go to app.go.tmpl? If not, you could clone the module, rename all the .go files that are embedded, and generate a patch with git diff > wail.patch . This can be passed that to go_repo via patch = ["wail.patch"].