Commit 0f0d7ff5 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang

win32: integrate python scripts for native build

Change-Id: I8d6598b9739f04e5c64c8236740091786222a33a
parent b0e2d411
This diff is collapsed.
# Install Choco
Set-ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString("https://chocolatey.org/install.ps1"))
if( $LASTEXITCODE -eq 0 ) {
write-host "Choco Installation Succeeded" -ForegroundColor Green
} else {
write-host "Choco Installation Failed" -ForegroundColor Red
exit $LASTEXITCODE
}
# Install 7zip, unzip, wget --version 1.19.4, cmake, git --version 2.10.2
# pandoc, strawberryperl, msys2
# Note that: msys2 installes at C:/tools/msys64
Function choco_pack_install($packages) {
Foreach ($i in $packages){
if($i -eq 'wget'){
iex ("choco install -fy --allow-downgrade '$i' --version 1.19.4 --acceptlicense")
} elseif ($i -eq 'git.install') {
iex ("choco install -fy --allow-downgrade '$i' --version 2.10.2 --acceptlicense")
} else {
iex ("choco install -fy '$i' --acceptlicense")
}
if( $LASTEXITCODE -ne 0 ) {
write-host "Choco Packages Installation Failed" -ForegroundColor Red
exit 1
}
}
write-host "Choco Packages Installation Succeeded" -ForegroundColor Green
}
$packages = [System.Collections.Generic.List[System.Object]]('wget', 'git.install', '7zip', 'unzip', 'cmake', 'pandoc', 'strawberryperl', 'msys2')
if(Test-Path -Path "C:\Program Files\CMake\bin"){
# file with path $path does exist
$null = $packages.Remove('cmake')
write-host "Cmake installed" -ForegroundColor Green
}
if(Test-Path -Path "C:\Strawberry"){
$null = $packages.Remove('strawberryperl')
write-host "Strawberry Perl installed" -ForegroundColor Green
}
if(!(Test-Path -Path "C:\msys64")){
if(!(Test-Path -Path "C:\tools\msys64")){
$Env:Path += ";C:\tools\msys64\usr\bin"
$msys2_path = "C:\tools\msys64\usr\bin"
}
} else {
$null = $packages.Remove('msys2')
write-host "MSYS2 64 installed" -ForegroundColor Green
$Env:Path += ";C:\msys64\usr\bin"
$msys2_path = "C:\msys64\usr\bin"
}
choco_pack_install($packages)
# Web installed msys2_64 bit to install make, gcc, perl, diffutils
Function pacman_pack_install($packages) {
Foreach ($i in $packages){
iex ("pacman -S '$i' --noconfirm")
if( $LASTEXITCODE -ne 0 ) {
write-host "Pacman Packages Installation Failed" -ForegroundColor Red
exit 1
}
}
write-host "Pacman Packages Installation Succeeded" -ForegroundColor Green
}
$packages = [System.Collections.Generic.List[System.Object]]('make', 'gcc', 'perl', 'diffutils')
pacman_pack_install($packages)
# Web Download VSNASM, VSYASM
Function download_file_to_temp($download_name, $url, $output_name) {
write-host "Downloading $download_name" -ForegroundColor Yellow
$output = $env:TEMP + "\$output_name"
(New-Object System.Net.WebClient).DownloadFile($url, $output)
if( $LASTEXITCODE -eq 0 ) {
write-host "Download $download_name Succeeded" -ForegroundColor Green
} else {
write-host "Download $download_name Failed" -ForegroundColor Red
exit $LASTEXITCODE
}
}
download_file_to_temp 'VSNASM' "https://github.com/ShiftMediaProject/VSNASM/releases/download/0.5/VSNASM.zip" 'VSNASM.zip'
download_file_to_temp 'VSYASM' "https://github.com/ShiftMediaProject/VSYASM/releases/download/0.4/VSYASM.zip" 'VSYASM.zip'
# Unzip VSNASM.zip, VSYASM.zip
Function unzip_file_from_temp($unzip_name, $zip_file_name, $unzip_file_output_name) {
write-host "Unzip $unzip_name" -ForegroundColor Yellow
$zip_path = $env:TEMP + "\$zip_file_name"
$unzip_path = $env:TEMP + "\$unzip_file_output_name"
iex("unzip -o $zip_path -d $unzip_path")
if( $LASTEXITCODE -eq 0 ) {
write-host "Unzip $unzip_name Succeeded" -ForegroundColor Green
} else {
write-host "Unzip $unzip_name Failed" -ForegroundColor Red
exit $LASTEXITCODE
}
}
unzip_file_from_temp 'VSNASM' 'VSNASM.zip' 'VSNASM_UNZIP'
unzip_file_from_temp 'VSYASM' 'VSYASM.zip' 'VSYASM_UNZIP'
# Generate nasm(VS), yasm.exe (VS)
Function run_batch($batch_cmd, $task_desp) {
write-host $task_desp -ForegroundColor Yellow
Start-Process "cmd.exe" $batch_cmd -Wait -NoNewWindow
if( $LASTEXITCODE -eq 0 ) {
write-host "$task_desp Succeeded" -ForegroundColor Green
} else {
write-host "$task_desp Failed" -ForegroundColor Red
exit $LASTEXITCODE
}
}
$batch_path = "/c set ISINSTANCE=1 && " + $env:TEMP + "\VSNASM_UNZIP\install_script.bat"
run_batch $batch_path "Generate nasm(VS)"
$batch_path = "/c set ISINSTANCE=1 &&" + $env:TEMP + "\VSYASM_UNZIP\install_script.bat"
run_batch $batch_path "Generate yasm(VS)"
# Web Download gas-preprocessor.pl, yasm.exe (win64)
download_file_to_temp 'yasm.exe (win64)' "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe" 'yasm.exe'
download_file_to_temp 'gas-preprocessor.pl' "https://github.com/FFmpeg/gas-preprocessor/blob/master/gas-preprocessor.pl" 'gas-preprocessor.pl'
# Move gas-preprocessor.pl, yasm.exe into msys64
Function move_file_from_temp_to_msys64($file_name, $task_desp) {
write-host $task_desp -ForegroundColor Yellow
$file_path = $env:TEMP + "\$file_name"
Move-item -Path $file_path -Destination $msys2_path -Force
if( $LASTEXITCODE -eq 0 ) {
write-host "$task_desp Succeeded" -ForegroundColor Green
} else {
write-host "$task_desp Failed" -ForegroundColor Red
exit $LASTEXITCODE
}
}
move_file_from_temp_to_msys64 'gas-preprocessor.pl' 'Move gas-preprocessor.pl to msys64 folder'
move_file_from_temp_to_msys64 'yasm.exe' 'Move yasm.exe (win64) to msys64 folder'
write-host "Dependencies Built Finished" -ForegroundColor Green
\ No newline at end of file
import argparse
import subprocess
import os
import sys
this_dir = os.path.dirname(os.path.realpath(__file__))
def execute_cmd(cmd, with_shell=False):
p = subprocess.Popen(cmd, shell=with_shell)
_, perr = p.communicate()
if perr:
return 1
return 0
def build_daemon(parsed_args):
make_cmd = os.path.dirname(this_dir) + '\\daemon\\msvc\\winmake.py'
return execute_cmd('python ' + make_cmd + ' -iv -t ' + parsed_args.toolset + ' -s ' + parsed_args.sdk + ' -b daemon')
def build_lrc(parsed_args):
make_cmd = os.path.dirname(this_dir) + '\\lrc\\make-lrc.py'
return execute_cmd('python ' + make_cmd + ' -gb ' + ' -t ' + parsed_args.toolset + ' -s ' + parsed_args.sdk)
def build_client(parsed_args):
os.chdir('./client-windows')
ret = 0
ret &= not execute_cmd('pandoc -f markdown -t html5 -o changelog.html changelog.md', True)
ret &= not execute_cmd('python make-client.py -d')
ret &= not execute_cmd('python make-client.py -b ' + '-t ' + parsed_args.toolset + ' -s ' + parsed_args.sdk)
if not os.path.exists('./x64/Release/qt.conf'):
ret &= not execute_cmd(
'powershell -ExecutionPolicy Unrestricted -File copy-runtime-files.ps1', True)
return ret
def parse_args():
ap = argparse.ArgumentParser(description="Qt Client build tool")
ap.add_argument('--toolset', default='', type=str,
help='Windows use only, specify Visual Studio toolset version')
ap.add_argument('--sdk', default='', type=str,
help='Windows use only, specify Windows SDK version')
parsed_args = ap.parse_args()
return parsed_args
def main():
parsed_args = parse_args()
if build_daemon(parsed_args) != 0:
print('daemon build failure!')
sys.exit(1)
if build_lrc(parsed_args) != 0:
print('lrc build failure!')
sys.exit(1)
if build_client(parsed_args) != 0:
print('client build failure!')
sys.exit(1)
if __name__ == "__main__":
main()
#!/bin/bash
rootdir=$(pwd)
HOST=i686-w64-mingw32
ARCH=32
CMAKE_TOOLCHAIN_FILE=$rootdir/lrc/cmake/winBuild.cmake
echo "running compilation on ${CORES:=`nproc --all`} threads"
while test -n "$1"
do
case "$1" in
--clean)
;;
--arch=*)
ARCH="${1#--arch=}"
;;
esac
shift
done
if [ "$ARCH" = "64" ]
then
HOST=x86_64-w64-mingw32
CMAKE_TOOLCHAIN_FILE=$rootdir/lrc/cmake/winBuild64.cmake
fi
INSTALL_PREFIX=$rootdir/install_win${ARCH}
cd daemon/contrib
mkdir -p native${ARCH}
cd native${ARCH}
../bootstrap --host=${HOST}
make fetch || exit 1
make -j$CORES || exit 1
cd ../..
./autogen.sh || exit 1
mkdir -p "build${ARCH}"
cd build${ARCH}
$rootdir/daemon/configure --host=${HOST} --without-dbus --prefix=$INSTALL_PREFIX
rsync -a $rootdir/daemon/src/buildinfo.cpp ./src/buildinfo.cpp
make -j$CORES install || exit 1
cd $rootdir
cd lrc
mkdir -p build${ARCH}
cd build${ARCH}
export CMAKE_PREFIX_PATH=/usr/${HOST}/sys-root/mingw/lib/cmake
cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DRING_BUILD_DIR=$INSTALL_PREFIX -DENABLE_LIBWRAP=true ..
make -j$CORES install || exit 1
cd $rootdir
cd client-windows
git submodule update --init
if [ ! -f "$INSTALL_PREFIX/bin/WinSparkle.dll" ]
then
cd winsparkle
git submodule init && git submodule update
mkdir -p build${ARCH} && cd build${ARCH}
cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ../cmake
make -j$CORES || exit 1
make install
cd ../../
fi
if [ ! -f "$INSTALL_PREFIX/bin/libqrencode.dll" ]
then
cd libqrencode
./autogen.sh || exit 1
mkdir -p build${ARCH} && cd build${ARCH}
../configure --host=${HOST} --prefix=$INSTALL_PREFIX
make -j$CORES || exit 1
make install
cd ../..
fi
mkdir -p build${ARCH}
cd build${ARCH}
${HOST}-qmake-qt5 ../RingWinClient.pro -r -spec mingw-w64-g++ RING=$INSTALL_PREFIX
make -j$CORES || exit 1
make install
#!/bin/bash
rootdir=$(pwd)
HOST=i686-w64-mingw32
ARCH=32
CMAKE_TOOLCHAIN_FILE=$rootdir/lrc/cmake/winBuild.cmake
while test -n "$1"
do
case "$1" in
--clean)
;;
--arch=*)
ARCH="${1#--arch=}"
;;
esac
shift
done
if [ "$ARCH" = "64" ]
then
HOST=x86_64-w64-mingw32
CMAKE_TOOLCHAIN_FILE=$rootdir/lrc/cmake/winBuild64.cmake
fi
INSTALL_PREFIX=$rootdir/install_win${ARCH}
cd lrc
mkdir -p build${ARCH}
cd build${ARCH}
export CMAKE_PREFIX_PATH=/usr/${HOST}/sys-root/mingw/lib/cmake
cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DRING_BUILD_DIR=$rootdir/daemon/src -DENABLE_LIBWRAP=true ..
make -j4 install || exit 1
cd $rootdir
cd client-windows
git submodule update --init
if [ ! -f "$INSTALL_PREFIX/bin/WinSparkle.dll" ]
then
cd winsparkle
git submodule init && git submodule update
mkdir -p build${ARCH} && cd build${ARCH}
cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ../cmake
make -j4 || exit 1
make install
cd ../../
fi
if [ ! -f "$INSTALL_PREFIX/bin/libqrencode.dll" ]
then
cd libqrencode
./autogen.sh || exit 1
mkdir -p build${ARCH} && cd build${ARCH}
../configure --host=${HOST} --prefix=$INSTALL_PREFIX
make -j4 || exit 1
make install
cd ../..
fi
mkdir -p build${ARCH}
cd build${ARCH}
${HOST}-qmake-qt5 ../RingWinClient.pro -r -spec win32-g++ RING=$INSTALL_PREFIX INCLUDEPATH=$rootdir/client-windows/winsparkle
make -j4 || exit 1
make install
#!/bin/bash
# Update SPARKLE_FILE with given executable
# Usage ./winsparkle-xml-updater.sh ring.exe <URI of winsparkle-ring.xml>
PACKAGE=$1
SPARKLE_SOURCE=$2
SPARKLE_FILE=winsparkle-ring.xml
TMP_FILE=winsparkle.tmp
REPO_URL=${2%/${SPARKLE_FILE}}
if [ ! -f ${PACKAGE} ]; then
echo "Can't find package aborting..."
exit 1
fi
if [ ! -s ${SPARKLE_FILE} ]; then
wget --no-check-certificate --retry-connrefused --tries=20 --wait=2 \
--random-wait --waitretry=10 ${SPARKLE_SOURCE} -O ${SPARKLE_FILE}
if [ $? -eq 127 ]; then
rm -f ${SPARKLE_FILE}
COUNTER=0
curl --retry 2 --retry-delay 2 ${SPARKLE_SOURCE} -o ${SPARKLE_FILE}
until [ $? -eq 0 -o $COUNTER -gt 10 ]; do
sleep 1
let COUNTER=COUNTER+1
curl --retry 2 --retry-delay 2 ${SPARKLE_SOURCE} -o ${SPARKLE_FILE}
done
if [ $? -ne 0 ]; then
echo 'the winsparkle file have been badly overwriten; deleting it.'
rm -f winsparkle.xml
exit 1
fi
fi
fi
if [[ $(basename ${PACKAGE}) == *"x86_64"* ]]
then
OS="windows-x64";
else
OS="windows-x86";
fi
# update URI in <link> field
gawk -v source="${SPARKLE_SOURCE}" '/<link>/{printf " <link>";
printf source; print "</link>"; next}1' ${SPARKLE_FILE}
# update xml list with new image item
URL="${REPO_URL}/$(basename ${PACKAGE})"
LENGTH="$(stat -c %s ${PACKAGE})"
python3 ./scripts/winsparkle.py winsparkle-ring.xml "Ring nightly" ${URL} ${OS} ${LENGTH}
"""
* Copyright (C) 2016-2019 Savoir-faire Linux Inc.
*
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
import sys
import xml.etree.ElementTree as ET
from xml.dom import minidom
import datetime
from email.utils import formatdate
def sameDate(timestamp, pub):
date1 = timestamp.split()
date2 = pub.text.split()
return date1[:4] == date2[:4]
def insertNewPackage(parent_element, title, attrib):
now = datetime.datetime.now()
new_item = ET.Element("item")
titre = ET.SubElement(new_item,"titre")
titre.text = title + now.strftime("%Y/%m/%d %H:%M")
pubDate = ET.SubElement(new_item, "pubDate")
pubDate.text = formatdate()
enclosure = ET.SubElement(new_item, "enclosure", attrib=attrib)
parent_element.insert(4,new_item)
if __name__ == "__main__":
now = datetime.datetime.now()
now_timestamp = formatdate() # rfc 2822
sparkle_file = sys.argv[1]
title = sys.argv[2]
url = sys.argv[3]
os = sys.argv[4]
length = sys.argv[5]
ET.register_namespace('sparkle','http://www.andymatuschak.org/xml-namespaces/sparkle')
namespace = {'sparkle' : 'http://www.andymatuschak.org/xml-namespaces/sparkle'}
tree = ET.parse(sparkle_file)
channel = tree.find("channel")
attrib = {'url' : url,
'sparkle:version' : now.strftime("%Y%m%d"),
'sparkle:shortVersionString' : "nightly-" + now.strftime("%Y%m%d"),
'sparkle:os' : os,
'length' : length,
'type' : "application/octet-stream"
}
# remove all publications of the same day (but not same os)
for item in tree.findall(".//item"):
if sameDate(now_timestamp, item.find("pubDate")) and not\
item.find("./enclosure[@sparkle:os='%s']" % os, namespace) is None:
channel.remove(item)
insertNewPackage(channel, title, attrib)
# Pretty printing with xml dom
str_tree = ET.tostring(tree.getroot(),encoding='utf-8').decode('utf-8').replace('\n','').replace('\r','')
reparsed_doc = minidom.parseString(str_tree)
xml_out = open(sparkle_file,"wb")
xml_out.write(reparsed_doc.toprettyxml(indent=' ', newl='\n',encoding="utf-8"))
xml_out.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment