BuildSystem: Rewrite port compilation system
Now ports define some environment variables, and call a unified bash script that handles configuration, recompilation and installation. If a port uses non-configure buildsystem, port script can also specify custom build and install step.
This commit is contained in:
parent
4d96ae56ac
commit
352c1ddc16
|
@ -1 +1,3 @@
|
||||||
installed
|
*/*
|
||||||
|
!*/patches/
|
||||||
|
!*/build.sh
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd $(dirname $(realpath $0))
|
|
||||||
|
|
||||||
if [ ! -f installed ]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
while read port; do
|
|
||||||
${port}/build.sh
|
|
||||||
done < installed
|
|
|
@ -1 +0,0 @@
|
||||||
curl-*
|
|
|
@ -1,58 +1,11 @@
|
||||||
#!/bin/sh
|
#!/bin/bash ../install.sh
|
||||||
|
|
||||||
if [ -z $BANAN_ARCH ]; then
|
NAME='curl'
|
||||||
echo "You must set the BANAN_ARCH environment variable" >&2
|
VERSION='8.8.0'
|
||||||
exit 1
|
DOWNLOAD_URL="https://curl.se/download/curl-$VERSION.tar.gz#77c0e1cd35ab5b45b659645a93b46d660224d0024f1185e8a95cdb27ae3d787d"
|
||||||
fi
|
CONFIGURE_OPTIONS=(
|
||||||
|
'--without-ssl'
|
||||||
if [ -z $BANAN_SYSROOT ]; then
|
'--disable-threaded-resolver'
|
||||||
echo "You must set the BANAN_ARCH environment variable" >&2
|
'--disable-ipv6'
|
||||||
exit 1
|
'--disable-docs'
|
||||||
fi
|
)
|
||||||
|
|
||||||
if [ -z $BANAN_TOOLCHAIN_PREFIX ]; then
|
|
||||||
echo "You must set the BANAN_TOOLCHAIN_PREFIX environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
CURL_VERSION="curl-8.8.0"
|
|
||||||
CURL_TAR="$CURL_VERSION.tar.gz"
|
|
||||||
CURL_URL="https://curl.se/download/$CURL_TAR"
|
|
||||||
|
|
||||||
cd $(dirname $(realpath $0))
|
|
||||||
|
|
||||||
if [ ! -d $CURL_VERSION ]; then
|
|
||||||
if [ ! -f $CURL_TAR ]; then
|
|
||||||
wget $CURL_URL
|
|
||||||
fi
|
|
||||||
tar xf $CURL_TAR
|
|
||||||
|
|
||||||
for patch in ./patches/*; do
|
|
||||||
patch -ruN -d $CURL_VERSION < "$patch"
|
|
||||||
done
|
|
||||||
|
|
||||||
grep -qxF curl ../installed || echo curl >> ../installed
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $CURL_VERSION
|
|
||||||
|
|
||||||
export PATH="$BANAN_TOOLCHAIN_PREFIX/bin:$PATH"
|
|
||||||
|
|
||||||
if [ ! -d "build-${BANAN_ARCH}" ]; then
|
|
||||||
mkdir -p "build-${BANAN_ARCH}"
|
|
||||||
cd "build-${BANAN_ARCH}"
|
|
||||||
|
|
||||||
../configure \
|
|
||||||
--host=x86_64-banan_os \
|
|
||||||
--prefix=$BANAN_SYSROOT/usr \
|
|
||||||
--without-ssl \
|
|
||||||
--disable-threaded-resolver \
|
|
||||||
--disable-ipv6 \
|
|
||||||
--disable-docs
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "build-${BANAN_ARCH}"
|
|
||||||
|
|
||||||
make -j $(nproc) && make install
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
doomgeneric/
|
|
||||||
doom1.wad
|
|
|
@ -1 +0,0 @@
|
||||||
This is a port of doomgeneric. You will need doom wad to play. Copy the wad file into sysroot and use the -iwad argument to specify wad location.
|
|
|
@ -1,33 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/bash ../install.sh
|
||||||
|
|
||||||
if [ -z $BANAN_ARCH ]; then
|
NAME='doom'
|
||||||
echo "You must set the BANAN_ARCH environment variable" >&2
|
VERSION='git'
|
||||||
exit 1
|
DOWNLOAD_URL="https://github.com/ozkl/doomgeneric.git#613f870b6fa83ede448a247de5a2571092fa729d"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $BANAN_SYSROOT ]; then
|
|
||||||
echo "You must set the BANAN_ARCH environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $(dirname $(realpath $0))
|
|
||||||
|
|
||||||
if [ ! -d "doomgeneric" ]; then
|
|
||||||
git clone https://github.com/ozkl/doomgeneric.git
|
|
||||||
cd doomgeneric
|
|
||||||
git checkout 613f870b6fa83ede448a247de5a2571092fa729d
|
|
||||||
for patch in ../patches/*; do
|
|
||||||
git am "$patch"
|
|
||||||
done
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
grep -qxF doom ../installed || echo doom >> ../installed
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
build() {
|
||||||
if [ ! -f doom1.wad ]; then
|
if [ ! -f doom1.wad ]; then
|
||||||
wget https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad
|
wget https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad || exit 1
|
||||||
fi
|
fi
|
||||||
|
make --directory doomgeneric --file Makefile.banan_os -j$(nproc) || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
make --directory doomgeneric/doomgeneric --file Makefile.banan_os -j $(nproc)
|
install() {
|
||||||
cp "doomgeneric/doomgeneric/build-${BANAN_ARCH}/doomgeneric" "${BANAN_SYSROOT}/bin/doom"
|
cp doomgeneric/build/doom "${BANAN_SYSROOT}/bin/" || exit 1
|
||||||
cp doom1.wad $BANAN_SYSROOT/home/user/
|
cp ./doom1.wad "$BANAN_SYSROOT/home/user/" || exit 1
|
||||||
|
}
|
||||||
|
|
|
@ -29,16 +29,16 @@ index 0000000..0878148
|
||||||
+ VB=@
|
+ VB=@
|
||||||
+endif
|
+endif
|
||||||
+
|
+
|
||||||
+CC=$(BANAN_TOOLCHAIN_PREFIX)/bin/$(BANAN_ARCH)-banan_os-gcc
|
+CC=$(BANAN_ARCH)-banan_os-gcc
|
||||||
+CXX=$(BANAN_TOOLCHAIN_PREFIX)/bin/$(BANAN_ARCH)-banan_os-g++
|
+CXX=$(BANAN_ARCH)-banan_os-g++
|
||||||
+CFLAGS+=-O3 -Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE
|
+CFLAGS+=-O3 -Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE
|
||||||
+CXXFLAGS+=$(CFLAGS) --std=c++20
|
+CXXFLAGS+=$(CFLAGS) --std=c++20
|
||||||
+LDFLAGS+=
|
+LDFLAGS+=
|
||||||
+LIBS+=-lgui -linput -lstdc++
|
+LIBS+=-lgui -linput -lstdc++
|
||||||
+
|
+
|
||||||
+# subdirectory for objects
|
+# subdirectory for objects
|
||||||
+OBJDIR=build-$(BANAN_ARCH)
|
+OBJDIR=build
|
||||||
+OUTPUT=$(OBJDIR)/doomgeneric
|
+OUTPUT=$(OBJDIR)/doom
|
||||||
+
|
+
|
||||||
+SRC_DOOM = dummy.o am_map.o doomdef.o doomstat.o dstrings.o d_event.o d_items.o d_iwad.o d_loop.o d_main.o d_mode.o d_net.o f_finale.o f_wipe.o g_game.o hu_lib.o hu_stuff.o info.o i_cdmus.o i_endoom.o i_joystick.o i_scale.o i_sound.o i_system.o i_timer.o memio.o m_argv.o m_bbox.o m_cheat.o m_config.o m_controls.o m_fixed.o m_menu.o m_misc.o m_random.o p_ceilng.o p_doors.o p_enemy.o p_floor.o p_inter.o p_lights.o p_map.o p_maputl.o p_mobj.o p_plats.o p_pspr.o p_saveg.o p_setup.o p_sight.o p_spec.o p_switch.o p_telept.o p_tick.o p_user.o r_bsp.o r_data.o r_draw.o r_main.o r_plane.o r_segs.o r_sky.o r_things.o sha1.o sounds.o statdump.o st_lib.o st_stuff.o s_sound.o tables.o v_video.o wi_stuff.o w_checksum.o w_file.o w_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_banan_os.o
|
+SRC_DOOM = dummy.o am_map.o doomdef.o doomstat.o dstrings.o d_event.o d_items.o d_iwad.o d_loop.o d_main.o d_mode.o d_net.o f_finale.o f_wipe.o g_game.o hu_lib.o hu_stuff.o info.o i_cdmus.o i_endoom.o i_joystick.o i_scale.o i_sound.o i_system.o i_timer.o memio.o m_argv.o m_bbox.o m_cheat.o m_config.o m_controls.o m_fixed.o m_menu.o m_misc.o m_random.o p_ceilng.o p_doors.o p_enemy.o p_floor.o p_inter.o p_lights.o p_map.o p_maputl.o p_mobj.o p_plats.o p_pspr.o p_saveg.o p_setup.o p_sight.o p_spec.o p_switch.o p_telept.o p_tick.o p_user.o r_bsp.o r_data.o r_draw.o r_main.o r_plane.o r_segs.o r_sky.o r_things.o sha1.o sounds.o statdump.o st_lib.o st_stuff.o s_sound.o tables.o v_video.o wi_stuff.o w_checksum.o w_file.o w_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_banan_os.o
|
||||||
+OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM))
|
+OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM))
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if (( $# != 1 )); then
|
||||||
|
echo "No arguments given for $0" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BANAN_ROOT_DIR="$(dirname $(realpath $0))/.."
|
||||||
|
source "$BANAN_ROOT_DIR/script/config.sh"
|
||||||
|
export PATH="$BANAN_TOOLCHAIN_PREFIX/bin:$PATH"
|
||||||
|
|
||||||
|
if [ ! -f "$BANAN_SYSROOT/usr/lib/libc.a" ]; then
|
||||||
|
pushd "$BANAN_ROOT_DIR" >/dev/null
|
||||||
|
./bos libc || exit 1
|
||||||
|
./bos install || exit 1
|
||||||
|
popd >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
find . -mindepth 1 -maxdepth 1 -not -name 'patches' -not -name 'build.sh' -exec rm -rf {} +
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
configure_options=("--host=$BANAN_ARCH-banan_os" "--prefix=/usr" )
|
||||||
|
configure_options+=(${CONFIGURE_OPTIONS[*]})
|
||||||
|
|
||||||
|
./configure ${configure_options[*]} || exit 1
|
||||||
|
make -j$(nproc) || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
install() {
|
||||||
|
make install "DESTDIR=$BANAN_SYSROOT" || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
source $1
|
||||||
|
|
||||||
|
if [ -z $NAME ] || [ -z $VERSION ] || [ -z $DOWNLOAD_URL ]; then
|
||||||
|
echo "Port does not set needed environment variables" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for dependency in "${DEPENDENCIES[@]}"; do
|
||||||
|
pushd "../$dependency" >/dev/null
|
||||||
|
pwd
|
||||||
|
if ! ./build.sh; then
|
||||||
|
echo "Failed to install dependency '$dependency' of port '$NAME'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
popd >/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
build_dir="$NAME-$VERSION-$BANAN_ARCH"
|
||||||
|
|
||||||
|
if [ "$VERSION" = "git" ]; then
|
||||||
|
regex="(.*/.*\.git)#(.*)"
|
||||||
|
|
||||||
|
if [[ $DOWNLOAD_URL =~ $regex ]]; then
|
||||||
|
REPO_URL="${BASH_REMATCH[1]}"
|
||||||
|
COMMIT="${BASH_REMATCH[2]}"
|
||||||
|
|
||||||
|
if [ -d "$build_dir" ]; then
|
||||||
|
pushd $build_dir >/dev/null
|
||||||
|
if [ ! "$(git rev-parse HEAD)" = "$COMMIT" ]; then
|
||||||
|
clean
|
||||||
|
fi
|
||||||
|
popd >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$build_dir" ]; then
|
||||||
|
git clone "$REPO_URL" "$build_dir" || exit 1
|
||||||
|
|
||||||
|
pushd "$build_dir" >/dev/null
|
||||||
|
git checkout "$COMMIT" || exit 1
|
||||||
|
if [ -d patches ]; then
|
||||||
|
for patch in ../patches/*; do
|
||||||
|
git apply "$patch" || exit 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
popd >/dev/null
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Invalid format in DOWNLOAD_URL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
regex=".*/(.*\.tar\..*)#(.*)"
|
||||||
|
if [[ $DOWNLOAD_URL =~ $regex ]]; then
|
||||||
|
TAR_NAME="${BASH_REMATCH[1]}"
|
||||||
|
TAR_HASH="${BASH_REMATCH[2]}"
|
||||||
|
|
||||||
|
if [ -f "$TAR_NAME" ]; then
|
||||||
|
if ! echo "$TAR_HASH $TAR_NAME" | sha256sum --check >/dev/null; then
|
||||||
|
clean
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$TAR_NAME" ]; then
|
||||||
|
wget "$DOWNLOAD_URL" || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! echo "$TAR_HASH $TAR_NAME" | sha256sum --check >/dev/null; then
|
||||||
|
echo "Tar hash does not match" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$build_dir" ]; then
|
||||||
|
tar xf "$TAR_NAME" || exit 1
|
||||||
|
|
||||||
|
: "${TAR_CONTENT:=$NAME-$VERSION}"
|
||||||
|
mv "$TAR_CONTENT" "$build_dir" || exit 1
|
||||||
|
|
||||||
|
if [ -d patches ]; then
|
||||||
|
for patch in ./patches/*; do
|
||||||
|
patch -ruN -d "$build_dir" < "$patch" || exit 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Invalid format in DOWNLOAD_URL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
needs_compile=1
|
||||||
|
if [ -f ".compile_hash-$BANAN_ARCH" ]; then
|
||||||
|
cat ".compile_hash-$BANAN_ARCH" | sha256sum --check >/dev/null
|
||||||
|
needs_compile=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$build_dir"
|
||||||
|
|
||||||
|
if (( $needs_compile )); then
|
||||||
|
build
|
||||||
|
sha256sum "$BANAN_SYSROOT/usr/lib/libc.a" > "../.compile_hash-$BANAN_ARCH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
install
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd $(dirname $(realpath $0))
|
||||||
|
|
||||||
|
for port in ./*/.compile_hash*; do
|
||||||
|
pushd $(dirname "$port") >/dev/null
|
||||||
|
./build.sh
|
||||||
|
popd >/dev/null
|
||||||
|
done
|
|
@ -49,7 +49,7 @@ create_image () {
|
||||||
build_target all
|
build_target all
|
||||||
build_target install
|
build_target install
|
||||||
|
|
||||||
$BANAN_ROOT_DIR/ports/build.sh
|
$BANAN_ROOT_DIR/ports/update.sh
|
||||||
|
|
||||||
pushd $BANAN_SYSROOT >/dev/null
|
pushd $BANAN_SYSROOT >/dev/null
|
||||||
run_fakeroot tar cf ${BANAN_SYSROOT_TAR} *
|
run_fakeroot tar cf ${BANAN_SYSROOT_TAR} *
|
||||||
|
@ -121,6 +121,7 @@ case $1 in
|
||||||
;;
|
;;
|
||||||
distclean)
|
distclean)
|
||||||
rm -rf $BANAN_BUILD_DIR
|
rm -rf $BANAN_BUILD_DIR
|
||||||
|
rm $BANAN_ROOT_DIR/ports/*/.compile_hash*
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
build_target $1
|
build_target $1
|
||||||
|
|
Loading…
Reference in New Issue