Skip to content
Snippets Groups Projects
Commit 0f0d7ff5 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang
Browse files

win32: integrate python scripts for native build

Change-Id: I8d6598b9739f04e5c64c8236740091786222a33a
parent b0e2d411
Branches
Tags
No related merge requests found
...@@ -14,10 +14,16 @@ import time ...@@ -14,10 +14,16 @@ import time
import platform import platform
import multiprocessing import multiprocessing
import shutil import shutil
import signal
IOS_DISTRIBUTION_NAME = "ios" IOS_DISTRIBUTION_NAME = "ios"
OSX_DISTRIBUTION_NAME = "osx" OSX_DISTRIBUTION_NAME = "osx"
ANDROID_DISTRIBUTION_NAME = "android" ANDROID_DISTRIBUTION_NAME = "android"
WIN32_DISTRIBUTION_NAME = "win32"
# vs help
win_sdk_default = '10.0.16299.0'
win_toolset_default = 'v141'
APT_BASED_DISTROS = [ APT_BASED_DISTROS = [
'debian', 'debian',
...@@ -87,22 +93,6 @@ ZYPPER_DEPENDENCIES = [ ...@@ -87,22 +93,6 @@ ZYPPER_DEPENDENCIES = [
'NetworkManager-devel', 'libcanberra-gtk3-devel' 'NetworkManager-devel', 'libcanberra-gtk3-devel'
] ]
MINGW64_FEDORA_DEPENDENCIES = [
'mingw64-binutils', 'mingw64-gcc', 'mingw64-headers', 'mingw64-crt', 'mingw64-gcc-c++',
'mingw64-pkg-config', 'yasm', 'gettext-devel', 'cmake', 'patch', 'libtool', 'automake',
'autoconf', 'autoconf-archive', 'make', 'xz', 'bzip2', 'which', 'mingw64-qt5-qtbase',
'mingw64-qt5-qttools', 'mingw64-qt5-qtsvg', 'mingw64-qt5-qtwinextras', 'mingw64-libidn',
'mingw64-xz-libs','msgpack-devel'
]
MINGW32_FEDORA_DEPENDENCIES = [
'mingw32-binutils', 'mingw32-gcc', 'mingw32-headers', 'mingw32-crt', 'mingw32-gcc-c++',
'mingw32-pkg-config', 'yasm', 'gettext-devel', 'cmake', 'patch', 'libtool', 'automake',
'autoconf', 'autoconf-archive', 'make', 'xz', 'bzip2', 'which', 'mingw32-qt5-qtbase',
'mingw32-qt5-qttools', 'mingw32-qt5-qtsvg', 'mingw32-qt5-qtwinextras', 'mingw32-libidn',
'mingw32-xz-libs', 'msgpack-devel'
]
DNF_DEPENDENCIES = [ DNF_DEPENDENCIES = [
'autoconf', 'autoconf-archive', 'automake', 'cmake', 'speexdsp-devel', 'pulseaudio-libs-devel', 'autoconf', 'autoconf-archive', 'automake', 'cmake', 'speexdsp-devel', 'pulseaudio-libs-devel',
'libtool', 'dbus-devel', 'expat-devel', 'pcre-devel', 'libtool', 'dbus-devel', 'expat-devel', 'pcre-devel',
...@@ -180,26 +170,29 @@ STOP_SCRIPT = [ ...@@ -180,26 +170,29 @@ STOP_SCRIPT = [
] ]
def run_powersell_cmd(cmd):
p = subprocess.Popen(["powershell.exe", cmd], stdout=sys.stdout)
p.communicate()
p.wait()
return
def run_dependencies(args): def run_dependencies(args):
if args.distribution in APT_BASED_DISTROS: if(args.distribution == WIN32_DISTRIBUTION_NAME):
run_powersell_cmd(
'Set-ExecutionPolicy Unrestricted; .\\scripts\\build-package-windows.ps1')
elif args.distribution in APT_BASED_DISTROS:
execute_script(APT_INSTALL_SCRIPT, execute_script(APT_INSTALL_SCRIPT,
{"packages": ' '.join(APT_DEPENDENCIES)} {"packages": ' '.join(APT_DEPENDENCIES)}
) )
elif args.distribution in DNF_BASED_DISTROS: elif args.distribution in DNF_BASED_DISTROS:
execute_script( execute_script(
RPM_INSTALL_SCRIPT, RPM_INSTALL_SCRIPT,
{"packages": ' '.join(DNF_DEPENDENCIES)} {"packages": ' '.join(DNF_DEPENDENCIES)}
) )
elif args.distribution == "mingw32":
execute_script(
RPM_INSTALL_SCRIPT,
{"packages": ' '.join(MINGW32_FEDORA_DEPENDENCIES)}
)
elif args.distribution == "mingw64":
execute_script(
RPM_INSTALL_SCRIPT,
{"packages": ' '.join(MINGW64_FEDORA_DEPENDENCIES)}
)
elif args.distribution in PACMAN_BASED_DISTROS: elif args.distribution in PACMAN_BASED_DISTROS:
execute_script( execute_script(
PACMAN_INSTALL_SCRIPT, PACMAN_INSTALL_SCRIPT,
...@@ -240,10 +233,16 @@ def run_dependencies(args): ...@@ -240,10 +233,16 @@ def run_dependencies(args):
print("The Android version does not need more dependencies.\nPlease continue with the --install instruction.") print("The Android version does not need more dependencies.\nPlease continue with the --install instruction.")
sys.exit(1) sys.exit(1)
elif args.distribution == WIN32_DISTRIBUTION_NAME:
print("The win32 version does not install dependencies with this script.\nPlease continue with the --install instruction.")
sys.exit(1)
else: else:
print("Not yet implemented for current distribution (%s)" % args.distribution) print("Not yet implemented for current distribution (%s)" %
args.distribution)
sys.exit(1) sys.exit(1)
def run_init(): def run_init():
# Extract modules path from '.gitmodules' file # Extract modules path from '.gitmodules' file
module_names = [] module_names = []
...@@ -257,6 +256,7 @@ def run_init(): ...@@ -257,6 +256,7 @@ def run_init():
for name in module_names: for name in module_names:
copy_file("./scripts/commit-msg", ".git/modules/"+name+"/hooks") copy_file("./scripts/commit-msg", ".git/modules/"+name+"/hooks")
def copy_file(src, dest): def copy_file(src, dest):
print("Copying:" + src + " to " + dest) print("Copying:" + src + " to " + dest)
try: try:
...@@ -268,6 +268,7 @@ def copy_file(src, dest): ...@@ -268,6 +268,7 @@ def copy_file(src, dest):
except IOError as e: except IOError as e:
print('Error: %s' % e.strerror) print('Error: %s' % e.strerror)
def run_install(args): def run_install(args):
install_args = ' -p ' + str(multiprocessing.cpu_count()) install_args = ' -p ' + str(multiprocessing.cpu_count())
if args.static: if args.static:
...@@ -275,30 +276,25 @@ def run_install(args): ...@@ -275,30 +276,25 @@ def run_install(args):
if args.global_install: if args.global_install:
install_args += ' -g' install_args += ' -g'
if args.distribution == OSX_DISTRIBUTION_NAME: if args.distribution == OSX_DISTRIBUTION_NAME:
proc= subprocess.Popen("brew --prefix qt5", shell=True, stdout=subprocess.PIPE) proc = subprocess.Popen("brew --prefix qt5",
shell=True, stdout=subprocess.PIPE)
qt5dir = proc.stdout.read() qt5dir = proc.stdout.read()
os.environ['CMAKE_PREFIX_PATH'] = str(qt5dir.decode('ascii')) os.environ['CMAKE_PREFIX_PATH'] = str(qt5dir.decode('ascii'))
install_args += " -c client-macosx" install_args += " -c client-macosx"
execute_script(["CONFIGURE_FLAGS='--without-dbus' ./scripts/install.sh " + install_args]) execute_script(
["CONFIGURE_FLAGS='--without-dbus' ./scripts/install.sh " + install_args])
elif args.distribution == IOS_DISTRIBUTION_NAME: elif args.distribution == IOS_DISTRIBUTION_NAME:
os.chdir("./client-ios") os.chdir("./client-ios")
execute_script(["./compile-ios.sh"]) execute_script(["./compile-ios.sh"])
elif args.distribution == ANDROID_DISTRIBUTION_NAME: elif args.distribution == ANDROID_DISTRIBUTION_NAME:
os.chdir("./client-android") os.chdir("./client-android")
execute_script(["./compile.sh"]) execute_script(["./compile.sh"])
elif args.distribution == 'mingw32': elif args.distribution == WIN32_DISTRIBUTION_NAME:
os.environ['CMAKE_PREFIX_PATH'] = '/usr/i686-w64-mingw32/sys-root/mingw/lib/cmake' subprocess.call('python ' + os.getcwd() + '/scripts/build-windows.py ' + '--toolset ' + args.toolset + ' --sdk ' + args.sdk)
os.environ['QTDIR'] = '/usr/i686-w64-mingw32/sys-root/mingw/lib/qt5/'
os.environ['PATH'] = '/usr/i686-w64-mingw32/bin/qt5/:' + os.environ['PATH']
execute_script(["./scripts/win_compile.sh"])
elif args.distribution == 'mingw64':
os.environ['CMAKE_PREFIX_PATH'] = '/usr/x86_64-w64-mingw32/sys-root/mingw/lib/cmake'
os.environ['QTDIR'] = '/usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/'
os.environ['PATH'] = '/usr/x86_64-w64-mingw32/bin/qt5/:' + os.environ['PATH']
execute_script(["./scripts/win_compile.sh --arch=64"])
else: else:
if args.distribution in ZYPPER_BASED_DISTROS: if args.distribution in ZYPPER_BASED_DISTROS:
os.environ['JSONCPP_LIBS'] = "-ljsoncpp" #fix jsoncpp pkg-config bug, remove when jsoncpp package bumped # fix jsoncpp pkg-config bug, remove when jsoncpp package bumped
os.environ['JSONCPP_LIBS'] = "-ljsoncpp"
install_args += ' -c client-gnome' install_args += ' -c client-gnome'
execute_script(["./scripts/install.sh " + install_args]) execute_script(["./scripts/install.sh " + install_args])
...@@ -312,15 +308,18 @@ def run_uninstall(args): ...@@ -312,15 +308,18 @@ def run_uninstall(args):
def run_run(args): def run_run(args):
if args.distribution == OSX_DISTRIBUTION_NAME: if args.distribution == OSX_DISTRIBUTION_NAME:
subprocess.Popen(["install/client-macosx/Ring.app/Contents/MacOS/Ring"]) subprocess.Popen(
["install/client-macosx/Ring.app/Contents/MacOS/Ring"])
return True return True
run_env = os.environ run_env = os.environ
run_env['LD_LIBRARY_PATH'] = run_env.get('LD_LIBRARY_PATH', '') + ":install/lrc/lib" run_env['LD_LIBRARY_PATH'] = run_env.get(
'LD_LIBRARY_PATH', '') + ":install/lrc/lib"
try: try:
dring_log = open("daemon.log", 'a') dring_log = open("daemon.log", 'a')
dring_log.write('=== Starting daemon (%s) ===' % time.strftime("%d/%m/%Y %H:%M:%S")) dring_log.write('=== Starting daemon (%s) ===' %
time.strftime("%d/%m/%Y %H:%M:%S"))
dring_process = subprocess.Popen( dring_process = subprocess.Popen(
["./install/daemon/lib/ring/dring", "-c", "-d"], ["./install/daemon/lib/ring/dring", "-c", "-d"],
stdout=dring_log, stdout=dring_log,
...@@ -331,7 +330,8 @@ def run_run(args): ...@@ -331,7 +330,8 @@ def run_run(args):
f.write(str(dring_process.pid)+'\n') f.write(str(dring_process.pid)+'\n')
client_log = open("jami-gnome.log", 'a') client_log = open("jami-gnome.log", 'a')
client_log.write('=== Starting client (%s) ===' % time.strftime("%d/%m/%Y %H:%M:%S")) client_log.write('=== Starting client (%s) ===' %
time.strftime("%d/%m/%Y %H:%M:%S"))
client_process = subprocess.Popen( client_process = subprocess.Popen(
["./install/client-gnome/bin/jami-gnome", "-d"], ["./install/client-gnome/bin/jami-gnome", "-d"],
stdout=client_log, stdout=client_log,
...@@ -377,6 +377,7 @@ def run_run(args): ...@@ -377,6 +377,7 @@ def run_run(args):
def run_stop(args): def run_stop(args):
execute_script(STOP_SCRIPT) execute_script(STOP_SCRIPT)
def execute_script(script, settings=None, fail=True): def execute_script(script, settings=None, fail=True):
if settings == None: if settings == None:
settings = {} settings = {}
...@@ -384,21 +385,25 @@ def execute_script(script, settings=None, fail=True): ...@@ -384,21 +385,25 @@ def execute_script(script, settings=None, fail=True):
line = line % settings line = line % settings
rv = os.system(line) rv = os.system(line)
if rv != 0 and fail == True: if rv != 0 and fail == True:
print('Error executing script! Exit code: %s' % rv, file=sys.stderr) print('Error executing script! Exit code: %s' %
rv, file=sys.stderr)
sys.exit(1) sys.exit(1)
def validate_args(parsed_args): def validate_args(parsed_args):
"""Validate the args values, exit if error is found""" """Validate the args values, exit if error is found"""
# Check arg values # Check arg values
supported_distros = [ANDROID_DISTRIBUTION_NAME, OSX_DISTRIBUTION_NAME, IOS_DISTRIBUTION_NAME] + APT_BASED_DISTROS + DNF_BASED_DISTROS + PACMAN_BASED_DISTROS + ZYPPER_BASED_DISTROS + ['mingw32','mingw64'] supported_distros = [ANDROID_DISTRIBUTION_NAME, OSX_DISTRIBUTION_NAME, IOS_DISTRIBUTION_NAME,
WIN32_DISTRIBUTION_NAME] + APT_BASED_DISTROS + DNF_BASED_DISTROS + PACMAN_BASED_DISTROS + ZYPPER_BASED_DISTROS
if parsed_args.distribution not in supported_distros: if parsed_args.distribution not in supported_distros:
print('Distribution \''+parsed_args.distribution+'\' not supported.\nChoose one of: %s' \ print('Distribution \''+parsed_args.distribution+'\' not supported.\nChoose one of: %s'
% ', '.join(supported_distros), % ', '.join(supported_distros),
file=sys.stderr) file=sys.stderr)
sys.exit(1) sys.exit(1)
def parse_args(): def parse_args():
ap = argparse.ArgumentParser(description="Ring build tool") ap = argparse.ArgumentParser(description="Ring build tool")
...@@ -428,6 +433,10 @@ def parse_args(): ...@@ -428,6 +433,10 @@ def parse_args():
ap.add_argument('--debug', default=False, action='store_true') ap.add_argument('--debug', default=False, action='store_true')
ap.add_argument('--background', default=False, action='store_true') ap.add_argument('--background', default=False, action='store_true')
if choose_distribution() == WIN32_DISTRIBUTION_NAME:
ap.add_argument('--toolset', default=win_toolset_default, type=str, help='Windows use only, specify Visual Studio toolset version')
ap.add_argument('--sdk', default=win_sdk_default, type=str, help='Windows use only, specify Windows SDK version')
parsed_args = ap.parse_args() parsed_args = ap.parse_args()
if (parsed_args.distribution is not None): if (parsed_args.distribution is not None):
...@@ -435,17 +444,19 @@ def parse_args(): ...@@ -435,17 +444,19 @@ def parse_args():
else: else:
parsed_args.distribution = choose_distribution() parsed_args.distribution = choose_distribution()
if parsed_args.distribution in ['mingw32', 'mingw64']: if parsed_args.distribution == WIN32_DISTRIBUTION_NAME:
if choose_distribution() != "fedora": if platform.release() != '10':
print('Windows version must be built on a Fedora distribution (>=23)') print('Windows version must be built on Windows 10')
sys.exit(1) sys.exit(1)
validate_args(parsed_args) validate_args(parsed_args)
return parsed_args return parsed_args
def choose_distribution(): def choose_distribution():
system = platform.system().lower() system = platform.system().lower()
if system == "linux" or system == "linux2": if system == "linux" or system == "linux2":
if os.path.isfile("/etc/arch-release"): if os.path.isfile("/etc/arch-release"):
return "arch" return "arch"
...@@ -456,6 +467,8 @@ def choose_distribution(): ...@@ -456,6 +467,8 @@ def choose_distribution():
return v.strip().replace('"', '').split(' ')[0] return v.strip().replace('"', '').split(' ')[0]
elif system == "darwin": elif system == "darwin":
return OSX_DISTRIBUTION_NAME return OSX_DISTRIBUTION_NAME
elif system == "windows":
return WIN32_DISTRIBUTION_NAME
return 'Unknown' return 'Unknown'
......
# 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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment