Browse Source

Properly added xgo

master
konrad 1 year ago
parent
commit
764966bddb
Signed by: konrad GPG Key ID: F40E70337AB24C9B
10 changed files with 428 additions and 75 deletions
  1. +1
    -1
      go.mod
  2. +3
    -2
      go.sum
  3. +1
    -1
      tools.go
  4. +2
    -2
      vendor/modules.txt
  5. +53
    -0
      vendor/src.techknowlogick.com/xgo/.drone.jsonnet
  6. +289
    -0
      vendor/src.techknowlogick.com/xgo/.drone.yml
  7. +3
    -22
      vendor/src.techknowlogick.com/xgo/LICENSE
  8. +5
    -7
      vendor/src.techknowlogick.com/xgo/testsuite.go
  9. +71
    -40
      vendor/src.techknowlogick.com/xgo/xgo.go

+ 1
- 1
go.mod View File

@ -6,11 +6,11 @@ require (
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835
github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/karalabe/xgo v0.0.0-20181007145344-72da7d1d3970
github.com/mitchellh/go-homedir v1.0.0
github.com/prometheus/client_golang v0.9.2
github.com/spf13/cobra v0.0.3
github.com/spf13/viper v1.3.1
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3
golang.org/x/tools v0.0.0-20181128225727-c5b00d9557fd // indirect
src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15
)

+ 3
- 2
go.sum View File

@ -22,8 +22,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/karalabe/xgo v0.0.0-20181007145344-72da7d1d3970 h1:0+1ZURVRim6FxA/jhWhJklsgoWc69q1sxlIu2Ztnhy0=
github.com/karalabe/xgo v0.0.0-20181007145344-72da7d1d3970/go.mod h1:iYGcTYIPUvEWhFo6aKUuLchs+AV4ssYdyuBbQJZGcBk=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
@ -64,6 +62,7 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -75,3 +74,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15 h1:pHKgCq4abc5TAZRZGcSCxuJOTvRwzGfnbZdgTsFDgng=
src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15/go.mod h1:Ood88figJtEukTnU20P1IrXhyAkbOIGi4YzmeHVtGH0=

+ 1
- 1
tools.go View File

@ -42,6 +42,6 @@ import (
_ "github.com/client9/misspell/cmd/misspell"
_ "github.com/fzipp/gocyclo"
_ "github.com/gordonklaus/ineffassign"
_ "github.com/karalabe/xgo"
_ "golang.org/x/lint/golint"
_ "src.techknowlogick.com/xgo"
)

+ 2
- 2
vendor/modules.txt View File

@ -24,8 +24,6 @@ github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/json/token
# github.com/inconshreveable/mousetrap v1.0.0
github.com/inconshreveable/mousetrap
# github.com/karalabe/xgo v0.0.0-20181007145344-72da7d1d3970
github.com/karalabe/xgo
# github.com/magiconair/properties v1.8.0
github.com/magiconair/properties
# github.com/matttproud/golang_protobuf_extensions v1.0.1
@ -79,3 +77,5 @@ golang.org/x/tools/go/gcexportdata
golang.org/x/tools/go/internal/gcimporter
# gopkg.in/yaml.v2 v2.2.2
gopkg.in/yaml.v2
# src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15
src.techknowlogick.com/xgo

+ 53
- 0
vendor/src.techknowlogick.com/xgo/.drone.jsonnet View File

@ -0,0 +1,53 @@
local BuildSwitchDryRun(version='go-latest', tags='latest', dry=false) = {
name: if dry then 'dry-run-' + version else 'build-' + version,
pull: 'always',
image: 'plugins/docker',
settings: {
dockerfile: 'docker/' + version + '/Dockerfile',
context: 'docker/' + version,
password: {
from_secret: 'docker_password'
},
username: {
from_secret: 'docker_username'
},
repo: 'techknowlogick/xgo',
tags: tags,
dry_run: dry
},
[if !dry then 'when']: {
branch: ['master'],
event: {exclude: ['pull_request']}
},
[if dry then 'when']: {
event: {include: ['pull_request']}
},
};
local BuildWithDiffTags(version='go-latest', tags='latest') = BuildSwitchDryRun(version, tags, false);
local BuildWithDiffTagsDry(version='go-latest', tags='latest') = BuildSwitchDryRun(version, tags, true);
local BuildStep(version='go-latest') = BuildWithDiffTags(version, version);
local BuildStepDry(version='go-latest') = BuildSwitchDryRun(version, version, true);
{
kind: 'pipeline',
name: 'default',
steps: [
BuildStepDry('base'),
BuildStepDry('go-1.12.4'),
BuildStepDry('go-1.11.9'),
BuildStep('base'),
BuildStep('go-1.12.4'),
BuildStep('go-1.12.x'),
BuildWithDiffTags(),
BuildStep('go-1.11.9'),
BuildStep('go-1.11.x'),
BuildStep('go-1.12.3'),
BuildStep('go-1.12.2'),
BuildStep('go-1.12.1'),
BuildStep('go-1.12.0'),
BuildStep('go-1.11.8'),
BuildStep('go-1.11.7'),
]
}

+ 289
- 0
vendor/src.techknowlogick.com/xgo/.drone.yml View File

@ -0,0 +1,289 @@
---
kind: pipeline
name: default
platform:
os: linux
arch: amd64
steps:
- name: dry-run-base
pull: always
image: plugins/docker
settings:
context: docker/base
dockerfile: docker/base/Dockerfile
dry_run: true
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: base
username:
from_secret: docker_username
when:
event:
- pull_request
- name: dry-run-go-1.12.4
pull: always
image: plugins/docker
settings:
context: docker/go-1.12.4
dockerfile: docker/go-1.12.4/Dockerfile
dry_run: true
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.12.4
username:
from_secret: docker_username
when:
event:
- pull_request
- name: dry-run-go-1.11.9
pull: always
image: plugins/docker
settings:
context: docker/go-1.11.9
dockerfile: docker/go-1.11.9/Dockerfile
dry_run: true
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.11.9
username:
from_secret: docker_username
when:
event:
- pull_request
- name: build-base
pull: always
image: plugins/docker
settings:
context: docker/base
dockerfile: docker/base/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: base
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.12.4
pull: always
image: plugins/docker
settings:
context: docker/go-1.12.4
dockerfile: docker/go-1.12.4/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.12.4
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.12.x
pull: always
image: plugins/docker
settings:
context: docker/go-1.12.x
dockerfile: docker/go-1.12.x/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.12.x
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-latest
pull: always
image: plugins/docker
settings:
context: docker/go-latest
dockerfile: docker/go-latest/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: latest
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.11.9
pull: always
image: plugins/docker
settings:
context: docker/go-1.11.9
dockerfile: docker/go-1.11.9/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.11.9
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.11.x
pull: always
image: plugins/docker
settings:
context: docker/go-1.11.x
dockerfile: docker/go-1.11.x/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.11.x
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.12.3
pull: always
image: plugins/docker
settings:
context: docker/go-1.12.3
dockerfile: docker/go-1.12.3/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.12.3
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.12.2
pull: always
image: plugins/docker
settings:
context: docker/go-1.12.2
dockerfile: docker/go-1.12.2/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.12.2
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.12.1
pull: always
image: plugins/docker
settings:
context: docker/go-1.12.1
dockerfile: docker/go-1.12.1/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.12.1
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.12.0
pull: always
image: plugins/docker
settings:
context: docker/go-1.12.0
dockerfile: docker/go-1.12.0/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.12.0
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.11.8
pull: always
image: plugins/docker
settings:
context: docker/go-1.11.8
dockerfile: docker/go-1.11.8/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.11.8
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
- name: build-go-1.11.7
pull: always
image: plugins/docker
settings:
context: docker/go-1.11.7
dockerfile: docker/go-1.11.7/Dockerfile
password:
from_secret: docker_password
repo: techknowlogick/xgo
tags: go-1.11.7
username:
from_secret: docker_username
when:
branch:
- master
event:
exclude:
- pull_request
...

vendor/github.com/karalabe/xgo/LICENSE → vendor/src.techknowlogick.com/xgo/LICENSE View File


vendor/github.com/karalabe/xgo/testsuite.go → vendor/src.techknowlogick.com/xgo/testsuite.go View File

@ -26,11 +26,10 @@ var layers = []struct {
tag string
dir string
}{
{"karalabe/xgo-base", "base"},
{"karalabe/xgo-1.6.2", "go-1.6.2"},
{"karalabe/xgo-1.6.x", "go-1.6.x"},
{"karalabe/xgo-latest", "go-latest"},
//{"karalabe/xgo-latest-ios", "go-latest-ios"}, // Non-public layer (XCode licensing)
{"techknowlogick/xgo:base", "base"},
{"techknowlogick/xgo:1.12.4", "go-1.12.4"},
{"techknowlogick/xgo:1.12.x", "go-1.12.x"},
{"techknowlogick/xgo:latest", "go-latest"},
}
// tests defaines all the input test cases and associated arguments the cross
@ -44,12 +43,11 @@ var tests = []struct {
{"github.com/karalabe/xgo/tests/embedded_cpp", nil},
// Baseline projects to ensure minimal requirements
//{"github.com/project-iris/iris", nil}, // Deps failed, disable
{"github.com/ethereum/go-ethereum/cmd/geth", []string{"--branch", "develop"}},
// Third party projects using xgo, smoke test that they don't break
{"github.com/rwcarlsen/cyan/cmd/cyan", nil},
{"github.com/cockroachdb/cockroach", []string{"--targets", "darwin-10.11/amd64"}},
{"github.com/cockroachdb/cockroach", []string{"--targets", "darwin-10.6/amd64"}},
}
func main() {

vendor/github.com/karalabe/xgo/xgo.go → vendor/src.techknowlogick.com/xgo/xgo.go View File

@ -4,7 +4,7 @@
// Released under the MIT license.
// Wrapper around the GCO cross compiler docker container.
package main
package main // import "src.techknowlogick.com/xgo"
import (
"bytes"
@ -39,8 +39,8 @@ func init() {
}
// Cross compilation docker containers
var dockerBase = "karalabe/xgo-base"
var dockerDist = "karalabe/xgo-"
var dockerBase = "techknowlogick/xgo:base"
var dockerDist = "techknowlogick/xgo:"
// Command line arguments to fine tune the compilation
var (
@ -233,49 +233,58 @@ func pullDockerImage(image string) error {
func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string) error {
// If a local build was requested, find the import path and mount all GOPATH sources
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)
// Determine if this is a module-based repository
var modFile = config.Repository + "/go.mod"
_, err := os.Stat(modFile)
usesModules = !os.IsNotExist(err)
// Iterate over all the local libs and export the mount points
if os.Getenv("GOPATH") == "" {
if os.Getenv("GOPATH") == "" && !usesModules {
log.Fatalf("No $GOPATH is set or forwarded to xgo")
}
for _, gopath := range strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) {
// Since docker sandboxes volumes, resolve any symlinks manually
sources := filepath.Join(gopath, "src")
filepath.Walk(sources, func(path string, info os.FileInfo, err error) error {
// Skip any folders that errored out
if err != nil {
log.Printf("Failed to access GOPATH element %s: %v", path, err)
return nil
}
// Skip anything that's not a symlink
if info.Mode()&os.ModeSymlink == 0 {
return nil
}
// Resolve the symlink and skip if it's not a folder
target, err := filepath.EvalSymlinks(path)
if err != nil {
return nil
}
if info, err = os.Stat(target); err != nil || !info.IsDir() {
return nil
}
// Skip if the symlink points within GOPATH
if filepath.HasPrefix(target, sources) {
if !usesModules {
for _, gopath := range strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) {
// Since docker sandboxes volumes, resolve any symlinks manually
sources := filepath.Join(gopath, "src")
filepath.Walk(sources, func(path string, info os.FileInfo, err error) error {
// Skip any folders that errored out
if err != nil {
log.Printf("Failed to access GOPATH element %s: %v", path, err)
return nil
}
// Skip anything that's not a symlink
if info.Mode()&os.ModeSymlink == 0 {
return nil
}
// Resolve the symlink and skip if it's not a folder
target, err := filepath.EvalSymlinks(path)
if err != nil {
return nil
}
if info, err = os.Stat(target); err != nil || !info.IsDir() {
return nil
}
// Skip if the symlink points within GOPATH
if filepath.HasPrefix(target, sources) {
return nil
}
// Folder needs explicit mounting due to docker symlink security
locals = append(locals, target)
mounts = append(mounts, filepath.Join("/ext-go", strconv.Itoa(len(locals)), "src", strings.TrimPrefix(path, sources)))
paths = append(paths, filepath.Join("/ext-go", strconv.Itoa(len(locals))))
return nil
}
// Folder needs explicit mounting due to docker symlink security
locals = append(locals, target)
mounts = append(mounts, filepath.Join("/ext-go", strconv.Itoa(len(locals)), "src", strings.TrimPrefix(path, sources)))
})
// Export the main mount point for this GOPATH entry
locals = append(locals, sources)
mounts = append(mounts, filepath.Join("/ext-go", strconv.Itoa(len(locals)), "src"))
paths = append(paths, filepath.Join("/ext-go", strconv.Itoa(len(locals))))
return nil
})
// Export the main mount point for this GOPATH entry
locals = append(locals, sources)
mounts = append(mounts, filepath.Join("/ext-go", strconv.Itoa(len(locals)), "src"))
paths = append(paths, filepath.Join("/ext-go", strconv.Itoa(len(locals))))
}
}
}
// Assemble and run the cross compilation command
@ -299,10 +308,32 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
"-e", fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode),
"-e", "TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1),
}
for i := 0; i < len(locals); i++ {
args = append(args, []string{"-v", fmt.Sprintf("%s:%s:ro", locals[i], mounts[i])}...)
if usesModules {
args = append(args, []string{"-e", "GO111MODULE=on"}...)
args = append(args, []string{"-v", os.Getenv("GOPATH") + ":/go"}...)
// Map this repository to the /source folder
absRepository, err := filepath.Abs(config.Repository)
if err != nil {
log.Fatalf("Failed to locate requested module repository: %v.", err)
}
args = append(args, []string{"-v", absRepository + ":/source"}...)
fmt.Printf("Enabled Go module support\n")
// Check whether it has a vendor folder, and if so, use it
vendorPath := absRepository + "/vendor"
vendorfolder, err := os.Stat(vendorPath)
if !os.IsNotExist(err) && vendorfolder.Mode().IsDir() {
args = append(args, []string{"-e", "FLAG_MOD=vendor"}...)
fmt.Printf("Using vendored Go module dependencies\n")
}
} else {
for i := 0; i < len(locals); i++ {
args = append(args, []string{"-v", fmt.Sprintf("%s:%s:ro", locals[i], mounts[i])}...)
}
args = append(args, []string{"-e", "EXT_GOPATH=" + strings.Join(paths, ":")}...)
}
args = append(args, []string{"-e", "EXT_GOPATH=" + strings.Join(paths, ":")}...)
args = append(args, []string{image, config.Repository}...)
return run(exec.Command("docker", args...))

Loading…
Cancel
Save