mirror of
https://github.com/namecoin/ncdns-repro
synced 2024-11-13 19:12:01 +00:00
3ee637e39f
To match style of the rest of tor-browser-build. Thanks boklm for review.
94 lines
4.2 KiB
Bash
94 lines
4.2 KiB
Bash
#!/bin/bash
|
|
[% c("var/set_default_env") -%]
|
|
distdir=/var/tmp/dist/[% project %]
|
|
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
|
|
# Set up compiler
|
|
|
|
shopt -s globstar
|
|
|
|
# Required for "import ssl"
|
|
tar -C /var/tmp/dist -xf [% c('input_files_by_name/openssl') %]
|
|
openssldir=/var/tmp/dist/openssl/openssl
|
|
cp -a $openssldir/include/openssl /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/include/openssl
|
|
cp -a $openssldir/lib/* $openssldir/bin/*.dll /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/lib/
|
|
|
|
# Required for "import ctypes"
|
|
tar -C /var/tmp/dist -xf [% c('input_files_by_name/libffi-src') %]
|
|
pushd /var/tmp/dist/*libffi*
|
|
# The Python devs got high on LSD and appear to have committed the libffi
|
|
# source code from a Windows machine, which stripped off all the +x bits.
|
|
# Kids, drugs and coding don't mix.
|
|
chmod -R +x ./
|
|
./configure --host=[% c("arch") %]-w64-mingw32
|
|
# Always errors on this step, but still produces the .dll files we want.
|
|
make || true
|
|
cp ./[% c("arch") %]-w64-mingw32/include/*.h /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/include
|
|
cp ./[% c("arch") %]-w64-mingw32/.libs/* /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/lib/
|
|
popd
|
|
|
|
# Unpack dependencies
|
|
mkdir -p /var/tmp/build
|
|
tar -C /var/tmp/build -xf [% c('input_files_by_name/python') %]
|
|
tar -C /var/tmp/build -xf [% c('input_files_by_name/meson') %]
|
|
tar -C /var/tmp/build -xf [% c('input_files_by_name/ninja') %]
|
|
tar -C /var/tmp/build -xf [% c('input_files_by_name/python-buildscript') %]
|
|
# Add dependencies to PATH
|
|
PATH=/var/tmp/build/meson-[% c("meson_version") %]:"$PATH"
|
|
PATH=/var/tmp/build/ninja:"$PATH"
|
|
|
|
# Python includes build timestamp by default
|
|
patch /var/tmp/build/Python-[% c("version") %]/Modules/getbuildinfo.c < $rootdir/omit-build-timestamp.patch
|
|
# Patch build script to statically link pthread
|
|
patch /var/tmp/build/cross-python-[% c("cp_githash") %]/meson.build << 'EOF'
|
|
113c113
|
|
< add_project_link_arguments('-municode', '-mconsole', '-static-libgcc', language:'c')
|
|
---
|
|
> add_project_link_arguments('-municode', '-mconsole', '-static-libgcc', '-Wl,-Bstatic', '-lwinpthread', '-Wl,-Bdynamic', language:'c')
|
|
1076c1076
|
|
< python_libraries = both_libraries(
|
|
---
|
|
> libpython = shared_library(
|
|
1086,1087d1085
|
|
<
|
|
< libpython = python_libraries.get_shared_lib()
|
|
EOF
|
|
# Prepare libwinpthread for static linking
|
|
# This is a hack. (TODO: refactor)
|
|
# We need to link this statically, because we aren't shipping the mingw runtime.
|
|
# https://stackoverflow.com/questions/14665691/static-linking-with-libwinpthread
|
|
ranlib /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/lib/libwinpthread.a
|
|
|
|
# Project pulls in sqlite, zlib, and build files.
|
|
# Download them outside, in rbm, to avoid container network access.
|
|
mkdir -p /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache
|
|
cp [% c('input_files_by_name/sqlite-src') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/sqlite-amalgamation-3250100.zip
|
|
cp [% c('input_files_by_name/sqlite-patch') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/sqlite-3250100-1-wrap.zip
|
|
cp [% c('input_files_by_name/zlib-src') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/zlib-1.2.11.tar.gz
|
|
cp [% c('input_files_by_name/zlib-patch') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/zlib-1.2.11-4-wrap.zip
|
|
|
|
# Enter the build directory
|
|
cd /var/tmp/build/cross-python-[% c("cp_githash") %]
|
|
|
|
# cf. ./configure
|
|
LDFLAGS="-Wl,--no-insert-timestamp" meson.py -Dsource=../Python-[% c("version") %] --cross-file cross-files/[% c("arch") %]-w64-mingw32.txt --prefix=$distdir builddir
|
|
# cf. make
|
|
ninja -C builddir
|
|
# cf. make install
|
|
ninja -C builddir install
|
|
|
|
# These files don't reproduce, and are useless
|
|
find $distdir -name '*.a' -exec rm '{}' +
|
|
|
|
# Required for "import ssl" and "import ctypes"
|
|
cp $openssldir/bin/*.dll /var/tmp/dist/*libffi*/[% c("arch") %]-w64-mingw32/.libs/*.dll $gcclibs/*.dll $distdir/bin/
|
|
|
|
# Delete unit tests to save space (71 to 49 MB)
|
|
cd $distdir/bin
|
|
rm -rf ./**/test ./**/tests ./**/test_*
|
|
|
|
cd /var/tmp/dist
|
|
[% c('tar', {
|
|
tar_src => [ project ],
|
|
tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
|
|
}) %]
|