Skip to content

Commit 2edda78

Browse files
committed
Build virglrenderer and DirectFB2
1 parent 3a174df commit 2edda78

File tree

4 files changed

+111
-2
lines changed

4 files changed

+111
-2
lines changed

configs/riscv-cross-file

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[binaries]
2+
c = 'riscv32-buildroot-linux-gnu-gcc'
3+
strip = 'riscv32-buildroot-linux-gnu-strip'
4+
pkgconfig = 'pkg-config'
5+
python = '/usr/bin/python3'
6+
7+
[properties]
8+
pkg_config_libdir = ['@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot/usr/local/lib/pkgconfig',
9+
'@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot/usr/share/pkgconfig/',
10+
'@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot/usr/lib/pkgconfig/'
11+
]
12+
sys_root = '@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot'
13+
14+
[host_machine]
15+
system = 'linux'
16+
cpu_family = 'riscv'
17+
cpu = 'riscv32-ima'
18+
endian = 'little'

scripts/build-image.sh

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8793
function 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
9197
Options:
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
@@ -101,6 +108,7 @@ EOF
101108

102109
BUILD_BUILDROOT=0
103110
BUILD_LINUX=0
111+
BUILD_EXTRA_PACKAGES=0
104112
EXTERNAL_ROOT=0
105113
CLEAN_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
134145
done
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+
136216
if [[ $BUILD_BUILDROOT -eq 0 && $BUILD_LINUX -eq 0 ]]; then
137217
echo "Error: No build target specified. Use --buildroot, --linux, or --all."
138218
show_help
139219
fi
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+
141226
if [[ $CLEAN_BUILD -eq 1 && $BUILD_BUILDROOT -eq 1 && -d buildroot ]]; then
142227
echo "Removing buildroot/ for clean build..."
143228
rm -rf buildroot

scripts/rootfs_ext4.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ echo "[*] Remove old rootfs directory..."
1111
rm -rf $DIR
1212
mkdir -p $DIR
1313

14+
cp -r extra_packages/* $DIR
15+
1416
echo "[*] Extract CPIO"
1517
pushd $DIR
1618
cpio -idmv < ../$ROOTFS_CPIO

target/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/bash
2+
3+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
4+
export PATH=$PATH:/usr/local/bin/

0 commit comments

Comments
 (0)