Skip to content

Commit 7ada6f3

Browse files
committed
Ports build process to dockcross env
1 parent da4990b commit 7ada6f3

File tree

8 files changed

+766
-0
lines changed

8 files changed

+766
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/openssl-*/
2+
/otp_*/
3+
/sysroot/
4+
*.tar.gz

build-erlang-bootstrap.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Erlang bootstrap build script
5+
readonly OTP_VERSION="26.2.1"
6+
readonly BUILD_CROSS_TRIPLE="${CROSS_TRIPLE}"
7+
#readonly HOST_CROSS_TRIPLE="armv7l-linux-musleabihf"
8+
9+
download_erlang() {
10+
local url="https://github.com/erlang/otp/releases/download/OTP-$OTP_VERSION/otp_src_$OTP_VERSION.tar.gz"
11+
local file="otp_src_$OTP_VERSION.tar.gz"
12+
13+
if [ ! -f "$file" ]; then
14+
echo "Downloading Erlang/OTP..."
15+
wget "$url" -O "$file"
16+
fi
17+
18+
if [ ! -d "otp_src_$OTP_VERSION" ]; then
19+
echo "Extracting Erlang/OTP..."
20+
tar xzf "$file"
21+
fi
22+
}
23+
24+
build_erlang_bootstrap() {
25+
local erlang_dir="otp_src_$OTP_VERSION"
26+
export ERL_TOP="$(realpath ${erlang_dir})"
27+
pushd "$erlang_dir"
28+
29+
./configure \
30+
--enable-bootstrap-only \
31+
--build "${BUILD_CROSS_TRIPLE}"
32+
33+
make -j$(nproc)
34+
35+
popd
36+
}
37+
38+
echo "Building Erlang/OTP bootstrap system $OTP_VERSION (${CROSS_TRIPLE})"
39+
download_erlang
40+
build_erlang_bootstrap
41+
echo "Erlang/OTP bootstrap build completed."

build-erlang.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Erlang build script
5+
readonly OTP_VERSION="26.2.1"
6+
readonly BUILD_CROSS_TRIPLE="x86_64-linux-gnu"
7+
readonly HOST_CROSS_TRIPLE="${CROSS_TRIPLE}"
8+
9+
download_erlang() {
10+
local url="https://github.com/erlang/otp/releases/download/OTP-$OTP_VERSION/otp_src_$OTP_VERSION.tar.gz"
11+
local file="otp_src_$OTP_VERSION.tar.gz"
12+
13+
if [ ! -f "$file" ]; then
14+
echo "Downloading Erlang/OTP..."
15+
wget "$url" -O "$file"
16+
fi
17+
18+
if [ ! -d "otp_src_$OTP_VERSION" ]; then
19+
echo "Extracting Erlang/OTP..."
20+
tar xzf "$file"
21+
fi
22+
}
23+
24+
build_erlang() {
25+
local erlang_dir="otp_src_$OTP_VERSION"
26+
pushd "$erlang_dir"
27+
28+
./configure \
29+
--without-javac \
30+
--without-jinterface \
31+
--without-wx \
32+
--without-termcap \
33+
--without-megaco \
34+
--with-ssl=$(pwd)/../sysroot \
35+
--disable-dynamic-ssl-lib \
36+
--host "${HOST_CROSS_TRIPLE}" \
37+
--build="${BUILD_CROSS_TRIPLE}"
38+
make -j$(nproc)
39+
40+
local release_root="$(pwd)/release/otp_armv7l_linux_${OTP_VERSION}"
41+
make release -j$(nproc) RELEASE_ROOT="$release_root"
42+
43+
popd
44+
}
45+
46+
package_erlang(){
47+
tar czf otp_${OTP_VERSION}_linux_any_armv7l_ssl_${OPENSSL_VERSION}.tar.gz ./otp*
48+
}
49+
50+
echo "Building Erlang/OTP $OTP_VERSION"
51+
download_erlang
52+
build_erlang
53+
echo "Erlang/OTP build completed."

build-openssl.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# OpenSSL build script
5+
readonly OPENSSL_VERSION="3.2.1"
6+
7+
download_openssl() {
8+
local url="https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz"
9+
local file="openssl-$OPENSSL_VERSION.tar.gz"
10+
11+
if [ ! -f "$file" ]; then
12+
echo "Downloading OpenSSL..."
13+
wget "$url" -O "$file"
14+
fi
15+
16+
if [ ! -d "openssl-$OPENSSL_VERSION" ]; then
17+
echo "Extracting OpenSSL..."
18+
tar xzf "$file"
19+
fi
20+
}
21+
22+
build_openssl() {
23+
local openssl_dir="openssl-$OPENSSL_VERSION"
24+
local sysroot_dir="$(pwd)/sysroot"
25+
26+
mkdir -p "$sysroot_dir"
27+
pushd "$openssl_dir"
28+
29+
export LDFLAGS="-L${CROSS_ROOT}/${CROSS_TRIPLE}/lib -latomic"
30+
export RANLIB="/usr/bin/ranlib"
31+
32+
./config linux-generic32 no-asm no-tests no-shared --prefix="$sysroot_dir" --cross-compile-prefix=/
33+
make -j$(nproc) && make install_sw
34+
35+
popd
36+
ln -sf "$sysroot_dir/lib64" "$sysroot_dir/lib"
37+
}
38+
39+
echo "Building OpenSSL $OPENSSL_VERSION"
40+
download_openssl
41+
build_openssl
42+
echo "OpenSSL build completed."

build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
readonly OPENSSL_VERSION="3.2.1"
5+
readonly OTP_VERSION="26.2.1"
6+
7+
./dockcross-linux-armv7l-musl ./build-openssl.sh
8+
./dockcross-linux-x64 ./build-erlang-bootstrap.sh
9+
./dockcross-linux-armv7l-musl ./build-erlang.sh
10+
11+
./package.sh

0 commit comments

Comments
 (0)