Skip to content
Myr

compile-ios.sh

This file

Path

compile-ios.sh

106 lines · 3.2 KiB · Shell

Last changed by

Update builtin oniguruma to 6.9.10 to suppress clang warnings (#3258)itchynybefore adoption4350637

History of this file

Take it

The walk stopped after 200 commits: lines older than fa6a2ff point at it.

website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff

lines 1–5why, one step back
1#!/usr/bin/env bash
2# Mac C. compile-ios.sh for JQ.34# Defaults5set -e

Update builtin oniguruma to 6.9.10 to suppress clang warnings (#3258)itchynybefore adoption4350637

line 6why, one step back
6oniguruma='6.9.10'

website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff

lines 7–106why, one step back
7
8unset CFLAGS9unset CXXFLAGS10unset LDFLAGS1112# Parse args. 13usage(){14cat << EOF15${0##*/}: usage1617 Description:18 This simple script builds oniguruma and jq for all *-apple-darwin devices.1920 Arguments:21 --extra-cflags <arg>: Pass defines or includes to clang.22 --extra-ldflags <arg>: Pass libs or includes to ld64.2324 --with-oniguruma <arg>: Change default version of onigurma from ${oniguruma}.25EOF26exit 127}2829while (( $# )); do30 case "$1" in31 --with-oniguruma) shift; oniguruma="${1}" ;;3233 --extra-cflags) shift; export CFLAGS_="${1}" ;;34 --extra-ldflags) shift; export LDFLAGS_="${1}" ;;3536 --help) usage ;;37 *) echo -e "Unknown option: ${1}\n"; usage ;;38 esac39 shift40done 4142# Start building.43echo "Building..."44MAKEJOBS="$(sysctl -n hw.ncpu || echo 1)"45CC_="$(xcrun -f clang || echo clang)"4647onig_url="https://github.com/kkos/oniguruma/releases/download/v${oniguruma}/onig-${oniguruma}.tar.gz"48builddir="${TMPDIR:-/tmp}/${RANDOM:-'xxxxx'}-compile-ios-build"49cwd="$(realpath ${PWD} 2>/dev/null || echo ${PWD})"5051t_exit() {52cat << EOF5354A error as occurred.55 oniguruma location: ${builddir}/onig/onig-${oniguruma}56 jq location: ${cwd}5758 Provide config.log and console logs when posting a issue.5960EOF61}62trap t_exit ERR6364# Onig.65mkdir -p "${builddir}/onig"66cd "${builddir}/"67 curl -L ${onig_url} | tar xz68 for arch in i386 x86_64 armv7 armv7s arm64; do69 if [[ "$arch" = "i386" || "$arch" = "x86_64" ]]; then70 SYSROOT=$(xcrun -f --sdk iphonesimulator --show-sdk-path)71 else72 SYSROOT=$(xcrun -f --sdk iphoneos --show-sdk-path)73 fi74 HOST="${arch}-apple-darwin"75 [[ "${arch}" = "arm64" ]] && HOST="aarch64-apple-darwin"7677 CFLAGS="-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${CFLAGS_} -D_REENTRANT"78 LDFLAGS="-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${LDFLAGS_}"79 CC="${CC_} ${CFLAGS}"8081 # ./configure; make install82 cd "${builddir}/onig-${oniguruma}"83 CC=${CC} LDFLAGS=${LDFLAGS} \84 ./configure --host=${HOST} --build=$(./config.guess) --enable-shared=no --enable-static=yes --prefix=/85 make -j${MAKEJOBS} install DESTDIR="${cwd}/ios/onig/${arch}"86 make clean87 88 # Jump back to JQ.89 cd ${cwd}90 [[ ! -f ./configure ]] && autoreconf -ivf91 CC=${CC} LDFLAGS=${LDFLAGS} \92 ./configure --host=${HOST} --build=$(./config/config.guess) --enable-docs=no --enable-shared=no --enable-static=yes --prefix=/ --with-oniguruma=${cwd}/ios/onig/${arch} $(test -z ${BISON+x} || echo '--enable-maintainer-mode')93 make -j${MAKEJOBS} install DESTDIR="${cwd}/ios/jq/${arch}"94 make clean95 done9697mkdir -p "${cwd}/ios/dest/lib"98# lipo, make a static lib.99lipo -create -output ${cwd}/ios/dest/lib/libonig.a ${cwd}/ios/onig/{i386,x86_64,armv7,armv7s,arm64}/lib/libonig.a100lipo -create -output ${cwd}/ios/dest/lib/libjq.a ${cwd}/ios/jq/{i386,x86_64,armv7,armv7s,arm64}/lib/libjq.a101102# Take the arm64 headers- the most common target.103cp -r ${cwd}/ios/jq/arm64/include ${cwd}/ios/dest/104rm -rf ${cwd}/build/ios/{i386,x86_64,armv7,armv7s,arm64}105106echo "Output to ${cwd}/ios/dest"