On Thu, 20 Dec 2018 at 11:00, Matt Madison <matt@madison.systems> wrote: > > On Thu, Dec 20, 2018 at 6:02 AM Damien Riegel <damien.rie...@gmail.com> wrote: > > > > On Thu, 20 Dec 2018 at 07:53, Matt Madison <matt@madison.systems> wrote: > > > > > > On Wed, Dec 19, 2018 at 5:52 PM Damien Riegel <damien.rie...@gmail.com> > > > wrote: > > > > > > > > On Wed, 19 Dec 2018 at 16:41, Matt Madison <matt@madison.systems> wrote: > > > > > > > > > > On Wed, Dec 19, 2018 at 9:51 AM Damien Riegel > > > > > <damien.rie...@gmail.com> wrote: > > > > > > > > > > > > To package a go application in Yocto, one needs to also package its > > > > > > dependencies to keep the build reproducible and under control. The > > > > > > default install task of the go class puts the source in > > > > > > ${libdir}/go/src. > > > > > > > > > > > > ${libdir}/go/src is where the standard go packages resides, aka > > > > > > $GOROOT. > > > > > > When a go package has dependencies on other go packages, they must > > > > > > be > > > > > > located under $GOPATH, otherwise errors like this one may happen: > > > > > > > > > > > > Non-standard package <packagename> in standard package > > > > > > <packagename> > > > > > > > > > > > > This point of this patch is to trigger a discussion on how this > > > > > > issue > > > > > > can be tackled in Yocto. Following code is working but should not be > > > > > > considered for inclusion. > > > > > > > > > > Can you describe the context of this a bit more? The way go.bbclass > > > > > is set up, all of your recipe's dependencies (and their dependencies) > > > > > should already have been installed in the per-recipe sysroot (where > > > > > GOROOT lives for the current recipe's build), and should get resolved > > > > > from there. GOPATH gets set to ${B} for the current recipe's build. > > > > > Nothing in the GOROOT should be importing packages that reside in > > > > > GOPATH, which is what that particular error message is indicating. If > > > > > you're getting that error, then there might be something wrong with > > > > > recipe dependencies. > > > > > > > > Sure. I think the issue is because I have the following chain of > > > > dependencies: > > > > > > > > A --> B --> C > > > > `-> C > > > > > > > > Building C is fine, building B is fine, but building A triggers the > > > > error I mentioned, because the Go compiler complains about B using a > > > > non-standard package C. It thinks B is a standard package because it's > > > > located in GOROOT. > > > > > > Are the three packages in separate source repositories? If so, the go > > > tool should not be finding any C files in GOPATH. > > > > > > If A and C are part of the same source repository, but B is separate, > > > that would make the situation a bit trickier, but still solvable. > > > > They are three separate repositories. The issue is precisely that C > > files are not in GOPATH but in GOROOT. C files _should be_ in GOPATH or > > that will break Go tools. > > Go does allow for non-"standard" packages to be in GOROOT as well. > The way the go tool marks a package as "standard" is if it resides in > GOROOT _and_ starts with a prefix that does not look like a domain > name (specifically, does not contain a dot '.'). The Go convention, > though, is to use a domain name as the first element of the import > path for anything that isn't part of the base runtime (std, cmd).
Damn, I think that's the issue, some packages don't use a domain name as the first element of the import path. > If you do have a situation where you have multiple interdependent > packages that for some reason have import paths that do not start with > a domain name, you could build them all using a single recipe, rather > than splitting them up into separate recipes. I've had to do that for > cases where there were circular dependencies between two (or more) > packages; the same technique could work this, though, too. Okay, got it. There are no circular dependencies here, it's really a straightforward situation "A needs B", so fixing the package names should solve the issue. On a side note, it would be nice to have documentation somewhere on how to use the go class, especially for GO_IMPORT and GO_INSTALL. Does that belong in the class file itself? Or should that be put in the doc repository? Thank your very much for your help! -- Damien -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core