2
0
mirror of synced 2025-02-23 23:08:14 +00:00

cmd/gomobile: always use abolute paths to replace in go.mod

A replative path in go.mod works only in the directory of the
go.mod. When creating go.mod for gobind, copying relative paths
did not work since go.mod is in a different temporary directory.

This CL fixes the issue to use Dir, which is an absolute path to
the module, instead of Path.

Updates golang/go#27234

Change-Id: Ib009ec508aa3ce3d092af14f921a57192feaac61
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/215421
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Hajime Hoshi 2020-01-21 16:07:39 +09:00
parent 23a0503ab4
commit 82c397c4c5

View File

@ -263,7 +263,7 @@ func getModuleVersions(targetOS string, targetArch string, src string) (*modfile
if mod != nil {
switch {
case mod.Replace != nil:
f.AddReplace(mod.Path, mod.Version, mod.Replace.Path, mod.Replace.Version)
f.AddReplace(mod.Path, mod.Version, mod.Replace.Dir, mod.Replace.Version)
case mod.Version == "":
// When the version part is empty, the module is local and mod.Dir represents the location.
f.AddReplace(mod.Path, "", mod.Dir, "")