mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 04:35:41 +03:00
Build: Sprinkle some portability, fix on OpenBSD
realpath(1) is specific to coreutils and its behavior can be had with readlink -f Create the Toolchain Build directory if it doesn't exist before calling readlink, since realpath(3) on at least OpenBSD will error on a non-existent path
This commit is contained in:
parent
4021264201
commit
0d215b5548
Notes:
sideshowbarker
2024-07-18 22:20:41 +09:00
Author: https://github.com/jcs Commit: https://github.com/SerenityOS/serenity/commit/0d215b55487 Pull-request: https://github.com/SerenityOS/serenity/pull/5337
@ -19,7 +19,8 @@ if [ "$(uname -s)" = "Darwin" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
disk_usage() {
|
disk_usage() {
|
||||||
du -sm "$1" | cut -f1
|
# shellcheck disable=SC2003
|
||||||
|
expr "$(du -sk "$1" | cut -f1)" / 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
DISK_SIZE=$(($(disk_usage "$SERENITY_ROOT/Base") + $(disk_usage Root) + 100))
|
DISK_SIZE=$(($(disk_usage "$SERENITY_ROOT/Base") + $(disk_usage Root) + 100))
|
||||||
@ -33,7 +34,7 @@ printf "creating new filesystem... "
|
|||||||
if [ "$(uname -s)" = "OpenBSD" ]; then
|
if [ "$(uname -s)" = "OpenBSD" ]; then
|
||||||
VND=$(vnconfig _disk_image)
|
VND=$(vnconfig _disk_image)
|
||||||
(echo "e 0"; echo 83; echo n; echo 0; echo "*"; echo "quit") | fdisk -e "$VND"
|
(echo "e 0"; echo 83; echo n; echo 0; echo "*"; echo "quit") | fdisk -e "$VND"
|
||||||
mkfs.ext2 -I 128 -F "/dev/${VND}i" || die "could not create filesystem"
|
newfs_ext2fs -D 128 "/dev/r${VND}i" || die "could not create filesystem"
|
||||||
elif [ "$(uname -s)" = "FreeBSD" ]; then
|
elif [ "$(uname -s)" = "FreeBSD" ]; then
|
||||||
MD=$(mdconfig _disk_image)
|
MD=$(mdconfig _disk_image)
|
||||||
mke2fs -q -I 128 _disk_image || die "could not create filesystem"
|
mke2fs -q -I 128 _disk_image || die "could not create filesystem"
|
||||||
|
@ -85,7 +85,7 @@ mkdir -p mnt/dev
|
|||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
printf "writing version file... "
|
printf "writing version file... "
|
||||||
GIT_HASH=$( (git log --pretty=format:'%h' -n 1 | head -c 7) || true )
|
GIT_HASH=$( (git log --pretty=format:'%h' -n 1 | cut -c1-7) || true )
|
||||||
printf "[Version]\nMajor=1\nMinor=0\nGit=%s\n" "$GIT_HASH" > mnt/res/version.ini
|
printf "[Version]\nMajor=1\nMinor=0\nGit=%s\n" "$GIT_HASH" > mnt/res/version.ini
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ trap cleanup 0 1 2 3 6
|
|||||||
"$@" > "${DST_FILE}.tmp"
|
"$@" > "${DST_FILE}.tmp"
|
||||||
# If we get here, the command was successful, and we can overwrite the destination.
|
# If we get here, the command was successful, and we can overwrite the destination.
|
||||||
|
|
||||||
if ! cmp --quiet -- "${DST_FILE}.tmp" "${DST_FILE}"; then
|
if ! cmp -s -- "${DST_FILE}.tmp" "${DST_FILE}"; then
|
||||||
# File changed, need to overwrite:
|
# File changed, need to overwrite:
|
||||||
mv -f -- "${DST_FILE}.tmp" "${DST_FILE}"
|
mv -f -- "${DST_FILE}.tmp" "${DST_FILE}"
|
||||||
fi
|
fi
|
||||||
|
@ -12,12 +12,13 @@ echo "$DIR"
|
|||||||
ARCH=${ARCH:-"i686"}
|
ARCH=${ARCH:-"i686"}
|
||||||
TARGET="$ARCH-pc-serenity"
|
TARGET="$ARCH-pc-serenity"
|
||||||
PREFIX="$DIR/Local/$ARCH"
|
PREFIX="$DIR/Local/$ARCH"
|
||||||
BUILD=$(realpath "$DIR/../Build")
|
BUILD="$DIR/../Build"
|
||||||
SYSROOT="$BUILD/Root"
|
SYSROOT="$BUILD/Root"
|
||||||
|
|
||||||
MAKE="make"
|
MAKE="make"
|
||||||
MD5SUM="md5sum"
|
MD5SUM="md5sum"
|
||||||
NPROC="nproc"
|
NPROC="nproc"
|
||||||
|
REALPATH="realpath"
|
||||||
|
|
||||||
if command -v ginstall &>/dev/null; then
|
if command -v ginstall &>/dev/null; then
|
||||||
INSTALL=ginstall
|
INSTALL=ginstall
|
||||||
@ -29,6 +30,7 @@ if [ "$(uname -s)" = "OpenBSD" ]; then
|
|||||||
MAKE=gmake
|
MAKE=gmake
|
||||||
MD5SUM="md5 -q"
|
MD5SUM="md5 -q"
|
||||||
NPROC="sysctl -n hw.ncpuonline"
|
NPROC="sysctl -n hw.ncpuonline"
|
||||||
|
REALPATH="readlink -f"
|
||||||
export CC=egcc
|
export CC=egcc
|
||||||
export CXX=eg++
|
export CXX=eg++
|
||||||
export with_gmp=/usr/local
|
export with_gmp=/usr/local
|
||||||
@ -41,6 +43,12 @@ elif [ "$(uname -s)" = "FreeBSD" ]; then
|
|||||||
export with_mpfr=/usr/local
|
export with_mpfr=/usr/local
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# On at least OpenBSD, the path must exist to call realpath(3) on it
|
||||||
|
if [ ! -d "$BUILD" ]; then
|
||||||
|
mkdir -p "$BUILD"
|
||||||
|
fi
|
||||||
|
BUILD=$($REALPATH "$BUILD")
|
||||||
|
|
||||||
git_patch=
|
git_patch=
|
||||||
while [ "$1" != "" ]; do
|
while [ "$1" != "" ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
@ -236,7 +244,7 @@ pushd "$DIR/Build/$ARCH"
|
|||||||
mkdir -p "$BUILD"
|
mkdir -p "$BUILD"
|
||||||
pushd "$BUILD"
|
pushd "$BUILD"
|
||||||
mkdir -p Root/usr/include/
|
mkdir -p Root/usr/include/
|
||||||
SRC_ROOT=$(realpath "$DIR"/..)
|
SRC_ROOT=$($REALPATH "$DIR"/..)
|
||||||
FILES=$(find "$SRC_ROOT"/Userland/Libraries/LibC "$SRC_ROOT"/Userland/Libraries/LibM -name '*.h' -print)
|
FILES=$(find "$SRC_ROOT"/Userland/Libraries/LibC "$SRC_ROOT"/Userland/Libraries/LibM -name '*.h' -print)
|
||||||
for header in $FILES; do
|
for header in $FILES; do
|
||||||
target=$(echo "$header" | sed -e "s@$SRC_ROOT/Userland/Libraries/LibC@@" -e "s@$SRC_ROOT/Userland/Libraries/LibM@@")
|
target=$(echo "$header" | sed -e "s@$SRC_ROOT/Userland/Libraries/LibC@@" -e "s@$SRC_ROOT/Userland/Libraries/LibM@@")
|
||||||
|
Loading…
Reference in New Issue
Block a user