Skip to content

Instantly share code, notes, and snippets.

@digitalogical
Created May 27, 2018 19:05
Show Gist options
  • Save digitalogical/7ebc857f9e5453007959567a4b73470f to your computer and use it in GitHub Desktop.
Save digitalogical/7ebc857f9e5453007959567a4b73470f to your computer and use it in GitHub Desktop.
Arch Linux PKGBUILD for https://github.com/v8/v8 : uses Python2, installs to paths expected by https://github.com/phpv8/v8js
# Maintainer: Aaron Danielson <echo aaron.aarondanielson.com | sed 's/\./@/'>
pkgname=v8
pkgver=6.4.388.6
pkgrel=1
pkgdesc="Fast and modern Javascript engine used in Google Chrome."
arch=('x86_64')
url="https://code.google.com/p/v8/"
license=('BSD')
depends=('readline' 'icu')
makedepends=('clang' 'clang-tools-extra' 'python2' 'ninja' 'git' 'wget' 'ncurses5-compat-libs')
conflicts=('v8-3.14' 'v8-3.15' 'v8-3.20' 'v8-static-gyp' 'v8-static-gyp-5.4')
CANONICAL_GIT_URL="https://chromium.googlesource.com/chromium/tools/depot_tools.git"
source=("depot_tools::git+${CANONICAL_GIT_URL}")
sha256sums=('SKIP')
COMPRESSXZ=(xz -c -z - --threads=0)
V8_DEBUG=false # is_debug
V8_OFFICIAL_BUILD=false # is_official_build
V8_I18N_SUPPORT=true # v8_enable_i18n_support: Enable ECMAScript Internationalization API - adds dependency on the ICU library.
V8_USE_SYSROOT=false # use_sysroot
V8_WARNINGS_AS_ERRORS=false # treat_warnings_as_errors
V8_STRIP_DEBUG_INFO=true # strip_debug_info
V8_IS_STATIC_BUILD=false # v8_static_library
V8_COMPONENT_BUILD=$([ "${V8_IS_STATIC_BUILD}" = true ] && echo "false" || echo "true") # is_component_build
V8_IS_CLANG=true # is_clang
case "$CARCH" in
x86_64) V8_ARCH="x64" ;;
i686) V8_ARCH="ia32" ;;
esac
# Use python2 in the makepkg build environment
trap "rm -rf $PYTHON2DIR" EXIT
PYTHON2DIR=$(mktemp -d)
ln -s "$(which python2)" "${PYTHON2DIR}"/python
ln -s "$(which python2-config)" "${PYTHON2DIR}"/python-config
export PATH="$PYTHON2DIR":"$PATH"
BUILDPATH="out.gn/$V8_ARCH.release"
prepare() {
# Add depot_tools to PATH before calling gclient, gn, etc.
export PATH=`pwd`/depot_tools:"$PATH"
if [ ! -d "${srcdir}/v8" ] ; then
msg2 "Downloading V8 source code..."
yes | fetch v8
fi
msg2 "Downloading build dependencies..."
gclient sync --revision ${pkgver}
msg2 "Generating build files"
pushd "${srcdir}/v8"
# v8gen sets up the basic environment for ninja
./tools/dev/v8gen.py "$V8_ARCH.release"
BUILDARGS="${BUILDPATH}"/args.gn
install -D /dev/null "${BUILDARGS}"
tee > "${BUILDARGS}" <<EOF
is_debug = ${V8_DEBUG}
is_official_build = ${V8_OFFICIAL_BUILD}
target_cpu = "${V8_ARCH}"
is_component_build = ${V8_COMPONENT_BUILD}
v8_static_library = ${V8_IS_STATIC_BUILD}
is_clang = ${V8_IS_CLANG}
use_sysroot = ${V8_USE_SYSROOT}
treat_warnings_as_errors= ${V8_WARNINGS_AS_ERRORS}
strip_debug_info = ${V8_STRIP_DEBUG_INFO}
EOF
# Generate the full environment for ninja using the updated flags in args.gn
gn gen "${BUILDPATH}" -vv
popd
}
build() {
msg2 "Compiling V8 source..."
pushd v8
ninja -C "${BUILDPATH}"
popd
}
check() {
pushd v8
./tools/run-tests.py --gn
popd
}
package() {
pushd v8
V8JS=opt/v8
install -d ${pkgdir}/$V8JS/{lib,include}
install -Dm755 $BUILDPATH/lib*.so ${pkgdir}/$V8JS/lib/
install -Dm755 $BUILDPATH/*_blob.bin ${pkgdir}/$V8JS/lib/
install -Dm755 $BUILDPATH/icudtl.dat ${pkgdir}/$V8JS/lib/
install -Dm644 include/*.h ${pkgdir}/$V8JS/include/
install -d ${pkgdir}/$V8JS/include/libplatform
install -Dm644 include/libplatform/*.h ${pkgdir}/$V8JS/include/libplatform/
msg2 "Done building $pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT"
msg2 "Build PHP V8JS with `$ configure --with-v8js=/$V8JS --LDFLAGS=\"-lstdc++\"`"
popd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment