Skip to content

Commit e3b942c

Browse files
committed
Build DirectFB2 as extra package
1 parent 3a174df commit e3b942c

File tree

4 files changed

+81
-2
lines changed

4 files changed

+81
-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: 57 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
@@ -86,12 +90,13 @@ function do_linux
8690

8791
function show_help {
8892
cat << EOF
89-
Usage: $0 [--buildroot] [--linux] [--all] [--external-root] [--clean-build] [--help]
93+
Usage: $0 [--buildroot] [--linux] [--extra-packages] [--all] [--external-root] [--clean-build] [--help]
9094
9195
Options:
9296
--buildroot Build Buildroot rootfs
97+
--extra-packages Build extra packages along with Buildroot
9398
--linux Build Linux kernel
94-
--all Build both Buildroot and Linux
99+
--all Build both Buildroot and Linux kernel
95100
--external-root Use external rootfs instead of initramfs
96101
--clean-build Remove entire buildroot/ and/or linux/ directories before build
97102
--help Show this message
@@ -101,6 +106,7 @@ EOF
101106

102107
BUILD_BUILDROOT=0
103108
BUILD_LINUX=0
109+
BUILD_EXTRA_PACKAGES=0
104110
EXTERNAL_ROOT=0
105111
CLEAN_BUILD=0
106112

@@ -109,6 +115,9 @@ while [[ $# -gt 0 ]]; do
109115
--buildroot)
110116
BUILD_BUILDROOT=1
111117
;;
118+
--extra-packages)
119+
BUILD_EXTRA_PACKAGES=1
120+
;;
112121
--linux)
113122
BUILD_LINUX=1
114123
;;
@@ -133,11 +142,57 @@ while [[ $# -gt 0 ]]; do
133142
shift
134143
done
135144

145+
function do_directfb
146+
{
147+
export PATH=$PATH:$PWD/buildroot/output/host/bin
148+
export BUILDROOT_OUT=$PWD/buildroot/output/
149+
mkdir -p directfb
150+
151+
# Build DirectFB2
152+
ASSERT git clone https://github.com/directfb2/DirectFB2.git
153+
pushd DirectFB2
154+
cp ../configs/riscv-cross-file .
155+
ASSERT meson -Ddrmkms=true --cross-file riscv-cross-file build/riscv
156+
ASSERT meson compile -C build/riscv
157+
DESTDIR=$BUILDROOT_OUT/host/riscv32-buildroot-linux-gnu/sysroot meson install -C build/riscv
158+
DESTDIR=../../../directfb meson install -C build/riscv
159+
popd
160+
161+
# Build DirectFB2 examples
162+
ASSERT git clone https://github.com/directfb2/DirectFB-examples.git
163+
pushd DirectFB-examples/
164+
cp ../configs/riscv-cross-file .
165+
ASSERT meson --cross-file riscv-cross-file build/riscv
166+
ASSERT meson compile -C build/riscv
167+
DESTDIR=../../../directfb meson install -C build/riscv
168+
popd
169+
}
170+
171+
function do_extra_packages
172+
{
173+
export PATH="$PWD/buildroot/output/host/bin:$PATH"
174+
export CROSS_COMPILE=riscv32-buildroot-linux-gnu-
175+
176+
rm -rf extra_packages
177+
mkdir -p extra_packages
178+
mkdir -p extra_packages/root
179+
180+
do_directfb && OK
181+
182+
cp -r directfb/* extra_packages
183+
cp target/run.sh extra_packages/root/
184+
}
185+
136186
if [[ $BUILD_BUILDROOT -eq 0 && $BUILD_LINUX -eq 0 ]]; then
137187
echo "Error: No build target specified. Use --buildroot, --linux, or --all."
138188
show_help
139189
fi
140190

191+
if [[ $BUILD_EXTRA_PACKAGES -eq 1 && $BUILD_BUILDROOT -eq 0 ]]; then
192+
echo "Error: --extra-packages requires --buildroot to be specified."
193+
show_help
194+
fi
195+
141196
if [[ $CLEAN_BUILD -eq 1 && $BUILD_BUILDROOT -eq 1 && -d buildroot ]]; then
142197
echo "Removing buildroot/ for clean build..."
143198
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)