mirror of
https://github.com/jon4hz/xgo.git
synced 2025-12-19 23:55:59 +01:00
gomod fixes for go1.16 (#121)
* gomod fixes for go1.16 patch from: https://github.com/techknowlogick/xgo/issues/109#issuecomment-809396389 * Update test_pr.yml * Update test_pr.yml * kludge * re-enable eth smoke * Update xgo.bats * apply feedback from Z
This commit is contained in:
2
.github/workflows/test_pr.yml
vendored
2
.github/workflows/test_pr.yml
vendored
@@ -71,5 +71,7 @@ jobs:
|
||||
bats-version: 1.2.1
|
||||
- name: run BATS tests
|
||||
run: |
|
||||
mkdir -p .xgo-cache
|
||||
mkdir -p ~/go/src
|
||||
bats xgo.bats
|
||||
|
||||
|
||||
6
xgo.bats
6
xgo.bats
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
@test "embedded c" {
|
||||
export GO111MODULE=auto
|
||||
run go run xgo.go ./tests/embedded_c
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
@@ -33,8 +34,9 @@
|
||||
}
|
||||
|
||||
@test "eth smoke" {
|
||||
skip "remotes are temporarily disabled due to gomod"
|
||||
run go run xgo.go --remote github.com/ethereum/go-ethereum --targets "linux/amd64" github.com/ethereum/go-ethereum/cmd/geth
|
||||
# skip "remotes are temporarily disabled due to gomod"
|
||||
git clone https://github.com/ethereum/go-ethereum.git /tmp/eth
|
||||
run go run xgo.go --targets "linux/amd64" /tmp/eth/cmd/geth
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
17
xgo.go
17
xgo.go
@@ -258,13 +258,17 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
|
||||
locals, mounts, paths := []string{}, []string{}, []string{}
|
||||
var usesModules bool
|
||||
if strings.HasPrefix(config.Repository, string(filepath.Separator)) || strings.HasPrefix(config.Repository, ".") {
|
||||
// Resolve the repository import path from the file path
|
||||
config.Repository = resolveImportPath(config.Repository)
|
||||
if _, err := os.Stat(config.Repository + "/go.mod"); err == nil {
|
||||
usesModules = true
|
||||
}
|
||||
if !usesModules {
|
||||
// Resolve the repository import path from the file path
|
||||
config.Repository = resolveImportPath(config.Repository)
|
||||
|
||||
// Determine if this is a module-based repository
|
||||
var modFile = config.Repository + "/go.mod"
|
||||
_, err := os.Stat(modFile)
|
||||
usesModules = !os.IsNotExist(err)
|
||||
if _, err := os.Stat(config.Repository + "/go.mod"); err == nil {
|
||||
usesModules = true
|
||||
}
|
||||
}
|
||||
|
||||
gopathEnv := os.Getenv("GOPATH")
|
||||
if gopathEnv == "" && !usesModules {
|
||||
@@ -277,6 +281,7 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
|
||||
log.Fatalf("No $GOPATH is set or forwarded to xgo")
|
||||
}
|
||||
if !usesModules {
|
||||
|
||||
for _, gopath := range strings.Split(gopathEnv, string(os.PathListSeparator)) {
|
||||
// Since docker sandboxes volumes, resolve any symlinks manually
|
||||
sources := filepath.Join(gopath, "src")
|
||||
|
||||
Reference in New Issue
Block a user