Skip to content

Commit

Permalink
Added helper scripts to build Windows version using Vagrant.
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Jul 17, 2015
1 parent 5a33014 commit 42a6abe
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -52,3 +52,8 @@ build-*
contrib-*
install-*

# Ignore libde265 specific entries
.ccache/
.vagrant/
build_result/
scripts/vagrant/apt-cacher.conf
33 changes: 33 additions & 0 deletions Vagrantfile
@@ -0,0 +1,33 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

config.vm.define "linux-64bit" do |linux64bit|
linux64bit.vm.box = "ubuntu/vivid64"

linux64bit.vm.provision "shell", path: "scripts/vagrant/001_bootstrap.sh"
linux64bit.vm.provision "shell", path: "scripts/vagrant/010_checkout.sh", privileged: false
linux64bit.vm.provision "shell", path: "scripts/vagrant/020_dependencies.sh", privileged: false
linux64bit.vm.provision "shell", path: "scripts/vagrant/030_compile.sh", privileged: false
linux64bit.vm.provision "shell", path: "scripts/vagrant/040_package.sh", privileged: false
end

# Using a private network caused very slow network performance against the
# local apt-cacher proxy.
config.vm.network "public_network", bridge: "eth0"

config.vm.provider "virtualbox" do |vb|
# Don't show the VirtualBox GUI when booting the machine.
vb.gui = false

# I/O APIC must be enabled to support more than 1 cpu on 32bit systems
# http://makandracards.com/jan0sch/24843-vagrant-virtualbox-32bit-systems-and-more-than-one-cpu
vb.customize ["modifyvm", :id, "--ioapic", "on"]

# Use multiple cpus to speed up building.
vb.memory = 4096
vb.cpus = 8
end

end
79 changes: 79 additions & 0 deletions scripts/vagrant/001_bootstrap.sh
@@ -0,0 +1,79 @@
#!/bin/bash
set -eu

# switch to German mirrors
sed 's/http:\/\/archive/http:\/\/de.archive/g' -i /etc/apt/sources.list

# enable "multiverse" repository
sed 's/ universe$/ universe multiverse/g' -i /etc/apt/sources.list

# setup proxy to apt-cacher (if available)
if [ -f "/vagrant/scripts/vagrant/apt-cacher.conf" ]; then
cp /vagrant/scripts/vagrant/apt-cacher.conf /etc/apt/apt.conf.d/01proxy
fi

# enable i386 architecture (required for wine)
dpkg --add-architecture i386
sed 's/deb http/deb [arch=amd64,i386] http/g' -i /etc/apt/sources.list

# "accept" the mscorefonts eula
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections

# update package information
apt-get -y update

# install basic requirements
if [ ! -x "/usr/bin/eatmydata" ]; then
apt-get -y install eatmydata
fi
eatmydata apt-get -y install git ccache

# setup ccache
CCACHE_DIR=/vagrant/.ccache
if [ ! -d ${CCACHE_DIR} ]; then
mkdir -p ${CCACHE_DIR}; \
CCACHE_DIR=/vagrant/.ccache /usr/bin/ccache --max-size=4G;
chown -R vagrant:vagrant ${CCACHE_DIR};
fi
if ! grep -q CCACHE_DIR /etc/environment ; then
echo "CCACHE_DIR=${CCACHE_DIR}" >> /etc/environment ;
fi
if ! grep -q CCACHE_COMPRESS /etc/environment ; then
echo "CCACHE_COMPRESS=1" >> /etc/environment ;
fi
if ! grep -q CCACHE_COMPILERCHECK /etc/environment ; then
echo "CCACHE_COMPILERCHECK=content" >> /etc/environment ;
fi
sed 's/PATH="\/usr\/local/PATH="\/usr\/lib\/ccache:\/usr\/local/g' -i /etc/environment

# create file that can be sourced by other scripts to setup environment
if [ ! -f "/vagrant.env" ]; then
for line in $( cat /etc/environment ) ; do echo "export $line" >> /vagrant.env ; done
fi

# install build requirements
PACKAGES="\
autoconf \
libtool \
gettext \
nsis \
p7zip-full \
dos2unix \
subversion \
qt4-dev-tools \
wine-dev \
gcc-mingw-w64-i686 \
g++-mingw-w64-i686 \
mingw-w64-tools \
gcc-mingw-w64-x86-64 \
g++-mingw-w64-x86-64 \
mingw-w64-tools"

echo "Installing packages..."
eatmydata apt-get -y install ${PACKAGES}

# make sure all compilers are linked through ccache
/usr/sbin/update-ccache-symlinks

echo "Prepare for static linking..."
/vagrant/scripts/vagrant/prepare_static_linking.sh
15 changes: 15 additions & 0 deletions scripts/vagrant/010_checkout.sh
@@ -0,0 +1,15 @@
#!/bin/bash
set -eu

if [ -f "/vagrant.env" ]; then
. /vagrant.env
fi

# start from scratch (we are using ccache to speed up compilation)
rm -rf vlc
mkdir -p vlc
cd vlc

echo "Copy contents of git repository..."
( cd /vagrant && git archive --format=tar HEAD ) | tar xf -
cp -rf /vagrant/.git .
37 changes: 37 additions & 0 deletions scripts/vagrant/020_dependencies.sh
@@ -0,0 +1,37 @@
#!/bin/bash
set -eu

if [ -f "/vagrant.env" ]; then
. /vagrant.env
fi

PREBUILT_VERSION=20150519

cd vlc

function prepare_dependencies {
ARCH=$1

echo "Prepare dependencies for ${ARCH} version..."
mkdir -p contrib/win32
pushd contrib/win32
../bootstrap --host=${ARCH}-w64-mingw32
sed -i "s/-latest.tar/-${PREBUILT_VERSION}.tar/g" Makefile
CACHE_FILE=vlc-contrib-${ARCH}-w64-mingw32-${PREBUILT_VERSION}.tar.bz2
if [ -f "/vagrant/.cache/${CACHE_FILE}" ]; then
cp /vagrant/.cache/${CACHE_FILE} .
fi
eatmydata make prebuilt
eatmydata make .libde265 -j8
if [ ! -f "/vagrant/.cache/${CACHE_FILE}" ]; then
mkdir -p /vagrant/.cache/
cp ${CACHE_FILE} /vagrant/.cache/
fi
if [ "${ARCH}" = "i686" ]; then
rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc
fi
popd
}

prepare_dependencies i686
prepare_dependencies x86_64
35 changes: 35 additions & 0 deletions scripts/vagrant/030_compile.sh
@@ -0,0 +1,35 @@
#!/bin/bash
set -eu

if [ -f "/vagrant.env" ]; then
. /vagrant.env
fi

echo "Performing bootstrap..."

cd vlc
./bootstrap

CONFIGURE_FLAGS=""

function compile {
ARCH=$1
if [ "${ARCH}" = "i686" ]; then
WIN="win32"
fi
if [ "${ARCH}" = "x86_64" ]; then
WIN="win64"
fi

echo "Build ${ARCH} version..."
rm -rf ${WIN}
mkdir -p ${WIN}
pushd ${WIN}
export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/${ARCH}-w64-mingw32/lib/pkgconfig:$HOME/vlc/contrib/${WIN}/libde265
eatmydata ../extras/package/win32/configure.sh --host=${ARCH}-w64-mingw32 ${CONFIGURE_FLAGS}
eatmydata make -j8
popd
}

compile i686
compile x86_64
29 changes: 29 additions & 0 deletions scripts/vagrant/040_package.sh
@@ -0,0 +1,29 @@
#!/bin/bash
set -eu

if [ -f "/vagrant.env" ]; then
. /vagrant.env
fi

cd vlc

NOW=`date +%Y%m%d-%H%M%S`

function package {
WIN=$1

echo "Build ${WIN} installer..."
pushd ${WIN}
eatmydata make fetch-npapi
(cd npapi-vlc && git submodule init && git submodule update )
eatmydata make package-win32 -j8

mkdir -p /vagrant/build_result/${NOW}
cp *-${WIN}* /vagrant/build_result/${NOW}/
popd
}

package win32
package win64

echo "Done, packages have been copied to build_result/${NOW}"
29 changes: 29 additions & 0 deletions scripts/vagrant/prepare_static_linking.sh
@@ -0,0 +1,29 @@
#!/bin/bash

# This script enforces statically linking of libgcc, libstdc++-6, and libpthread,
# without needing to rebuild gcc and mingw-w64 from scratch.
# -static-libgcc -static-libstdc++ flags can not be used in a libtool build system,
# as libtool removes flags that it doesn't understand.

move() {
[ -f $1 ] || return 1
mkdir -p old/
mv -v $* old/
return 0
}

for x in i686 x86_64
do
library_path_list=`$x-w64-mingw32-gcc -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2|sort|uniq`
IFS=':'
for i in $library_path_list
do
cd $i
move libstdc++-6.dll libstdc++.dll.a libgcc_s.a libgcc_s_sjlj-1.dll && ln -s libgcc_eh.a libgcc_s.a
move libpthread.dll.a libwinpthread.dll.a
move libwinpthread-1.dll
[ -d ../bin ] && cd ../bin && move libwinpthread-1.dll
done
done

exit 0

0 comments on commit 42a6abe

Please sign in to comment.