Skip to content

Commit

Permalink
Move python bootstrap to its own file, more mod audio build stuff
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Sep 21, 2023
1 parent 833c32f commit 40327ed
Show file tree
Hide file tree
Showing 6 changed files with 425 additions and 236 deletions.
200 changes: 1 addition & 199 deletions bootstrap-carla.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fi
./bootstrap-plugins.sh "${target}"

if [ -z "${PAWPAW_SKIP_QT}" ]; then
./bootstrap-python.sh "${target}"
./bootstrap-qt.sh "${target}"
fi

Expand All @@ -48,76 +49,6 @@ if [ -n "${PAWPAW_SKIP_QT}" ]; then
exit 0
fi

# ---------------------------------------------------------------------------------------------------------------------
# custom function for python

function build_conf_python() {
local name="${1}"
local version="${2}"
local extraconfrules="${3}"

local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"

if [ -n "${TOOLCHAIN_PREFIX}" ]; then
extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=$(gcc -dumpmachine)"
fi

_prebuild "${name}" "${pkgdir}"

# remove flags not compatible with python
export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fvisibility=hidden//')"
export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-ffast-math//')"
export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
export CFLAGS="$(echo ${CFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip,-dead_strip_dylibs,-x//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-O1,--gc-sections,--no-undefined//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--as-needed,--strip-all//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fno-strict-aliasing -flto//')"

# add host/native binaries to path
if [ "${CROSS_COMPILING}" -eq 1 ]; then
export PATH="${PAWPAW_PREFIX}-host/bin:${PATH}"
fi

if [ "${WIN32}" -eq 1 ] && [ ! -f "${pkgdir}/.stamp_preconfigured" ]; then
pushd "${pkgdir}"
autoreconf -vfi
touch .stamp_preconfigured
popd
fi

if [ ! -f "${pkgdir}/.stamp_configured" ]; then
pushd "${pkgdir}"
./configure ${extraconfrules}
touch .stamp_configured
popd
fi

if [ ! -f "${pkgdir}/.stamp_built" ]; then
pushd "${pkgdir}"
# if [ "${WIN32}" -eq 1 ]; then
# # inject exe-wrapper
# if [ -n "${EXE_WRAPPER}" ]; then
# sed -i -e "s|\t./Programs/_freeze_importlib|\t${EXE_WRAPPER} ./Programs/_freeze_importlib|" Makefile
# fi
# make regen-importlib
# fi
make ${MAKE_ARGS}
touch .stamp_built
popd
fi

if [ ! -f "${pkgdir}/.stamp_installed" ]; then
pushd "${pkgdir}"
make ${MAKE_ARGS} -j 1 install
touch .stamp_installed
popd
fi

_postbuild
}

# ---------------------------------------------------------------------------------------------------------------------
# custom function for sip and pyqt packages

Expand Down Expand Up @@ -208,78 +139,6 @@ function build_pyqt() {
unset LINK
}

# ---------------------------------------------------------------------------------------------------------------------
# wine bootstrap for python (needed for cross-compilation)

if [ "${WIN32}" -eq 1 ] && [ -n "${EXE_WRAPPER}" ] && [ ! -d "${WINEPREFIX}" ]; then
wineboot -u
fi

# ---------------------------------------------------------------------------------------------------------------------
# python

# build for host first
if [ "${CROSS_COMPILING}" -eq 1 ]; then
download host-Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz" "" Python
build_host_autoconf host-Python "${PYTHON_VERSION}" "--build=$(gcc -dumpmachine) --prefix=${PAWPAW_PREFIX}-host"

# sed -i -e "s|${PAWPAW_PREFIX}-host|${PAWPAW_PREFIX}|" "${PAWPAW_PREFIX}-host/bin/python3.8-config"

# # FIXME
# mkdir -p "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools"
# ln -sf "${PAWPAW_PREFIX}-host/bin" "${PAWPAW_PREFIX}-host/lib/python3.8/config-3.8-x86_64-linux-gnu/Tools/scripts"

# # may be available in host, but not in build target
# if [ "${WIN32}" -eq 1 ] && [ ! -e "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e" ]; then
# sed -i -e '/HAVE_CRYPT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
# sed -i -e '/HAVE_CRYPT_R/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
# sed -i -e '/HAVE_SYS_SELECT_H/d' "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h"
# touch "${PAWPAW_PREFIX}-host/include/python3.8/pyconfig.h-e"
# fi
fi

PYTHON_EXTRAFLAGS=""

if [ "${MACOS}" -eq 1 ]; then
if [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
PYTHON_EXTRAFLAGS+=" --enable-optimizations"
PYTHON_EXTRAFLAGS+=" ac_cv_lib_intl_textdomain=no"
PYTHON_EXTRAFLAGS+=" ac_cv_header_libintl_h=no"
PYTHON_EXTRAFLAGS+=" ac_cv_func_setlocale=no"
fi
PYTHON_EXTRAFLAGS+=" ac_cv_func_futimens=no"
PYTHON_EXTRAFLAGS+=" ac_cv_func_preadv=no"
PYTHON_EXTRAFLAGS+=" ac_cv_func_pwritev=no"
PYTHON_EXTRAFLAGS+=" ac_cv_func_sendfile=no"
PYTHON_EXTRAFLAGS+=" ac_cv_func_utimensat=no"
elif [ "${WIN32}" -eq 1 ]; then
export EXTRA_CFLAGS=" -fwrapv -D_WIN32_WINNT=0x0601"
export EXTRA_CXXFLAGS=" -fwrapv -D_WIN32_WINNT=0x0601"
PYTHON_EXTRAFLAGS="--with-nt-threads"
PYTHON_EXTRAFLAGS+=" --without-ensurepip"
PYTHON_EXTRAFLAGS+=" --without-c-locale-coercion"
# Workaround for conftest error on 64-bit builds
PYTHON_EXTRAFLAGS+=" ac_cv_working_tzset=no"
# Workaround for when dlfcn exists on Windows, which causes
# some conftests to succeed when they shouldn't (we don't use dlfcn).
PYTHON_EXTRAFLAGS+=" ac_cv_header_dlfcn_h=no"
PYTHON_EXTRAFLAGS+=" ac_cv_lib_dl_dlopen=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_GLOBAL=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LAZY=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_LOCAL=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOW=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_DEEPBIND=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_MEMBER=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NODELETE=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOLOAD=no"
fi

download Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz"
if [ "${PYTHON_VERSION}" = "3.7.4" ]; then
patch_file Python "${PYTHON_VERSION}" "Modules/Setup.dist" 's/#zlib zlibmodule.c/zlib zlibmodule.c/'
fi
build_conf_python Python "${PYTHON_VERSION}" "--prefix=${PAWPAW_PREFIX} --enable-shared ${PYTHON_EXTRAFLAGS}"

# ---------------------------------------------------------------------------------------------------------------------
# sip

Expand Down Expand Up @@ -330,14 +189,6 @@ if [ "${CROSS_COMPILING}" -eq 1 ]; then
unset PKG_CONFIG_SYSROOT_DIR
fi

# ---------------------------------------------------------------------------------------------------------------------
# cython (optional)

if [ -n "${CYTHON_VERSION}" ]; then
download Cython "${CYTHON_VERSION}" "https://files.pythonhosted.org/packages/6c/9f/f501ba9d178aeb1f5bf7da1ad5619b207c90ac235d9859961c11829d0160"
build_python Cython "${CYTHON_VERSION}"
fi

# ---------------------------------------------------------------------------------------------------------------------
# pyliblo

Expand All @@ -363,52 +214,3 @@ if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then
fi

# ---------------------------------------------------------------------------------------------------------------------
# setuptools_scm (optional)

if [ -n "${SETUPTOOLS_SCM_VERSION}" ]; then
download setuptools_scm "${SETUPTOOLS_SCM_VERSION}" "https://files.pythonhosted.org/packages/ed/b6/979bfa7b81878b2b4475dde092aac517e7f25dd33661796ec35664907b31"
build_python setuptools_scm "${SETUPTOOLS_SCM_VERSION}"
fi

# ---------------------------------------------------------------------------------------------------------------------
# toml (optional)

if [ -n "${TOML_VERSION}" ]; then
download toml "${TOML_VERSION}" "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c"
build_python toml "${TOML_VERSION}"
fi

# ---------------------------------------------------------------------------------------------------------------------
# zipp (optional)

if [ -n "${ZIPP_VERSION}" ]; then
download zipp "${ZIPP_VERSION}" "https://files.pythonhosted.org/packages/ce/b0/757db659e8b91cb3ea47d90350d7735817fe1df36086afc77c1c4610d559"
build_python zipp "${ZIPP_VERSION}"
fi

# ---------------------------------------------------------------------------------------------------------------------
# importlib_metadata (optional)

if [ -n "${IMPORTLIB_METADATA_VERSION}" ]; then
download importlib_metadata "${IMPORTLIB_METADATA_VERSION}" "https://files.pythonhosted.org/packages/f8/41/8ffb059708359ea14a3ec74a99a2bf0cd44a0c983a0c480d9eb7a69438bb"
build_python importlib_metadata "${IMPORTLIB_METADATA_VERSION}"
fi

# ---------------------------------------------------------------------------------------------------------------------
# cxfreeze

git_clone cx_Freeze "${CXFREEZE_VERSION}" "https://github.com/anthony-tuininga/cx_Freeze.git"
build_python cx_Freeze "${CXFREEZE_VERSION}"

if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then
PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
if [ ! -e "${PYTHONPATH}/cx_Freeze" ]; then
ln -sv "${PYTHONPATH}"/cx_Freeze-*.egg/cx_Freeze "${PYTHONPATH}/cx_Freeze"
fi
if [ ! -e "${PYTHONPATH}/cx_Freeze/util.pyd" ]; then
ln -sv "$(realpath "${PYTHONPATH}/cx_Freeze"/util.*)" "${PYTHONPATH}/cx_Freeze/util.pyd"
fi
unset PYTHONPATH
fi

# ---------------------------------------------------------------------------------------------------------------------
75 changes: 75 additions & 0 deletions bootstrap-mod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

set -e

cd $(dirname ${0})
PAWPAW_ROOT="${PWD}"

# ---------------------------------------------------------------------------------------------------------------------
# check target

target="${1}"

if [ -z "${target}" ]; then
echo "usage: ${0} <target>"
exit 1
fi

# ---------------------------------------------------------------------------------------------------------------------
# source setup code

source setup/check_target.sh
source setup/env.sh
source setup/functions.sh
source setup/versions.sh

# ---------------------------------------------------------------------------------------------------------------------
# run bootstrap dependencies

./bootstrap-common.sh "${target}"
./bootstrap-jack2.sh "${target}"
./bootstrap-plugins.sh "${target}"
./bootstrap-python.sh "${target}"

# ---------------------------------------------------------------------------------------------------------------------
# jack2

JACK2_EXTRAFLAGS=""

if [ "${CROSS_COMPILING}" -eq 1 ]; then
if [ "${LINUX}" -eq 1 ]; then
JACK2_EXTRAFLAGS+=" --platform=linux"
elif [ "${MACOS}" -eq 1 ]; then
JACK2_EXTRAFLAGS+=" --platform=darwin"
elif [ "${WIN32}" -eq 1 ]; then
JACK2_EXTRAFLAGS+=" --platform=win32"
fi
fi

if [ "${WIN32}" -eq 1 ]; then
JACK2_EXTRAFLAGS+=" --static"
fi

JACK2_VERSION="250420381b1a6974798939ad7104ab1a4b9a9994"
JACK2_URL="https://github.com/jackaudio/jack2.git"

download jack2 "${JACK2_VERSION}" "${JACK2_URL}" "" "git"
build_waf jack2 "${JACK2_VERSION}" "${JACK2_EXTRAFLAGS}"

# ---------------------------------------------------------------------------------------------------------------------
# aggdraw

AGGDRAW_VERSION="1.3.11"

download aggdraw "${AGGDRAW_VERSION}" "https://files.pythonhosted.org/packages/ef/29/fddf555c68920bb0aff977425af786226db2a78379e706951ff32b4492ef"
build_python aggdraw "${AGGDRAW_VERSION}"

# ---------------------------------------------------------------------------------------------------------------------
# tornado

TORNADO_VERSION="4.3"

download tornado "${TORNADO_VERSION}" "https://files.pythonhosted.org/packages/21/29/e64c97013e97d42d93b3d5997234a6f17455f3744847a7c16289289f8fa6"
build_python tornado "${TORNADO_VERSION}"

# ---------------------------------------------------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion bootstrap-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ else
CAIRO_EXTRAFLAGS+=" --disable-xcb"
CAIRO_EXTRAFLAGS+=" --disable-xlib-xcb"
CAIRO_EXTRAFLAGS+=" --disable-xcb-shm"
CAIRO_EXTRAFLAGS+=" ax_cv_c_float_words_bigendian=no"
fi

if [ "${MACOS}" -eq 1 ]; then
Expand All @@ -259,7 +260,6 @@ fi
if [ "${WIN32}" -eq 1 ]; then
CAIRO_EXTRAFLAGS+=" --enable-win32"
CAIRO_EXTRAFLAGS+=" --enable-win32-font"
CAIRO_EXTRAFLAGS+=" ax_cv_c_float_words_bigendian=no"
else
CAIRO_EXTRAFLAGS+=" --disable-win32"
CAIRO_EXTRAFLAGS+=" --disable-win32-font"
Expand Down
Loading

0 comments on commit 40327ed

Please sign in to comment.