@@ -53,6 +53,10 @@ function do_buildroot
5353 ASSERT make $PARALLEL
5454 popd
5555
56+ if [[ $BUILD_EXTRA_PACKAGES -eq 1 ]]; then
57+ do_extra_packages
58+ fi
59+
5660 if [[ $EXTERNAL_ROOT -eq 1 ]]; then
5761 echo " Copying rootfs.cpio to rootfs_full.cpio (external root mode)"
5862 cp -f buildroot/output/images/rootfs.cpio ./rootfs_full.cpio
@@ -77,21 +81,24 @@ function do_linux
7781 export PATH=" $PWD /buildroot/output/host/bin:$PATH "
7882 export CROSS_COMPILE=riscv32-buildroot-linux-gnu-
7983 export ARCH=riscv
84+ export INSTALL_MOD_PATH=" out"
8085 pushd linux
8186 ASSERT make olddefconfig
8287 ASSERT make $PARALLEL
88+ ASSERT make modules_install
8389 cp -f arch/riscv/boot/Image ../Image
8490 popd
8591}
8692
8793function show_help {
8894 cat << EOF
89- Usage: $0 [--buildroot] [--linux] [--all] [--external-root] [--clean-build] [--help]
95+ Usage: $0 [--buildroot] [--linux] [--extra-packages] [-- all] [--external-root] [--clean-build] [--help]
9096
9197Options:
9298 --buildroot Build Buildroot rootfs
99+ --extra-packages Build extra packages along with Buildroot
93100 --linux Build Linux kernel
94- --all Build both Buildroot and Linux
101+ --all Build both Buildroot, Linux kernel
95102 --external-root Use external rootfs instead of initramfs
96103 --clean-build Remove entire buildroot/ and/or linux/ directories before build
97104 --help Show this message
101108
102109BUILD_BUILDROOT=0
103110BUILD_LINUX=0
111+ BUILD_EXTRA_PACKAGES=0
104112EXTERNAL_ROOT=0
105113CLEAN_BUILD=0
106114
@@ -109,6 +117,9 @@ while [[ $# -gt 0 ]]; do
109117 --buildroot)
110118 BUILD_BUILDROOT=1
111119 ;;
120+ --extra-packages)
121+ BUILD_EXTRA_PACKAGES=1
122+ ;;
112123 --linux)
113124 BUILD_LINUX=1
114125 ;;
@@ -133,11 +144,85 @@ while [[ $# -gt 0 ]]; do
133144 shift
134145done
135146
147+ function do_libepoxy
148+ {
149+ ASSERT git clone https://github.com/anholt/libepoxy.git
150+ pushd libepoxy
151+ cp ../configs/riscv-cross-file .
152+ ASSERT meson --cross-file riscv-cross-file build/riscv
153+ ASSERT meson compile -C build/riscv
154+ DESTDIR=../../../libepoxy_out meson install -C build/riscv
155+ DESTDIR=../../../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot meson install -C build/riscv
156+ popd
157+ }
158+
159+ function do_virglrenderer
160+ {
161+ ASSERT git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git
162+ pushd virglrenderer
163+ cp ../configs/riscv-cross-file .
164+ ASSERT meson --cross-file riscv-cross-file build/riscv
165+ ASSERT meson compile -C build/riscv
166+ DESTDIR=../../../virglrenderer_out meson install -C build/riscv
167+ popd
168+ }
169+
170+ function do_directfb
171+ {
172+ export PATH=$PATH :$PWD /buildroot/output/host/bin
173+ export BUILDROOT_OUT=$PWD /buildroot/output/
174+ mkdir -p directfb
175+
176+ # Build DirectFB2
177+ ASSERT git clone https://github.com/directfb2/DirectFB2.git
178+ pushd DirectFB2
179+ cp ../configs/riscv-cross-file .
180+ ASSERT meson -Ddrmkms=true --cross-file riscv-cross-file build/riscv
181+ ASSERT meson compile -C build/riscv
182+ DESTDIR=$BUILDROOT_OUT /host/riscv32-buildroot-linux-gnu/sysroot meson install -C build/riscv
183+ DESTDIR=../../../directfb meson install -C build/riscv
184+ popd
185+
186+ # Build DirectFB2 examples
187+ ASSERT git clone https://github.com/directfb2/DirectFB-examples.git
188+ pushd DirectFB-examples/
189+ cp ../configs/riscv-cross-file .
190+ ASSERT meson --cross-file riscv-cross-file build/riscv
191+ ASSERT meson compile -C build/riscv
192+ DESTDIR=../../../directfb meson install -C build/riscv
193+ popd
194+ }
195+
196+ function do_extra_packages
197+ {
198+ export PATH=" $PWD /buildroot/output/host/bin:$PATH "
199+ export CROSS_COMPILE=riscv32-buildroot-linux-gnu-
200+
201+ rm -rf extra_packages
202+ mkdir -p extra_packages
203+ mkdir -p extra_packages/root
204+
205+ do_libepoxy && OK
206+ do_virglrenderer && OK
207+ do_directfb && OK
208+
209+ cp -r libepoxy_out/* extra_packages
210+ cp -r virglrenderer_out/* extra_packages
211+ cp -r directfb/* extra_packages
212+
213+ cp target/run.sh extra_packages/root/
214+ }
215+
136216if [[ $BUILD_BUILDROOT -eq 0 && $BUILD_LINUX -eq 0 ]]; then
137217 echo " Error: No build target specified. Use --buildroot, --linux, or --all."
138218 show_help
139219fi
140220
221+ if [[ $BUILD_EXTRA_PACKAGES -eq 1 && $BUILD_BUILDROOT -eq 0 ]]; then
222+ echo " Error: --extra-packages requires --buildroot to be specified."
223+ show_help
224+ fi
225+
141226if [[ $CLEAN_BUILD -eq 1 && $BUILD_BUILDROOT -eq 1 && -d buildroot ]]; then
142227 echo " Removing buildroot/ for clean build..."
143228 rm -rf buildroot
0 commit comments