Switched to techknowlogick/xgo

This commit is contained in:
kolaente 2019-04-22 14:02:18 +02:00
parent c8858f6cfb
commit 10f80c190b
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
12 changed files with 443 additions and 76 deletions

View File

@ -146,6 +146,7 @@ steps:
image: techknowlogick/xgo:latest
pull: true
commands:
- export PATH=$PATH:$GOPATH/bin
- make release-dirs
- name: static-build-windows
@ -154,6 +155,7 @@ steps:
environment:
GOPATH: /srv/app
commands:
- export PATH=$PATH:$GOPATH/bin
- make release-windows
depends_on: [ before-static-build ]
@ -163,6 +165,7 @@ steps:
environment:
GOPATH: /srv/app
commands:
- export PATH=$PATH:$GOPATH/bin
- make release-linux
depends_on: [ before-static-build ]

View File

@ -108,7 +108,7 @@ release-dirs:
.PHONY: release-windows
release-windows:
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install $(GOFLAGS) github.com/karalabe/xgo; \
go install $(GOFLAGS) src.techknowlogick.com/xgo; \
fi
xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out vikunja-$(VERSION) .
ifneq ($(DRONE_WORKSPACE),'')
@ -118,7 +118,7 @@ endif
.PHONY: release-linux
release-linux:
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install $(GOFLAGS) github.com/karalabe/xgo; \
go install $(GOFLAGS) src.techknowlogick.com/xgo; \
fi
xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out vikunja-$(VERSION) .
ifneq ($(DRONE_WORKSPACE),'')
@ -128,7 +128,7 @@ endif
.PHONY: release-darwin
release-darwin:
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install $(GOFLAGS) github.com/karalabe/xgo; \
go install $(GOFLAGS) src.techknowlogick.com/xgo; \
fi
xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out vikunja-$(VERSION) .
ifneq ($(DRONE_WORKSPACE),'')

4
go.mod
View File

@ -23,6 +23,7 @@ require (
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
github.com/client9/misspell v0.3.4
github.com/d4l3k/messagediff v1.2.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835
github.com/garyburd/redigo v1.6.0 // indirect
@ -40,7 +41,7 @@ require (
github.com/imdario/mergo v0.3.6
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb
github.com/karalabe/xgo v0.0.0-20181007145344-72da7d1d3970
github.com/karalabe/xgo v0.0.0-20181007145344-72da7d1d3970 // indirect
github.com/kisielk/gotool v1.0.0 // indirect
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/gommon v0.2.8
@ -74,5 +75,6 @@ require (
gopkg.in/testfixtures.v2 v2.5.3
gopkg.in/yaml.v2 v2.2.2 // indirect
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a
src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15
src.techknowlogick.com/xormigrate v0.0.0-20190321151057-24497c23c09c
)

10
go.sum
View File

@ -29,9 +29,12 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLM
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cweill/gotests v1.5.2 h1:kKqmKmS2wCV3tuLnfpbiuN8OlkosQZTpCfiqmiuNAsA=
github.com/cweill/gotests v1.5.3 h1:k3t4wW/x/YNixWZJhUIn+mivmK5iV1tJVOwVYkx0UcU=
github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U=
github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -69,6 +72,7 @@ github.com/go-xorm/core v0.5.8 h1:vQ0ghlVGnlnFmm4SpHY+xNnPlH810paMcw+Hwz9BCqE=
github.com/go-xorm/core v0.5.8/go.mod h1:d8FJ9Br8OGyQl12MCclmYBuBqqxsyeedpXciV5Myih8=
github.com/go-xorm/core v0.6.0 h1:tp6hX+ku4OD9khFZS8VGBDRY3kfVCtelPfmkgCyHxL0=
github.com/go-xorm/core v0.6.0/go.mod h1:d8FJ9Br8OGyQl12MCclmYBuBqqxsyeedpXciV5Myih8=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
github.com/go-xorm/tests v0.5.6 h1:E4nmVkKfHQAm+i2/pmOJ5JUej6sORVcvwl6/LQybif4=
github.com/go-xorm/tests v0.5.6/go.mod h1:s8J/EnVBcXQR93dN7Jy6Dwlo92HUP5nTgKWF1wGeCDg=
@ -92,7 +96,9 @@ github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc=
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ=
github.com/jackc/pgx v3.2.0+incompatible h1:0Vihzu20St42/UDsvZGdNE6jak7oi/UOeMzwMPHkgFY=
github.com/jackc/pgx v3.2.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb h1:D5s1HIu80AcMGcqmk7fNIVptmAubVHHaj3v5Upex6Zs=
github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb/go.mod h1:82TxjOpWQiPmywlbIaB2ZkqJoSYJdLGPgAJDvM3PbKc=
@ -167,7 +173,9 @@ github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jO
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE=
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
@ -269,5 +277,7 @@ honnef.co/go/tools v0.0.0-20190215041234-466a0476246c h1:z+UFwlQ7KVwdlQTE5JjvDvf
honnef.co/go/tools v0.0.0-20190215041234-466a0476246c/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a h1:LJwr7TCTghdatWv40WobzlKXc9c4s8oGa7QKJUtHhWA=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15 h1:pHKgCq4abc5TAZRZGcSCxuJOTvRwzGfnbZdgTsFDgng=
src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15/go.mod h1:Ood88figJtEukTnU20P1IrXhyAkbOIGi4YzmeHVtGH0=
src.techknowlogick.com/xormigrate v0.0.0-20190321151057-24497c23c09c h1:fTwL7EZ3ouk3xeiPiRBYEjSPWTREb9T57bjzpRBNOpQ=
src.techknowlogick.com/xormigrate v0.0.0-20190321151057-24497c23c09c/go.mod h1:B2NutmcRaDDw4EGe7DoCwyWCELA8W+KxXPhLtgqFUaU=

View File

@ -25,9 +25,9 @@ import (
_ "github.com/cweill/gotests/..."
_ "github.com/fzipp/gocyclo"
_ "github.com/gordonklaus/ineffassign"
_ "github.com/karalabe/xgo"
_ "github.com/swaggo/swag/cmd/swag"
_ "golang.org/x/lint/golint"
_ "src.techknowlogick.com/xgo"
_ "github.com/jgautheron/goconst/cmd/goconst"
_ "honnef.co/go/tools/cmd/staticcheck"

4
vendor/modules.txt vendored
View File

@ -79,8 +79,6 @@ github.com/inconshreveable/mousetrap
# github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb
github.com/jgautheron/goconst/cmd/goconst
github.com/jgautheron/goconst
# github.com/karalabe/xgo v0.0.0-20181007145344-72da7d1d3970
github.com/karalabe/xgo
# github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/echo
github.com/labstack/echo/middleware
@ -225,5 +223,7 @@ honnef.co/go/tools/staticcheck/vrp
honnef.co/go/tools/go/types/typeutil
honnef.co/go/tools/callgraph
honnef.co/go/tools/callgraph/static
# src.techknowlogick.com/xgo v0.0.0-20190415010919-1502273fab15
src.techknowlogick.com/xgo
# src.techknowlogick.com/xormigrate v0.0.0-20190321151057-24497c23c09c
src.techknowlogick.com/xormigrate

53
vendor/src.techknowlogick.com/xgo/.drone.jsonnet generated vendored Normal file
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
vendor/src.techknowlogick.com/xgo/.drone.yml generated vendored Normal file
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
...

View File

@ -38,12 +38,12 @@ a single command to compile a Go package to various platforms and architectures.
Although you could build the container manually, it is available as an automatic
trusted build from Docker's container registry (not insignificant in size):
docker pull karalabe/xgo-latest
docker pull techknowlogick/xgo:latest
To prevent having to remember a potentially complex Docker command every time,
a lightweight Go wrapper was written on top of it.
go get github.com/karalabe/xgo
go get src.techknowlogick.com/xgo
## Usage
@ -202,8 +202,6 @@ versions of the same operating system. This however can lead to issues if a used
dependency is only supported by more recent systems. As such, `xgo` supports the
selection of specific platform versions by appending them to the OS target string.
* `--targets=ios-8.1/*`: cross compile to iOS 8.1
* `--targets=android-16/*`: cross compile to Android Jelly Bean
* `--targets=darwin-10.9/*`: cross compile to Mac OS X Mavericks
* `--targets=windows-6.0/*`: cross compile to Windows Vista
@ -211,24 +209,7 @@ The supported platforms are:
* All Android APIs up to Android Lollipop 5.0 ([API level ids](https://source.android.com/source/build-numbers.html))
* All Windows APIs up to Windows 8.1 limited by `mingw-w64` ([API level ids](https://en.wikipedia.org/wiki/Windows_NT#Releases))
* OSX APIs in the range of 10.6 - 10.11
* All iOS APIs up to iOS 9.3
### Mobile libraries
Apart from the usual runnable binaries, `xgo` also supports building library
archives for Android (`android/aar`) and iOS (`ios/framework`). Opposed to
`gomobile` however `xgo` does not derive library APIs from the Go code, so
proper CGO C external methods must be defined within the package.
In the case of Android archives, all architectures will be bundled that are
supported by the requested Android platform version. For iOS frameworks `xgo`
will bundle armv7 and arm64 by default, and also the x86_64 simulator builds
if the iPhoneSimulator.sdk was injected by the user:
* Create a new docker image based on xgo: `FROM karalabe/xgo-latest`
* Inject the simulator SDK: `ADD iPhoneSimulator9.3.sdk.tar.xz /iPhoneSimulator9.3.sdk.tar.xz`
* Bootstrap the simulator SDK: `$UPDATE_IOS /iPhoneSimulator9.3.sdk.tar.xz`
* OSX APIs in the range of 10.6 - 10.14
### CGO dependencies

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() {

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)
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
}
// 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)))
})
// 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...))