diff --git a/toolchain/build.sh b/toolchain/build.sh index 5e4054f..8b3cc43 100644 --- a/toolchain/build.sh +++ b/toolchain/build.sh @@ -1,13 +1,7 @@ #!/bin/bash -e # Clone source code -if [ "$model" = "Padavanonly_MT798X_v24.10" ]; then - git clone -b 2410 --single-branch --filter=blob:none https://github.com/padavanonly/immortalwrt-mt798x-24.10 openwrt -elif [ "$model" = "Hanwckf_MT798X_v21.02" ]; then - git clone --depth=1 https://github.com/hanwckf/immortalwrt-mt798x openwrt -elif [ "$model" = "OpenWrt_Rockchip_v24.10" ] || [ "$model" = "OpenWrt_X86_64_v24.10" ]; then - git clone -b openwrt-24.10 --single-branch --filter=blob:none https://github.com/immortalwrt/immortalwrt openwrt -fi +git clone -b openwrt-24.10 --single-branch --filter=blob:none https://github.com/openwrt/openwrt openwrt # Enter source code cd openwrt @@ -16,16 +10,32 @@ cd openwrt ./scripts/feeds update -a ./scripts/feeds install -a +# gcc15 patches +curl -s https://raw.githubusercontent.com/oppen321/ZeroWrt-Action/refs/heads/master/patch/GCC/202-toolchain-gcc-add-support-for-GCC-15.patch | patch -p1 + # Load devices Config -if [ "$model" = "Padavanonly_MT798X_v24.10" ]; then - curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/padavanonly_mt798x.config > .config -elif [ "$model" = "Hanwckf_MT798X_v21.02" ]; then - curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/hanwckf_mt798x.config > .config -elif [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then +if [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/immortalwrt_rockchip.config > .config elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/immortalwrt_x86_64.config > .config -fi +fi + +# gcc14 & 15 +if [ "$USE_GCC13" = y ]; then + export USE_GCC13=y gcc_version=13 +elif [ "$USE_GCC14" = y ]; then + export USE_GCC14=y gcc_version=14 +elif [ "$USE_GCC15" = y ]; then + export USE_GCC15=y gcc_version=15 +else + export USE_GCC14=y gcc_version=14 +fi + +# gcc config +echo -e "\n# gcc ${gcc_version}" >> .config +echo -e "CONFIG_DEVEL=y" >> .config +echo -e "CONFIG_TOOLCHAINOPTS=y" >> .config +echo -e "CONFIG_GCC_USE_VERSION_${gcc_version}=y\n" >> .config # Compile make defconfig @@ -67,13 +77,23 @@ fi mkdir toolchain-cache # Compression toolchain -if [ "$model" = "Padavanonly_MT798X_v24.10" ]; then - tar -I zstd -cvf toolchain-cache/toolchain_musl_padavanonly_mediatek_gcc-13.tar.zst build_dir dl tmp staging_dir -elif [ "$model" = "Hanwckf_MT798X_v21.02" ]; then - tar -I zstd -cvf toolchain-cache/toolchain_musl_hanwckf_mediatek_gcc-8.tar.zst build_dir dl tmp staging_dir -elif [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then - tar -I zstd -cvf toolchain-cache/toolchain_musl_immortalwrt_rockchip_gcc-13.tar.zst build_dir dl tmp staging_dir -elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then - tar -I zstd -cvf toolchain-cache/toolchain_musl_immortalwrt_X86_64_gcc-13.tar.zst build_dir dl tmp staging_dir -fi +case "$model" in + "OpenWrt_Rockchip_v24.10" | "OpenWrt_X86_64_v24.10") + if [ -z "$gcc_version" ]; then + echo "Error: GCC version not set!" + exit 1 + fi + if [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then + output_file="toolchain_musl_openwrt_rockchip_gcc-${gcc_version}.tar.zst" + elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then + output_file="toolchain_musl_openwrt_X86_64_gcc-${gcc_version}.tar.zst" + fi + + tar -I zstd -cvf "toolchain-cache/${output_file}" build_dir dl tmp staging_dir + ;; + *) + echo "Error: Unknown model '$model'!" + exit 1 + ;; +esac