diff --git a/.travis.yml b/.travis.yml index 3cbbe3824d..6406c78c87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 ) diff --git a/src/build.sh b/src/build.sh index a4ebaac262..8840019179 100755 --- a/src/build.sh +++ b/src/build.sh @@ -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 diff --git a/src/get-clang.sh b/src/get-clang.sh index d5090f98a7..b6243bfd5d 100755 --- a/src/get-clang.sh +++ b/src/get-clang.sh @@ -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 - 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 + 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;; + esac + fi fi # Clang diff --git a/src/get-openwrt.sh b/src/get-openwrt.sh new file mode 100755 index 0000000000..41a81d814b --- /dev/null +++ b/src/get-openwrt.sh @@ -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 diff --git a/src/get-sysroot.sh b/src/get-sysroot.sh new file mode 100644 index 0000000000..fa3b3d1b5e --- /dev/null +++ b/src/get-sysroot.sh @@ -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 +} diff --git a/tests/basic.sh b/tests/basic.sh index 26105f6cbe..a7306c6f0a 100755 --- a/tests/basic.sh +++ b/tests/basic.sh @@ -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