feat(clusterApp): cross-compile clusterApp ok

This commit is contained in:
2026-04-18 19:00:17 +08:00
parent 0108dbb67f
commit 553d242e7d
73 changed files with 18616 additions and 36 deletions

View File

@@ -6,12 +6,17 @@ CROSS_PREFIX="arm-none-linux-gnueabihf"
readonly PKG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rm -rf ./install/ ./zlib-1.2.11/ ./libpng-1.6.34/ ./jpeg-9c/ ./freetype-2.13.2/ ./glew-2.1.0/ ./cJSON-v1.7.18/ ./expat-2.5.0/ ./libffi-3.4.6/ ./libdrm-2.4.120/ ./mesa-24.1.7/
tar -zxvf cJSON-v1.7.18.tar.gz
tar -zxvf freetype-2.13.2.tar.gz
tar -zxvf glew-2.1.0.tgz
tar -zxvf jpegsrc.v9c.tar.gz
tar -zxvf libpng-1.6.34.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
tar -xzf expat-2.5.0.tar.gz
tar -xvf libdrm-2.4.120.tar.xz
tar -xzf libffi-3.4.6.tar.gz
tar -xvf mesa-24.1.7.tar.xz
mkdir -p install
@@ -25,13 +30,12 @@ export CFLAGS="-I${PKG_DIR}/install/include"
export CPPFLAGS="-I${PKG_DIR}/install/include"
export LDFLAGS="-L${PKG_DIR}/install/lib"
# 1. zlib
cd zlib-1.2.11
./configure \
--prefix=${PKG_DIR}/install \
--host=${CROSS_PREFIX} \
--enable-shared \
--enable-static
--prefix=${PKG_DIR}/install/ \
--enable-shared
make
make install
cd ..
@@ -39,7 +43,7 @@ cd ..
# 2. libpng
cd libpng-1.6.34
./configure \
--prefix=${PKG_DIR}/install \
--prefix=${PKG_DIR}/install/ \
--host=${CROSS_PREFIX} \
--enable-shared \
--enable-static
@@ -50,7 +54,7 @@ cd ..
# 3. JPEG
cd jpeg-9c
./configure \
--prefix=${PKG_DIR}/install \
--prefix=${PKG_DIR}/install/ \
--host=${CROSS_PREFIX} \
--enable-shared \
--enable-static
@@ -61,8 +65,9 @@ cd ..
#4.Freetype
cd freetype-2.13.2
./configure \
--prefix=${PKG_DIR}/install \
--prefix=${PKG_DIR}/install/ \
--host=${CROSS_PREFIX} \
--with-zlib=${PKG_DIR}/install/include \
--enable-shared \
--enable-static \
--without-brotli
@@ -72,16 +77,71 @@ cd ..
# 5. GLEW(DRM)
cd glew-2.1.0
make
make install GLEW_DEST=${PKG_DIR}/install
make GLEW_EGL=1
make install GLEW_DEST=${PKG_DIR}/install/
cd ..
#6. CJson
cd cJSON-v1.7.18
mkdir -P build
mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${PKG_DIR}/install -DBUILD_SHARED_LIBS=OFF #static complie
cmake .. -DCMAKE_INSTALL_PREFIX=${PKG_DIR}/install/ -DBUILD_SHARED_LIBS=OFF #static complie
make
make install
cd ../../
#expat
cd expat-2.5.0
./configure \
--host=${CROSS_PREFIX} \
--prefix=${PKG_DIR}/install/ \
--enable-shared \
--enable-static \
--without-docbook
make
make install
cd ..
#libffi
cd libffi-3.4.6
./configure \
--host=${CROSS_PREFIX} \
--prefix=${PKG_DIR}/install/ \
--enable-shared \
--enable-static
make
make install
cd ..
#drm
cd libdrm-2.4.120
meson setup build_dir/ \
--prefix=${PKG_DIR}/install \
-Dc_args="-I${PKG_DIR}/install/include/" \
-Dc_link_args="-L${PKG_DIR}/install/lib" \
--cross-file ../cross_file.txt
ninja -C build_dir/ install
cd ..
#. mesa (GLESv2,EGL, gbm) ## need :zlib,expat,libdrm,libffi,ibelf
cd mesa-24.1.7
meson setup build_dir/ \
--prefix=${PKG_DIR}/install \
-D egl=enabled \
-D gles1=disabled \
-D gles2=enabled \
-D gbm=enabled \
-D glx=disabled \
-D platforms= \
-D gallium-drivers=panfrost \
-D vulkan-drivers= \
-D llvm=disabled \
-D xlib-lease=disabled \
-D gbm-backends-path= \
-Dc_args="-I${PKG_DIR}/install/include/" \
-Dc_link_args="-L${PKG_DIR}/install/lib" \
--cross-file ../cross_file.txt
ninja -C build_dir/ install
cd ..

22
packages/cross_file.txt Normal file
View File

@@ -0,0 +1,22 @@
# cross_file_armhf.txt
[binaries]
c = '/opt/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc' # 你的 C 交叉编译器
cpp = '/opt/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++' # 你的 C++ 交叉编译器
ar = '/opt/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-ar' # 归档工具
strip = '/opt/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-strip' # strip 工具
pkg-config = 'pkg-config' # pkg-config通常使用主机的即可可能需要调整 PKG_CONFIG_PATH
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7' # 或 'cortex-a7' 等更具体的型号
endian = 'little'
[built-in options] # 将 c_args / c_link_args 移到这里
c_args = ['-march=armv7-a']
c_link_args = []
[properties]
needs_exe_wrapper = true # 因为无法在主机上运行目标二进制文件
sys_root = '/home/huaxu/develop/Cluster/packages/install'
pkg_config_libdir = '//home/huaxu/develop/Cluster/packages/install/lib/pkgconfig'