Skip to content

Commit

Permalink
Release 0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ngld committed Jun 21, 2017
2 parents 3e6586b + 0e4facf commit a549842
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 224 deletions.
13 changes: 5 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import sys
import os.path
import subprocess
from codecs import open

os.chdir(os.path.abspath(os.path.dirname(__file__)))
sys.path.insert(0, os.path.abspath('tools/common'))
Expand Down Expand Up @@ -74,12 +76,7 @@
]

# Grab the current version
with open('knossos/center.py', 'r', encoding='utf-8') as f:
m = re.search(r"VERSION = '([^']+)'", f.read())
if m:
version = m.group(1)
else:
version = 'XXX'
version = subprocess.check_output([sys.executable, 'setup.py', 'get_version']).decode('utf8').strip()

info('Checking Python version...')
if sys.hexversion < 0x20700 or (sys.hexversion > 0x30000 and sys.hexversion < 0x30200):
Expand Down Expand Up @@ -129,7 +126,7 @@
for path in RCC_FILES:
if os.path.basename(path) == 'hlp.png':
out += '<file alias="hlp.png">%s</file>' % os.path.abspath(path)
elif path.endswith(('.min.js', '.es5.js')):
elif path.endswith(('.min.js', '.out.js')):
out += '<file alias="%s">%s</file>' % (path[:-7] + '.js', os.path.abspath(path))
else:
out += '<file alias="%s">%s</file>' % (path, os.path.abspath(path))
Expand Down Expand Up @@ -192,7 +189,7 @@
n.comment('Win32')

if check_module('PyInstaller', required=False):
pyinstaller = 'cmd /C "cd releng\\windows" && ' + cmd2str([sys.executable, '-OO', '-mPyInstaller', '-d', '--distpath=.\\dist', '--workpath=.\\build', 'Knossos.spec', '-y'])
pyinstaller = 'cmd /C "cd releng\\windows && %s"' % cmd2str([sys.executable, '-OO', '-mPyInstaller', '-d', '--distpath=.\\dist', '--workpath=.\\build', 'Knossos.spec', '-y'])
n.rule('pyinstaller', pyinstaller, 'PACKAGE', pool='console')
n.build('pyi', 'pyinstaller', ['resources'] + SRC_FILES)

Expand Down
11 changes: 10 additions & 1 deletion html/js/modlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ function init() {
}
}

function connectOnce(sig, cb) {
let wrapper = function () {
sig.disconnect(wrapper);
return cb.apply(this, arguments);
};
sig.connect(wrapper);
}

Vue.component('kn-mod', {
template: '#kn-mod',
props: ['mod', 'tab'],
Expand Down Expand Up @@ -81,7 +89,7 @@ function init() {
}),

beforeMount() {
call(fs2mod.getSettings, (settings) => {
connectOnce(fs2mod.settingsArrived, (settings) => {
settings = JSON.parse(settings);

this.knossos = Object.assign({}, settings.knossos);
Expand All @@ -90,6 +98,7 @@ function init() {
this.default_fs2_bin = settings.knossos.fs2_bin;
this.default_fred_bin = settings.knossos.fred_bin;
});
fs2mod.getSettings();
call(fs2mod.getDefaultFsoCaps, (caps) => {
this.caps = JSON.parse(caps);
});
Expand Down
2 changes: 1 addition & 1 deletion knossos/center.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# The version should follow the http://semver.org guidelines.
# Only remove the -dev tag if you're making a release!
VERSION = '0.5.1'
VERSION = '0.5.2'
UPDATE_LINK = 'https://dev.tproxy.de/knossos'
INNOEXTRACT_LINK = 'https://dev.tproxy.de/knossos/innoextract.txt'
DEBUG = os.getenv('KN_DEBUG', '0').strip() == '1'
Expand Down
11 changes: 11 additions & 0 deletions knossos/clibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def init_sdl():
SDL_INIT_JOYSTICK = 0x00000200

# SDL.h
sdl.SDL_SetMainReady.argtypes = []
sdl.SDL_SetMainReady.restype = None

sdl.SDL_Init.argtypes = [ctypes.c_uint32]
sdl.SDL_Init.restype = ctypes.c_int

sdl.SDL_InitSubSystem.argtypes = [ctypes.c_uint32]
sdl.SDL_InitSubSystem.restype = ctypes.c_int

Expand Down Expand Up @@ -189,6 +195,11 @@ def init_sdl():
sdl.SDL_JoystickName.restype = ctypes.c_char_p

if SDL2:
sdl.SDL_SetMainReady()
if sdl.SDL_Init(0) != 0:
logging.error('Failed to init SDL!')
logging.error(sdl.SDL_GetError())

def get_modes():
if sdl.SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 or sdl.SDL_VideoInit(None) < 0:
logging.error('Failed to init SDL\'s video subsystem!')
Expand Down
20 changes: 15 additions & 5 deletions knossos/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import json
import logging
from collections import OrderedDict
from threading import Thread

from . import center, util, api, launcher, runner
from .tasks import run_task, CheckTask
Expand All @@ -28,7 +29,18 @@
tr = QtCore.QCoreApplication.translate


def get_settings():
def get_settings(cb):
t = Thread(target=get_settings_p2, args=(cb,))
t.start()


def get_settings_p2(cb):
dev_info = get_deviceinfo()

if not dev_info:
cb(None)
return

fso = {}

fs2_bins = OrderedDict()
Expand All @@ -51,8 +63,6 @@ def get_settings():
fso['fs2_bins'] = fs2_bins
fso['fred_bins'] = fred_bins

dev_info = get_deviceinfo()

# ---Read fs2_open.ini or the registry---
# Be careful with any change, the keys are all case sensitive.
config = parse_fso_config()
Expand Down Expand Up @@ -192,12 +202,12 @@ def get_settings():

fso['has_voice'] = sys.platform == 'win32'

return {
cb({
'knossos': kn_settings,
'languages': center.LANGUAGES,
'has_log': launcher.log_path is not None,
'fso': fso
}
})


def save_fso_settings(new_settings):
Expand Down
2 changes: 1 addition & 1 deletion knossos/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ def __init__(self):
def work(self, item):
progress.update(0, 'Checking for updates...')

update_base = util.pjoin(center.UPDATE_LINK, center.settings['update_channel'])
update_base = util.pjoin(center.UPDATE_LINK, 'stable')
version = util.get(update_base + '/version?me=' + center.VERSION)

if version is None:
Expand Down
23 changes: 7 additions & 16 deletions knossos/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import semantic_version
import requests
from collections import OrderedDict
from threading import Condition, Event
from threading import Condition, Event, Thread
from collections import deque

from . import center, progress
Expand Down Expand Up @@ -293,14 +293,9 @@ def get_speed(self):
def call(*args, **kwargs):
if sys.platform.startswith('win') and not center.DEBUG:
# Provide the called program with proper I/O on Windows.
if 'stdin' not in kwargs:
kwargs['stdin'] = subprocess.DEVNULL

if 'stdout' not in kwargs:
kwargs['stdout'] = subprocess.DEVNULL

if 'stderr' not in kwargs:
kwargs['stderr'] = subprocess.DEVNULL
kwargs.setdefault('stdin', subprocess.DEVNULL)
kwargs.setdefault('stdout', subprocess.DEVNULL)
kwargs.setdefault('stderr', subprocess.DEVNULL)

si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
Expand All @@ -315,20 +310,16 @@ def call(*args, **kwargs):
def check_output(*args, **kwargs):
if sys.platform.startswith('win'):
# Provide the called program with proper I/O on Windows.
if 'stdin' not in kwargs:
kwargs['stdin'] = subprocess.DEVNULL

if 'stderr' not in kwargs:
kwargs['stderr'] = subprocess.DEVNULL
kwargs.setdefault('stdin', subprocess.DEVNULL)
kwargs.setdefault('stderr', subprocess.DEVNULL)

si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = subprocess.SW_HIDE

kwargs['startupinfo'] = si

if 'universal_newlines' not in kwargs:
kwargs['universal_newlines'] = True
kwargs.setdefault('universal_newlines', True)

logging.debug('Running %s', args[0])
return subprocess.check_output(*args, **kwargs)
Expand Down
8 changes: 6 additions & 2 deletions knossos/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class WebBridge(QtCore.QObject):
showRetailPrompt = QtCore.Signal()
updateModlist = QtCore.Signal('QVariantList', str)
modProgress = QtCore.Signal(str, float, str)
settingsArrived = QtCore.Signal(str)

taskStarted = QtCore.Signal(float, str, list)
taskProgress = QtCore.Signal(float, float, str)
Expand Down Expand Up @@ -351,9 +352,12 @@ def setBasePath(self, path):
tasks.run_task(tasks.FetchTask())
center.main_win.check_fso()

@QtCore.Slot(result=str)
@QtCore.Slot()
def getSettings(self):
return json.dumps(settings.get_settings())
def cb(res):
self.settingsArrived.emit(json.dumps(res))

settings.get_settings(cb)

@QtCore.Slot(str, str)
def saveSetting(self, key, value):
Expand Down
18 changes: 3 additions & 15 deletions releng/macos/Knossos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import sys
import os.path
import re
import logging
import subprocess
import ctypes.util
from shutil import which, copytree

Expand Down Expand Up @@ -52,25 +53,12 @@ if not os.path.dirname(sdl2_path).endswith('.framework'):
'download the .dmg file and install it according to the contained README.')
sys.exit(1)

with open('../../knossos/center.py') as stream:
match = re.search(r"VERSION = '([^']+)'", stream.read())
version = subprocess.check_output([sys.executable, '../../setup.py', 'get_version']).decode('utf-8')

if not match:
if not version:
print('ERROR: Could not determine version!')
sys.exit(1)

version = match.group(1)
if '-dev' in version:
if not os.path.exists('../../.git'):
print('\nWARNING: No .git directory found while building a devbuild!\n')
else:
with open('../../.git/HEAD') as stream:
ref = stream.read().strip().split(':')
assert ref[0] == 'ref'

with open('../../.git/' + ref[1].strip()) as stream:
version += '+' + stream.read()[:7]

with open('version', 'w') as stream:
stream.write(version)

Expand Down
2 changes: 1 addition & 1 deletion releng/macos/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eo pipefail

echo "==> Installing build tools"
brew update
brew install python p7zip ninja
brew install python p7zip ninja qt5
pip install -U pip
pip install dmgbuild

Expand Down
19 changes: 3 additions & 16 deletions releng/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,11 @@ echo "==> Building PyPi package..."
./pypi/build.sh

echo "==> Uploading artifacts to GitHub..."
githubrelease release ngld/knossos create "v$VERSION" --name "Knossos $VERSION" --body "$(cat "$rel_text")" \
--publish --prerelease \
githubrelease release ngld/knossos create "v$VERSION" --name "Knossos $VERSION" --publish --prerelease \
windows/dist/{Knossos,update}-"$VERSION".exe macos/dist/Knossos-"$VERSION".dmg

rm "$rel_text"

echo "==> Killing VMs..."
cd windows
vagrant destroy

cd ../macos
vagrant destroy
githubrelease release ngld/knossos edit "v$VERSION" --body "$(cat "$rel_text")"

echo "==> Killing VMs..."
cd windows
vagrant destroy

cd ../macos
vagrant destroy
rm "$rel_text"

echo "==> Done."
17 changes: 17 additions & 0 deletions releng/ubuntu/auto-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -eo pipefail

cd /build
sudo chown packager .
rsync -a --exclude=dist --exclude=build --exclude=packer --exclude=.vagrant src/ work/
cd work

export QT_SELECT=5

echo "Installing Babel..."
rm -rf node_modules
cp -r /build/node_modules .

python3 configure.py
exec ninja debug
7 changes: 7 additions & 0 deletions releng/ubuntu/launch-ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -eo pipefail
cd "$(dirname "$0")"

exec docker run --rm -it -v/tmp/.X11-unix:/tmp/.X11-unix -v"$(cd ../..; pwd)":/build/src \
-u packager -e DISPLAY="$DISPLAY" knossos-ubuntu-builder bash /build/src/releng/ubuntu/auto-run.sh
18 changes: 3 additions & 15 deletions releng/windows/Knossos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sys
import os.path
import re
import subprocess
import PyQt5

onefile = False
Expand Down Expand Up @@ -44,25 +45,12 @@ if debug:
qt_path = os.path.dirname(PyQt5.__file__)
qt_bin = os.path.join(qt_path, 'qt', 'bin')

with open('../../knossos/center.py') as stream:
match = re.search(r"VERSION = '([^']+)'", stream.read())
version = subprocess.check_output([sys.executable, '../../setup.py', 'get_version']).decode('utf-8')

if not match:
if not version:
print('ERROR: Could not determine version!')
sys.exit(1)

version = match.group(1)
if '-dev' in version:
if not os.path.exists('../../.git'):
print('\nWARNING: No .git directory found while building a devbuild!\n')
else:
with open('../../.git/HEAD') as stream:
ref = stream.read().strip().split(':')
assert ref[0] == 'ref'

with open('../../.git/' + ref[1].strip()) as stream:
version += '+' + stream.read()[:7]

with open('version', 'w') as stream:
stream.write(version)

Expand Down
3 changes: 2 additions & 1 deletion releng/windows/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Vagrant.require_version ">= 1.6.2"

Vagrant.configure("2") do |config|
config.vm.define "knossos-builder"
config.vm.box = "windows_10"
config.vm.box = "windows_7"

config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../..", "/cygdrive/c/knossos", type: "rsync",
rsync__args: ["--verbose", "--archive", "-z", "--copy-links"],
rsync__exclude: ["dist", "build", "packer", ".vagrant"]
Expand Down
Loading

0 comments on commit a549842

Please sign in to comment.