22set -eu
33. " $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) /common"
44set -- ${cli_build:- } " $@ "
5- mkdir -p " ${out_dir } "
6- br2_cli_file=" ${out_dir } /br2_cli"
5+ mkdir -p " ${common_out_dir } "
6+ br2_cli_file=" ${common_out_dir } /br2_cli"
77rm -f " $br2_cli_file "
88touch " $br2_cli_file "
9- kernel_config_fragment_cli_file=" ${out_dir } /kernel_config_fragment_cli"
9+ kernel_config_fragment_cli_file=" ${common_out_dir } /kernel_config_fragment_cli"
1010kernel_config_fragment_cli_file_tmp=" ${kernel_config_fragment_cli_file} _tmp"
1111rm -f " $kernel_config_fragment_cli_file_tmp "
1212touch " $kernel_config_fragment_cli_file_tmp "
1313configure=true
14- config_fragments=" ${root_dir } /br2/default"
14+ config_fragments=" ${common_root_dir } /br2/default"
1515extra_make_args=
1616j=" $( nproc) "
1717linux_reconfigure=false
1818linux_kernel_custom_config_file=
1919kernel_config_fragments=
2020post_script_args=
2121qemu_sdl=' --enable-sdl --with-sdlabi=2.0'
22- suffix=
2322v=0
2423while getopts ' a:B:b:C:c:fGgj:hIiK:kL:lM:p:Q:qSst::v' OPT; do
2524 case " $OPT " in
2625 a)
27- arch =" $OPTARG "
26+ common_arch =" $OPTARG "
2827 ;;
2928 B)
3029 echo " $OPTARG " >> " $br2_cli_file "
@@ -44,7 +43,7 @@ while getopts 'a:B:b:C:c:fGgj:hIiK:kL:lM:p:Q:qSst::v' OPT; do
4443 g)
4544 extra_make_args=" ${extra_make_args} gem5-reconfigure \\
4645"
47- gem5 =true
46+ common_gem5 =true
4847 ;;
4948 h)
5049 cat build-usage.adoc 1>&2
@@ -99,7 +98,7 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
9998 qemu_sdl=
10099 ;;
101100 s)
102- suffix =" $OPTARG "
101+ common_suffix =" $OPTARG "
103102 ;;
104103 t)
105104 common_gem5_build_type=" $OPTARG "
@@ -114,9 +113,9 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
114113done
115114shift $(( $OPTIND - 1 ))
116115extra_make_args=" ${extra_make_args} $@ "
117- set_common_vars -L " $common_linux_variant " -M " $common_gem5_variant " " $arch " " $gem5 " " $suffix "
118- config_file=" ${buildroot_out_dir } /.config"
119- case " $arch " in
116+ common_setup
117+ config_file=" ${common_buildroot_out_dir } /.config"
118+ case " $common_arch " in
120119 x86_64)
121120 defconfig=qemu_x86_64_defconfig
122121 ;;
@@ -130,7 +129,7 @@ case "$arch" in
130129 defconfig=qemu_mips64r6_malta_defconfig
131130 ;;
132131esac
133- config_fragments=" ${config_fragments} ${root_dir } /br2/qemu ${br2_cli_file} "
132+ config_fragments=" ${config_fragments} ${common_root_dir } /br2/qemu ${br2_cli_file} "
134133
135134time {
136135# Configure.
@@ -139,16 +138,16 @@ if "$configure"; then
139138 # Only copy if modified, otherwise the kernel always rebuilds.
140139 cp " ${kernel_config_fragment_cli_file_tmp} " " ${kernel_config_fragment_cli_file} "
141140 fi
142- cd " ${buildroot_dir } "
143- for p in $( find " ${root_dir } /buildroot_patches/" -maxdepth 1 -name ' *.patch' -print) ; do
141+ cd " ${common_buildroot_dir } "
142+ for p in $( find " ${common_root_dir } /buildroot_patches/" -maxdepth 1 -name ' *.patch' -print) ; do
144143 patch -N -r - -p 1 < " $p " || :
145144 done
146145 br2_external=' ../kernel_module:../gem5:../parsec-benchmark'
147- packages_dir=" ${root_dir } /packages"
146+ packages_dir=" ${common_root_dir } /packages"
148147 for package_dir in " ${packages_dir} " /* /; do
149148 br2_external=" ${br2_external} :../packages/$( basename " ${package_dir} " ) "
150149 done
151- make O=" $buildroot_out_dir " BR2_EXTERNAL=" $br2_external " " $defconfig "
150+ make O=" $common_buildroot_out_dir " BR2_EXTERNAL=" $br2_external " " $defconfig "
152151 # TODO Can't get rid of these for now.
153152 # http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
154153 for config_fragment in $config_fragments ; do
@@ -159,7 +158,7 @@ BR2_JLEVEL=${j}
159158BR2_DL_DIR=\" ${common_dir} /dl\"
160159BR2_ROOTFS_POST_SCRIPT_ARGS=\" ${post_script_args} \"
161160" >> " $config_file "
162- if " $gem5 " ; then
161+ if " $common_gem5 " ; then
163162 printf " BR2_PACKAGE_GEM5=y\n" >> " ${config_file} "
164163 fi
165164 kernel_config_fragment_dir=../kernel_config_fragment
@@ -182,11 +181,11 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
182181 # https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
183182 touch " ${kernel_config_fragment_dir} /min"
184183 fi
185- if [ " $arch " = ' mips64' ]; then
184+ if [ " $common_arch " = ' mips64' ]; then
186185 # Workaround for: https://bugs.busybox.net/show_bug.cgi?id=10276
187186 sed -Ei ' s/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' " $config_file "
188187 fi
189- make O=" $buildroot_out_dir " olddefconfig
188+ make O=" $common_buildroot_out_dir " olddefconfig
190189fi
191190 echo ' config time:'
192191}
@@ -214,13 +213,13 @@ symlink_buildroot_variant "$common_qemu_custom_dir" "$common_qemu_variant_dir"
214213# symlink_buildroot_variant "$common_qemu_guest_custom_dir" "$common_qemu_guest_variant_dir"
215214
216215# Manage gem5 variants.
217- if " $gem5 " ; then
216+ if " $common_gem5 " ; then
218217 if [ ! -e " ${common_gem5_src_dir} /.git" ]; then
219218 git -C " $common_gem5_default_src_dir " worktree add -b " wt/${common_gem5_variant} " " ${common_gem5_src_dir} "
220219 fi
221220fi
222221
223- cd " $buildroot_dir "
222+ cd " $common_buildroot_dir "
224223# HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times.
225224# It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936
226225#
@@ -233,7 +232,7 @@ cmd="time \\
233232env \\
234233-u LD_LIBRARY_PATH \\
235234make \\
236- O='${buildroot_out_dir } ' \\
235+ O='${common_buildroot_out_dir } ' \\
237236HOST_QEMU_OPTS='--enable-debug --enable-trace-backends=simple ${qemu_sdl} ' \\
238237GEM5_LKMC_GEM5_BUILD_TYPE=" $common_gem5_build_type " \\
239238GEM5_LKMC_OUTDIR=" $common_gem5_out_dir " \\
@@ -242,4 +241,4 @@ V='${v}' \\
242241${extra_make_args} \
243242all \\
244243"
245- " ${root_dir } /eeval" " $cmd " " ${out_arch_dir } /build.sh"
244+ " ${common_root_dir } /eeval" " $cmd " " ${common_out_arch_dir } /build.sh"
0 commit comments