Skip to content

Instantly share code, notes, and snippets.

@b1tninja
Last active November 9, 2019 23:16
Show Gist options
  • Save b1tninja/4db2a5b37f056d34ebe24cdafe5e4714 to your computer and use it in GitHub Desktop.
Save b1tninja/4db2a5b37f056d34ebe24cdafe5e4714 to your computer and use it in GitHub Desktop.
gcc-python-plugin
# Maintainer: Nicolas Iooss (nicolas <dot> iooss <at> m4x <dot> org)
# Contributor: Justin Capella (justin <dot> capella <at> gmail <dot> com)
pkgbase="gcc-python-plugin"
pkgname=('gcc-python-plugin-git' 'gcc-python-plugin-c-api' 'gcc-python-plugin-doc')
pkgver=v0.17.r6.g8276f91
pkgrel=1
pkgdesc="GCC plugin that embeds CPython inside the compiler"
arch=('i686' 'x86_64')
url='https://gcc-python-plugin.readthedocs.io/en/latest/'
license=('GPL3')
makedepends=('python-lxml' 'python-pygments' 'python-six' 'python-sphinx')
source=("${pkgbase}::git+https://github.com/davidmalcolm/gcc-python-plugin.git")
sha256sums=('SKIP')
pkgver() {
cd "${pkgbase}"
git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}
#prepare() {
# cp -a "${pkgbase}" -t "${}"
#}
build() {
GCCPLUGINS_DIR="$(${CC:-gcc} --print-file-name=plugin)"
make -C "${pkgbase}" plugin man html \
PLUGIN_NAME=python PYTHON=python PYTHON_CONFIG=python-config \
PLUGIN_PYTHONPATH="$GCCPLUGINS_DIR/python"
}
check() {
pushd "${pkgbase}"
# This test fails with Python 3. Ignore it.
LD_LIBRARY_PATH=gcc-c-api PLUGIN_NAME=python python run-test-suite.py || :
LD_LIBRARY_PATH=gcc-c-api PLUGIN_NAME=python python testcpychecker.py -v
popd
}
package_gcc-python-plugin-git() {
provide=('gcc-python-plugin')
conflicts=('gcc-python-plugin')
depends=('python-lxml' 'python-pygments' 'python-six' 'gcc-python-plugin-c-api')
optdepends=('graphviz: for examples')
cd "${pkgbase}"
GCCPLUGINS_DIR="$(${CC:-gcc} --print-file-name=plugin)"
make DESTDIR="${pkgdir}" install \
PLUGIN_NAME=python PYTHON=python PYTHON_CONFIG=python-config \
PLUGIN_PYTHONPATH="$GCCPLUGINS_DIR/python"
rm "${pkgdir}/$(${CC:-gcc} --print-file-name=plugin)/libgcc-c-api.so"
}
package_gcc-python-plugin-c-api() {
cd "${pkgbase}"
# Install only once the library which is provided by both versions
GCCPLUGINS_DIR="$(${CC:-gcc} --print-file-name=plugin)"
install -Dm755 gcc-c-api/libgcc-c-api.so "${pkgdir}/$GCCPLUGINS_DIR/libgcc-c-api.so"
}
package_gcc-python-plugin-doc() {
cd "${pkgbase}"
mkdir -p "${pkgdir}/usr/share/doc/$pkgbase"
cp -r docs/_build/html examples "$pkgdir/usr/share/doc/${pkgbase}/"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment