Skip to content

Commit 37d04cb

Browse files
committed
Merge branch 'umbynos/draft_docker_crossbuild'
2 parents e331e03 + f4bac9e commit 37d04cb

File tree

411 files changed

+503114
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

411 files changed

+503114
-1
lines changed

Dockerfile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
FROM ubuntu:latest
2+
3+
ENV TZ=Europe/Rome
4+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
5+
RUN apt-get update && \
6+
# TODO add --no-install-recommends
7+
apt-get install -y \
8+
build-essential \
9+
# Intall clang compiler used by macos
10+
clang \
11+
cmake \
12+
curl \
13+
dh-autoreconf \
14+
git \
15+
gperf \
16+
# various libs required to compile osxcross
17+
libxml2-dev \
18+
libssl-dev \
19+
libz-dev \
20+
# liblzma5 \
21+
# Install Windows cross-tools
22+
mingw-w64 \
23+
p7zip-full \
24+
pkg-config \
25+
tar \
26+
# xz-utils \
27+
&& rm -rf /var/lib/apt/lists/*
28+
# Install toolchains in /opt
29+
RUN curl downloads.arduino.cc/tools/internal/toolchains.tar.gz | tar -xz "opt"
30+
RUN curl downloads.arduino.cc/tools/internal/i686-ubuntu16.04-linux-gnu.tar.gz | tar -xzC /opt
31+
# Remove useless toolchains:
32+
RUN rm -r /opt/arm-rpi-4.9.3-linux-gnueabihf/
33+
RUN rm -r /opt/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/
34+
RUN rm -r /opt/*ubuntu12.04*
35+
#install proper arm toolchains
36+
RUN curl -L 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz' | tar -xJC /opt
37+
RUN curl -L 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz' | tar -xJC /opt
38+
39+
# install macos10.15 sdk
40+
COPY MacOSX10.15.sdk.tar.xz /opt/osxcross/tarballs/
41+
# remove old unused macos10.09 sdk because we are using 10.15 one
42+
RUN rm -rf /opt/osxcross/tarballs/MacOSX10.9.sdk.tar.bz2
43+
RUN cd /opt/osxcross; git pull; UNATTENDED=1 SDK_VERSION=10.15 ./build.sh
44+
# Set toolchains paths
45+
# arm-linux-gnueabihf-gcc -> linux_arm
46+
ENV PATH=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/:$PATH
47+
# aarch64-linux-gnu-gcc -> linux_arm64
48+
ENV PATH=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/:$PATH
49+
# x86_64-ubuntu16.04-linux-gnu-gcc -> linux_amd64
50+
ENV PATH=/opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin/:$PATH
51+
# i686-ubuntu16.04-linux-gnu-gcc -> linux_386
52+
ENV PATH=/opt/i686-ubuntu16.04-linux-gnu/bin/:$PATH
53+
# o64-clang -> darwin_amd64
54+
ENV PATH=/opt/osxcross/target/bin/:$PATH
55+
56+
RUN mkdir -p /workdir
57+
WORKDIR /workdir
58+
59+
# debug/utilities
60+
RUN alias ll="ls -lah"
61+
RUN apt-get update && apt-get install -y tree cmake-curses-gui nano && rm -rf /var/lib/apt/lists/*
62+
63+
# Handle libusb and libudev
64+
COPY deps/ /opt/lib/
65+
# compiler name is arm-linux-gnueabihf-gcc '-gcc' is added by ./configure
66+
ENV CROSS_COMPILE=x86_64-ubuntu16.04-linux-gnu
67+
RUN /opt/lib/build_libs.sh
68+
ENV CROSS_COMPILE=arm-linux-gnueabihf
69+
RUN /opt/lib/build_libs.sh
70+
ENV CROSS_COMPILE=aarch64-linux-gnu
71+
RUN /opt/lib/build_libs.sh
72+
ENV CROSS_COMPILE=i686-ubuntu16.04-linux-gnu
73+
RUN /opt/lib/build_libs.sh
74+
ENV CROSS_COMPILE=i686-w64-mingw32
75+
RUN /opt/lib/build_libs.sh
76+
# macos does not need eudev
77+
# CROSS_COMPILER is used to override the compiler
78+
ENV CROSS_COMPILER=o64-clang
79+
ENV CROSS_COMPILE=x86_64-apple-darwin13
80+
RUN /opt/lib/build_libs.sh
81+
82+
ENTRYPOINT ["/bin/bash"]

build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
export CROSS_COMPILE=x86_64-ubuntu16.04-linux-gnu
3+
./build_tools.sh
4+
export CROSS_COMPILE=arm-linux-gnueabihf
5+
./build_tools.sh
6+
export CROSS_COMPILE=aarch64-linux-gnu
7+
./build_tools.sh
8+
export CROSS_COMPILE=i686-ubuntu16.04-linux-gnu
9+
./build_tools.sh
10+
export CROSS_COMPILE=i686-w64-mingw32
11+
./build_tools.sh
12+
# macos does not need eudev
13+
# CROSS_COMPILER is used to override the compiler
14+
export CROSS_COMPILER=o64-clang
15+
export CROSS_COMPILE=x86_64-apple-darwin13
16+
./build_tools.sh
17+
tar -czvf /workdir/tools.tar.gz /tmp/x86_64-apple-darwin13/ /tmp/aarch64-linux-gnu/ /tmp/arm-linux-gnueabihf/ /tmp/i686-ubuntu16.04-linux-gnu/ /tmp/i686-w64-mingw32/ /tmp/x86_64-ubuntu16.04-linux-gnu/

build_tools.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
#before running this script export CROSS_COMPILE and eventually CROSS_COMPILER env vars
3+
cd /tmp
4+
mkdir -p ${CROSS_COMPILE}
5+
6+
# apt install libfl-dev -y
7+
8+
if [ ! -d 'pico-sdk' ]; then
9+
git clone https://github.com/raspberrypi/pico-sdk.git
10+
fi
11+
if [ ! -d 'picotool' ]; then
12+
git clone https://github.com/raspberrypi/picotool.git
13+
fi
14+
15+
export PICO_SDK_PATH=$PWD/pico-sdk
16+
export LIBUSB_DIR=/opt/lib/libusb-1.0.20/libusb/
17+
if [[ ${CROSS_COMPILE} != *apple* ]]; then
18+
CROSS_COMPILER=${CROSS_COMPILE}-gcc
19+
export LIBUSBUDEV=/opt/lib/$CROSS_COMPILE/libusbudev.a
20+
else
21+
export LIBUSBUDEV=$LIBUSB_DIR.libs/libusb-1.0.a
22+
fi
23+
24+
if [[ ${CROSS_COMPILE} == *mingw* ]]; then
25+
export CFLAGS="-mno-ms-bitfields $CFLAGS"
26+
fi
27+
28+
cd picotool
29+
git reset --hard
30+
if [[ ${CROSS_COMPILE} != *apple* ]]; then
31+
git apply /workdir/patches/picotool_cmakelists.patch # TODO apply only one time and if ! macos
32+
fi
33+
if [[ ${CROSS_COMPILE} == *mingw* ]]; then
34+
git apply /workdir/patches/windows_mingw.patch # maybe apply not only on win 🤷‍♂️
35+
fi
36+
rm -rf build
37+
mkdir build
38+
cd build
39+
if [[ ${CROSS_COMPILE} != *apple* ]]; then
40+
cmake -DCMAKE_C_COMPILER=$CROSS_COMPILE-gcc -DCMAKE_CXX_COMPILER=$CROSS_COMPILE-g++ -DLIBUSB_LIBRARIES=$LIBUSBUDEV -DLIBUSB_INCLUDE_DIR=$LIBUSB_DIR ..
41+
else
42+
cmake -DCMAKE_C_COMPILER=$CROSS_COMPILER -DCMAKE_CXX_COMPILER=$CROSS_COMPILER++ -DCMAKE_CXX_FLAGS="-framework IOKit -framework Cocoa" -DLIBUSB_LIBRARIES=$LIBUSBUDEV -DLIBUSB_INCLUDE_DIR=$LIBUSB_DIR ..
43+
fi
44+
make
45+
if [[ ${CROSS_COMPILE} == *mingw* ]]; then
46+
cp picotool.exe ../../$CROSS_COMPILE
47+
else
48+
cp picotool ../../$CROSS_COMPILE
49+
fi
50+
cd ..
51+
cd ..
52+
53+
cd pico-sdk/tools/elf2uf2/
54+
git reset --hard
55+
if [[ ${CROSS_COMPILE} != *apple* ]]; then
56+
git apply /workdir/patches/elf2uf2_cmakelists.patch
57+
fi
58+
rm -rf build
59+
mkdir build
60+
cd build
61+
if [[ ${CROSS_COMPILE} != *apple* ]]; then
62+
cmake -DCMAKE_C_COMPILER=$CROSS_COMPILE-gcc -DCMAKE_CXX_COMPILER=$CROSS_COMPILE-g++ ..
63+
else
64+
cmake -DCMAKE_C_COMPILER=$CROSS_COMPILER -DCMAKE_CXX_COMPILER=$CROSS_COMPILER++ -DCMAKE_CXX_FLAGS="-framework IOKit -framework Cocoa" ..
65+
fi
66+
make
67+
if [[ ${CROSS_COMPILE} == *mingw* ]]; then
68+
cp elf2uf2.exe ../../../../$CROSS_COMPILE #exe for win
69+
else
70+
cp elf2uf2 ../../../../$CROSS_COMPILE #exe for win
71+
fi
72+
cd ..
73+
cd ..
74+
cd ..

deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ VERSION=`cat main.go| grep "const Version" |cut -f4 -d " " | tr -d '"'`
44

55
#Remember to set GOROOT accordingly with your installation
66

7-
declare -a target_folders=("linux_amd64" "linux_arm64" "linux_arm" "darwin_amd64" "windows_386")
7+
declare -a target_folders=("linux_amd64" "linux_386" "linux_arm64" "linux_arm" "darwin_amd64" "windows_386")
88

99
rm -rf distrib
1010
mkdir distrib

deps/build_libs.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
if [ x$CROSS_COMPILER == x ]; then
4+
CROSS_COMPILER=${CROSS_COMPILE}-gcc
5+
else
6+
export CC=$CROSS_COMPILER
7+
fi
8+
# udev lib not required for macos
9+
if [[ ${CROSS_COMPILE} != *apple* ]]; then
10+
cd /opt/lib/eudev-3.2.10
11+
export UDEV_DIR=`pwd`
12+
./autogen.sh
13+
./configure --enable-static --disable-shared --disable-blkid --disable-kmod --disable-manpages --host=${CROSS_COMPILE}
14+
make clean
15+
make -j4
16+
cd ..
17+
export CFLAGS="-I$UDEV_DIR/src/libudev/"
18+
export LDFLAGS="-L$UDEV_DIR/src/libudev/.libs/"
19+
export LIBS="-ludev"
20+
fi
21+
cd /opt/lib/libusb-1.0.20
22+
export LIBUSB_DIR=`pwd`
23+
./configure --enable-static --disable-shared --host=${CROSS_COMPILE}
24+
make clean
25+
make
26+
cd ..
27+
# libusbudev.a merged not required for macos
28+
if [[ ${CROSS_COMPILE} != *apple* ]]; then
29+
mkdir -p ${CROSS_COMPILE}/libusb
30+
mkdir -p ${CROSS_COMPILE}/libudev
31+
cd ${CROSS_COMPILE}/libusb/
32+
ar -x ../../libusb-1.0.20/libusb/.libs/libusb-1.0.a
33+
cd ../libudev/
34+
ar -x ../../eudev-3.2.10/src/libudev/.libs/libudev.a
35+
cd ..
36+
ar -qc libusbudev.a libudev/* libusb/*
37+
fi

deps/eudev-3.2.10/.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
src/udev/udevadm
2+
src/udev/udevd
3+
4+
*.[oa]
5+
*.l[oa]
6+
.libs
7+
.deps
8+
Makefile
9+
Makefile.in
10+
11+
aclocal.m4
12+
autom4te.cache
13+
compile
14+
config.*
15+
configure
16+
libtool
17+
stamp-h1
18+
19+
depcomp
20+
install-sh
21+
ltmain.sh
22+
missing
23+
24+
*.pc
25+
26+
m4/libtool.m4
27+
m4/ltoptions.m4
28+
m4/ltsugar.m4
29+
m4/ltversion.m4
30+
m4/lt~obsolete.m4
31+
32+
rule_generator/write_net_rules
33+
34+
rules/64-btrfs.rules
35+
36+
src/ata_id/ata_id
37+
src/cdrom_id/cdrom_id
38+
src/collect/collect
39+
src/mtd_probe/mtd_probe
40+
src/scsi_id/scsi_id
41+
src/v4l_id/v4l_id
42+
43+
src/udev/keyboard-keys-from-name.gperf
44+
src/udev/keyboard-keys-from-name.h
45+
src/udev/keyboard-keys-to-name.h
46+
src/udev/keyboard-keys.txt
47+
48+
test/test-libudev
49+
test/test-udev
50+
test/test
51+
test-driver
52+
53+
test/rules-test.sh.log
54+
test/rules-test.sh.trs
55+
test/test-suite.log
56+
test/udev-test.pl.log
57+
test/udev-test.pl.trs
58+
59+
eudev-*.tar.gz

deps/eudev-3.2.10/.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: c
2+
compiler:
3+
- gcc
4+
- clang
5+
before_install:
6+
- sudo apt-get update -qq
7+
- sudo apt-get install autotools-dev automake autoconf libtool gperf xsltproc docbook-xsl
8+
script: ./autogen.sh && ./configure && make V=1 distcheck
9+
notifications:
10+
irc:
11+
channels:
12+
- "irc.freenode.org#gentoo-udev"
13+
on_success: change
14+
on_failure: always

0 commit comments

Comments
 (0)