Compare commits
1 Commits
6dbb1939ab
...
f25ff99f4d
| Author | SHA1 | Date |
|---|---|---|
|
|
f25ff99f4d |
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/build
|
||||
/build*
|
||||
|
||||
# ---> C++
|
||||
# Prerequisites
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class BmrConan(ConanFile):
|
|||
|
||||
def configure(self):
|
||||
self.options["boost"].without_cobalt = True
|
||||
if self.settings.arch == "armv7":
|
||||
if self.settings.arch == "armv7" or self.settings.arch == "armv6":
|
||||
self.options["libpng"].neon = False
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
# Creating cross-compilers
|
||||
This folder contains configuration, scripts and docker images that are used for creating cross-compilers. The intended use case is to build C and C++ software for various platforms. Docker is being used to provide a common environment and isolating the build process.
|
||||
|
||||
## How to use:
|
||||
1. Clone the repository to a location of your liking.
|
||||
2. Create a docker image containing crosstool-ng.
|
||||
``cd support/create-cross-compiler``
|
||||
``docker build -t <docker image name> -f create-cross-compiler.Dockerfile .``
|
||||
3. Use the docker image to create the cross comiler.
|
||||
* Configuration needs to be provided. (environment variable: CROSS_TARGET_INFO_PATH).
|
||||
* Destination location needs to be provided (environment variable: CROSS_TARGET_DST_PATH).
|
||||
* Use docker volume functionality to link directories to the docker container.
|
||||
``docker run -ti -e CROSS_TARGET_INFO_PATH=/config -e CROSS_TARGET_DST_PATH=/dst -v ./armv6-rpi-linux:/config -v ./dst:/dst <docker image name>``
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
[settings]
|
||||
os=Linux
|
||||
arch=armv6
|
||||
compiler=gcc
|
||||
build_type=Release
|
||||
compiler.cppstd=gnu17
|
||||
compiler.libcxx=libstdc++11
|
||||
compiler.version=14
|
||||
[buildenv]
|
||||
CC=/x-tools/armv6-rpi-linux-gnueabihf/bin/armv6-rpi-linux-gnueabihf-gcc
|
||||
CXX=/x-tools/armv6-rpi-linux-gnueabihf/bin/armv6-rpi-linux-gnueabihf-g++
|
||||
LD=/x-tools/armv6-rpi-linux-gnueabihf/bin/armv6-rpi-linux-gnueabihf-ld
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
mkdir -p ../../build-tools/x-tools
|
||||
|
||||
docker build \
|
||||
-t bmr-create-cross-compiler \
|
||||
-f create-cross-compiler.Dockerfile .
|
||||
|
||||
docker run -ti \
|
||||
-e CROSS_TARGET_INFO_PATH=/extern-config \
|
||||
-e CROSS_TARGET_DST_PATH=/extern-dst \
|
||||
-v ./armv6-rpi-linux:/extern-config \
|
||||
-v ../../build-tools/x-tools:/extern-dst bmr-create-cross-compiler
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
FROM alpine:3.22.2
|
||||
|
||||
# Install packages needed in both building and running.
|
||||
RUN apk update && \
|
||||
apk add --no-cache \
|
||||
libstdc++
|
||||
|
||||
# Install tools required for building.
|
||||
RUN mkdir -p /root/.local/bin
|
||||
ENV PATH="${PATH}:/root/.local/bin"
|
||||
|
||||
RUN apk add --no-cache \
|
||||
autoconf \
|
||||
bash \
|
||||
binutils \
|
||||
build-base \
|
||||
cmake \
|
||||
clang \
|
||||
clang-extra-tools \
|
||||
gdb \
|
||||
git \
|
||||
libtool \
|
||||
linux-headers \
|
||||
ninja \
|
||||
m4 \
|
||||
perl \
|
||||
python3 \
|
||||
pipx
|
||||
|
||||
# Install tools we need for building the cross compiler.
|
||||
RUN apk add --no-cache \
|
||||
gpg \
|
||||
gpg-agent \
|
||||
automake \
|
||||
flex \
|
||||
make \
|
||||
texinfo \
|
||||
xz \
|
||||
help2man \
|
||||
gawk \
|
||||
bison \
|
||||
ncurses-dev \
|
||||
rsync \
|
||||
wget
|
||||
|
||||
RUN mkdir -p /workspace
|
||||
WORKDIR /workspace
|
||||
|
||||
# Download crosstool-ng that we use to build the cross compiler.
|
||||
RUN <<EOF
|
||||
gpg --keyserver pgp.surfnet.nl --recv-keys 721B0FB1CDC8318AEBB888B809F6DD5F1F30EF2E
|
||||
wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.28.0.tar.bz2.sig
|
||||
wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.28.0.tar.bz2
|
||||
gpg --verify crosstool-ng-1.28.0.tar.bz2.sig
|
||||
tar -xjf crosstool-ng-1.28.0.tar.bz2
|
||||
mv /workspace/crosstool-ng-1.28.0 /crosstool
|
||||
EOF
|
||||
|
||||
# - Add a user that we need for building (crosstool-ng requires non-root user for that).
|
||||
# - Add some directories we need in the future for building.
|
||||
# - Build crosstool-ng, which in it's turn will be used to build the cross compiler.
|
||||
|
||||
ENV CROSS_DESTDIR=/x-tools
|
||||
|
||||
WORKDIR /crosstool
|
||||
RUN <<EOF
|
||||
adduser -D crosstoolng
|
||||
|
||||
mkdir -p /home/crosstoolng/src
|
||||
mkdir -p $CROSS_DESTDIR
|
||||
|
||||
./bootstrap
|
||||
./configure
|
||||
make DESTDIR=$CROSS_DESTDIR
|
||||
make install
|
||||
|
||||
chown -R crosstoolng:crosstoolng /crosstool
|
||||
chown -R crosstoolng:crosstoolng $CROSS_DESTDIR
|
||||
chown -R crosstoolng:crosstoolng /home/crosstoolng
|
||||
EOF
|
||||
|
||||
# We now have crosstool-ng built and ready to be used for building the cross-compiler that we actually want. To
|
||||
# do that we need to feed some configuration
|
||||
|
||||
WORKDIR /workspace
|
||||
ADD --chmod=544 ./scripts/create-cross-compiler.py .
|
||||
ADD --chmod=544 ./scripts/entrypoint.sh .
|
||||
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#! /usr/bin/python
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def runcmd(command):
|
||||
print('RUN ' + command)
|
||||
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
|
||||
for line in iter(process.stdout.readline, b''): # b'' indicates EOF
|
||||
print(line.decode('utf-8'), end='')
|
||||
|
||||
def load_environment(filename):
|
||||
with open(filename) as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--cross-target-info-path', dest='target_info')
|
||||
parser.add_argument('--cross-destination-path', dest='dst')
|
||||
args = parser.parse_args()
|
||||
|
||||
cross_target_info_path = args.target_info
|
||||
cross_destination_path = args.dst
|
||||
ctng_config = cross_target_info_path + '/ct-ng.config'
|
||||
cross_destdir = os.environ['CROSS_DESTDIR']
|
||||
|
||||
if not os.path.isdir(cross_destdir):
|
||||
raise Exception("ERROR... expected internal destination for ct-ng does not exist")
|
||||
if not os.path.isdir(cross_target_info_path):
|
||||
raise Exception("Supplied configuration info path is not a directory")
|
||||
if not os.path.isfile(ctng_config):
|
||||
raise Exception("No crosstool ng configuration file found (ct-ng.config)")
|
||||
|
||||
shutil.copy(ctng_config, '/crosstool/.config')
|
||||
os.chdir('/crosstool')
|
||||
|
||||
runcmd("su crosstoolng -c 'ct-ng source'")
|
||||
runcmd("su crosstoolng -c 'ct-ng build'")
|
||||
|
||||
runcmd("cp -rv " + cross_destdir + "/* " + cross_destination_path + "/")
|
||||
|
||||
sys.exit(0)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
./create-cross-compiler.py --cross-target-info-path=$CROSS_TARGET_INFO_PATH --cross-destination-path=$CROSS_TARGET_DST_PATH
|
||||
|
||||
Loading…
Reference in New Issue