Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 4 additions & 2 deletions xgo.bats
Original file line number Diff line number Diff line change
@@ -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 ]
Expand Down Expand Up @@ -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 ]
}
Expand Down
17 changes: 11 additions & 6 deletions xgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
Expand Down