Update OpenWRT build

This commit is contained in:
klzgrad 2019-12-01 03:02:59 +08:00
parent 07ca5ac92d
commit 04d06b1e0e
6 changed files with 95 additions and 37 deletions

View File

@ -20,14 +20,10 @@ matrix:
os: linux
dist: bionic
env: EXTRA_FLAGS='target_cpu="arm"'
- name: "linux-mipsel"
- name: "openwrt-mipsel_24kc"
os: linux
dist: bionic
env: EXTRA_FLAGS='target_cpu="mipsel" mips_arch_variant="r2"'
- name: "openwrt-mips"
os: linux
dist: bionic
env: EXTRA_FLAGS='target_cpu="mips" mips_arch_variant="r2" mips_float_abi="soft" use_allocator="none" use_allocator_shim=false is_openwrt=true target_sysroot="//out/sysroot-build/openwrt/mips" ldso_path="/lib/ld-musl-mips-sf.so.1"'
env: EXTRA_FLAGS='target_cpu="mipsel" mips_arch_variant="r2" mips_float_abi="soft" mips_tune="24kc" use_allocator="none" use_allocator_shim=false is_openwrt=true ldso_path="/lib/ld-musl-mipsel-sf.so.1"' OPENWRT_ARCH=mipsel_24kc OPENWRT_RELEASE=19.07.0-rc1 OPENWRT_GCC=gcc-7.4.0
- name: "osx"
os: osx
osx_image: xcode10.2
@ -42,7 +38,10 @@ addons:
packages:
- ninja
- ccache
cache: ccache
cache:
directories:
- $HOME/.ccache
- src/out/sysroot-build/openwrt
script:
- ./tools/import-upstream.sh
- ( cd src; ./get-clang.sh )

View File

@ -63,20 +63,11 @@ if [ "$(uname)" = Linux ]; then
ozone_auto_platforms=false
ozone_platform="headless"
ozone_platform_headless=true'
if [ ! "$target_sysroot" ]; then
eval "$EXTRA_FLAGS"
sysroot_type=''
case "$target_cpu" in
x64) sysroot_type=amd64;;
x86) sysroot_type=i386;;
arm64) sysroot_type=arm64;;
arm) sysroot_type=arm;;
mipsel) sysroot_type=mips;;
esac
if [ "$sysroot_type" ]; then
flags="$flags"'
target_sysroot="//out/sysroot-build/sid/sid_'"$sysroot_type"'_staging"'
fi
. ./get-sysroot.sh
sysroot=$(get_sysroot)
if [ "$sysroot" ]; then
flags="$flags
target_sysroot=\"//$sysroot\""
fi
fi

View File

@ -7,21 +7,22 @@ case "$ARCH" in
MSYS*) ARCH=Windows;;
esac
eval "$EXTRA_FLAGS"
build_sysroot() {
./build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh "BuildSysroot$1"
}
if [ "$ARCH" = Linux ]; then
if [ "$OPENWRT_ARCH" ]; then
./get-openwrt.sh
else
eval "$EXTRA_FLAGS"
case "$target_cpu" in
x64) build_sysroot Amd64;;
x86) build_sysroot I386;;
arm64) build_sysroot ARM64;;
arm) build_sysroot ARM;;
mips64el) build_sysroot Mips64el;;
mipsel) build_sysroot Mips;;
esac
fi
fi
# Clang

48
src/get-openwrt.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
set -ex
arch=$OPENWRT_ARCH
release=$OPENWRT_RELEASE
gcc_ver=$OPENWRT_GCC
case "$arch" in
mipsel_24kc) target=ramips subtarget=rt305x;;
*) exit 1;;
esac
sysroot=$PWD/out/sysroot-build/openwrt/$release/$arch
if [ -d $sysroot/lib ]; then
exit 0
fi
mkdir -p $sysroot
SDK_PATH=openwrt-sdk-$release-$target-${subtarget}_${gcc_ver}_musl.Linux-x86_64
SDK_URL=https://downloads.openwrt.org/releases/$release/targets/$target/$subtarget/$SDK_PATH.tar.xz
rm -rf $SDK_PATH
curl $SDK_URL | tar xJf -
cd $SDK_PATH
./scripts/feeds update base packages
./scripts/feeds install libnss
cp ../$target-$subtarget.config .config
yes | make oldconfig
make
full_root=staging_dir/toolchain-${arch}_${gcc_ver}_musl
cp -r staging_dir/target-${arch}_musl/usr $full_root
echo '
./include
./lib/*.o
./lib/gcc/*/libgcc.a
./lib/libatomic.so*
./lib/libc.so
./lib/libdl.a
./lib/ld-*
./lib/libgcc_s.*
./lib/libm.a
./lib/libpthread.a
./lib/libresolv.a
./lib/librt.a
./usr
' >include.txt
tar cf - -C $full_root . | tar xf - -C $sysroot --wildcards --wildcards-match-slash -T include.txt
rm include.txt

18
src/get-sysroot.sh Normal file
View File

@ -0,0 +1,18 @@
get_sysroot() {
eval "$EXTRA_FLAGS"
if [ "$OPENWRT_ARCH" -a "$OPENWRT_RELEASE" ]; then
echo "out/sysroot-build/openwrt/$OPENWRT_RELEASE/$OPENWRT_ARCH"
elif [ ! "$target_sysroot" ]; then
local sysroot_type
case "$target_cpu" in
x64) sysroot_type=amd64;;
x86) sysroot_type=i386;;
arm64) sysroot_type=arm64;;
arm) sysroot_type=arm;;
mipsel) sysroot_type=mips;;
esac
if [ "$sysroot_type" ]; then
echo "out/sysroot-build/sid/sid_${sysroot_type}_staging"
fi
fi
}

View File

@ -2,14 +2,15 @@
[ "$1" ] || exit 1
naive="$1"
eval "$EXTRA_FLAGS"
if [ "$(uname)" = Linux ]; then
. src/get-sysroot.sh
sysroot=$(get_sysroot)
eval "$EXTRA_FLAGS"
case "$target_cpu" in
arm64) naive="qemu-aarch64 -L src/build/linux/debian_sid_arm64-sysroot $naive";;
arm) naive="qemu-arm -L src/build/linux/debian_sid_arm-sysroot $naive";;
x86) naive="qemu-i386 -L src/build/linux/debian_sid_i386-sysroot $naive";;
mipsel) naive="qemu-mipsel -L src/build/linux/debian_sid_mips-sysroot $naive";;
mips64el) naive="qemu-mips64el -L src/build/linux/debian_sid_mips64el-sysroot $naive";;
arm64) naive="qemu-aarch64 -L src/$sysroot $naive";;
arm) naive="qemu-arm -L src/$sysroot $naive";;
x86) naive="qemu-i386 -L src/$sysroot $naive";;
mipsel) naive="qemu-mipsel -L src/$sysroot $naive";;
esac
fi