Make builds incremental by preserving source/build dirs (#45)

This commit is contained in:
Adeeb Shihadeh
2026-03-04 09:17:55 -08:00
committed by GitHub
parent 2e9aed768a
commit 331d94a683
37 changed files with 221 additions and 367 deletions

View File

@@ -7,18 +7,15 @@ cd "$DIR"
VERSION="3.1.0"
INSTALL_DIR="$DIR/libjpeg/install"
# Idempotent: skip if already built
if [ -f "$INSTALL_DIR/lib/libjpeg.a" ]; then
echo "libjpeg already present, skipping build."
exit 0
fi
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
# Clone
if [ ! -d "libjpeg-turbo-src" ]; then
git clone --depth 1 --branch "${VERSION}" https://github.com/libjpeg-turbo/libjpeg-turbo.git libjpeg-turbo-src
# Clone/update source
if [ ! -d "libjpeg-turbo-src/.git" ]; then
rm -rf libjpeg-turbo-src
git clone --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo.git libjpeg-turbo-src
fi
git -C libjpeg-turbo-src fetch --depth 1 origin "${VERSION}"
git -C libjpeg-turbo-src checkout --force FETCH_HEAD
# Build
PREFIX="$DIR/build/prefix"
@@ -50,8 +47,5 @@ cp "$PREFIX/include/jconfig.h" "$INSTALL_DIR/include/"
cp "$PREFIX/include/jerror.h" "$INSTALL_DIR/include/"
cp "$PREFIX/include/jmorecfg.h" "$INSTALL_DIR/include/"
# Clean up
rm -rf libjpeg-turbo-src "$DIR/build"
echo "Installed libjpeg to $INSTALL_DIR"
du -sh "$INSTALL_DIR"

View File

@@ -15,11 +15,8 @@ class BuildLibjpeg(build_py):
def run(self):
pkg_dir = os.path.dirname(os.path.abspath(__file__))
marker = os.path.join(pkg_dir, "libjpeg", "install", "lib", "libjpeg.a")
if not os.path.exists(marker):
build_script = os.path.join(pkg_dir, "build.sh")
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
build_script = os.path.join(pkg_dir, "build.sh")
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
super().run()