Skip to content

Commit

Permalink
mapbox#749 fixes link libpng 1.6.32 and added 1.6.39
Browse files Browse the repository at this point in the history
  • Loading branch information
smellman committed Mar 18, 2023
1 parent 722b88b commit 2a9fbf2
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/libpng/1.6.32/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ZLIB_SHARED_VERSION=1.2.8

function mason_load_source {
mason_download \
https://downloads.sourceforge.net/project/libpng/libpng16/${MASON_VERSION}/libpng-${MASON_VERSION}.tar.gz \
https://downloads.sourceforge.net/project/libpng/libpng16/older-releases/${MASON_VERSION}/libpng-${MASON_VERSION}.tar.gz \
752b19285db1aab9d0b8f5ef2312390734f71e70

mason_extract_tar_gz
Expand Down
45 changes: 45 additions & 0 deletions scripts/libpng/1.6.39/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
language: generic

matrix:
include:
- os: osx
osx_image: xcode8.2
compiler: clang
- os: linux
env: MASON_PLATFORM_VERSION=cortex_a9
sudo: false
- os: linux
env: MASON_PLATFORM_VERSION=i686
sudo: false
addons:
apt:
packages: [ 'zlib1g-dev:i386' ]
- os: linux
env: MASON_PLATFORM=linux
compiler: clang
sudo: false
- os: linux
env: MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v5
sudo: false
- os: linux
env: MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v7
sudo: false
- os: linux
env: MASON_PLATFORM=android MASON_ANDROID_ABI=arm-v8
sudo: false
- os: linux
env: MASON_PLATFORM=android MASON_ANDROID_ABI=x86
sudo: false
- os: linux
env: MASON_PLATFORM=android MASON_ANDROID_ABI=x86-64
sudo: false
- os: linux
env: MASON_PLATFORM=android MASON_ANDROID_ABI=mips
sudo: false
- os: linux
env: MASON_PLATFORM=android MASON_ANDROID_ABI=mips-64
sudo: false

script:
- ./mason build ${MASON_NAME} ${MASON_VERSION}
- ./mason publish ${MASON_NAME} ${MASON_VERSION}
71 changes: 71 additions & 0 deletions scripts/libpng/1.6.39/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

MASON_NAME=libpng
MASON_VERSION=1.6.39
MASON_LIB_FILE=lib/libpng.a
MASON_PKGCONFIG_FILE=lib/pkgconfig/libpng.pc

# Used when cross compiling to cortex_a9
ZLIB_SHARED_VERSION=1.2.8

. ${MASON_DIR}/mason.sh

function mason_load_source {
mason_download \
https://downloads.sourceforge.net/project/libpng/libpng16/${MASON_VERSION}/libpng-${MASON_VERSION}.tar.gz \
752b19285db1aab9d0b8f5ef2312390734f71e70

mason_extract_tar_gz

export MASON_BUILD_PATH=${MASON_ROOT}/.build/libpng-${MASON_VERSION}
}

function mason_prepare_compile {
# Install the zlib dependency when cross compiling as usually the host system only
# provides the zlib headers and libraries in the path for the host architecture.
if [ ${MASON_PLATFORM_VERSION} == "cortex_a9" ] || [ ${MASON_PLATFORM_VERSION} == "i686" ]; then
cd $(dirname ${MASON_ROOT})
${MASON_DIR}/mason install zlib_shared ${ZLIB_SHARED_VERSION}
${MASON_DIR}/mason link zlib_shared ${ZLIB_SHARED_VERSION}

MASON_ZLIB_CFLAGS="$(${MASON_DIR}/mason cflags zlib_shared ${ZLIB_SHARED_VERSION})"
MASON_ZLIB_LDFLAGS="-L$(${MASON_DIR}/mason prefix zlib_shared ${ZLIB_SHARED_VERSION})/lib"
fi
}

function mason_compile {
export CFLAGS="${CFLAGS:-} ${MASON_ZLIB_CFLAGS:-} -O3 -DNDEBUG"
export LDFLAGS="${CFLAGS:-} ${MASON_ZLIB_LDFLAGS:-}"

if [ ${MASON_PLATFORM_VERSION} == "cortex_a9" ] || [ ${MASON_PLATFORM_VERSION} == "i686" ]; then
# XXX: This hack is because libpng does not respect CFLAGS
# for all the files. Bruteforce in the compiler command line.
export CC="${CC:-} ${CFLAGS}"
fi

./configure \
--prefix=${MASON_PREFIX} \
${MASON_HOST_ARG} \
--enable-static \
--with-pic \
--disable-shared \
--disable-dependency-tracking

V=1 VERBOSE=1 make install -j${MASON_CONCURRENCY}
}

function mason_strip_ldflags {
shift # -L...
shift # -lpng16
echo "$@"
}

function mason_ldflags {
mason_strip_ldflags $(`mason_pkgconfig` --static --libs)
}

function mason_clean {
make clean
}

mason_run "$@"

0 comments on commit 2a9fbf2

Please sign in to comment.