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:
4
.github/workflows/test_pr.yml
vendored
4
.github/workflows/test_pr.yml
vendored
@@ -71,5 +71,7 @@ jobs:
|
|||||||
bats-version: 1.2.1
|
bats-version: 1.2.1
|
||||||
- name: run BATS tests
|
- name: run BATS tests
|
||||||
run: |
|
run: |
|
||||||
|
mkdir -p .xgo-cache
|
||||||
|
mkdir -p ~/go/src
|
||||||
bats xgo.bats
|
bats xgo.bats
|
||||||
|
|
||||||
|
|||||||
6
xgo.bats
6
xgo.bats
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
@test "embedded c" {
|
@test "embedded c" {
|
||||||
|
export GO111MODULE=auto
|
||||||
run go run xgo.go ./tests/embedded_c
|
run go run xgo.go ./tests/embedded_c
|
||||||
echo "$output"
|
echo "$output"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
@@ -33,8 +34,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "eth smoke" {
|
@test "eth smoke" {
|
||||||
skip "remotes are temporarily disabled due to gomod"
|
# 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
|
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"
|
echo "$output"
|
||||||
[ "$status" -eq 0 ]
|
[ "$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{}
|
locals, mounts, paths := []string{}, []string{}, []string{}
|
||||||
var usesModules bool
|
var usesModules bool
|
||||||
if strings.HasPrefix(config.Repository, string(filepath.Separator)) || strings.HasPrefix(config.Repository, ".") {
|
if strings.HasPrefix(config.Repository, string(filepath.Separator)) || strings.HasPrefix(config.Repository, ".") {
|
||||||
// Resolve the repository import path from the file path
|
if _, err := os.Stat(config.Repository + "/go.mod"); err == nil {
|
||||||
config.Repository = resolveImportPath(config.Repository)
|
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
|
if _, err := os.Stat(config.Repository + "/go.mod"); err == nil {
|
||||||
var modFile = config.Repository + "/go.mod"
|
usesModules = true
|
||||||
_, err := os.Stat(modFile)
|
}
|
||||||
usesModules = !os.IsNotExist(err)
|
}
|
||||||
|
|
||||||
gopathEnv := os.Getenv("GOPATH")
|
gopathEnv := os.Getenv("GOPATH")
|
||||||
if gopathEnv == "" && !usesModules {
|
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")
|
log.Fatalf("No $GOPATH is set or forwarded to xgo")
|
||||||
}
|
}
|
||||||
if !usesModules {
|
if !usesModules {
|
||||||
|
|
||||||
for _, gopath := range strings.Split(gopathEnv, string(os.PathListSeparator)) {
|
for _, gopath := range strings.Split(gopathEnv, string(os.PathListSeparator)) {
|
||||||
// Since docker sandboxes volumes, resolve any symlinks manually
|
// Since docker sandboxes volumes, resolve any symlinks manually
|
||||||
sources := filepath.Join(gopath, "src")
|
sources := filepath.Join(gopath, "src")
|
||||||
|
|||||||
Reference in New Issue
Block a user