Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
43 changes: 24 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04 as build
FROM ubuntu:22.04 AS build

ENV TZ=Europe/Rome
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
Expand All @@ -12,7 +12,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &
dh-autoreconf \
git \
gperf \
# various libs required to compile osxcross
# various libs requied to compile osxcross
libxml2-dev \
libssl-dev \
libz-dev \
Expand All @@ -26,21 +26,24 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &
llvm \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/bin/clang-13 /usr/bin/clang \
&& ln -s /usr/bin/clang++-13 /usr/bin/clang++
&& ln -s /usr/bin/clang++-13 /usr/bin/clang++ \
# pretend to have 1.17 instead of 1.16
&& ln -s /usr/bin/aclocal /usr/bin/aclocal-1.17 \
&& ln -s /usr/bin/automake /usr/bin/automake-1.17

# Install toolchains in /opt
RUN curl -L downloads.arduino.cc/tools/internal/toolchains.tar.gz | tar -xz "opt"
# install proper arm toolchains (already present in the toolchains.tar.gz archive)
# 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 && \
# 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

RUN cd /opt/osxcross && \
git pull && \
WORKDIR /opt/osxcross
RUN git pull && \
# use a specific version of osxcross (it does not have tags), this commit has the automatic install of compiler_rt libraries
git checkout b875d7c1360c8ff2077463d7a5a12e1cff1cc683 && \
UNATTENDED=1 SDK_VERSION=10.15 ./build.sh
RUN cd /opt/osxcross && \
UNATTENDED=1 SDK_VERSION=10.15 ./build.sh && \
ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=10.15 ./build_compiler_rt.sh

# Set toolchains paths
# arm-linux-gnueabihf-gcc -> linux_arm
# aarch64-linux-gnu-gcc -> linux_arm64
Expand All @@ -49,18 +52,16 @@ RUN cd /opt/osxcross && \
# o64-clang -> darwin_amd64
ENV PATH=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/:/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/:/opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin/:/opt/i686-ubuntu16.04-linux-gnu/bin/:/opt/osxcross/target/bin/:$PATH

WORKDIR /workdir

# Handle libusb and libudev compilation and merging
COPY deps/ /opt/lib/
# compiler name is arm-linux-gnueabihf-gcc '-gcc' is added by ./configure
RUN CROSS_COMPILE=x86_64-ubuntu16.04-linux-gnu /opt/lib/build_libs.sh
RUN CROSS_COMPILE=arm-linux-gnueabihf /opt/lib/build_libs.sh
RUN CROSS_COMPILE=aarch64-linux-gnu /opt/lib/build_libs.sh
RUN CROSS_COMPILE=i686-ubuntu16.04-linux-gnu /opt/lib/build_libs.sh
RUN CROSS_COMPILE=i686-w64-mingw32 /opt/lib/build_libs.sh
# CROSS_COMPILER is used to override the compiler
RUN CROSS_COMPILER=o64-clang CROSS_COMPILE=x86_64-apple-darwin13 AR=/opt/osxcross/target/bin/x86_64-apple-darwin13-ar RANLIB=/opt/osxcross/target/bin/x86_64-apple-darwin13-ranlib /opt/lib/build_libs.sh
RUN CROSS_COMPILE=x86_64-ubuntu16.04-linux-gnu /opt/lib/build_libs.sh && \
CROSS_COMPILE=arm-linux-gnueabihf /opt/lib/build_libs.sh && \
CROSS_COMPILE=aarch64-linux-gnu /opt/lib/build_libs.sh && \
CROSS_COMPILE=i686-ubuntu16.04-linux-gnu /opt/lib/build_libs.sh && \
CROSS_COMPILE=i686-w64-mingw32 /opt/lib/build_libs.sh && \
# CROSS_COMPILER is used to override the compiler
CROSS_COMPILER=o64-clang CROSS_COMPILE=x86_64-apple-darwin13 AR=/opt/osxcross/target/bin/x86_64-apple-darwin13-ar RANLIB=/opt/osxcross/target/bin/x86_64-apple-darwin13-ranlib /opt/lib/build_libs.sh

FROM ubuntu:22.04
# Copy all the installed toolchains and compiled libs
Expand All @@ -70,7 +71,7 @@ ENV TZ=Europe/Rome
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
apt-get update && \
apt-get install -y \
build-essential \
build-essential \
# Intall clang compiler used by macos
clang-13 \
cmake \
Expand All @@ -86,6 +87,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/bin/clang-13 /usr/bin/clang \
&& ln -s /usr/bin/clang++-13 /usr/bin/clang++

# Set toolchains paths
# arm-linux-gnueabihf-gcc -> linux_arm
# aarch64-linux-gnu-gcc -> linux_arm64
Expand All @@ -94,6 +96,9 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &
# o64-clang -> darwin_amd64
ENV PATH=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/:/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/:/opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin/:/opt/i686-ubuntu16.04-linux-gnu/bin/:/opt/osxcross/target/bin/:$PATH

WORKDIR /workdir
COPY ./configure_toolchain.sh /
RUN chmod +x /configure_toolchain.sh

ENTRYPOINT ["/bin/bash"]
WORKDIR /workdir
ENTRYPOINT ["/configure_toolchain.sh"]
CMD ["bash"]
47 changes: 47 additions & 0 deletions configure_toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash -e

Check failure on line 1 in configure_toolchain.sh

View workflow job for this annotation

GitHub Actions / executable

non-executable script file: ./configure_toolchain.sh

Check failure on line 1 in configure_toolchain.sh

View workflow job for this annotation

GitHub Actions / executable

non-executable script file: ./configure_toolchain.sh

Check failure on line 1 in configure_toolchain.sh

View workflow job for this annotation

GitHub Actions / executable

non-executable script file: ./configure_toolchain.sh

# Check if the CROSS_COMPILE variable is set
if [ -z "$CROSS_COMPILE" ]; then
echo "Error: CROSS_COMPILE is not set. Please specify the toolchain prefix (e.g., arm-linux-gnueabihf-)."
exit 1
fi

# Detect if the toolchain is osxcross
if [[ "$CROSS_COMPILE" == *"apple-darwin"* ]]; then
# Set osxcross-specific tools
export CC="o64-clang"
export CXX="o64-clang++"
else
export CC="${CROSS_COMPILE}-gcc"
export CXX="${CROSS_COMPILE}-g++"
fi

# Set default compilation flags
export AR="${CROSS_COMPILE}-ar"
export RANLIB="${CROSS_COMPILE}-ranlib"
export LD="${CROSS_COMPILE}-ld"
export STRIP="${CROSS_COMPILE}-strip"
export CFLAGS="-O2"
export CXXFLAGS="$CFLAGS"

# Add toolchain's lib directory to library paths
TOOLCHAIN_LIB_DIR="/opt/lib/${CROSS_COMPILE%/}/lib"
TOOLCHAIN_INCLUDE_DIR="/opt/lib/${CROSS_COMPILE%/}/include"
export LIBRARY_PATH="$TOOLCHAIN_LIB_DIR:$LIBRARY_PATH"
export PKG_CONFIG_PATH="$TOOLCHAIN_LIB_DIR/pkgconfig:$PKG_CONFIG_PATH"
export CPATH="$TOOLCHAIN_INCLUDE_DIR:$CPATH"
export C_INCLUDE_PATH="$TOOLCHAIN_INCLUDE_DIR:$C_INCLUDE_PATH"
export CPLUS_INCLUDE_PATH="$TOOLCHAIN_INCLUDE_DIR:$CPLUS_INCLUDE_PATH"

echo "Configured toolchain: $CROSS_COMPILE"
echo " CC=$CC, CXX=$CXX, AR=$AR, RANLIB=$RANLIB, LD=$LD, STRIP=$STRIP"
echo " CFLAGS=$CFLAGS, CXXFLAGS=$CXXFLAGS, LDFLAGS=$LDFLAGS"
echo " LIBRARY_PATH=$LIBRARY_PATH"
echo " LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
echo " PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
echo " CPATH=$CPATH"
echo " C_INCLUDE_PATH=$C_INCLUDE_PATH"
echo " CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH"

# Execute the provided command
exec "$@"
6 changes: 6 additions & 0 deletions deps/build_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
export CC=$CROSS_COMPILER
export CXX=$CROSS_COMPILER++
CROSS_COMPILER=$CC
CROSS_COMPILER_CXX=$CXX

Check warning on line 16 in deps/build_libs.sh

View workflow job for this annotation

GitHub Actions / Generate problem matcher output

CROSS_COMPILER_CXX appears unused. Verify use (or export if used externally). [SC2034]

Check warning on line 16 in deps/build_libs.sh

View workflow job for this annotation

GitHub Actions / Generate problem matcher output

CROSS_COMPILER_CXX appears unused. Verify use (or export if used externally). [SC2034]

Check warning on line 16 in deps/build_libs.sh

View workflow job for this annotation

GitHub Actions / Generate problem matcher output

CROSS_COMPILER_CXX appears unused. Verify use (or export if used externally). [SC2034]
fi
cd /opt/lib/libusb-1.0.28
LIBUSB_DIR=$(pwd)
Expand Down Expand Up @@ -111,3 +111,9 @@
./configure --prefix="$PREFIX" --enable-static --disable-shared --host="$CROSS_COMPILE"
make -j"$(nproc)"
make install

cd /opt/lib/libxml2-2.14.3
./autogen.sh --prefix="$PREFIX" --disable-shared --enable-static --without-python --without-iconv --host="$CROSS_COMPILE"
make -j"$(nproc)"
make install

11 changes: 11 additions & 0 deletions deps/libxml2-2.14.3/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# EditorConfig : http://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 4
tab_width = 8

[Makefile*]
indent_style = tab
2 changes: 2 additions & 0 deletions deps/libxml2-2.14.3/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/result/** -text
/test/** -text
65 changes: 65 additions & 0 deletions deps/libxml2-2.14.3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
*.exe
*.o
*.la
*.lo
*.pyc

# Executables
/xmlcatalog
/xmllint

# Test executables
/runsuite
/runtest
/runxmlconf
/testModule
/testapi
/testchar
/testdict
/testlimits
/testparser
/testrecurse

# Tests
/missing.lst
/runsuite.log
/runxmlconf.log
/test.out
/xmlconf

# Generated by build system
/config.h
/include/libxml/xmlversion.h
/libxml-2.0.pc
/libxml2-config.cmake
/xml2-config

# Autotools
.deps
.libs
Makefile
Makefile.in
/INSTALL
/aclocal.m4
/autom4te.cache
/compile
/config.guess
/config.guess~
/config.h.in
/config.h.in~
/config.log
/config.status
/config.sub
/config.sub~
/configure
/configure~
/depcomp
/install-sh
/install-sh~
/libtool
/ltmain.sh
/missing
/m4/libtool.m4
/m4/lt*.m4
/py-compile
/stamp-h1
Loading
Loading