├── LICENSE ├── README.md ├── docker ├── base │ ├── Dockerfile │ ├── bootstrap.sh │ ├── bootstrap_pure.sh │ ├── bootstrap_repo.sh │ ├── build.sh │ ├── build_deps.sh │ ├── fetch.sh │ ├── patch.tar.xz │ └── update_ios.sh ├── go-1.10.0 │ └── Dockerfile ├── go-1.10.1 │ └── Dockerfile ├── go-1.10.2 │ └── Dockerfile ├── go-1.10.3 │ └── Dockerfile ├── go-1.10.4 │ └── Dockerfile ├── go-1.10.x │ └── Dockerfile ├── go-1.11.0 │ └── Dockerfile ├── go-1.11.1 │ └── Dockerfile ├── go-1.11.2 │ └── Dockerfile ├── go-1.11.3 │ └── Dockerfile ├── go-1.11.4 │ └── Dockerfile ├── go-1.11.5 │ └── Dockerfile ├── go-1.11.x │ └── Dockerfile ├── go-1.12.0 │ └── Dockerfile ├── go-1.12.1 │ └── Dockerfile ├── go-1.12.10 │ └── Dockerfile ├── go-1.12.11 │ └── Dockerfile ├── go-1.12.12 │ └── Dockerfile ├── go-1.12.13 │ └── Dockerfile ├── go-1.12.2 │ └── Dockerfile ├── go-1.12.3 │ └── Dockerfile ├── go-1.12.4 │ └── Dockerfile ├── go-1.12.5 │ └── Dockerfile ├── go-1.12.6 │ └── Dockerfile ├── go-1.12.7 │ └── Dockerfile ├── go-1.12.8 │ └── Dockerfile ├── go-1.12.9 │ └── Dockerfile ├── go-1.12.x │ └── Dockerfile ├── go-1.13.0 │ └── Dockerfile ├── go-1.13.1 │ └── Dockerfile ├── go-1.13.2 │ └── Dockerfile ├── go-1.13.3 │ └── Dockerfile ├── go-1.13.4 │ └── Dockerfile ├── go-1.13.x │ └── Dockerfile ├── go-1.3.0 │ └── Dockerfile ├── go-1.3.1 │ └── Dockerfile ├── go-1.3.3 │ └── Dockerfile ├── go-1.3.x │ └── Dockerfile ├── go-1.4.2 │ └── Dockerfile ├── go-1.4.x │ └── Dockerfile ├── go-1.4 │ └── Dockerfile ├── go-1.5.0 │ └── Dockerfile ├── go-1.5.1 │ └── Dockerfile ├── go-1.5.2 │ └── Dockerfile ├── go-1.5.3 │ └── Dockerfile ├── go-1.5.4 │ └── Dockerfile ├── go-1.5.x │ └── Dockerfile ├── go-1.6.0 │ └── Dockerfile ├── go-1.6.1 │ └── Dockerfile ├── go-1.6.2 │ └── Dockerfile ├── go-1.6.3 │ └── Dockerfile ├── go-1.6.x │ └── Dockerfile ├── go-1.7.0 │ └── Dockerfile ├── go-1.7.1 │ └── Dockerfile ├── go-1.7.3 │ └── Dockerfile ├── go-1.7.4 │ └── Dockerfile ├── go-1.7.5 │ └── Dockerfile ├── go-1.7.x │ └── Dockerfile ├── go-1.8.0 │ └── Dockerfile ├── go-1.8.1 │ └── Dockerfile ├── go-1.8.3 │ └── Dockerfile ├── go-1.8.x │ └── Dockerfile ├── go-1.9.0 │ └── Dockerfile ├── go-1.9.1 │ └── Dockerfile ├── go-1.9.2 │ └── Dockerfile ├── go-1.9.3 │ └── Dockerfile ├── go-1.9.4 │ └── Dockerfile ├── go-1.9.x │ └── Dockerfile ├── go-develop │ └── Dockerfile └── go-latest │ └── Dockerfile ├── tests ├── embedded_c │ └── main.go └── embedded_cpp │ ├── main.go │ ├── snippet.cpp │ └── snippet.h ├── testsuite.go └── xgo.go /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Péter Szilágyi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xgo - Go CGO cross compiler 2 | 3 | Although Go strives to be a cross platform language, cross compilation from one 4 | platform to another is not as simple as it could be, as you need the Go sources 5 | bootstrapped to each platform and architecture. 6 | 7 | The first step towards cross compiling was Dave Cheney's [golang-crosscompile](https://github.com/davecheney/golang-crosscompile) 8 | package, which automatically bootstrapped the necessary sources based on your 9 | existing Go installation. Although this was enough for a lot of cases, certain 10 | drawbacks became apparent where the official libraries used CGO internally: any 11 | dependency to third party platform code is unavailable, hence those parts don't 12 | cross compile nicely (native DNS resolution, system certificate access, etc). 13 | 14 | A step forward in enabling cross compilation was Alan Shreve's [gonative](https://github.com/inconshreveable/gonative) 15 | package, which instead of bootstrapping the different platforms based on the 16 | existing Go installation, downloaded the official pre-compiled binaries from the 17 | golang website and injected those into the local toolchain. Since the pre-built 18 | binaries already contained the necessary platform specific code, the few missing 19 | dependencies were resolved, and true cross compilation could commence... of pure 20 | Go code. 21 | 22 | However, there was still one feature missing: cross compiling Go code that used 23 | CGO itself, which isn't trivial since you need access to OS specific headers and 24 | libraries. This becomes very annoying when you need access only to some trivial 25 | OS specific functionality (e.g. query the CPU load), but need to configure and 26 | maintain separate build environments to do it. 27 | 28 | ## Enter xgo 29 | 30 | My solution to the challenge of cross compiling Go code with embedded C/C++ snippets 31 | (i.e. CGO_ENABLED=1) is based on the concept of [lightweight Linux containers](http://en.wikipedia.org/wiki/LXC). 32 | All the necessary Go tool-chains, C cross compilers and platform headers/libraries 33 | have been assembled into a single Docker container, which can then be called as if 34 | a single command to compile a Go package to various platforms and architectures. 35 | 36 | ## Installation 37 | 38 | Although you could build the container manually, it is available as an automatic 39 | trusted build from Docker's container registry (not insignificant in size): 40 | 41 | docker pull karalabe/xgo-latest 42 | 43 | To prevent having to remember a potentially complex Docker command every time, 44 | a lightweight Go wrapper was written on top of it. 45 | 46 | go get github.com/karalabe/xgo 47 | 48 | ## Usage 49 | 50 | Simply specify the import path you want to build, and xgo will do the rest: 51 | 52 | $ xgo github.com/project-iris/iris 53 | ... 54 | 55 | $ ls -al 56 | -rwxr-xr-x 1 root root 9995000 Nov 24 16:44 iris-android-16-arm 57 | -rwxr-xr-x 1 root root 6776500 Nov 24 16:44 iris-darwin-10.6-386 58 | -rwxr-xr-x 1 root root 8755532 Nov 24 16:44 iris-darwin-10.6-amd64 59 | -rwxr-xr-x 1 root root 7114176 Nov 24 16:45 iris-ios-5.0-arm 60 | -rwxr-xr-x 1 root root 10135248 Nov 24 16:44 iris-linux-386 61 | -rwxr-xr-x 1 root root 12598472 Nov 24 16:44 iris-linux-amd64 62 | -rwxr-xr-x 1 root root 10040464 Nov 24 16:44 iris-linux-arm 63 | -rwxr-xr-x 1 root root 7516368 Nov 24 16:44 iris-windows-4.0-386.exe 64 | -rwxr-xr-x 1 root root 9549416 Nov 24 16:44 iris-windows-4.0-amd64.exe 65 | 66 | 67 | If the path is not a canonical import path, but rather a local path (starts with 68 | a dot `.` or a dash `/`), xgo will use the local GOPATH contents for the cross 69 | compilation. 70 | 71 | 72 | ### Build flags 73 | 74 | A handful of flags can be passed to `go build`. The currently supported ones are 75 | 76 | - `-v`: prints the names of packages as they are compiled 77 | - `-x`: prints the build commands as compilation progresses 78 | - `-race`: enables data race detection (supported only on amd64, rest built without) 79 | - `-tags='tag list'`: list of build tags to consider satisfied during the build 80 | - `-ldflags='flag list'`: arguments to pass on each go tool link invocation 81 | - `-buildmode=mode`: binary type to produce by the compiler 82 | 83 | 84 | ### Go releases 85 | 86 | As newer versions of the language runtime, libraries and tools get released, 87 | these will get incorporated into xgo too as extensions layers to the base cross 88 | compilation image (only Go 1.3 and above will be supported). 89 | 90 | You can select which Go release to work with through the `-go` command line flag 91 | to xgo and if the specific release was already integrated, it will automatically 92 | be retrieved and installed. 93 | 94 | $ xgo -go 1.6.1 github.com/project-iris/iris 95 | 96 | Additionally, a few wildcard release strings are also supported: 97 | 98 | - `latest` will use the latest Go release (this is the default) 99 | - `1.6.x` will use the latest point release of a specific Go version 100 | - `1.6-develop` will use the develop branch of a specific Go version 101 | - `develop` will use the develop branch of the entire Go repository 102 | 103 | ### Output prefixing 104 | 105 | xgo by default uses the name of the package being cross compiled as the output 106 | file prefix. This can be overridden with the `-out` flag. 107 | 108 | $ xgo -out iris-v0.3.2 github.com/project-iris/iris 109 | ... 110 | 111 | $ ls -al 112 | -rwxr-xr-x 1 root root 9995000 Nov 24 16:44 iris-v0.3.2-android-16-arm 113 | -rwxr-xr-x 1 root root 6776500 Nov 24 16:44 iris-v0.3.2-darwin-10.6-386 114 | -rwxr-xr-x 1 root root 8755532 Nov 24 16:44 iris-v0.3.2-darwin-10.6-amd64 115 | -rwxr-xr-x 1 root root 7114176 Nov 24 16:45 iris-v0.3.2-ios-5.0-arm 116 | -rwxr-xr-x 1 root root 10135248 Nov 24 16:44 iris-v0.3.2-linux-386 117 | -rwxr-xr-x 1 root root 12598472 Nov 24 16:44 iris-v0.3.2-linux-amd64 118 | -rwxr-xr-x 1 root root 10040464 Nov 24 16:44 iris-v0.3.2-linux-arm 119 | -rwxr-xr-x 1 root root 7516368 Nov 24 16:44 iris-v0.3.2-windows-4.0-386.exe 120 | -rwxr-xr-x 1 root root 9549416 Nov 24 16:44 iris-v0.3.2-windows-4.0-amd64.exe 121 | 122 | 123 | ### Branch selection 124 | 125 | Similarly to `go get`, xgo also uses the `master` branch of a repository during 126 | source code retrieval. To switch to a different branch before compilation pass 127 | the desired branch name through the `--branch` argument. 128 | 129 | $ xgo --branch release-branch.go1.4 golang.org/x/tools/cmd/goimports 130 | ... 131 | 132 | $ ls -al 133 | -rwxr-xr-x 1 root root 4171248 Nov 24 16:40 goimports-android-16-arm 134 | -rwxr-xr-x 1 root root 4139868 Nov 24 16:40 goimports-darwin-10.6-386 135 | -rwxr-xr-x 1 root root 5186720 Nov 24 16:40 goimports-darwin-10.6-amd64 136 | -rwxr-xr-x 1 root root 3202364 Nov 24 16:40 goimports-ios-5.0-arm 137 | -rwxr-xr-x 1 root root 4189456 Nov 24 16:40 goimports-linux-386 138 | -rwxr-xr-x 1 root root 5264136 Nov 24 16:40 goimports-linux-amd64 139 | -rwxr-xr-x 1 root root 4209416 Nov 24 16:40 goimports-linux-arm 140 | -rwxr-xr-x 1 root root 4348416 Nov 24 16:40 goimports-windows-4.0-386.exe 141 | -rwxr-xr-x 1 root root 5415424 Nov 24 16:40 goimports-windows-4.0-amd64.exe 142 | 143 | 144 | ### Remote selection 145 | 146 | Yet again similarly to `go get`, xgo uses the repository remote corresponding to 147 | the import path being built. To switch to a different remote while preserving the 148 | original import path, use the `--remote` argument. 149 | 150 | $ xgo --remote github.com/golang/tools golang.org/x/tools/cmd/goimports 151 | ... 152 | 153 | ### Package selection 154 | 155 | If you used the above *branch* or *remote* selection machanisms, it may happen 156 | that the path you are trying to build is only present in the specific branch and 157 | not the default repository, causing Go to fail at locating it. To circumvent this, 158 | you may specify only the repository root for xgo, and use an additional `--pkg` 159 | parameter to select the exact package within, honoring any prior *branch* and 160 | *remote* selections. 161 | 162 | $ xgo --pkg cmd/goimports golang.org/x/tools 163 | ... 164 | 165 | $ ls -al 166 | -rwxr-xr-x 1 root root 4194956 Nov 24 16:38 goimports-android-16-arm 167 | -rwxr-xr-x 1 root root 4164448 Nov 24 16:38 goimports-darwin-10.6-386 168 | -rwxr-xr-x 1 root root 5223584 Nov 24 16:38 goimports-darwin-10.6-amd64 169 | -rwxr-xr-x 1 root root 3222848 Nov 24 16:39 goimports-ios-5.0-arm 170 | -rwxr-xr-x 1 root root 4217184 Nov 24 16:38 goimports-linux-386 171 | -rwxr-xr-x 1 root root 5295768 Nov 24 16:38 goimports-linux-amd64 172 | -rwxr-xr-x 1 root root 4233120 Nov 24 16:38 goimports-linux-arm 173 | -rwxr-xr-x 1 root root 4373504 Nov 24 16:38 goimports-windows-4.0-386.exe 174 | -rwxr-xr-x 1 root root 5450240 Nov 24 16:38 goimports-windows-4.0-amd64.exe 175 | 176 | This argument may at some point be integrated into the import path itself, but for 177 | now it exists as an independent build parameter. Also, there is not possibility 178 | for now to build mulitple commands in one go. 179 | 180 | ### Limit build targets 181 | 182 | By default `xgo` will try and build the specified package to all platforms and 183 | architectures supported by the underlying Go runtime. If you wish to restrict 184 | the build to only a few target systems, use the comma separated `--targets` CLI 185 | argument: 186 | 187 | * `--targets=linux/arm`: builds only the ARMv5 Linux binaries (`arm-6`/`arm-7` allowed) 188 | * `--targets=windows/*,darwin/*`: builds all Windows and OSX binaries 189 | * `--targets=*/arm`: builds ARM binaries for all platforms 190 | * `--targets=*/*`: builds all suppoted targets (default) 191 | 192 | The supported targets are: 193 | 194 | * Platforms: `android`, `darwin`, `ios`, `linux`, `windows` 195 | * Achitectures: `386`, `amd64`, `arm-5`, `arm-6`, `arm-7`, `arm64`, `mips`, `mipsle`, `mips64`, `mips64le` 196 | 197 | ### Platform versions 198 | 199 | By default `xgo` tries to cross compile to the lowest possible versions of every 200 | supported platform, in order to produce binaries that are portable among various 201 | versions of the same operating system. This however can lead to issues if a used 202 | dependency is only supported by more recent systems. As such, `xgo` supports the 203 | selection of specific platform versions by appending them to the OS target string. 204 | 205 | * `--targets=ios-8.1/*`: cross compile to iOS 8.1 206 | * `--targets=android-16/*`: cross compile to Android Jelly Bean 207 | * `--targets=darwin-10.9/*`: cross compile to Mac OS X Mavericks 208 | * `--targets=windows-6.0/*`: cross compile to Windows Vista 209 | 210 | The supported platforms are: 211 | 212 | * All Android APIs up to Android Lollipop 5.0 ([API level ids](https://source.android.com/source/build-numbers.html)) 213 | * All Windows APIs up to Windows 8.1 limited by `mingw-w64` ([API level ids](https://en.wikipedia.org/wiki/Windows_NT#Releases)) 214 | * OSX APIs in the range of 10.6 - 10.11 215 | * All iOS APIs up to iOS 9.3 216 | 217 | ### Mobile libraries 218 | 219 | Apart from the usual runnable binaries, `xgo` also supports building library 220 | archives for Android (`android/aar`) and iOS (`ios/framework`). Opposed to 221 | `gomobile` however `xgo` does not derive library APIs from the Go code, so 222 | proper CGO C external methods must be defined within the package. 223 | 224 | In the case of Android archives, all architectures will be bundled that are 225 | supported by the requested Android platform version. For iOS frameworks `xgo` 226 | will bundle armv7 and arm64 by default, and also the x86_64 simulator builds 227 | if the iPhoneSimulator.sdk was injected by the user: 228 | 229 | * Create a new docker image based on xgo: `FROM karalabe/xgo-latest` 230 | * Inject the simulator SDK: `ADD iPhoneSimulator9.3.sdk.tar.xz /iPhoneSimulator9.3.sdk.tar.xz` 231 | * Bootstrap the simulator SDK: `$UPDATE_IOS /iPhoneSimulator9.3.sdk.tar.xz` 232 | 233 | ### CGO dependencies 234 | 235 | The main differentiator of xgo versus other cross compilers is support for basic 236 | embedded C/C++ code and target-platform specific OS SDK availability. The current 237 | xgo release introduces an experimental CGO *dependency* cross compilation, enabling 238 | building Go programs that require external C/C++ libraries. 239 | 240 | It is assumed that the dependent C/C++ library is `configure/make` based, was 241 | properly prepared for cross compilation and is available as a tarball download 242 | (`.tar`, `.tar.gz` or `.tar.bz2`). Further plans include extending this to cmake 243 | based projects, if need arises (please open an issue if it's important to you). 244 | 245 | Such dependencies can be added via the `--deps` argument. They will be retrieved 246 | prior to starting the cross compilation and the packages cached to save bandwidth 247 | on subsequent calls. 248 | 249 | A complex sample for such a scenario is building the Ethereum CLI node, which has 250 | the GNU Multiple Precision Arithmetic Library as it's dependency. 251 | 252 | $ xgo --deps=https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2 \ 253 | --targets=windows/* github.com/ethereum/go-ethereum/cmd/geth 254 | ... 255 | 256 | $ ls -al 257 | -rwxr-xr-x 1 root root 16315679 Nov 24 16:39 geth-windows-4.0-386.exe 258 | -rwxr-xr-x 1 root root 19452036 Nov 24 16:38 geth-windows-4.0-amd64.exe 259 | 260 | Some trivial arguments may be passed to the dependencies' configure script via 261 | `--depsargs`. 262 | 263 | $ xgo --deps=https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2 \ 264 | --targets=ios/* --depsargs=--disable-assembly \ 265 | github.com/ethereum/go-ethereum/cmd/geth 266 | ... 267 | 268 | $ ls -al 269 | -rwxr-xr-x 1 root root 14804160 Nov 24 16:32 geth-ios-5.0-arm 270 | 271 | Note, that since xgo needs to cross compile the dependencies for each platform 272 | and architecture separately, build time can increase significantly. 273 | -------------------------------------------------------------------------------- /docker/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Base cross-compilation layer 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM ubuntu:16.04 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Mark the image as xgo enabled to support xgo-in-xgo 11 | ENV XGO_IN_XGO 1 12 | 13 | 14 | # Configure the Go environment, since it's not going to change 15 | ENV PATH /usr/local/go/bin:$PATH 16 | ENV GOPATH /go 17 | 18 | 19 | # Inject the remote file fetcher and checksum verifier 20 | ADD fetch.sh /fetch.sh 21 | ENV FETCH /fetch.sh 22 | RUN chmod +x $FETCH 23 | 24 | 25 | # Make sure apt-get is up to date and dependent packages are installed 26 | RUN \ 27 | apt-get update && \ 28 | apt-get install -y automake autogen build-essential ca-certificates \ 29 | gcc-5-arm-linux-gnueabi g++-5-arm-linux-gnueabi libc6-dev-armel-cross \ 30 | gcc-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf libc6-dev-armhf-cross \ 31 | gcc-5-aarch64-linux-gnu g++-5-aarch64-linux-gnu libc6-dev-arm64-cross \ 32 | gcc-5-mips-linux-gnu g++-5-mips-linux-gnu libc6-dev-mips-cross \ 33 | gcc-5-mipsel-linux-gnu g++-5-mipsel-linux-gnu libc6-dev-mipsel-cross \ 34 | gcc-5-mips64-linux-gnuabi64 g++-5-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ 35 | gcc-5-mips64el-linux-gnuabi64 g++-5-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ 36 | gcc-5-multilib g++-5-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ 37 | libtool libxml2-dev uuid-dev libssl-dev swig openjdk-8-jdk pkg-config patch \ 38 | make xz-utils cpio wget zip unzip p7zip git mercurial bzr texinfo help2man \ 39 | --no-install-recommends 40 | 41 | # Fix any stock package issues 42 | RUN ln -s /usr/include/asm-generic /usr/include/asm 43 | 44 | # Configure the container for OSX cross compilation 45 | ENV OSX_SDK MacOSX10.11.sdk 46 | ENV OSX_NDK_X86 /usr/local/osx-ndk-x86 47 | 48 | RUN \ 49 | OSX_SDK_PATH=https://s3.dockerproject.org/darwin/v2/$OSX_SDK.tar.xz && \ 50 | $FETCH $OSX_SDK_PATH dd228a335194e3392f1904ce49aff1b1da26ca62 && \ 51 | \ 52 | git clone https://github.com/tpoechtrager/osxcross.git && \ 53 | mv `basename $OSX_SDK_PATH` /osxcross/tarballs/ && \ 54 | \ 55 | sed -i -e 's|-march=native||g' /osxcross/build_clang.sh /osxcross/wrapper/build.sh && \ 56 | UNATTENDED=yes OSX_VERSION_MIN=10.6 /osxcross/build.sh && \ 57 | mv /osxcross/target $OSX_NDK_X86 && \ 58 | \ 59 | rm -rf /osxcross 60 | 61 | ADD patch.tar.xz $OSX_NDK_X86/SDK/$OSX_SDK/usr/include/c++ 62 | ENV PATH $OSX_NDK_X86/bin:$PATH 63 | 64 | # Configure the container for iOS cross compilation 65 | ENV IOS_NDK_ARM_7 /usr/local/ios-ndk-arm-7 66 | ENV IOS_NDK_ARM64 /usr/local/ios-ndk-arm64 67 | ENV IOS_SIM_NDK_AMD64 /usr/local/ios-sim-ndk-amd64 68 | 69 | ADD update_ios.sh /update_ios.sh 70 | ENV UPDATE_IOS /update_ios.sh 71 | RUN chmod +x $UPDATE_IOS 72 | 73 | RUN \ 74 | IOS_SDK_PATH=https://sdks.website/dl/iPhoneOS9.3.sdk.tbz2 && \ 75 | $FETCH $IOS_SDK_PATH db5ecf91617abf26d3db99e769bd655b943905e5 && \ 76 | mv `basename $IOS_SDK_PATH` iPhoneOS9.3.sdk.tar.bz2 && \ 77 | $UPDATE_IOS /iPhoneOS9.3.sdk.tar.bz2 && \ 78 | rm -rf /iPhoneOS9.3.sdk.tar.bz2 79 | 80 | # Configure the container for Android cross compilation 81 | ENV ANDROID_NDK android-ndk-r11c 82 | ENV ANDROID_NDK_PATH http://dl.google.com/android/repository/$ANDROID_NDK-linux-x86_64.zip 83 | ENV ANDROID_NDK_ROOT /usr/local/$ANDROID_NDK 84 | ENV ANDROID_NDK_LIBC $ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/4.9 85 | ENV ANDROID_PLATFORM 21 86 | ENV ANDROID_CHAIN_ARM arm-linux-androideabi-4.9 87 | ENV ANDROID_CHAIN_ARM64 aarch64-linux-android-4.9 88 | ENV ANDROID_CHAIN_386 x86-4.9 89 | 90 | RUN \ 91 | $FETCH $ANDROID_NDK_PATH de5ce9bddeee16fb6af2b9117e9566352aa7e279 && \ 92 | unzip `basename $ANDROID_NDK_PATH` \ 93 | "$ANDROID_NDK/build/*" \ 94 | "$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.9/include/*" \ 95 | "$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi*/*" \ 96 | "$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64*/*" \ 97 | "$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/*" \ 98 | "$ANDROID_NDK/prebuilt/linux-x86_64/*" \ 99 | "$ANDROID_NDK/platforms/*/arch-arm/*" \ 100 | "$ANDROID_NDK/platforms/*/arch-arm64/*" \ 101 | "$ANDROID_NDK/platforms/*/arch-x86/*" \ 102 | "$ANDROID_NDK/toolchains/$ANDROID_CHAIN_ARM/*" \ 103 | "$ANDROID_NDK/toolchains/$ANDROID_CHAIN_ARM64/*" \ 104 | "$ANDROID_NDK/toolchains/$ANDROID_CHAIN_386/*" -d /usr/local > /dev/null && \ 105 | rm -f `basename $ANDROID_NDK_PATH` 106 | 107 | ENV PATH /usr/$ANDROID_CHAIN_ARM/bin:$PATH 108 | ENV PATH /usr/$ANDROID_CHAIN_ARM64/bin:$PATH 109 | ENV PATH /usr/$ANDROID_CHAIN_386/bin:$PATH 110 | 111 | # Inject the old Go package downloader and tool-chain bootstrapper 112 | ADD bootstrap.sh /bootstrap.sh 113 | ENV BOOTSTRAP /bootstrap.sh 114 | RUN chmod +x $BOOTSTRAP 115 | 116 | # Inject the new Go root distribution downloader and bootstrapper 117 | ADD bootstrap_pure.sh /bootstrap_pure.sh 118 | ENV BOOTSTRAP_PURE /bootstrap_pure.sh 119 | RUN chmod +x $BOOTSTRAP_PURE 120 | 121 | # Inject the Go source distribution downloader and bootstrapper 122 | ADD bootstrap_repo.sh /bootstrap_repo.sh 123 | ENV BOOTSTRAP_REPO /bootstrap_repo.sh 124 | RUN chmod +x $BOOTSTRAP_REPO 125 | 126 | # Inject the C dependency cross compiler 127 | ADD build_deps.sh /build_deps.sh 128 | ENV BUILD_DEPS /build_deps.sh 129 | RUN chmod +x $BUILD_DEPS 130 | 131 | # Inject the container entry point, the build script 132 | ADD build.sh /build.sh 133 | ENV BUILD /build.sh 134 | RUN chmod +x $BUILD 135 | 136 | ENTRYPOINT ["/build.sh"] 137 | -------------------------------------------------------------------------------- /docker/base/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Contains the Go tool-chain bootstrapper, that retrieves all the configured 4 | # distribution packages, extracts the binaries and deletes anything not needed. 5 | # 6 | # Usage: bootstrap.sh 7 | # 8 | # Needed environment variables: 9 | # FETCH - Remote file fetcher and checksum verifier (injected by image) 10 | # DIST_LINUX_64, DIST_LINUX_64_SHA - 64 bit Linux Go binaries and checksum 11 | # DIST_LINUX_32, DIST_LINUX_32_SHA - 32 bit Linux Go binaries and checksum 12 | # DIST_LINUX_ARM, DIST_LINUX_ARM_SHA - ARM v5 Linux Go binaries and checksum 13 | # DIST_OSX_64, DIST_OSX_64_SHA - 64 bit Mac OSX Go binaries and checksum 14 | # DIST_OSX_32, DIST_OSX_32_SHA - 32 bit Mac OSX Go binaries and checksum 15 | # DIST_WIN_64, DIST_WIN_64_SHA - 64 bit Windows Go binaries and checksum 16 | # DIST_WIN_32, DIST_WIN_32_SHA - 32 bit Windows Go binaries and checksum 17 | set -e 18 | 19 | # Download and verify all the binary packages 20 | $FETCH $DIST_LINUX_64 $DIST_LINUX_64_SHA 21 | $FETCH $DIST_LINUX_32 $DIST_LINUX_32_SHA 22 | $FETCH $DIST_LINUX_ARM $DIST_LINUX_ARM_SHA 23 | $FETCH $DIST_OSX_64 $DIST_OSX_64_SHA 24 | $FETCH $DIST_OSX_32 $DIST_OSX_32_SHA 25 | $FETCH $DIST_WIN_64 $DIST_WIN_64_SHA 26 | $FETCH $DIST_WIN_32 $DIST_WIN_32_SHA 27 | 28 | # Extract the 64 bit Linux package as the primary Go SDK 29 | tar -C /usr/local -xzf `basename $DIST_LINUX_64` 30 | rm -f `basename $DIST_LINUX_64` 31 | 32 | export GOROOT=/usr/local/go 33 | export GOROOT_BOOTSTRAP=$GOROOT 34 | 35 | # Extract all other packages as secondary ones, keeping only the binaries 36 | if [ "$DIST_LINUX_32" != "" ]; then 37 | tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_32` go/pkg/linux_386* 38 | GOOS=linux GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap 39 | rm -f `basename $DIST_LINUX_32` 40 | fi 41 | if [ "$DIST_LINUX_ARM" != "" ]; then 42 | tar -C /usr/local --wildcards -xzf `basename $DIST_LINUX_ARM` go/pkg/linux_arm* 43 | GOOS=linux GOARCH=arm /usr/local/go/pkg/tool/linux_amd64/dist bootstrap 44 | rm -f `basename $DIST_LINUX_ARM` 45 | fi 46 | 47 | if [ "$DIST_OSX_64" != "" ]; then 48 | tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_64` go/pkg/darwin_amd64* 49 | GOOS=darwin GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap 50 | rm -f `basename $DIST_OSX_64` 51 | fi 52 | if [ "$DIST_OSX_32" != "" ]; then 53 | tar -C /usr/local --wildcards -xzf `basename $DIST_OSX_32` go/pkg/darwin_386* 54 | GOOS=darwin GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap 55 | rm -f `basename $DIST_OSX_32` 56 | fi 57 | 58 | if [ "$DIST_WIN_64" != "" ]; then 59 | unzip -d /usr/local -q `basename $DIST_WIN_64` go/pkg/windows_amd64* 60 | GOOS=windows GOARCH=amd64 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap 61 | rm -f `basename $DIST_WIN_64` 62 | fi 63 | if [ "$DIST_WIN_32" != "" ]; then 64 | unzip -d /usr/local -q `basename $DIST_WIN_32` go/pkg/windows_386* 65 | GOOS=windows GOARCH=386 /usr/local/go/pkg/tool/linux_amd64/dist bootstrap 66 | rm -f `basename $DIST_WIN_32` 67 | fi 68 | 69 | # Install xgo within the container to enable internal cross compilation 70 | echo "Installing xgo-in-xgo..." 71 | go get -u github.com/karalabe/xgo 72 | -------------------------------------------------------------------------------- /docker/base/bootstrap_pure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Contains the Go tool-chain pure-Go bootstrapper, that as of Go 1.5, initiates 4 | # not only a few pre-built Go cross compilers, but rather bootstraps all of the 5 | # supported platforms from the origin Linux amd64 distribution. 6 | # 7 | # Usage: bootstrap_pure.sh 8 | # 9 | # Environment variables for remote bootstrapping: 10 | # FETCH - Remote file fetcher and checksum verifier (injected by image) 11 | # ROOT_DIST - 64 bit Linux Go binary distribution package 12 | # ROOT_DIST_SHA - 64 bit Linux Go distribution package checksum 13 | # 14 | # Environment variables for local bootstrapping: 15 | # GOROOT - Path to the lready installed Go runtime 16 | set -e 17 | 18 | # Download, verify and install the root distribution if pulled remotely 19 | if [ "$GOROOT" == "" ]; then 20 | $FETCH $ROOT_DIST $ROOT_DIST_SHA 21 | 22 | tar -C /usr/local -xzf `basename $ROOT_DIST` 23 | rm -f `basename $ROOT_DIST` 24 | 25 | export GOROOT=/usr/local/go 26 | fi 27 | export GOROOT_BOOTSTRAP=$GOROOT 28 | 29 | # Pre-build all guest distributions based on the root distribution 30 | echo "Bootstrapping linux/386..." 31 | GOOS=linux GOARCH=386 CGO_ENABLED=1 go install std 32 | 33 | echo "Bootstrapping linux/arm64..." 34 | GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc-5 go install std 35 | 36 | if [ $GO_VERSION -ge 170 ]; then 37 | echo "Bootstrapping linux/mips64..." 38 | GOOS=linux GOARCH=mips64 CGO_ENABLED=1 CC=mips64-linux-gnuabi64-gcc-5 go install std 39 | 40 | echo "Bootstrapping linux/mips64le..." 41 | GOOS=linux GOARCH=mips64le CGO_ENABLED=1 CC=mips64el-linux-gnuabi64-gcc-5 go install std 42 | fi 43 | 44 | if [ $GO_VERSION -ge 180 ]; then 45 | echo "Bootstrapping linux/mips..." 46 | GOOS=linux GOARCH=mips CGO_ENABLED=1 CC=mips-linux-gnu-gcc-5 go install std 47 | 48 | echo "Bootstrapping linux/mipsle..." 49 | GOOS=linux GOARCH=mipsle CGO_ENABLED=1 CC=mipsel-linux-gnu-gcc-5 go install std 50 | fi 51 | 52 | echo "Bootstrapping windows/amd64..." 53 | GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go install std 54 | 55 | echo "Bootstrapping windows/386..." 56 | GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go install std 57 | 58 | echo "Bootstrapping darwin/amd64..." 59 | GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CC=o64-clang go install std 60 | 61 | echo "Bootstrapping darwin/386..." 62 | GOOS=darwin GOARCH=386 CGO_ENABLED=1 CC=o32-clang go install std 63 | 64 | # Install xgo within the container to enable internal cross compilation 65 | echo "Installing xgo-in-xgo..." 66 | go get -u github.com/karalabe/xgo 67 | ln -s /go/bin/xgo /usr/bin/xgo 68 | -------------------------------------------------------------------------------- /docker/base/bootstrap_repo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Contains the Go tool-chain source repository bootstrapper, that builds and 4 | # bootstraps a Go environment from the official GitHub repository, opposed to 5 | # using pre-build packages. 6 | # 7 | # Usage: bootstrap_repo.sh 8 | # 9 | # Needed environment variables: 10 | # FETCH - Remote file fetcher and checksum verifier (injected by image) 11 | set -e 12 | 13 | # Define the paths to deploy the bootstrapper and the final distribution 14 | export GOROOT=/usr/local/go 15 | export GOROOT_BOOTSTRAP=${GOROOT}-boot 16 | 17 | # Download and install the Go bootstrap distribution 18 | BOOT_DIST=https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz 19 | BOOT_DIST_SHA=332b64236d30a8805fc8dd8b3a269915b4c507fe 20 | 21 | $FETCH $BOOT_DIST $BOOT_DIST_SHA 22 | 23 | tar -C /usr/local -xzf `basename $BOOT_DIST` 24 | rm -f `basename $BOOT_DIST` 25 | mv $GOROOT $GOROOT_BOOTSTRAP 26 | 27 | # Download, build and install the requesed Go sources 28 | (cd /usr/local && git clone https://go.googlesource.com/go) 29 | (cd $GOROOT && git checkout $1) 30 | (cd $GOROOT/src && ./make.bash) 31 | 32 | rm -rf $GOROOT_BOOTSTRAP 33 | export GOROOT_BOOTSTRAP=$GOROOT 34 | 35 | $BOOTSTRAP_PURE 36 | -------------------------------------------------------------------------------- /docker/base/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Contains the main cross compiler, that individually sets up each target build 4 | # platform, compiles all the C dependencies, then build the requested executable 5 | # itself. 6 | # 7 | # Usage: build.sh 8 | # 9 | # Needed environment variables: 10 | # REPO_REMOTE - Optional VCS remote if not the primary repository is needed 11 | # REPO_BRANCH - Optional VCS branch to use, if not the master branch 12 | # DEPS - Optional list of C dependency packages to build 13 | # ARGS - Optional arguments to pass to C dependency configure scripts 14 | # PACK - Optional sub-package, if not the import path is being built 15 | # OUT - Optional output prefix to override the package name 16 | # FLAG_V - Optional verbosity flag to set on the Go builder 17 | # FLAG_X - Optional flag to print the build progress commands 18 | # FLAG_RACE - Optional race flag to set on the Go builder 19 | # FLAG_TAGS - Optional tag flag to set on the Go builder 20 | # FLAG_LDFLAGS - Optional ldflags flag to set on the Go builder 21 | # FLAG_BUILDMODE - Optional buildmode flag to set on the Go builder 22 | # TARGETS - Comma separated list of build targets to compile for 23 | # GO_VERSION - Bootstrapped version of Go to disable uncupported targets 24 | # EXT_GOPATH - GOPATH elements mounted from the host filesystem 25 | 26 | # Define a function that figures out the binary extension 27 | function extension { 28 | if [ "$FLAG_BUILDMODE" == "archive" ] || [ "$FLAG_BUILDMODE" == "c-archive" ]; then 29 | if [ "$1" == "windows" ]; then 30 | echo ".lib" 31 | else 32 | echo ".a" 33 | fi 34 | elif [ "$FLAG_BUILDMODE" == "shared" ] || [ "$FLAG_BUILDMODE" == "c-shared" ]; then 35 | if [ "$1" == "windows" ]; then 36 | echo ".dll" 37 | elif [ "$1" == "darwin" ] || [ "$1" == "ios" ]; then 38 | echo ".dylib" 39 | else 40 | echo ".so" 41 | fi 42 | else 43 | if [ "$1" == "windows" ]; then 44 | echo ".exe" 45 | fi 46 | fi 47 | } 48 | 49 | # Either set a local build environemnt, or pull any remote imports 50 | if [ "$EXT_GOPATH" != "" ]; then 51 | # If local builds are requested, inject the sources 52 | echo "Building locally $1..." 53 | export GOPATH=$GOPATH:$EXT_GOPATH 54 | set -e 55 | 56 | # Find and change into the package folder 57 | cd `go list -e -f {{.Dir}} $1` 58 | export GOPATH=$GOPATH:`pwd`/Godeps/_workspace 59 | else 60 | # Inject all possible Godep paths to short circuit go gets 61 | GOPATH_ROOT=$GOPATH/src 62 | IMPORT_PATH=$1 63 | while [ "$IMPORT_PATH" != "." ]; do 64 | export GOPATH=$GOPATH:$GOPATH_ROOT/$IMPORT_PATH/Godeps/_workspace 65 | IMPORT_PATH=`dirname $IMPORT_PATH` 66 | done 67 | 68 | # Otherwise download the canonical import path (may fail, don't allow failures beyond) 69 | echo "Fetching main repository $1..." 70 | go get -v -d $1 71 | set -e 72 | 73 | cd $GOPATH_ROOT/$1 74 | 75 | # Switch over the code-base to another checkout if requested 76 | if [ "$REPO_REMOTE" != "" ] || [ "$REPO_BRANCH" != "" ]; then 77 | # Detect the version control system type 78 | IMPORT_PATH=$1 79 | while [ "$IMPORT_PATH" != "." ] && [ "$REPO_TYPE" == "" ]; do 80 | if [ -d "$GOPATH_ROOT/$IMPORT_PATH/.git" ]; then 81 | REPO_TYPE="git" 82 | elif [ -d "$GOPATH_ROOT/$IMPORT_PATH/.hg" ]; then 83 | REPO_TYPE="hg" 84 | fi 85 | IMPORT_PATH=`dirname $IMPORT_PATH` 86 | done 87 | 88 | if [ "$REPO_TYPE" == "" ]; then 89 | echo "Unknown version control system type, cannot switch remotes and branches." 90 | exit -1 91 | fi 92 | # If we have a valid VCS, execute the switch operations 93 | if [ "$REPO_REMOTE" != "" ]; then 94 | echo "Switching over to remote $REPO_REMOTE..." 95 | if [ "$REPO_TYPE" == "git" ]; then 96 | git remote set-url origin $REPO_REMOTE 97 | git fetch --all 98 | git reset --hard origin/HEAD 99 | git clean -dxf 100 | elif [ "$REPO_TYPE" == "hg" ]; then 101 | echo -e "[paths]\ndefault = $REPO_REMOTE\n" >> .hg/hgrc 102 | hg pull 103 | fi 104 | fi 105 | if [ "$REPO_BRANCH" != "" ]; then 106 | echo "Switching over to branch $REPO_BRANCH..." 107 | if [ "$REPO_TYPE" == "git" ]; then 108 | git reset --hard origin/$REPO_BRANCH 109 | git clean -dxf 110 | elif [ "$REPO_TYPE" == "hg" ]; then 111 | hg checkout $REPO_BRANCH 112 | fi 113 | fi 114 | fi 115 | fi 116 | 117 | # Download all the C dependencies 118 | mkdir /deps 119 | DEPS=($DEPS) && for dep in "${DEPS[@]}"; do 120 | if [ "${dep##*.}" == "tar" ]; then cat "/deps-cache/`basename $dep`" | tar -C /deps -x; fi 121 | if [ "${dep##*.}" == "gz" ]; then cat "/deps-cache/`basename $dep`" | tar -C /deps -xz; fi 122 | if [ "${dep##*.}" == "bz2" ]; then cat "/deps-cache/`basename $dep`" | tar -C /deps -xj; fi 123 | done 124 | 125 | DEPS_ARGS=($ARGS) 126 | 127 | # Save the contents of the pre-build /usr/local folder for post cleanup 128 | USR_LOCAL_CONTENTS=`ls /usr/local` 129 | 130 | # Configure some global build parameters 131 | NAME=`basename $1/$PACK` 132 | if [ "$OUT" != "" ]; then 133 | NAME=$OUT 134 | fi 135 | 136 | if [ "$FLAG_V" == "true" ]; then V=-v; fi 137 | if [ "$FLAG_X" == "true" ]; then X=-x; fi 138 | if [ "$FLAG_RACE" == "true" ]; then R=-race; fi 139 | if [ "$FLAG_TAGS" != "" ]; then T=(--tags "$FLAG_TAGS"); fi 140 | if [ "$FLAG_LDFLAGS" != "" ]; then LD="$FLAG_LDFLAGS"; fi 141 | 142 | if [ "$FLAG_BUILDMODE" != "" ] && [ "$FLAG_BUILDMODE" != "default" ]; then BM="--buildmode=$FLAG_BUILDMODE"; fi 143 | 144 | # If no build targets were specified, inject a catch all wildcard 145 | if [ "$TARGETS" == "" ]; then 146 | TARGETS="./." 147 | fi 148 | 149 | # Build for each requested platform individually 150 | for TARGET in $TARGETS; do 151 | # Split the target into platform and architecture 152 | XGOOS=`echo $TARGET | cut -d '/' -f 1` 153 | XGOARCH=`echo $TARGET | cut -d '/' -f 2` 154 | 155 | # Check and build for Android targets 156 | if ([ $XGOOS == "." ] || [[ $XGOOS == android* ]]); then 157 | # Split the platform version and configure the linker options 158 | PLATFORM=`echo $XGOOS | cut -d '-' -f 2` 159 | if [ "$PLATFORM" == "" ] || [ "$PLATFORM" == "." ] || [ "$PLATFORM" == "android" ]; then 160 | PLATFORM=16 # Jelly Bean 4.0.0 161 | fi 162 | if [ "$PLATFORM" -ge 16 ]; then 163 | CGO_CCPIE="-fPIE" 164 | CGO_LDPIE="-fPIE" 165 | EXT_LDPIE="-extldflags=-pie" 166 | else 167 | unset CGO_CCPIE CGO_LDPIE EXT_LDPIE 168 | fi 169 | mkdir -p /build-android-aar 170 | 171 | # Iterate over the requested architectures, bootstrap and build 172 | if [ $XGOARCH == "." ] || [ $XGOARCH == "arm" ] || [ $XGOARCH == "aar" ]; then 173 | if [ "$GO_VERSION" -lt 150 ]; then 174 | echo "Go version too low, skipping android-$PLATFORM/arm..." 175 | else 176 | # Include a linker workaround for pre Go 1.6 releases 177 | if [ "$GO_VERSION" -lt 160 ]; then 178 | EXT_LDAMD="-extldflags=-Wl,--allow-multiple-definition" 179 | fi 180 | 181 | echo "Assembling toolchain for android-$PLATFORM/arm..." 182 | $ANDROID_NDK_ROOT/build/tools/make-standalone-toolchain.sh --ndk-dir=$ANDROID_NDK_ROOT --install-dir=/usr/$ANDROID_CHAIN_ARM --toolchain=$ANDROID_CHAIN_ARM --arch=arm > /dev/null 2>&1 183 | 184 | echo "Bootstrapping android-$PLATFORM/arm..." 185 | CC=arm-linux-androideabi-gcc GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go install std 186 | 187 | echo "Compiling for android-$PLATFORM/arm..." 188 | CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ HOST=arm-linux-androideabi PREFIX=/usr/$ANDROID_CHAIN_ARM/arm-linux-androideabi $BUILD_DEPS /deps ${DEPS_ARGS[@]} 189 | export PKG_CONFIG_PATH=/usr/$ANDROID_CHAIN_ARM/arm-linux-androideabi/lib/pkgconfig 190 | 191 | if [ $XGOARCH == "." ] || [ $XGOARCH == "arm" ]; then 192 | CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 193 | CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $EXT_LDAMD $LD" $BM -o "/build/$NAME-android-$PLATFORM-arm`extension android`" ./$PACK 194 | fi 195 | if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then 196 | CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 197 | CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $EXT_LDAMD $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-arm.so" ./$PACK 198 | fi 199 | fi 200 | fi 201 | if [ "$GO_VERSION" -lt 160 ]; then 202 | echo "Go version too low, skipping android-$PLATFORM/386,arm64..." 203 | else 204 | if [ "$PLATFORM" -ge 9 ] && ([ $XGOARCH == "." ] || [ $XGOARCH == "386" ] || [ $XGOARCH == "aar" ]); then 205 | echo "Assembling toolchain for android-$PLATFORM/386..." 206 | $ANDROID_NDK_ROOT/build/tools/make-standalone-toolchain.sh --ndk-dir=$ANDROID_NDK_ROOT --install-dir=/usr/$ANDROID_CHAIN_386 --toolchain=$ANDROID_CHAIN_386 --arch=x86 > /dev/null 2>&1 207 | 208 | echo "Bootstrapping android-$PLATFORM/386..." 209 | CC=i686-linux-android-gcc GOOS=android GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go install std 210 | 211 | echo "Compiling for android-$PLATFORM/386..." 212 | CC=i686-linux-android-gcc CXX=i686-linux-android-g++ HOST=i686-linux-android PREFIX=/usr/$ANDROID_CHAIN_386/i686-linux-android $BUILD_DEPS /deps ${DEPS_ARGS[@]} 213 | export PKG_CONFIG_PATH=/usr/$ANDROID_CHAIN_386/i686-linux-android/lib/pkgconfig 214 | 215 | if [ $XGOARCH == "." ] || [ $XGOARCH == "386" ]; then 216 | CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 217 | CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $LD" $BM -o "/build/$NAME-android-$PLATFORM-386`extension android`" ./$PACK 218 | fi 219 | if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then 220 | CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 221 | CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-386.so" ./$PACK 222 | fi 223 | fi 224 | if [ "$PLATFORM" -ge 21 ] && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ] || [ $XGOARCH == "aar" ]); then 225 | echo "Assembling toolchain for android-$PLATFORM/arm64..." 226 | $ANDROID_NDK_ROOT/build/tools/make-standalone-toolchain.sh --ndk-dir=$ANDROID_NDK_ROOT --install-dir=/usr/$ANDROID_CHAIN_ARM64 --toolchain=$ANDROID_CHAIN_ARM64 --arch=arm64 > /dev/null 2>&1 227 | 228 | echo "Bootstrapping android-$PLATFORM/arm64..." 229 | CC=aarch64-linux-android-gcc GOOS=android GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go install std 230 | 231 | echo "Compiling for android-$PLATFORM/arm64..." 232 | CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ HOST=aarch64-linux-android PREFIX=/usr/$ANDROID_CHAIN_ARM64/aarch64-linux-android $BUILD_DEPS /deps ${DEPS_ARGS[@]} 233 | export PKG_CONFIG_PATH=/usr/$ANDROID_CHAIN_ARM64/aarch64-linux-android/lib/pkgconfig 234 | 235 | if [ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ]; then 236 | CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 237 | CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $LD" $BM -o "/build/$NAME-android-$PLATFORM-arm64`extension android`" ./$PACK 238 | fi 239 | if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then 240 | CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 241 | CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-arm64.so" ./$PACK 242 | fi 243 | fi 244 | fi 245 | # Assemble the Android Archive from the built shared libraries 246 | if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then 247 | title=${NAME^} 248 | archive=/build/$NAME-android-$PLATFORM-aar 249 | bundle=/build/$NAME-android-$PLATFORM.aar 250 | 251 | # Generate the Java import path based on the Go one 252 | package=`go list ./$PACK | tr '-' '_'` 253 | package=$(for p in `echo ${package//\// }`; do echo $p | awk 'BEGIN{FS="."}{for (i=NF; i>0; i--){printf "%s.", $i;}}'; done | sed 's/.$//') 254 | package=${package%.*} 255 | 256 | # Create a fresh empty Android archive 257 | rm -rf $archive $bundle 258 | mkdir -p $archive 259 | 260 | echo -e "\n \n" > $archive/AndroidManifest.xml 261 | mkdir -p $archive/res 262 | touch $archive/R.txt 263 | 264 | # Generate the JNI wrappers automatically with SWIG 265 | jni=`mktemp -d` 266 | header=`find /build-android-aar | grep '\.h$' | head -n 1` 267 | if [ "$header" == "" ]; then 268 | echo "No API C header specified, skipping android-$PLATFORM/aar..." 269 | else 270 | cp $header $jni/$NAME.h 271 | sed -i -e 's|__complex|complex|g' $jni/$NAME.h 272 | sed -i -e 's|_Complex|complex|g' $jni/$NAME.h 273 | echo -e "%module $title\n%{\n#include \"$NAME.h\"\n%}\n%pragma(java) jniclasscode=%{\nstatic {\nSystem.loadLibrary(\"$NAME\");\n}\n%}\n%include \"$NAME.h\"" > $jni/$NAME.i 274 | 275 | mkdir -p $jni/${package//.//} 276 | swig -java -package $package -outdir $jni/${package//.//} $jni/$NAME.i 277 | 278 | # Assemble the Go static libraries and the JNI interface into shared libraries 279 | for lib in `find /build-android-aar | grep '\.so$'`; do 280 | if [[ "$lib" = *-arm.so ]]; then cc=arm-linux-androideabi-gcc; abi="armeabi-v7a"; fi 281 | if [[ "$lib" = *-arm64.so ]]; then cc=aarch64-linux-android-gcc; abi="arm64-v8a"; fi 282 | if [[ "$lib" = *-386.so ]]; then cc=i686-linux-android-gcc; abi="x86"; fi 283 | 284 | mkdir -p $archive/jni/$abi 285 | cp ${lib%.*}.h $jni/${NAME}.h 286 | cp $lib $archive/jni/$abi/lib${NAME}raw.so 287 | (cd $archive/jni/$abi && $cc -shared -fPIC -o lib${NAME}.so -I"$ANDROID_NDK_LIBC/include" -I"$ANDROID_NDK_LIBC/libs/$abi/include" -I"$jni" lib${NAME}raw.so $jni/${NAME}_wrap.c) 288 | done 289 | 290 | # Compile the Java wrapper and assemble into a .jar file 291 | mkdir -p $jni/build 292 | javac -target 1.7 -source 1.7 -cp . -d $jni/build $jni/${package//.//}/*.java 293 | (cd $jni/build && jar cvf $archive/classes.jar *) 294 | 295 | # Finally assemble the archive contents into an .aar and clean up 296 | (cd $archive && zip -r $bundle *) 297 | rm -rf $jni $archive 298 | fi 299 | fi 300 | # Clean up the android builds, toolchains and runtimes 301 | rm -rf /build-android-aar 302 | rm -rf /usr/local/go/pkg/android_* 303 | rm -rf /usr/$ANDROID_CHAIN_ARM /usr/$ANDROID_CHAIN_ARM64 /usr/$ANDROID_CHAIN_386 304 | fi 305 | # Check and build for Linux targets 306 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]); then 307 | echo "Compiling for linux/amd64..." 308 | HOST=x86_64-linux PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} 309 | GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 310 | GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" $R $BM -o "/build/$NAME-linux-amd64$R`extension linux`" ./$PACK 311 | fi 312 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "386" ]); then 313 | echo "Compiling for linux/386..." 314 | HOST=i686-linux PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} 315 | GOOS=linux GOARCH=386 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 316 | GOOS=linux GOARCH=386 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-386`extension linux`" ./$PACK 317 | fi 318 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm" ] || [ $XGOARCH == "arm-5" ]); then 319 | if [ "$GO_VERSION" -ge 150 ]; then 320 | echo "Bootstrapping linux/arm-5..." 321 | CC=arm-linux-gnueabi-gcc-5 GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=1 CGO_CFLAGS="-march=armv5" CGO_CXXFLAGS="-march=armv5" go install std 322 | fi 323 | echo "Compiling for linux/arm-5..." 324 | CC=arm-linux-gnueabi-gcc-5 CXX=arm-linux-gnueabi-g++-5 HOST=arm-linux-gnueabi PREFIX=/usr/arm-linux-gnueabi CFLAGS="-march=armv5" CXXFLAGS="-march=armv5" $BUILD_DEPS /deps ${DEPS_ARGS[@]} 325 | export PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig 326 | 327 | CC=arm-linux-gnueabi-gcc-5 CXX=arm-linux-gnueabi-g++-5 GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=1 CGO_CFLAGS="-march=armv5" CGO_CXXFLAGS="-march=armv5" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 328 | CC=arm-linux-gnueabi-gcc-5 CXX=arm-linux-gnueabi-g++-5 GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=1 CGO_CFLAGS="-march=armv5" CGO_CXXFLAGS="-march=armv5" go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-arm-5`extension linux`" ./$PACK 329 | if [ "$GO_VERSION" -ge 150 ]; then 330 | echo "Cleaning up Go runtime for linux/arm-5..." 331 | rm -rf /usr/local/go/pkg/linux_arm 332 | fi 333 | fi 334 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm-6" ]); then 335 | if [ "$GO_VERSION" -lt 150 ]; then 336 | echo "Go version too low, skipping linux/arm-6..." 337 | else 338 | echo "Bootstrapping linux/arm-6..." 339 | CC=arm-linux-gnueabi-gcc-5 GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=1 CGO_CFLAGS="-march=armv6" CGO_CXXFLAGS="-march=armv6" go install std 340 | 341 | echo "Compiling for linux/arm-6..." 342 | CC=arm-linux-gnueabi-gcc-5 CXX=arm-linux-gnueabi-g++-5 HOST=arm-linux-gnueabi PREFIX=/usr/arm-linux-gnueabi CFLAGS="-march=armv6" CXXFLAGS="-march=armv6" $BUILD_DEPS /deps ${DEPS_ARGS[@]} 343 | export PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig 344 | 345 | CC=arm-linux-gnueabi-gcc-5 CXX=arm-linux-gnueabi-g++-5 GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=1 CGO_CFLAGS="-march=armv6" CGO_CXXFLAGS="-march=armv6" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 346 | CC=arm-linux-gnueabi-gcc-5 CXX=arm-linux-gnueabi-g++-5 GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=1 CGO_CFLAGS="-march=armv6" CGO_CXXFLAGS="-march=armv6" go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-arm-6`extension linux`" ./$PACK 347 | 348 | echo "Cleaning up Go runtime for linux/arm-6..." 349 | rm -rf /usr/local/go/pkg/linux_arm 350 | fi 351 | fi 352 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm-7" ]); then 353 | if [ "$GO_VERSION" -lt 150 ]; then 354 | echo "Go version too low, skipping linux/arm-7..." 355 | else 356 | echo "Bootstrapping linux/arm-7..." 357 | CC=arm-linux-gnueabihf-gcc-5 GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="-march=armv7-a" CGO_CXXFLAGS="-march=armv7-a" go install std 358 | 359 | echo "Compiling for linux/arm-7..." 360 | CC=arm-linux-gnueabihf-gcc-5 CXX=arm-linux-gnueabihf-g++-5 HOST=arm-linux-gnueabihf PREFIX=/usr/arm-linux-gnueabihf CFLAGS="-march=armv7-a -fPIC" CXXFLAGS="-march=armv7-a -fPIC" $BUILD_DEPS /deps ${DEPS_ARGS[@]} 361 | export PKG_CONFIG_PATH=/usr/arm-linux-gnueabihf/lib/pkgconfig 362 | 363 | CC=arm-linux-gnueabihf-gcc-5 CXX=arm-linux-gnueabihf-g++-5 GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="-march=armv7-a -fPIC" CGO_CXXFLAGS="-march=armv7-a -fPIC" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 364 | CC=arm-linux-gnueabihf-gcc-5 CXX=arm-linux-gnueabihf-g++-5 GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="-march=armv7-a -fPIC" CGO_CXXFLAGS="-march=armv7-a -fPIC" go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-arm-7`extension linux`" ./$PACK 365 | 366 | echo "Cleaning up Go runtime for linux/arm-7..." 367 | rm -rf /usr/local/go/pkg/linux_arm 368 | fi 369 | fi 370 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ]); then 371 | if [ "$GO_VERSION" -lt 150 ]; then 372 | echo "Go version too low, skipping linux/arm64..." 373 | else 374 | echo "Compiling for linux/arm64..." 375 | CC=aarch64-linux-gnu-gcc-5 CXX=aarch64-linux-gnu-g++-5 HOST=aarch64-linux-gnu PREFIX=/usr/aarch64-linux-gnu $BUILD_DEPS /deps ${DEPS_ARGS[@]} 376 | export PKG_CONFIG_PATH=/usr/aarch64-linux-gnu/lib/pkgconfig 377 | 378 | CC=aarch64-linux-gnu-gcc-5 CXX=aarch64-linux-gnu-g++-5 GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 379 | CC=aarch64-linux-gnu-gcc-5 CXX=aarch64-linux-gnu-g++-5 GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-arm64`extension linux`" ./$PACK 380 | fi 381 | fi 382 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "mips64" ]); then 383 | if [ "$GO_VERSION" -lt 170 ]; then 384 | echo "Go version too low, skipping linux/mips64..." 385 | else 386 | echo "Compiling for linux/mips64..." 387 | CC=mips64-linux-gnuabi64-gcc-5 CXX=mips64-linux-gnuabi64-g++-5 HOST=mips64-linux-gnuabi64 PREFIX=/usr/mips64-linux-gnuabi64 $BUILD_DEPS /deps ${DEPS_ARGS[@]} 388 | export PKG_CONFIG_PATH=/usr/mips64-linux-gnuabi64/lib/pkgconfig 389 | 390 | CC=mips64-linux-gnuabi64-gcc-5 CXX=mips64-linux-gnuabi64-g++-5 GOOS=linux GOARCH=mips64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 391 | CC=mips64-linux-gnuabi64-gcc-5 CXX=mips64-linux-gnuabi64-g++-5 GOOS=linux GOARCH=mips64 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-mips64`extension linux`" ./$PACK 392 | fi 393 | fi 394 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "mips64le" ]); then 395 | if [ "$GO_VERSION" -lt 170 ]; then 396 | echo "Go version too low, skipping linux/mips64le..." 397 | else 398 | echo "Compiling for linux/mips64le..." 399 | CC=mips64el-linux-gnuabi64-gcc-5 CXX=mips64el-linux-gnuabi64-g++-5 HOST=mips64el-linux-gnuabi64 PREFIX=/usr/mips64el-linux-gnuabi64 $BUILD_DEPS /deps ${DEPS_ARGS[@]} 400 | export PKG_CONFIG_PATH=/usr/mips64le-linux-gnuabi64/lib/pkgconfig 401 | 402 | CC=mips64el-linux-gnuabi64-gcc-5 CXX=mips64el-linux-gnuabi64-g++-5 GOOS=linux GOARCH=mips64le CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 403 | CC=mips64el-linux-gnuabi64-gcc-5 CXX=mips64el-linux-gnuabi64-g++-5 GOOS=linux GOARCH=mips64le CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-mips64le`extension linux`" ./$PACK 404 | fi 405 | fi 406 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "mips" ]); then 407 | if [ "$GO_VERSION" -lt 180 ]; then 408 | echo "Go version too low, skipping linux/mips..." 409 | else 410 | echo "Compiling for linux/mips..." 411 | CC=mips-linux-gnu-gcc-5 CXX=mips-linux-gnu-g++-5 HOST=mips-linux-gnu PREFIX=/usr/mips-linux-gnu $BUILD_DEPS /deps ${DEPS_ARGS[@]} 412 | export PKG_CONFIG_PATH=/usr/mips-linux-gnu/lib/pkgconfig 413 | 414 | CC=mips-linux-gnu-gcc-5 CXX=mips-linux-gnu-g++-5 GOOS=linux GOARCH=mips CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 415 | CC=mips-linux-gnu-gcc-5 CXX=mips-linux-gnu-g++-5 GOOS=linux GOARCH=mips CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-mips`extension linux`" ./$PACK 416 | fi 417 | fi 418 | if ([ $XGOOS == "." ] || [ $XGOOS == "linux" ]) && ([ $XGOARCH == "." ] || [ $XGOARCH == "mipsle" ]); then 419 | if [ "$GO_VERSION" -lt 180 ]; then 420 | echo "Go version too low, skipping linux/mipsle..." 421 | else 422 | echo "Compiling for linux/mipsle..." 423 | CC=mipsel-linux-gnu-gcc-5 CXX=mipsel-linux-gnu-g++-5 HOST=mipsel-linux-gnu PREFIX=/usr/mipsel-linux-gnu $BUILD_DEPS /deps ${DEPS_ARGS[@]} 424 | export PKG_CONFIG_PATH=/usr/mipsle-linux-gnu/lib/pkgconfig 425 | 426 | CC=mipsel-linux-gnu-gcc-5 CXX=mipsel-linux-gnu-g++-5 GOOS=linux GOARCH=mipsle CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 427 | CC=mipsel-linux-gnu-gcc-5 CXX=mipsel-linux-gnu-g++-5 GOOS=linux GOARCH=mipsle CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-linux-mipsle`extension linux`" ./$PACK 428 | fi 429 | fi 430 | # Check and build for Windows targets 431 | if [ $XGOOS == "." ] || [[ $XGOOS == windows* ]]; then 432 | # Split the platform version and configure the Windows NT version 433 | PLATFORM=`echo $XGOOS | cut -d '-' -f 2` 434 | if [ "$PLATFORM" == "" ] || [ "$PLATFORM" == "." ] || [ "$PLATFORM" == "windows" ]; then 435 | PLATFORM=4.0 # Windows NT 436 | fi 437 | 438 | MAJOR=`echo $PLATFORM | cut -d '.' -f 1` 439 | if [ "${PLATFORM/.}" != "$PLATFORM" ] ; then 440 | MINOR=`echo $PLATFORM | cut -d '.' -f 2` 441 | fi 442 | CGO_NTDEF="-D_WIN32_WINNT=0x`printf "%02d" $MAJOR``printf "%02d" $MINOR`" 443 | 444 | # Build the requested windows binaries 445 | if [ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]; then 446 | echo "Compiling for windows-$PLATFORM/amd64..." 447 | CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix HOST=x86_64-w64-mingw32 PREFIX=/usr/x86_64-w64-mingw32 $BUILD_DEPS /deps ${DEPS_ARGS[@]} 448 | export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig 449 | 450 | CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 451 | CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go build $V $X "${T[@]}" --ldflags="$V $LD" $R $BM -o "/build/$NAME-windows-$PLATFORM-amd64$R`extension windows`" ./$PACK 452 | fi 453 | if [ $XGOARCH == "." ] || [ $XGOARCH == "386" ]; then 454 | echo "Compiling for windows-$PLATFORM/386..." 455 | CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix HOST=i686-w64-mingw32 PREFIX=/usr/i686-w64-mingw32 $BUILD_DEPS /deps ${DEPS_ARGS[@]} 456 | export PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig 457 | 458 | CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix GOOS=windows GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK 459 | CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix GOOS=windows GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_NTDEF" CGO_CXXFLAGS="$CGO_NTDEF" go build $V $X "${T[@]}" --ldflags="$V $LD" $BM -o "/build/$NAME-windows-$PLATFORM-386`extension windows`" ./$PACK 460 | fi 461 | fi 462 | # Check and build for OSX targets 463 | if [ $XGOOS == "." ] || [[ $XGOOS == darwin* ]]; then 464 | # Split the platform version and configure the deployment target 465 | PLATFORM=`echo $XGOOS | cut -d '-' -f 2` 466 | if [ "$PLATFORM" == "" ] || [ "$PLATFORM" == "." ] || [ "$PLATFORM" == "darwin" ]; then 467 | PLATFORM=10.6 # OS X Snow Leopard 468 | fi 469 | export MACOSX_DEPLOYMENT_TARGET=$PLATFORM 470 | 471 | # Strip symbol table below Go 1.6 to prevent DWARF issues 472 | LDSTRIP="" 473 | if [ "$GO_VERSION" -lt 160 ]; then 474 | LDSTRIP="-s" 475 | fi 476 | # Build the requested darwin binaries 477 | if [ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]; then 478 | echo "Compiling for darwin-$PLATFORM/amd64..." 479 | CC=o64-clang CXX=o64-clang++ HOST=x86_64-apple-darwin15 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} 480 | CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" -d ./$PACK 481 | CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" $R $BM -o "/build/$NAME-darwin-$PLATFORM-amd64$R`extension darwin`" ./$PACK 482 | fi 483 | if [ $XGOARCH == "." ] || [ $XGOARCH == "386" ]; then 484 | echo "Compiling for darwin-$PLATFORM/386..." 485 | CC=o32-clang CXX=o32-clang++ HOST=i386-apple-darwin15 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} 486 | CC=o32-clang CXX=o32-clang++ GOOS=darwin GOARCH=386 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" -d ./$PACK 487 | CC=o32-clang CXX=o32-clang++ GOOS=darwin GOARCH=386 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-darwin-$PLATFORM-386`extension darwin`" ./$PACK 488 | fi 489 | # Remove any automatically injected deployment target vars 490 | unset MACOSX_DEPLOYMENT_TARGET 491 | fi 492 | # Check and build for iOS targets 493 | if [ $XGOOS == "." ] || [[ $XGOOS == ios* ]]; then 494 | # Split the platform version and configure the deployment target 495 | PLATFORM=`echo $XGOOS | cut -d '-' -f 2` 496 | if [ "$PLATFORM" == "" ] || [ "$PLATFORM" == "." ] || [ "$PLATFORM" == "ios" ]; then 497 | PLATFORM=5.0 # first iPad and upwards 498 | fi 499 | export IPHONEOS_DEPLOYMENT_TARGET=$PLATFORM 500 | 501 | # Build the requested iOS binaries 502 | if [ "$GO_VERSION" -lt 150 ]; then 503 | echo "Go version too low, skipping ios..." 504 | else 505 | # Add the 'ios' tag to all builds, otherwise the std libs will fail 506 | if [ "$FLAG_TAGS" != "" ]; then 507 | IOSTAGS=(--tags "ios $FLAG_TAGS") 508 | else 509 | IOSTAGS=(--tags ios) 510 | fi 511 | mkdir -p /build-ios-fw 512 | 513 | # Strip symbol table below Go 1.6 to prevent DWARF issues 514 | LDSTRIP="" 515 | if [ "$GO_VERSION" -lt 160 ]; then 516 | LDSTRIP="-s" 517 | fi 518 | # Cross compile to all available iOS and simulator platforms 519 | if [ -d "$IOS_NDK_ARM_7" ] && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm-7" ] || [ $XGOARCH == "framework" ]); then 520 | echo "Bootstrapping ios-$PLATFORM/arm-7..." 521 | export PATH=$IOS_NDK_ARM_7/bin:$PATH 522 | GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 CC=arm-apple-darwin11-clang go install --tags ios std 523 | 524 | echo "Compiling for ios-$PLATFORM/arm-7..." 525 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ HOST=arm-apple-darwin11 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} 526 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go get $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" -d ./$PACK 527 | if [ $XGOARCH == "." ] || [ $XGOARCH == "arm-7" ]; then 528 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-armv7`extension darwin`" ./$PACK 529 | fi 530 | if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then 531 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-armv7.a" ./$PACK 532 | fi 533 | echo "Cleaning up Go runtime for ios-$PLATFORM/arm-7..." 534 | rm -rf /usr/local/go/pkg/darwin_arm 535 | fi 536 | if [ -d "$IOS_NDK_ARM64" ] && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ] || [ $XGOARCH == "framework" ]); then 537 | echo "Bootstrapping ios-$PLATFORM/arm64..." 538 | export PATH=$IOS_NDK_ARM64/bin:$PATH 539 | GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 CC=arm-apple-darwin11-clang go install --tags ios std 540 | 541 | echo "Compiling for ios-$PLATFORM/arm64..." 542 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ HOST=arm-apple-darwin11 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} 543 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go get $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" -d ./$PACK 544 | if [ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ]; then 545 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-arm64`extension darwin`" ./$PACK 546 | fi 547 | if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then 548 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-arm64.a" ./$PACK 549 | fi 550 | echo "Cleaning up Go runtime for ios-$PLATFORM/arm64..." 551 | rm -rf /usr/local/go/pkg/darwin_arm64 552 | fi 553 | if [ -d "$IOS_SIM_NDK_AMD64" ] && ([ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ] || [ $XGOARCH == "framework" ]); then 554 | echo "Bootstrapping ios-$PLATFORM/amd64..." 555 | export PATH=$IOS_SIM_NDK_AMD64/bin:$PATH 556 | mv /usr/local/go/pkg/darwin_amd64 /usr/local/go/pkg/darwin_amd64_bak 557 | GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CC=arm-apple-darwin11-clang go install --tags ios std 558 | 559 | echo "Compiling for ios-$PLATFORM/amd64..." 560 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ HOST=arm-apple-darwin11 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} 561 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go get $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" -d ./$PACK 562 | if [ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]; then 563 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-x86_64`extension darwin`" ./$PACK 564 | fi 565 | if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then 566 | CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-x86_64.a" ./$PACK 567 | fi 568 | echo "Cleaning up Go runtime for ios-$PLATFORM/amd64..." 569 | rm -rf /usr/local/go/pkg/darwin_amd64 570 | mv /usr/local/go/pkg/darwin_amd64_bak /usr/local/go/pkg/darwin_amd64 571 | fi 572 | # Assemble the iOS framework from the built binaries 573 | if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then 574 | title=${NAME^} 575 | framework=/build/$NAME-ios-$PLATFORM-framework/$title.framework 576 | 577 | rm -rf $framework 578 | mkdir -p $framework/Versions/A 579 | (cd $framework/Versions && ln -nsf A Current) 580 | 581 | arches=() 582 | for lib in `ls /build-ios-fw | grep -e '\.a$'`; do 583 | arches+=("-arch" "`echo ${lib##*-} | cut -d '.' -f 1`" "/build-ios-fw/$lib") 584 | done 585 | arm-apple-darwin11-lipo -create "${arches[@]}" -o $framework/Versions/A/$title 586 | arm-apple-darwin11-ranlib $framework/Versions/A/$title 587 | (cd $framework && ln -nsf Versions/A/$title $title) 588 | 589 | mkdir -p $framework/Versions/A/Headers 590 | for header in `ls /build-ios-fw | grep -e '\.h$'`; do 591 | cp -f /build-ios-fw/$header $framework/Versions/A/Headers/$title.h 592 | done 593 | (cd $framework && ln -nsf Versions/A/Headers Headers) 594 | 595 | mkdir -p $framework/Versions/A/Resources 596 | echo -e "\n\n\n\n\n" > $framework/Versions/A/Resources/Info.plist 597 | (cd $framework && ln -nsf Versions/A/Resources Resources) 598 | 599 | mkdir -p $framework/Versions/A/Modules 600 | echo -e "framework module \"$title\" {\n header \"$title.h\"\n export *\n}" > $framework/Versions/A/Modules/module.modulemap 601 | (cd $framework && ln -nsf Versions/A/Modules Modules) 602 | 603 | chmod 777 -R /build/$NAME-ios-$PLATFORM-framework 604 | fi 605 | rm -rf /build-ios-fw 606 | fi 607 | # Remove any automatically injected deployment target vars 608 | unset IPHONEOS_DEPLOYMENT_TARGET 609 | fi 610 | done 611 | 612 | # Clean up any leftovers for subsequent build invocations 613 | echo "Cleaning up build environment..." 614 | rm -rf /deps 615 | 616 | for dir in `ls /usr/local`; do 617 | keep=0 618 | 619 | # Check against original folder contents 620 | for old in $USR_LOCAL_CONTENTS; do 621 | if [ "$old" == "$dir" ]; then 622 | keep=1 623 | fi 624 | done 625 | # Delete anything freshly generated 626 | if [ "$keep" == "0" ]; then 627 | rm -rf "/usr/local/$dir" 628 | fi 629 | done 630 | -------------------------------------------------------------------------------- /docker/base/build_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Contains the a dependency builder to iterate over all installed dependencies 4 | # and cross compile them to the requested target platform. 5 | # 6 | # Usage: build_deps.sh 7 | # 8 | # Needed environment variables: 9 | # CC - C cross compiler to use for the build 10 | # HOST - Target platform to build (used to find the needed tool-chains) 11 | # PREFIX - File-system path where to install the built binaries 12 | set -e 13 | 14 | # Remove any previous build leftovers, and copy a fresh working set (clean doesn't work for cross compiling) 15 | rm -rf /deps-build && cp -r $1 /deps-build 16 | 17 | # Build all the dependencies (no order for now) 18 | for dep in `ls /deps-build`; do 19 | echo "Configuring dependency $dep for $HOST..." 20 | (cd /deps-build/$dep && ./configure --disable-shared --host=$HOST --prefix=$PREFIX --silent ${@:2}) 21 | 22 | echo "Building dependency $dep for $HOST..." 23 | (cd /deps-build/$dep && make --silent -j install) 24 | done 25 | 26 | # Remove any build artifacts 27 | rm -rf /deps-build 28 | -------------------------------------------------------------------------------- /docker/base/fetch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Contains a simple fetcher to download a file from a remote URL and verify its 4 | # SHA1 or SHA256 checksum (selected based on provided length). 5 | # 6 | # Usage: fetch.sh 7 | set -e 8 | 9 | # Skip the download if no operands specified 10 | if [ "$1" == "" -o "$2" == "" ]; then 11 | echo "Fetch operands missing, skipping..." 12 | exit 13 | fi 14 | 15 | # Pull the file from the remote URL 16 | file=`basename $1` 17 | echo "Downloading $1..." 18 | wget -q $1 19 | 20 | # Generate a desired checksum report and check against it 21 | echo "$2 $file" > $file.sum 22 | if [ "${#2}" == "40" ]; then 23 | sha1sum -c $file.sum 24 | else 25 | sha256sum -c $file.sum 26 | fi 27 | rm $file.sum 28 | -------------------------------------------------------------------------------- /docker/base/patch.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karalabe/xgo/c5ccff8648a77686d274c1984e1cd6319736f5cb/docker/base/patch.tar.xz -------------------------------------------------------------------------------- /docker/base/update_ios.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Contains a simple tool that updates some of the iOS toolchains with the SDKs 4 | # explicitly provided. The goal is to allow using your own up to date SDKs or 5 | # the simulator one not supported out of the box. 6 | # 7 | # Usage: update_ios.sh /.sdk.tar. 8 | set -e 9 | 10 | # Figure out the base name of the SDK 11 | sdk=`basename $1` 12 | sdk=${sdk%.*} 13 | sdk=${sdk%.*} 14 | 15 | # Define a small extraction utility to 16 | function extract { 17 | case $1 in 18 | *.tar.xz) 19 | xz -dc $1 | tar xf - 20 | ;; 21 | *.tar.gz) 22 | gunzip -dc $1 | tar xf - 23 | ;; 24 | *.tar.bz2) 25 | bzip2 -dc $1 | tar xf - 26 | ;; 27 | esac 28 | } 29 | 30 | # Extract the SDK, patch it, clean it up and prep for bootstrapping 31 | extract $1 32 | 33 | if [[ "`basename $1`" =~ ^iPhoneSimulator ]]; then 34 | echo "Patching iOS simulator SDK with missing libraries..." 35 | ln -s $OSX_NDK_X86/SDK/$OSX_SDK/usr/lib/system/libsystem_kernel.dylib $sdk/usr/lib/system/libsystem_kernel.dylib 36 | ln -s $OSX_NDK_X86/SDK/$OSX_SDK/usr/lib/system/libsystem_platform.dylib $sdk/usr/lib/system/libsystem_platform.dylib 37 | ln -s $OSX_NDK_X86/SDK/$OSX_SDK/usr/lib/system/libsystem_pthread.dylib $sdk/usr/lib/system/libsystem_pthread.dylib 38 | ln -s $OSX_NDK_X86/SDK/$OSX_SDK/usr/lib/system/libsystem_kernel.tbd $sdk/usr/lib/system/libsystem_kernel.tbd 39 | ln -s $OSX_NDK_X86/SDK/$OSX_SDK/usr/lib/system/libsystem_platform.tbd $sdk/usr/lib/system/libsystem_platform.tbd 40 | ln -s $OSX_NDK_X86/SDK/$OSX_SDK/usr/lib/system/libsystem_pthread.tbd $sdk/usr/lib/system/libsystem_pthread.tbd 41 | fi 42 | 43 | tar -czf /tmp/$sdk.tar.gz $sdk 44 | rm -rf $sdk 45 | 46 | # Pull the iOS cross compiler tool and build the toolchain 47 | git clone https://github.com/tpoechtrager/cctools-port.git 48 | 49 | if [[ "`basename $1`" =~ ^iPhoneSimulator ]]; then 50 | rm -rf $IOS_SIM_NDK_AMD64 51 | /cctools-port/usage_examples/ios_toolchain/build.sh /tmp/$sdk.tar.gz x86_64 52 | mv /cctools-port/usage_examples/ios_toolchain/target $IOS_SIM_NDK_AMD64 53 | else 54 | rm -rf $IOS_NDK_ARM_7 $IOS_NDK_ARM64 55 | /cctools-port/usage_examples/ios_toolchain/build.sh /tmp/$sdk.tar.gz armv7 56 | mv /cctools-port/usage_examples/ios_toolchain/target $IOS_NDK_ARM_7 57 | /cctools-port/usage_examples/ios_toolchain/build.sh /tmp/$sdk.tar.gz arm64 58 | mv /cctools-port/usage_examples/ios_toolchain/target $IOS_NDK_ARM64 59 | fi 60 | 61 | rm -rf /cctools-port 62 | -------------------------------------------------------------------------------- /docker/go-1.10.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.10 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1100 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.10.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=b5a64335f1490277b585832d1f6c7f8c6c11206cba5cd3f771dcb87b98ad1a33 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.10.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.10.1 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1101 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.10.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=72d820dec546752e5a8303b33b009079c15c2390ce76d67cf514991646c6127b && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.10.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.10.2 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1102 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.10.2.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.10.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.10.3 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1103 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.10.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f43004f901035 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.10.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.10.4 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1104 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.10.4.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=fa04efdb17a275a0c6e137f969a1c4eb878939e91e1da16060ce42f02c2ec5ec && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.10.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.10.x 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.10.4 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.11.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.11 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1110 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.11.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=b3fcf280ff86558e0559e185b601c9eade0fd24c900b4c63cd14d1d38613e499 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.11.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.11.1 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1111 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.11.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=2871270d8ff0c8c69f161aaae42f9f28739855ff5c5204752a8d92a1c9f63993 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.11.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.11.2 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1112 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.11.2.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=1dfe664fa3d8ad714bbd15a36627992effd150ddabd7523931f077b3926d736d && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.11.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.11.3 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1113 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.11.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=d20a4869ffb13cee0f7ee777bf18c7b9b67ef0375f93fac1298519e0c227a07f && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.11.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.11.4 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1114 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.11.4.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=fb26c30e6a04ad937bbc657a1b5bba92f80096af1e8ee6da6430c045a8db3a5b && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.11.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.11.5 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 1115 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.11.5.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=ff54aafedff961eb94792487e827515da683d61a5f9482f668008832631e5d25 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.11.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.11.x 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.11.5 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.12.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11200 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=750a07fef8579ae4839458701f4df690e0b20b8bcce33b437e4df89c451b6f13 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.1 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11201 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=2a3fdabf665496a0db5f41ec6af7a9b15a49fbe71a85a50ca38b1f13a103aeec && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.10/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.10 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11210 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.10.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=aaa84147433aed24e70b31da369bb6ca2859464a45de47c2a5023d8573412f6b && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.11/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.11 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11211 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.11.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=2c5960292da8b747d83f171a28a04116b2977e809169c344268c893e4cf0a857 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.12/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.12 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11212 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.12.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=4cf11ac6a8fa42d26ab85e27a5d916ee171900a87745d9f7d4a29a21587d78fc && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.13/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.13 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11213 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.13.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=da036454cb3353f9f507f0ceed4048feac611065e4e1818b434365eb32ac9bdc && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.2 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11202 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.2.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=f28c1fde8f293cc5c83ae8de76373cf76ae9306909564f54e0edcf140ce8fe3f && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.3 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11203 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=3924819eed16e55114f02d25d03e77c916ec40b7fd15c8acb5838b63135b03df && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.4 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11204 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.4.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=d7d1f1f88ddfe55840712dc1747f37a790cbcaa448f6c9cf51bbe10aa65442f5 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.5 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11205 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.5.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=aea86e3c73495f205929cfebba0d63f1382c8ac59be081b6351681415f4063cf && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.6/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.6 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11206 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.6.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=dbcf71a3c1ea53b8d54ef1b48c85a39a6c9a935d01fc8291ff2b92028e59913c && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.7/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.7 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11207 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.7.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=66d83bfb5a9ede000e33c6579a91a29e6b101829ad41fffb5c5bb6c900e109d9 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.8/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.8 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11208 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.8.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=bd26cd4962a362ed3c11835bca32c2e131c2ae050304f2c4df9fa6ded8db85d2 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.9/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.9 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11209 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.12.9.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=ac2a6efcc1f5ec8bdc0db0a988bb1d301d64b6d61b7e8d9e42f662fbb75a2b9b && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.12.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.12.x 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.12.13 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.13.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.13 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11300 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.13.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=68a2297eb099d1a76097905a2ce334e3155004ec08cdea85f24527be3c48e856 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.13.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.13.1 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11301 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.13.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=94f874037b82ea5353f4061e543681a0e79657f787437974214629af8407d124 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.13.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.13.2 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11302 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.13.2.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=293b41a6ccd735eebcfb4094b6931bfd187595555cecf3e4386e9e119220c0b7 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.13.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.13.3 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11303 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.13.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=0804bf02020dceaa8a7d7275ee79f7a142f1996bfd0c39216ccb405f93f994c0 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.13.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.13.4 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 11304 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.13.4.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=692d17071736f74be04a72a06dab9cac1cd759377bd85316e52b2227604c004c && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.13.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.13.x 2 | # Copyright (c) 2019 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.13.4 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.3.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.3.0 layer 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the Go packages and bootstrap them 11 | RUN \ 12 | export DIST_LINUX_64=https://storage.googleapis.com/golang/go1.3.linux-amd64.tar.gz && \ 13 | export DIST_LINUX_64_SHA=b6b154933039987056ac307e20c25fa508a06ba6 && \ 14 | \ 15 | export DIST_LINUX_32=https://storage.googleapis.com/golang/go1.3.linux-386.tar.gz && \ 16 | export DIST_LINUX_32_SHA=22db33b0c4e242ed18a77b03a60582f8014fd8a6 && \ 17 | \ 18 | export DIST_LINUX_ARM=http://dave.cheney.net/paste/go.1.3.linux-arm~armv5-1.tar.gz && \ 19 | export DIST_LINUX_ARM_SHA=fc059c970a059757778b157b1140a3c56eb1a069 && \ 20 | \ 21 | export DIST_OSX_64=https://storage.googleapis.com/golang/go1.3.darwin-amd64-osx10.6.tar.gz && \ 22 | export DIST_OSX_64_SHA=82ffcfb7962ca7114a1ee0a96cac51c53061ea05 && \ 23 | \ 24 | export DIST_OSX_32=https://storage.googleapis.com/golang/go1.3.darwin-386-osx10.6.tar.gz && \ 25 | export DIST_OSX_32_SHA=159d2797bee603a80b829c4404c1fb2ee089cc00 && \ 26 | \ 27 | export DIST_WIN_64=https://storage.googleapis.com/golang/go1.3.windows-amd64.zip && \ 28 | export DIST_WIN_64_SHA=1e4888e1494aed7f6934acb5c4a1ffb0e9a022b1 && \ 29 | \ 30 | export DIST_WIN_32=https://storage.googleapis.com/golang/go1.3.windows-386.zip && \ 31 | export DIST_WIN_32_SHA=e4e5279ce7d8cafdf210a522a70677d5b9c7589d && \ 32 | \ 33 | $BOOTSTRAP 34 | 35 | ENV GO_VERSION 130 36 | -------------------------------------------------------------------------------- /docker/go-1.3.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.3.1 layer 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the Go packages and bootstrap them 11 | RUN \ 12 | export DIST_LINUX_64=https://storage.googleapis.com/golang/go1.3.1.linux-amd64.tar.gz && \ 13 | export DIST_LINUX_64_SHA=3af011cc19b21c7180f2604fd85fbc4ddde97143 && \ 14 | \ 15 | export DIST_LINUX_32=https://storage.googleapis.com/golang/go1.3.1.linux-386.tar.gz && \ 16 | export DIST_LINUX_32_SHA=36f87ce21cdb4cb8920bb706003d8655b4e1fc81 && \ 17 | \ 18 | export DIST_LINUX_ARM= && \ 19 | export DIST_LINUX_ARM_SHA= && \ 20 | \ 21 | export DIST_OSX_64=https://storage.googleapis.com/golang/go1.3.1.darwin-amd64-osx10.6.tar.gz && \ 22 | export DIST_OSX_64_SHA=40716361d352c4b40252e79048e8bc084c3f3d1b && \ 23 | \ 24 | export DIST_OSX_32=https://storage.googleapis.com/golang/go1.3.1.darwin-386-osx10.6.tar.gz && \ 25 | export DIST_OSX_32_SHA=84f70a4c83be24cea696654a5b55331ea32f8a3f && \ 26 | \ 27 | export DIST_WIN_64=https://storage.googleapis.com/golang/go1.3.1.windows-amd64.zip && \ 28 | export DIST_WIN_64_SHA=4548785cfa3bc228d18d2d06e39f58f0e4e014f1 && \ 29 | \ 30 | export DIST_WIN_32=https://storage.googleapis.com/golang/go1.3.1.windows-386.zip && \ 31 | export DIST_WIN_32_SHA=64f99e40e79e93a622e73d7d55a5b8340f07747f && \ 32 | \ 33 | $BOOTSTRAP 34 | 35 | ENV GO_VERSION 131 36 | -------------------------------------------------------------------------------- /docker/go-1.3.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.3.3 layer 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the Go packages and bootstrap them 11 | RUN \ 12 | export DIST_LINUX_64=https://storage.googleapis.com/golang/go1.3.3.linux-amd64.tar.gz && \ 13 | export DIST_LINUX_64_SHA=14068fbe349db34b838853a7878621bbd2b24646 && \ 14 | \ 15 | export DIST_LINUX_32=https://storage.googleapis.com/golang/go1.3.3.linux-386.tar.gz && \ 16 | export DIST_LINUX_32_SHA=9eb426d5505de55729e2656c03d85722795dd85e && \ 17 | \ 18 | export DIST_LINUX_ARM=http://dave.cheney.net/paste/go.1.3.3.linux-arm~armv5-1.tar.gz && \ 19 | export DIST_LINUX_ARM_SHA=78789a5e3288d9e86e0cd667e6588775594eae87 && \ 20 | \ 21 | export DIST_OSX_64=https://storage.googleapis.com/golang/go1.3.3.darwin-amd64-osx10.6.tar.gz && \ 22 | export DIST_OSX_64_SHA=dfe68de684f6e8d9c371d01e6d6a522efe3b8942 && \ 23 | \ 24 | export DIST_OSX_32=https://storage.googleapis.com/golang/go1.3.3.darwin-386-osx10.6.tar.gz && \ 25 | export DIST_OSX_32_SHA=04b3e38549183e984f509c07ad40d8bcd577a702 && \ 26 | \ 27 | export DIST_WIN_64=https://storage.googleapis.com/golang/go1.3.3.windows-amd64.zip && \ 28 | export DIST_WIN_64_SHA=5f0b3b104d3db09edd32ef1d086ba20bafe01ada && \ 29 | \ 30 | export DIST_WIN_32=https://storage.googleapis.com/golang/go1.3.3.windows-386.zip && \ 31 | export DIST_WIN_32_SHA=ba99083b22e0b22b560bb2d28b9b99b405d01b6b && \ 32 | \ 33 | $BOOTSTRAP 34 | 35 | ENV GO_VERSION 133 36 | -------------------------------------------------------------------------------- /docker/go-1.3.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest 1.3 release 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.3.3 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.4.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.4.2 layer 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the Go packages and bootstrap them 11 | RUN \ 12 | export DIST_LINUX_64=https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz && \ 13 | export DIST_LINUX_64_SHA=5020af94b52b65cc9b6f11d50a67e4bae07b0aff && \ 14 | \ 15 | export DIST_LINUX_32=https://storage.googleapis.com/golang/go1.4.2.linux-386.tar.gz && \ 16 | export DIST_LINUX_32_SHA=50557248e89b6e38d395fda93b2f96b2b860a26a && \ 17 | \ 18 | export DIST_LINUX_ARM=http://dave.cheney.net/paste/go1.4.2.linux-arm~armv5-1.tar.gz && \ 19 | export DIST_LINUX_ARM_SHA=1bcfc8ef9c2aa381722b71b8c8d83cb58e973116 && \ 20 | \ 21 | export DIST_OSX_64=https://storage.googleapis.com/golang/go1.4.2.darwin-amd64-osx10.6.tar.gz && \ 22 | export DIST_OSX_64_SHA=00c3f9a03daff818b2132ac31d57f054925c60e7 && \ 23 | \ 24 | export DIST_OSX_32=https://storage.googleapis.com/golang/go1.4.2.darwin-386-osx10.6.tar.gz && \ 25 | export DIST_OSX_32_SHA=fb3e6b30f4e1b1be47bbb98d79dd53da8dec24ec && \ 26 | \ 27 | export DIST_WIN_64=https://storage.googleapis.com/golang/go1.4.2.windows-amd64.zip && \ 28 | export DIST_WIN_64_SHA=91b229a3ff0a1ce6e791c832b0b4670bfc5457b5 && \ 29 | \ 30 | export DIST_WIN_32=https://storage.googleapis.com/golang/go1.4.2.windows-386.zip && \ 31 | export DIST_WIN_32_SHA=0e074e66a7816561d7947ff5c3514be96f347dc4 && \ 32 | \ 33 | $BOOTSTRAP 34 | 35 | ENV GO_VERSION 142 36 | -------------------------------------------------------------------------------- /docker/go-1.4.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest 1.4 release 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.4.2 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.4 layer 2 | # Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the Go packages and bootstrap them 11 | RUN \ 12 | export DIST_LINUX_64=https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz && \ 13 | export DIST_LINUX_64_SHA=cd82abcb0734f82f7cf2d576c9528cebdafac4c6 && \ 14 | \ 15 | export DIST_LINUX_32=https://storage.googleapis.com/golang/go1.4.linux-386.tar.gz && \ 16 | export DIST_LINUX_32_SHA=cb18d8122bfd3bbba20fa1a19b8f7566dcff795d && \ 17 | \ 18 | export DIST_LINUX_ARM=http://dave.cheney.net/paste/go1.4.linux-arm~armv5-1.tar.gz && \ 19 | export DIST_LINUX_ARM_SHA=21039e81df30bf17fa5847d02892c425f0c37fc6 && \ 20 | \ 21 | export DIST_OSX_64=https://storage.googleapis.com/golang/go1.4.darwin-amd64-osx10.6.tar.gz && \ 22 | export DIST_OSX_64_SHA=09621b9226abe12c2179778b015a33c1787b29d6 && \ 23 | \ 24 | export DIST_OSX_32=https://storage.googleapis.com/golang/go1.4.darwin-386-osx10.6.tar.gz && \ 25 | export DIST_OSX_32_SHA=ee31cd0e26245d0e48f11667e4298e2e7f54f9b6 && \ 26 | \ 27 | export DIST_WIN_64=https://storage.googleapis.com/golang/go1.4.windows-amd64.zip && \ 28 | export DIST_WIN_64_SHA=44f103d558b293919eb680041625c262dd00eb9a && \ 29 | \ 30 | export DIST_WIN_32=https://storage.googleapis.com/golang/go1.4.windows-386.zip && \ 31 | export DIST_WIN_32_SHA=f44240a1750dd051476ae78e9ad0502bc5c7661d && \ 32 | \ 33 | $BOOTSTRAP 34 | 35 | ENV GO_VERSION 140 36 | -------------------------------------------------------------------------------- /docker/go-1.5.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.5.0 layer 2 | # Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 150 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=5817fa4b2252afdb02e11e8b9dc1d9173ef3bd5a && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.5.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.5.1 layer 2 | # Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 151 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=46eecd290d8803887dec718c691cc243f2175fe0 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.5.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.5.2 layer 2 | # Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 152 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=cae87ed095e8d94a81871281d35da7829bd1234e && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.5.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.5.3 layer 2 | # Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 153 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=43afe0c5017e502630b1aea4d44b8a7f059bf60d7f29dfd58db454d4e4e0ae53 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.5.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.5.4 layer 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 154 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.5.4.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=a3358721210787dc1e06f5ea1460ae0564f22a0fbd91be9dcd947fb1d19b9560 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.5.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest 1.5 release 2 | # Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.5.4 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.6.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.6 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 160 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=5470eac05d273c74ff8bac7bef5bad0b5abbd1c4052efbdbc8db45332e836b0b && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.6.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.6.1 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 161 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.6.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=6d894da8b4ad3f7f6c295db0d73ccc3646bce630e1c43e662a0120681d47e988 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.6.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.6.2 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 162 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.6.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.6.3 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 163 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.6.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=cdde5e08530c0579255d6153b08fdb3b8e47caabbe717bc7bcd7561275a87aeb && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.6.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest 1.6 release 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.6.3 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.7.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.7 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 170 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=702ad90f705365227e902b42d91dd1a40e48ca7f67a2f4b2fd052aaa4295cd95 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.7.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.7.1 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 171 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=43ad621c9b014cde8db17393dc108378d37bc853aa351a6c74bf6432c1bbd182 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.7.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.7.3 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 173 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=508028aac0654e993564b6e2014bf2d4a9751e3b286661b0b0040046cf18028e && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.7.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.7.4 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 174 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=47fda42e46b4c3ec93fa5d4d4cc6a748aa3f9411a2a2b7e08e3a6d80d753ec8b && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.7.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.7.5 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 175 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.7.5.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=2e4dd6c44f0693bef4e7b46cc701513d74c3cc44f2419bf519d7868b12931ac3 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.7.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest 1.7 release 2 | # Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.7.5 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.8.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.8 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 180 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=53ab94104ee3923e228a2cb2116e5e462ad3ebaeea06ff04463479d7f12d27ca && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.8.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.8.1 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 181 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=a579ab19d5237e263254f1eac5352efcf1d70b9dacadb6d6bb12b0911ede8994 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.8.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.8.3 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 183 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=1862f4c3d3907e59b04a757cfda0ea7aa9ef39274af99a784f5be843c80c6772 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.8.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest 1.8 release 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.8.3 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-1.9.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.9 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 190 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=d70eadefce8e160638a9a6db97f7192d8463069ab33138893ad3bf31b0650a79 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.9.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.9.1 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 191 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=07d81c6b6b4c2dcf1b5ef7c27aaebd3691cdb40548500941f92b221147c5d9c7 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.9.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.9.2 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 192 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=de874549d9a8d8d8062be05808509c09a88a248e77ec14eb77453530829ac02b && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.9.3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.9.3 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 193 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.9.3.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=a4da5f4c07dfda8194c4621611aeb7ceaab98af0b38bfb29e1be2ebb04c3556c && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.9.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go 1.9.4 2 | # Copyright (c) 2018 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Configure the root Go distribution and bootstrap based on it 11 | ENV GO_VERSION 194 12 | 13 | RUN \ 14 | export ROOT_DIST=https://storage.googleapis.com/golang/go1.9.4.linux-amd64.tar.gz && \ 15 | export ROOT_DIST_SHA=15b0937615809f87321a457bb1265f946f9f6e736c563d6c5e0bd2c22e44f779 && \ 16 | \ 17 | $BOOTSTRAP_PURE 18 | -------------------------------------------------------------------------------- /docker/go-1.9.x/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest 1.9 release 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.9.4 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /docker/go-develop/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Go develop layer 2 | # Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-base 7 | 8 | MAINTAINER Péter Szilágyi 9 | 10 | # Clone and bootstrap the latest Go develop branch 11 | RUN $BOOTSTRAP_REPO master 12 | ENV GO_VERSION 999 13 | -------------------------------------------------------------------------------- /docker/go-latest/Dockerfile: -------------------------------------------------------------------------------- 1 | # Go cross compiler (xgo): Wildcard layer to the latest Go release 2 | # Copyright (c) 2017 Péter Szilágyi. All rights reserved. 3 | # 4 | # Released under the MIT license. 5 | 6 | FROM karalabe/xgo-1.13.x 7 | 8 | MAINTAINER Péter Szilágyi 9 | -------------------------------------------------------------------------------- /tests/embedded_c/main.go: -------------------------------------------------------------------------------- 1 | // Go cross compiler (xgo): Test file for embedded C snippets. 2 | // Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | // 4 | // Released under the MIT license. 5 | 6 | package main 7 | 8 | // #include 9 | // 10 | // void sayHi() { 11 | // printf("Hello, embedded C!\n"); 12 | // } 13 | import "C" 14 | 15 | func main() { 16 | C.sayHi() 17 | } 18 | -------------------------------------------------------------------------------- /tests/embedded_cpp/main.go: -------------------------------------------------------------------------------- 1 | // Go cross compiler (xgo): Test file for embedded C++ snippets. 2 | // Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | // 4 | // Released under the MIT license. 5 | 6 | package main 7 | 8 | // #include "snippet.h" 9 | import "C" 10 | 11 | func main() { 12 | C.sayHi() 13 | } 14 | -------------------------------------------------------------------------------- /tests/embedded_cpp/snippet.cpp: -------------------------------------------------------------------------------- 1 | // Go cross compiler (xgo): Test implementation for embedded C++ snippets. 2 | // Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | // 4 | // Released under the MIT license. 5 | 6 | #include 7 | #include "snippet.h" 8 | 9 | void sayHi() { 10 | std::cout << "Hello, embedded C++!" << std::endl; 11 | } 12 | -------------------------------------------------------------------------------- /tests/embedded_cpp/snippet.h: -------------------------------------------------------------------------------- 1 | // Go cross compiler (xgo): Test header for embedded C++ snippets. 2 | // Copyright (c) 2015 Péter Szilágyi. All rights reserved. 3 | // 4 | // Released under the MIT license. 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void sayHi(); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /testsuite.go: -------------------------------------------------------------------------------- 1 | // Go CGO cross compiler 2 | // Copyright (c) 2016 Péter Szilágyi. All rights reserved. 3 | // 4 | // Released under the MIT license. 5 | 6 | // This is a manual test suite to run the cross compiler against various known 7 | // projects, codebases and repositories to ensure at least a baseline guarantee 8 | // that things work as they supposed to. 9 | // 10 | // Run as: go run testsuite.go 11 | 12 | // +build ignore 13 | 14 | package main 15 | 16 | import ( 17 | "log" 18 | "os" 19 | "os/exec" 20 | "path/filepath" 21 | ) 22 | 23 | // layers defines all the docker layers needed for the final xgo image. The last 24 | // one will be used to run the test suite against. 25 | var layers = []struct { 26 | tag string 27 | dir string 28 | }{ 29 | {"karalabe/xgo-base", "base"}, 30 | {"karalabe/xgo-1.6.2", "go-1.6.2"}, 31 | {"karalabe/xgo-1.6.x", "go-1.6.x"}, 32 | {"karalabe/xgo-latest", "go-latest"}, 33 | //{"karalabe/xgo-latest-ios", "go-latest-ios"}, // Non-public layer (XCode licensing) 34 | } 35 | 36 | // tests defaines all the input test cases and associated arguments the cross 37 | // compiler should be ran for and with which arguments. 38 | var tests = []struct { 39 | path string 40 | args []string 41 | }{ 42 | // Tiny test cases to smoke test cross compilations 43 | {"github.com/karalabe/xgo/tests/embedded_c", nil}, 44 | {"github.com/karalabe/xgo/tests/embedded_cpp", nil}, 45 | 46 | // Baseline projects to ensure minimal requirements 47 | //{"github.com/project-iris/iris", nil}, // Deps failed, disable 48 | {"github.com/ethereum/go-ethereum/cmd/geth", []string{"--branch", "develop"}}, 49 | 50 | // Third party projects using xgo, smoke test that they don't break 51 | {"github.com/rwcarlsen/cyan/cmd/cyan", nil}, 52 | {"github.com/cockroachdb/cockroach", []string{"--targets", "darwin-10.11/amd64"}}, 53 | } 54 | 55 | func main() { 56 | // Retrieve the current working directory to locate the dockerfiles 57 | pwd, err := os.Getwd() 58 | if err != nil { 59 | log.Fatalf("Failed to retrieve local working directory: %v", err) 60 | } 61 | if _, err := os.Stat(filepath.Join(pwd, "docker", "base")); err != nil { 62 | log.Fatalf("Failed to locate docker image: %v", err) 63 | } 64 | // Assemble the multi-layered xgo docker image 65 | for _, layer := range layers { 66 | cmd := exec.Command("docker", "build", "--tag", layer.tag, filepath.Join(pwd, "docker", layer.dir)) 67 | 68 | cmd.Stdout = os.Stdout 69 | cmd.Stderr = os.Stderr 70 | 71 | if err := cmd.Run(); err != nil { 72 | log.Fatalf("Failed to build xgo layer: %v", err) 73 | } 74 | } 75 | // Iterate over each of the test cases and run them 76 | for i, test := range tests { 77 | cmd := exec.Command("docker", append([]string{"run", "--entrypoint", "xgo", layers[len(layers)-1].tag, "-v"}, append(test.args, test.path)...)...) 78 | 79 | cmd.Stdout = os.Stdout 80 | cmd.Stderr = os.Stderr 81 | 82 | if err := cmd.Run(); err != nil { 83 | log.Fatalf("Test #%d: cross compilation failed: %v", i, err) 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /xgo.go: -------------------------------------------------------------------------------- 1 | // Go CGO cross compiler 2 | // Copyright (c) 2014 Péter Szilágyi. All rights reserved. 3 | // 4 | // Released under the MIT license. 5 | 6 | // Wrapper around the GCO cross compiler docker container. 7 | package main 8 | 9 | import ( 10 | "bytes" 11 | "flag" 12 | "fmt" 13 | "go/build" 14 | "io" 15 | "log" 16 | "net/http" 17 | "os" 18 | "os/exec" 19 | "os/user" 20 | "path/filepath" 21 | "strconv" 22 | "strings" 23 | ) 24 | 25 | // Path where to cache external dependencies 26 | var depsCache string 27 | 28 | func init() { 29 | // Initialize the external dependency cache path to a few possible locations 30 | if home := os.Getenv("HOME"); home != "" { 31 | depsCache = filepath.Join(home, ".xgo-cache") 32 | return 33 | } 34 | if user, err := user.Current(); user != nil && err == nil && user.HomeDir != "" { 35 | depsCache = filepath.Join(user.HomeDir, ".xgo-cache") 36 | return 37 | } 38 | depsCache = filepath.Join(os.TempDir(), "xgo-cache") 39 | } 40 | 41 | // Cross compilation docker containers 42 | var dockerBase = "karalabe/xgo-base" 43 | var dockerDist = "karalabe/xgo-" 44 | 45 | // Command line arguments to fine tune the compilation 46 | var ( 47 | goVersion = flag.String("go", "latest", "Go release to use for cross compilation") 48 | srcPackage = flag.String("pkg", "", "Sub-package to build if not root import") 49 | srcRemote = flag.String("remote", "", "Version control remote repository to build") 50 | srcBranch = flag.String("branch", "", "Version control branch to build") 51 | outPrefix = flag.String("out", "", "Prefix to use for output naming (empty = package name)") 52 | outFolder = flag.String("dest", "", "Destination folder to put binaries in (empty = current)") 53 | crossDeps = flag.String("deps", "", "CGO dependencies (configure/make based archives)") 54 | crossArgs = flag.String("depsargs", "", "CGO dependency configure arguments") 55 | targets = flag.String("targets", "*/*", "Comma separated targets to build for") 56 | dockerImage = flag.String("image", "", "Use custom docker image instead of official distribution") 57 | ) 58 | 59 | // ConfigFlags is a simple set of flags to define the environment and dependencies. 60 | type ConfigFlags struct { 61 | Repository string // Root import path to build 62 | Package string // Sub-package to build if not root import 63 | Prefix string // Prefix to use for output naming 64 | Remote string // Version control remote repository to build 65 | Branch string // Version control branch to build 66 | Dependencies string // CGO dependencies (configure/make based archives) 67 | Arguments string // CGO dependency configure arguments 68 | Targets []string // Targets to build for 69 | } 70 | 71 | // Command line arguments to pass to go build 72 | var ( 73 | buildVerbose = flag.Bool("v", false, "Print the names of packages as they are compiled") 74 | buildSteps = flag.Bool("x", false, "Print the command as executing the builds") 75 | buildRace = flag.Bool("race", false, "Enable data race detection (supported only on amd64)") 76 | buildTags = flag.String("tags", "", "List of build tags to consider satisfied during the build") 77 | buildLdFlags = flag.String("ldflags", "", "Arguments to pass on each go tool link invocation") 78 | buildMode = flag.String("buildmode", "default", "Indicates which kind of object file to build") 79 | ) 80 | 81 | // BuildFlags is a simple collection of flags to fine tune a build. 82 | type BuildFlags struct { 83 | Verbose bool // Print the names of packages as they are compiled 84 | Steps bool // Print the command as executing the builds 85 | Race bool // Enable data race detection (supported only on amd64) 86 | Tags string // List of build tags to consider satisfied during the build 87 | LdFlags string // Arguments to pass on each go tool link invocation 88 | Mode string // Indicates which kind of object file to build 89 | } 90 | 91 | func main() { 92 | // Retrieve the CLI flags and the execution environment 93 | flag.Parse() 94 | 95 | xgoInXgo := os.Getenv("XGO_IN_XGO") == "1" 96 | if xgoInXgo { 97 | depsCache = "/deps-cache" 98 | } 99 | // Only use docker images if we're not already inside out own image 100 | image := "" 101 | 102 | if !xgoInXgo { 103 | // Ensure docker is available 104 | if err := checkDocker(); err != nil { 105 | log.Fatalf("Failed to check docker installation: %v.", err) 106 | } 107 | // Validate the command line arguments 108 | if len(flag.Args()) != 1 { 109 | log.Fatalf("Usage: %s [options] ", os.Args[0]) 110 | } 111 | // Select the image to use, either official or custom 112 | image = dockerDist + *goVersion 113 | if *dockerImage != "" { 114 | image = *dockerImage 115 | } 116 | // Check that all required images are available 117 | found, err := checkDockerImage(image) 118 | switch { 119 | case err != nil: 120 | log.Fatalf("Failed to check docker image availability: %v.", err) 121 | case !found: 122 | fmt.Println("not found!") 123 | if err := pullDockerImage(image); err != nil { 124 | log.Fatalf("Failed to pull docker image from the registry: %v.", err) 125 | } 126 | default: 127 | fmt.Println("found.") 128 | } 129 | } 130 | // Cache all external dependencies to prevent always hitting the internet 131 | if *crossDeps != "" { 132 | if err := os.MkdirAll(depsCache, 0751); err != nil { 133 | log.Fatalf("Failed to create dependency cache: %v.", err) 134 | } 135 | // Download all missing dependencies 136 | for _, dep := range strings.Split(*crossDeps, " ") { 137 | if url := strings.TrimSpace(dep); len(url) > 0 { 138 | path := filepath.Join(depsCache, filepath.Base(url)) 139 | 140 | if _, err := os.Stat(path); err != nil { 141 | fmt.Printf("Downloading new dependency: %s...\n", url) 142 | 143 | out, err := os.Create(path) 144 | if err != nil { 145 | log.Fatalf("Failed to create dependency file: %v.", err) 146 | } 147 | res, err := http.Get(url) 148 | if err != nil { 149 | log.Fatalf("Failed to retrieve dependency: %v.", err) 150 | } 151 | defer res.Body.Close() 152 | 153 | if _, err := io.Copy(out, res.Body); err != nil { 154 | log.Fatalf("Failed to download dependency: %v", err) 155 | } 156 | out.Close() 157 | 158 | fmt.Printf("New dependency cached: %s.\n", path) 159 | } else { 160 | fmt.Printf("Dependency already cached: %s.\n", path) 161 | } 162 | } 163 | } 164 | } 165 | // Assemble the cross compilation environment and build options 166 | config := &ConfigFlags{ 167 | Repository: flag.Args()[0], 168 | Package: *srcPackage, 169 | Remote: *srcRemote, 170 | Branch: *srcBranch, 171 | Prefix: *outPrefix, 172 | Dependencies: *crossDeps, 173 | Arguments: *crossArgs, 174 | Targets: strings.Split(*targets, ","), 175 | } 176 | flags := &BuildFlags{ 177 | Verbose: *buildVerbose, 178 | Steps: *buildSteps, 179 | Race: *buildRace, 180 | Tags: *buildTags, 181 | LdFlags: *buildLdFlags, 182 | Mode: *buildMode, 183 | } 184 | folder, err := os.Getwd() 185 | if err != nil { 186 | log.Fatalf("Failed to retrieve the working directory: %v.", err) 187 | } 188 | if *outFolder != "" { 189 | folder, err = filepath.Abs(*outFolder) 190 | if err != nil { 191 | log.Fatalf("Failed to resolve destination path (%s): %v.", *outFolder, err) 192 | } 193 | } 194 | // Execute the cross compilation, either in a container or the current system 195 | if !xgoInXgo { 196 | err = compile(image, config, flags, folder) 197 | } else { 198 | err = compileContained(config, flags, folder) 199 | } 200 | if err != nil { 201 | log.Fatalf("Failed to cross compile package: %v.", err) 202 | } 203 | } 204 | 205 | // Checks whether a docker installation can be found and is functional. 206 | func checkDocker() error { 207 | fmt.Println("Checking docker installation...") 208 | if err := run(exec.Command("docker", "version")); err != nil { 209 | return err 210 | } 211 | fmt.Println() 212 | return nil 213 | } 214 | 215 | // Checks whether a required docker image is available locally. 216 | func checkDockerImage(image string) (bool, error) { 217 | fmt.Printf("Checking for required docker image %s... ", image) 218 | out, err := exec.Command("docker", "images", "--no-trunc").Output() 219 | if err != nil { 220 | return false, err 221 | } 222 | return bytes.Contains(out, []byte(image)), nil 223 | } 224 | 225 | // Pulls an image from the docker registry. 226 | func pullDockerImage(image string) error { 227 | fmt.Printf("Pulling %s from docker registry...\n", image) 228 | return run(exec.Command("docker", "pull", image)) 229 | } 230 | 231 | // compile cross builds a requested package according to the given build specs 232 | // using a specific docker cross compilation image. 233 | func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string) error { 234 | // If a local build was requested, find the import path and mount all GOPATH sources 235 | locals, mounts, paths := []string{}, []string{}, []string{} 236 | if strings.HasPrefix(config.Repository, string(filepath.Separator)) || strings.HasPrefix(config.Repository, ".") { 237 | // Resolve the repository import path from the file path 238 | config.Repository = resolveImportPath(config.Repository) 239 | 240 | // Iterate over all the local libs and export the mount points 241 | if os.Getenv("GOPATH") == "" { 242 | log.Fatalf("No $GOPATH is set or forwarded to xgo") 243 | } 244 | for _, gopath := range strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) { 245 | // Since docker sandboxes volumes, resolve any symlinks manually 246 | sources := filepath.Join(gopath, "src") 247 | filepath.Walk(sources, func(path string, info os.FileInfo, err error) error { 248 | // Skip any folders that errored out 249 | if err != nil { 250 | log.Printf("Failed to access GOPATH element %s: %v", path, err) 251 | return nil 252 | } 253 | // Skip anything that's not a symlink 254 | if info.Mode()&os.ModeSymlink == 0 { 255 | return nil 256 | } 257 | // Resolve the symlink and skip if it's not a folder 258 | target, err := filepath.EvalSymlinks(path) 259 | if err != nil { 260 | return nil 261 | } 262 | if info, err = os.Stat(target); err != nil || !info.IsDir() { 263 | return nil 264 | } 265 | // Skip if the symlink points within GOPATH 266 | if filepath.HasPrefix(target, sources) { 267 | return nil 268 | } 269 | // Folder needs explicit mounting due to docker symlink security 270 | locals = append(locals, target) 271 | mounts = append(mounts, filepath.Join("/ext-go", strconv.Itoa(len(locals)), "src", strings.TrimPrefix(path, sources))) 272 | paths = append(paths, filepath.Join("/ext-go", strconv.Itoa(len(locals)))) 273 | return nil 274 | }) 275 | // Export the main mount point for this GOPATH entry 276 | locals = append(locals, sources) 277 | mounts = append(mounts, filepath.Join("/ext-go", strconv.Itoa(len(locals)), "src")) 278 | paths = append(paths, filepath.Join("/ext-go", strconv.Itoa(len(locals)))) 279 | } 280 | } 281 | // Assemble and run the cross compilation command 282 | fmt.Printf("Cross compiling %s...\n", config.Repository) 283 | 284 | args := []string{ 285 | "run", "--rm", 286 | "-v", folder + ":/build", 287 | "-v", depsCache + ":/deps-cache:ro", 288 | "-e", "REPO_REMOTE=" + config.Remote, 289 | "-e", "REPO_BRANCH=" + config.Branch, 290 | "-e", "PACK=" + config.Package, 291 | "-e", "DEPS=" + config.Dependencies, 292 | "-e", "ARGS=" + config.Arguments, 293 | "-e", "OUT=" + config.Prefix, 294 | "-e", fmt.Sprintf("FLAG_V=%v", flags.Verbose), 295 | "-e", fmt.Sprintf("FLAG_X=%v", flags.Steps), 296 | "-e", fmt.Sprintf("FLAG_RACE=%v", flags.Race), 297 | "-e", fmt.Sprintf("FLAG_TAGS=%s", flags.Tags), 298 | "-e", fmt.Sprintf("FLAG_LDFLAGS=%s", flags.LdFlags), 299 | "-e", fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode), 300 | "-e", "TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1), 301 | } 302 | for i := 0; i < len(locals); i++ { 303 | args = append(args, []string{"-v", fmt.Sprintf("%s:%s:ro", locals[i], mounts[i])}...) 304 | } 305 | args = append(args, []string{"-e", "EXT_GOPATH=" + strings.Join(paths, ":")}...) 306 | 307 | args = append(args, []string{image, config.Repository}...) 308 | return run(exec.Command("docker", args...)) 309 | } 310 | 311 | // compileContained cross builds a requested package according to the given build 312 | // specs using the current system opposed to running in a container. This is meant 313 | // to be used for cross compilation already from within an xgo image, allowing the 314 | // inheritance and bundling of the root xgo images. 315 | func compileContained(config *ConfigFlags, flags *BuildFlags, folder string) error { 316 | // If a local build was requested, resolve the import path 317 | local := strings.HasPrefix(config.Repository, string(filepath.Separator)) || strings.HasPrefix(config.Repository, ".") 318 | if local { 319 | config.Repository = resolveImportPath(config.Repository) 320 | } 321 | // Fine tune the original environment variables with those required by the build script 322 | env := []string{ 323 | "REPO_REMOTE=" + config.Remote, 324 | "REPO_BRANCH=" + config.Branch, 325 | "PACK=" + config.Package, 326 | "DEPS=" + config.Dependencies, 327 | "ARGS=" + config.Arguments, 328 | "OUT=" + config.Prefix, 329 | fmt.Sprintf("FLAG_V=%v", flags.Verbose), 330 | fmt.Sprintf("FLAG_X=%v", flags.Steps), 331 | fmt.Sprintf("FLAG_RACE=%v", flags.Race), 332 | fmt.Sprintf("FLAG_TAGS=%s", flags.Tags), 333 | fmt.Sprintf("FLAG_LDFLAGS=%s", flags.LdFlags), 334 | fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode), 335 | "TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1), 336 | } 337 | if local { 338 | env = append(env, "EXT_GOPATH=/non-existent-path-to-signal-local-build") 339 | } 340 | // Assemble and run the local cross compilation command 341 | fmt.Printf("Cross compiling %s...\n", config.Repository) 342 | 343 | cmd := exec.Command("/build.sh", config.Repository) 344 | cmd.Env = append(os.Environ(), env...) 345 | 346 | return run(cmd) 347 | } 348 | 349 | // resolveImportPath converts a package given by a relative path to a Go import 350 | // path using the local GOPATH environment. 351 | func resolveImportPath(path string) string { 352 | abs, err := filepath.Abs(path) 353 | if err != nil { 354 | log.Fatalf("Failed to locate requested package: %v.", err) 355 | } 356 | stat, err := os.Stat(abs) 357 | if err != nil || !stat.IsDir() { 358 | log.Fatalf("Requested path invalid.") 359 | } 360 | pack, err := build.ImportDir(abs, build.FindOnly) 361 | if err != nil { 362 | log.Fatalf("Failed to resolve import path: %v.", err) 363 | } 364 | return pack.ImportPath 365 | } 366 | 367 | // Executes a command synchronously, redirecting its output to stdout. 368 | func run(cmd *exec.Cmd) error { 369 | cmd.Stdout = os.Stdout 370 | cmd.Stderr = os.Stderr 371 | 372 | return cmd.Run() 373 | } 374 | --------------------------------------------------------------------------------