Set the ARCH, CROSS_COMPILE and PATH variables to support Linux kernel
cross compilation.
ARCH is set according to:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch?h=v5.2.2
PATH is set to include the cross toolchain path, which is used by the
kernel Makefile.
CROSS_COMPILE is the CROSS_TRIPLE with a dash appended, as the kernel
Makefile uses it to invoke the toolchain utils.
To build the kernel, depending on the config, libssl-dev and libelf-dev
are required. Those are not dealt in this commit as they are not
correlated to the environment variables.
Validated by build the kernel using default kernel config when possible,
otherwise randomly select a defconfig.
<arch> - <defconfig>
arm64 - defconfig
armv5 and armv5-musl - colibri_pxa270_defconfig
armv6 - bcm2835_defconfig
armv7 and armv7a- tegra_defconfig
*x86 - i386_defconfig
mips and mipsel - ath79_defconfig
ppc64le - wii_defconfig
s390x - defconfig
x64 - x86_64_defconfig
* x86 dockcross toolchain does not provide "ld" and compilation fails.
fix#160
Older versions of git included in older linux distributions are not able
to download source from Github. A newer version is required with a newer
OpenSSL. This requires to also build curl with the same OpenSSL.
CMake is downloaded precompiled if available (64bits system) or compiled
from source otherwise.
As recommended in by CircleCI, explicitly specify the "latest"
tag. This will be important when we will start versioning our images.
Copied from CircleCI documentation [1]:
"Make sure you tag the image you use in the FROM command in your
Dockerfile, even if it is the default “latest” tag. Otherwise, Docker
will pull down all tags for the image you specify. This will create
significant performance problems because the save/load strategy described
above only caches the image layers (and thus tags) that you specify in
the docker save command, so other tags will be re-pulled on every build
if a tag is not specified in the FROM command."
[1] https://circleci.com/docs/docker/#caching-docker-layers
To accommodate the requirements associated with x86 and x64 images, the
command building OpenSSL and CMake became overly complex and hard to
maintain.
This commit has multiple purposes:
(1) simplify common.docker
(2) fix the building of 64-bit shared libraries against the static openssl
libraries by passing the -fPIC flag.
(3) ensure [many]linux-x86 and [many]linux-x64 images have an up-to-date
OpenSSL install. Openssl static libraries are installed in /usr
(4) simplify and speedup CMake build avoiding the second build with
explicit -DCMAKE_USE_OPENSSL:BOOL=ON. Indeed, configuring CMake on Linux
already looks for OpenSSL.
(5) speedup download of CMake source directly downloading the archive
corresponding to the revision.
(6) test CMake by:
- running CMake.FileDownload test
- trying to download a file served over https
This commit build each images with the following arguments:
* IMAGE: Name of the image (e.g dockcross/base, dockcross/manylinux-x64, ...)
* VCS_REF: dockcross/dockcross commit from which this image is built
* VCS_URL: this repository obtained reading remote.origin.url
* BUILD_DATE: Date and time when the build was initiated
Then, within the Dockerfile, the metadata are associated with the image
using the "LABEL" instruction.
See https://docs.docker.com/engine/reference/builder/#/label
The corresponding labels can be found here:
http://label-schema.org/rc1/#build-time-labels
See #28
This will fix issue where emulator is used doing:
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} /path/to/prog arg1 arg2
Prior to this commit, it wasn't working because the following command
was used:
/bin/sh -c /path/to/prog arg1 arg2