|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# The folder "toolchains" should contain the toolchains and host tools |
| 4 | +# This script merges all files into a single installable file. |
| 5 | +# |
| 6 | +# SDK should follow a vM.m versioning scheme |
| 7 | +# |
| 8 | +# Major versions for big interface/usage changes |
| 9 | +# Minor versions for additions of interfaces, transparent changes |
| 10 | +# |
| 11 | +# Default installation directory should be /opt/zephyr-sdk/ |
| 12 | +# |
| 13 | + |
| 14 | + |
| 15 | +# Edit as needed: |
| 16 | +version_major=0 |
| 17 | +version_minor=10 |
| 18 | +subversion_minor=0 |
| 19 | +prerelease=beta3 |
| 20 | + |
| 21 | +if [ "$1" != "" ] ; then |
| 22 | + product_name=$1 |
| 23 | + else |
| 24 | + product_name=zephyr-sdk |
| 25 | +fi |
| 26 | + |
| 27 | +# Create ./setup.sh |
| 28 | + |
| 29 | +if [ "$subversion_minor" -ne "0" ]; then |
| 30 | + sdk_version=$version_major.$version_minor.$subversion_minor |
| 31 | +else |
| 32 | + sdk_version=$version_major.$version_minor |
| 33 | +fi |
| 34 | + |
| 35 | +if [ -n "$prerelease" ]; then |
| 36 | + sdk_version=${sdk_version}-${prerelease} |
| 37 | +fi |
| 38 | + |
| 39 | +setup=toolchains/setup.sh |
| 40 | +default_dir=/opt/${product_name}/ |
| 41 | +toolchain_name=${product_name}-${sdk_version}-setup.run |
| 42 | +version_dir=info-zephyr-sdk-${sdk_version} |
| 43 | + |
| 44 | +# Identify files present in toolchains folder |
| 45 | + |
| 46 | +parse_toolchain_name() |
| 47 | +{ |
| 48 | + local varname=$1 |
| 49 | + local arch=$2 |
| 50 | + local num |
| 51 | + local filename |
| 52 | + |
| 53 | + num=$(ls toolchains | grep $arch | wc -l) |
| 54 | + if [ "$num" -gt "1" ]; then |
| 55 | + echo "Error: Multiple toolchains for \"$arch\" " |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | + |
| 59 | + if [ "$num" -eq "0" ]; then |
| 60 | + echo "Warning: Missing toolchain for \"$arch\" " |
| 61 | + fi |
| 62 | + |
| 63 | + filename=$(ls toolchains | grep $arch) |
| 64 | + eval "$varname=\$filename" |
| 65 | +} |
| 66 | + |
| 67 | +parse_toolchain_name file_gcc_arm arm |
| 68 | +parse_toolchain_name file_gcc_arc arc |
| 69 | +parse_toolchain_name file_gcc_x86 i586 |
| 70 | +parse_toolchain_name file_gcc_iamcu iamcu |
| 71 | +parse_toolchain_name file_gcc_mips mips32r2 |
| 72 | +parse_toolchain_name file_gcc_nios2 nios2 |
| 73 | +parse_toolchain_name file_gcc_xtensa xtensa |
| 74 | +parse_toolchain_name file_gcc_riscv32 riscv32 |
| 75 | +parse_toolchain_name file_hosttools hosttools |
| 76 | + |
| 77 | +# Host tools are non-optional |
| 78 | +if [ -z "$file_hosttools" ]; then |
| 79 | + echo "Error: Missing host tools!" |
| 80 | + exit 1 |
| 81 | +fi |
| 82 | + |
| 83 | +echo '#!/bin/bash' > $setup |
| 84 | +echo "DEFAULT_INSTALL_DIR=$default_dir" >> $setup |
| 85 | +echo "TOOLCHAIN_NAME=$toolchain_name" >> $setup |
| 86 | +echo "VERSION_DIR=$version_dir" >> $setup |
| 87 | +echo "SDK_VERSION=${sdk_version}" >> $setup |
| 88 | + |
| 89 | +cat template_dir >>$setup |
| 90 | + |
| 91 | +if [ -n "$file_gcc_x86" ]; then |
| 92 | + echo "tar -C \$target_sdk_dir ./$file_gcc_x86 > /dev/null &" >> $setup |
| 93 | + echo "spinner \$! \"Installing x86 tools...\"" >> $setup |
| 94 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 95 | + echo "echo \"\"" >>$setup |
| 96 | +fi |
| 97 | + |
| 98 | +if [ -n "$file_gcc_arm" ]; then |
| 99 | + echo "tar -C \$target_sdk_dir ./$file_gcc_arm > /dev/null &" >> $setup |
| 100 | + echo "spinner \$! \"Installing arm tools...\"" >> $setup |
| 101 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 102 | + echo "echo \"\"" >>$setup |
| 103 | +fi |
| 104 | + |
| 105 | +if [ -n "$file_gcc_arc" ]; then |
| 106 | + echo "tar -C \$target_sdk_dir ./$file_gcc_arc > /dev/null &" >> $setup |
| 107 | + echo "spinner \$! \"Installing arc tools...\"" >> $setup |
| 108 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 109 | + echo "echo \"\"" >>$setup |
| 110 | +fi |
| 111 | + |
| 112 | +if [ -n "$file_gcc_iamcu" ]; then |
| 113 | + echo "tar -C \$target_sdk_dir ./$file_gcc_iamcu > /dev/null &" >> $setup |
| 114 | + echo "spinner \$! \"Installing iamcu tools...\"" >> $setup |
| 115 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 116 | + echo "echo \"\"" >>$setup |
| 117 | +fi |
| 118 | + |
| 119 | +if [ -n "$file_gcc_mips" ]; then |
| 120 | + echo "tar -C \$target_sdk_dir ./$file_gcc_mips > /dev/null &" >> $setup |
| 121 | + echo "spinner \$! \"Installing mips tools...\"" >> $setup |
| 122 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 123 | + echo "echo \"\"" >>$setup |
| 124 | +fi |
| 125 | + |
| 126 | +if [ -n "$file_gcc_nios2" ]; then |
| 127 | + echo "tar -C \$target_sdk_dir ./$file_gcc_nios2 > /dev/null &" >> $setup |
| 128 | + echo "spinner \$! \"Installing nios2 tools...\"" >> $setup |
| 129 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 130 | + echo "echo \"\"" >>$setup |
| 131 | +fi |
| 132 | + |
| 133 | +if [ -n "$file_gcc_xtensa" ]; then |
| 134 | + echo "tar -C \$target_sdk_dir -xf ./$file_gcc_xtensa > /dev/null &" >> $setup |
| 135 | + echo "spinner \$! \"Installing xtensa tools...\"" >> $setup |
| 136 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 137 | + echo "echo \"\"" >>$setup |
| 138 | +fi |
| 139 | + |
| 140 | +if [ -n "$file_gcc_riscv32" ]; then |
| 141 | + echo "tar -C \$target_sdk_dir -xf ./$file_gcc_riscv32 > /dev/null &" >> $setup |
| 142 | + echo "spinner \$! \"Installing riscv32 tools...\"" >> $setup |
| 143 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 144 | + echo "echo \"\"" >>$setup |
| 145 | +fi |
| 146 | + |
| 147 | +if [ -n "$file_hosttools" ]; then |
| 148 | + echo "./$file_hosttools -y -d \$target_sdk_dir > /dev/null &" >> $setup |
| 149 | + echo "spinner \$! \"Installing additional host tools...\"" >> $setup |
| 150 | + echo "[ \$? -ne 0 ] && echo \"Error(s) encountered during installation.\" && exit 1" >>$setup |
| 151 | + echo "echo \"\"" >>$setup |
| 152 | +fi |
| 153 | + |
| 154 | + |
| 155 | +echo "" >>$setup |
| 156 | +echo "do_cleanup" >>$setup |
| 157 | +echo "" >>$setup |
| 158 | + |
| 159 | +echo "echo \"Success installing SDK. SDK is ready to be used.\"" >>$setup |
| 160 | +chmod 777 $setup |
| 161 | + |
| 162 | +makeself toolchains/ $toolchain_name "SDK for Zephyr" ./setup.sh |
0 commit comments