diff --git a/distrib/autobuild.py b/distrib/autobuild.py index da6ccdadb3..dee1dd766c 100755 --- a/distrib/autobuild.py +++ b/distrib/autobuild.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # coding=utf-8 # # Script for performing automated build events. @@ -65,7 +65,7 @@ def todays_platform_release(): oldFiles = DirState('releases', subdirs=False) print 'platform_release.py...' - os.system("python platform_release.py > %s 2> %s" % \ + run_python2("platform_release.py > %s 2> %s" % \ ('buildlog.txt', 'builderrors.txt')) for n in DirState('releases', subdirs=False).list_new_files(oldFiles): diff --git a/distrib/build_number.py b/distrib/build_number.py index 800c873561..a0d53f086d 100755 --- a/distrib/build_number.py +++ b/distrib/build_number.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # Determining the number of a build. import time diff --git a/distrib/builder/utils.py b/distrib/builder/utils.py index a10e0f95eb..f18ef48ec4 100644 --- a/distrib/builder/utils.py +++ b/distrib/builder/utils.py @@ -193,3 +193,14 @@ def system_command(cmd): result = subprocess.call(cmd, shell=True) if result != 0: raise Exception("Error from " + cmd) + + +def python2_executable(): + if sys.platform[:3] == 'win': + return 'python' + else: + return 'python2.7' + + +def run_python2(script): + system_command(python2_executable() + " " + script) diff --git a/distrib/pilot.py b/distrib/pilot.py index 15dcd994f6..89f536786f 100755 --- a/distrib/pilot.py +++ b/distrib/pilot.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # coding=utf-8 # # The Doomsday Build Pilot @@ -35,6 +35,7 @@ import struct import time import SocketServer +import builder.utils def homeDir(): """Determines the path of the pilot home directory.""" @@ -414,8 +415,7 @@ def handleCompletedTasks(): def autobuild(cmd): - cmdLine = "python %s %s" % (os.path.join(pilotcfg.DISTRIB_DIR, - 'autobuild.py'), cmd) + cmdLine = "%s %s" % (os.path.join(pilotcfg.DISTRIB_DIR, 'autobuild.py'), cmd) cmdLine += " --distrib %s" % pilotcfg.DISTRIB_DIR if 'EVENTS_DIR' in dir(pilotcfg): cmdLine += " --events %s" % pilotcfg.EVENTS_DIR @@ -424,7 +424,7 @@ def autobuild(cmd): cmdLine += " --branch %s" % currentBranch() - systemCommand(cmdLine) + builder.utils.run_python2(cmdLine) return True diff --git a/distrib/platform_release.py b/distrib/platform_release.py index 0111fa765e..69c61e9af9 100755 --- a/distrib/platform_release.py +++ b/distrib/platform_release.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # This script builds the distribution packages platform-independently. # No parameters needed; config is auto-detected. @@ -160,7 +160,7 @@ def mac_package_snowberry(): f = file('VERSION', 'wt') f.write(DOOMSDAY_VERSION_FULL) f.close() - os.system('python buildapp.py py2app') + builder.utils.run_python2('buildapp.py py2app') # Share it. duptree('dist/Doomsday Engine.app', 'shared/') diff --git a/doomsday/build/build.pro b/doomsday/build/build.pro index 790e1c4a2c..8468b1b070 100644 --- a/doomsday/build/build.pro +++ b/doomsday/build/build.pro @@ -9,8 +9,10 @@ TEMPLATE = subdirs # Let's print the build configuration during this qmake invocation. CONFIG += deng_verbosebuildconfig +include(../macros.pri) + # Always update versions.pri. -system(cd "$$PWD/.." && python configure.py) +runPython2InDir($$PWD/.., configure.py) include(../config.pri) @@ -19,7 +21,7 @@ QMAKE_STRIP = true # Update the PK3 files. !deng_nopackres { - system(cd $$PWD/scripts/ && python packres.py --quiet \"$$OUT_PWD/..\") + runPython2InDir($$PWD/scripts/, packres.py --quiet \"$$OUT_PWD/..\") } # Install the launcher. diff --git a/doomsday/build/scripts/codex.py b/doomsday/build/scripts/codex.py index d20be2902c..de7798edd5 100755 --- a/doomsday/build/scripts/codex.py +++ b/doomsday/build/scripts/codex.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # coding=utf-8 # # Repository Codex Generator by diff --git a/doomsday/build/scripts/makehelp.py b/doomsday/build/scripts/makehelp.py index ef0b486169..8d8401720a 100755 --- a/doomsday/build/scripts/makehelp.py +++ b/doomsday/build/scripts/makehelp.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 import os, sys import conhelp diff --git a/doomsday/build/scripts/packres.py b/doomsday/build/scripts/packres.py index cc9c7e25b2..68f3ebc489 100755 --- a/doomsday/build/scripts/packres.py +++ b/doomsday/build/scripts/packres.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # This Python script will create a set of PK3 files that contain the files # that Doomsday needs at runtime. The PK3 files are organized using the # traditional data/ and defs/ structure. diff --git a/doomsday/build/scripts/wadcompiler.py b/doomsday/build/scripts/wadcompiler.py index b79d09314e..c1e7ce4da4 100755 --- a/doomsday/build/scripts/wadcompiler.py +++ b/doomsday/build/scripts/wadcompiler.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 import sys, os.path, struct diff --git a/doomsday/build/win32/qmake_msvc.py b/doomsday/build/win32/qmake_msvc.py index 93e17a4dbb..bc7370eb8c 100644 --- a/doomsday/build/win32/qmake_msvc.py +++ b/doomsday/build/win32/qmake_msvc.py @@ -1,6 +1,6 @@ -# qmake_msvc.py is a script that generates a full Visual Studio solution with -# a .vcxproj for each subproject. You must set up envconfig.bat before running -# the script. The solution is always placed in a folder called +# qmake_msvc.py is a Python 2 script that generates a full Visual Studio +# solution with a .vcxproj for each subproject. You must set up envconfig.bat +# before running the script. The solution is always placed in a folder called # "doomsday-msvc-build" at the repository root. # # qmake_msvc.py must be called whenever the .pro/.pri files change. The .sln diff --git a/doomsday/config.pri b/doomsday/config.pri index e5491a15cb..e38dda5637 100644 --- a/doomsday/config.pri +++ b/doomsday/config.pri @@ -47,67 +47,16 @@ DENG_MAC_INCLUDE_DIR = $$DENG_INCLUDE_DIR/macx DENG_WIN_INCLUDE_DIR = $$DENG_INCLUDE_DIR/windows DENG_MODULES_DIR = $$PWD/libdeng2/modules -# Versions ------------------------------------------------------------------- - -# Parse versions from the header files. -!exists(versions.pri): system(python configure.py) - -include(versions.pri) - # Macros --------------------------------------------------------------------- -defineTest(echo) { - deng_verbosebuildconfig { - !win32 { - message($$1) - } else { - # We don't want to get the printed messages after everything else, - # so print to stdout. - system(echo $$1) - } - } -} +include(macros.pri) -defineTest(useLibDir) { - btype = "" - win32 { - deng_debug: btype = "/Debug" - else: btype = "/Release" - } - exists($${1}$${btype}) { - LIBS += -L$${1}$${btype} - export(LIBS) - return(true) - } - return(false) -} +# Versions ------------------------------------------------------------------- -defineTest(doPostLink) { - isEmpty(QMAKE_POST_LINK) { - QMAKE_POST_LINK = $$1 - } else { - QMAKE_POST_LINK = $$QMAKE_POST_LINK && $$1 - } - export(QMAKE_POST_LINK) -} +# Parse versions from the header files. +!exists(versions.pri): runPython2(configure.py) -macx { - defineTest(removeQtLibPrefix) { - doPostLink("install_name_tool -change $$[QT_INSTALL_LIBS]/$$2 $$2 $$1") - } - defineTest(fixInstallName) { - # 1: binary file - # 2: library name - # 3: path to Frameworks/ - removeQtLibPrefix($$1, $$2) - doPostLink("install_name_tool -change $$2 @executable_path/$$3/Frameworks/$$2 $$1") - } - defineTest(fixPluginInstallId) { - # 1: target name - # 2: version - doPostLink("install_name_tool -id @executable_path/../DengPlugins/$${1}.bundle/Versions/$$2/$$1 $${1}.bundle/Versions/$$2/$$1") - } -} +include(versions.pri) # Build Options -------------------------------------------------------------- diff --git a/doomsday/config_unix_any.pri b/doomsday/config_unix_any.pri index ee45361ca1..4b8c87b1b0 100644 --- a/doomsday/config_unix_any.pri +++ b/doomsday/config_unix_any.pri @@ -36,11 +36,21 @@ deng_qt5 { # Unix System Tools ---------------------------------------------------------- -# Python to be used in generated scripts. +# Python 2 to be used in generated scripts. isEmpty(SCRIPT_PYTHON) { - exists(/usr/bin/python): SCRIPT_PYTHON = /usr/bin/python + exists(/usr/bin/python2.7): SCRIPT_PYTHON = /usr/bin/python2.7 + exists(/usr/bin/python2): SCRIPT_PYTHON = /usr/bin/python2 + exists(/usr/bin/python): SCRIPT_PYTHON = /usr/bin/python exists(/usr/local/bin/python): SCRIPT_PYTHON = /usr/local/bin/python } +isEmpty(SCRIPT_PYTHON) { + # Check the system path. + SCRIPT_PYTHON = $$system(which python2.7) +} +isEmpty(SCRIPT_PYTHON) { + # Check the system path. + SCRIPT_PYTHON = $$system(which python2) +} isEmpty(SCRIPT_PYTHON) { # Check the system path. SCRIPT_PYTHON = $$system(which python) diff --git a/doomsday/configure.py b/doomsday/configure.py index 83288c304c..15aa56888b 100755 --- a/doomsday/configure.py +++ b/doomsday/configure.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 # # Doomsday Build Configuration Script # diff --git a/doomsday/macros.pri b/doomsday/macros.pri new file mode 100644 index 0000000000..ab135723be --- /dev/null +++ b/doomsday/macros.pri @@ -0,0 +1,66 @@ +# The Doomsday Engine Project +# Copyright (c) 2011-2014 Jaakko Keränen +# Copyright (c) 2011-2013 Daniel Swanson + +defineTest(runPython2) { + win32: system(python $$1) # 2.7 still expected + else: system(python2.7 $$1) +} + +defineTest(runPython2InDir) { + win32: system(cd "$$1" && python $$2) + else: system(cd "$$1" && python2.7 $$2) +} + +defineTest(echo) { + deng_verbosebuildconfig { + !win32 { + message($$1) + } else { + # We don't want to get the printed messages after everything else, + # so print to stdout. + system(echo $$1) + } + } +} + +defineTest(useLibDir) { + btype = "" + win32 { + deng_debug: btype = "/Debug" + else: btype = "/Release" + } + exists($${1}$${btype}) { + LIBS += -L$${1}$${btype} + export(LIBS) + return(true) + } + return(false) +} + +defineTest(doPostLink) { + isEmpty(QMAKE_POST_LINK) { + QMAKE_POST_LINK = $$1 + } else { + QMAKE_POST_LINK = $$QMAKE_POST_LINK && $$1 + } + export(QMAKE_POST_LINK) +} + +macx { + defineTest(removeQtLibPrefix) { + doPostLink("install_name_tool -change $$[QT_INSTALL_LIBS]/$$2 $$2 $$1") + } + defineTest(fixInstallName) { + # 1: binary file + # 2: library name + # 3: path to Frameworks/ + removeQtLibPrefix($$1, $$2) + doPostLink("install_name_tool -change $$2 @executable_path/$$3/Frameworks/$$2 $$1") + } + defineTest(fixPluginInstallId) { + # 1: target name + # 2: version + doPostLink("install_name_tool -id @executable_path/../DengPlugins/$${1}.bundle/Versions/$$2/$$1 $${1}.bundle/Versions/$$2/$$1") + } +}