Skip to content

Commit

Permalink
Added new CONFIG option deng_packres - Package the Doomsday resources
Browse files Browse the repository at this point in the history
Made packaging of resources optional because its not typically necessary
on a daily basis (enabled by default in the release scripts however) and
the current packres.py script will always rebuild them in their entirety
(slowing down the development work cycle).
  • Loading branch information
danij-deng committed Oct 19, 2011
1 parent f3f95b4 commit 54102c5
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 47 deletions.
82 changes: 41 additions & 41 deletions distrib/platform_release.py
Expand Up @@ -30,29 +30,29 @@
def exit_with_error():
os.chdir(LAUNCH_DIR)
sys.exit(1)


def mkdir(n):
try:
os.mkdir(n)
except OSError:
print 'Directory', n, 'already exists.'


def remkdir(n):
if os.path.exists(n):
print n, 'exists, clearing it...'
shutil.rmtree(n, True)
os.mkdir(n)


def remove(n):
try:
os.remove(n)
except OSError:
print 'Cannot remove', n


def copytree(s, d):
try:
shutil.copytree(s, d)
Expand All @@ -63,18 +63,18 @@ def copytree(s, d):

def duptree(s, d):
os.system('cp -fRp "%s" "%s"' % (s, d))


def find_version():
build_version.find_version()

global DOOMSDAY_VERSION_FULL
global DOOMSDAY_VERSION_FULL_PLAIN
global DOOMSDAY_VERSION_MAJOR
global DOOMSDAY_VERSION_MINOR
global DOOMSDAY_VERSION_REVISION
global DOOMSDAY_RELEASE_TYPE

DOOMSDAY_RELEASE_TYPE = build_version.DOOMSDAY_RELEASE_TYPE
DOOMSDAY_VERSION_FULL_PLAIN = build_version.DOOMSDAY_VERSION_FULL_PLAIN
DOOMSDAY_VERSION_FULL = build_version.DOOMSDAY_VERSION_FULL
Expand All @@ -84,13 +84,13 @@ def find_version():


def prepare_work_dir():
remkdir(WORK_DIR)
remkdir(WORK_DIR)
print "Work directory prepared."


def mac_os_version():
return platform.mac_ver()[0][:4]


"""The Mac OS X release procedure."""
def mac_release():
Expand All @@ -105,28 +105,28 @@ def mac_release():
raise Exception("Python: py2app not found!")
# First we need to make a release build.
print "Building the release..."
# Must work in the deng root for qmake (resource bundling apparently
# Must work in the deng root for qmake (resource bundling apparently
# fails otherwise).
MAC_WORK_DIR = os.path.abspath(os.path.join(DOOMSDAY_DIR, '../macx_release_build'))
remkdir(MAC_WORK_DIR)
os.chdir(MAC_WORK_DIR)
if os.system('qmake -r -spec macx-g++ CONFIG+=release DENG_BUILD=%s ' % (DOOMSDAY_BUILD_NUMBER) +
'../doomsday/doomsday.pro && make -w ' +
if os.system('qmake -r -spec macx-g++ CONFIG+="release deng_packres" DENG_BUILD=%s ' % (DOOMSDAY_BUILD_NUMBER) +
'../doomsday/doomsday.pro && make -w ' +
'&& ../doomsday/build/mac/bundleapp.sh ../doomsday'):
raise Exception("Failed to build from source.")

# Now we can proceed to packaging.
target = OUTPUT_DIR + "/doomsday_" + DOOMSDAY_VERSION_FULL + "_" + DOOMSDAY_BUILD + ".dmg"
try:
os.remove(target)
print 'Removed existing target file', target
except:
print 'Target:', target

os.chdir(SNOWBERRY_DIR)
remkdir('dist')
remkdir('build')

print 'Copying resources...'
remkdir('build/addons')
remkdir('build/conf')
Expand All @@ -140,13 +140,13 @@ def mac_release():
'/conf/osx-doomsday.conf',
'/conf/snowberry.conf']:
shutil.copy(SNOWBERRY_DIR + f, 'build/conf')

for f in (glob.glob(SNOWBERRY_DIR + '/graphics/*.jpg') +
glob.glob(SNOWBERRY_DIR + '/graphics/*.png') +
glob.glob(SNOWBERRY_DIR + '/graphics/*.bmp') +
glob.glob(SNOWBERRY_DIR + '/graphics/*.ico')):
shutil.copy(f, 'build/graphics')

for f in glob.glob(SNOWBERRY_DIR + '/lang/*.lang'):
shutil.copy(f, 'build/lang')

Expand All @@ -168,20 +168,20 @@ def mac_release():
f.write(DOOMSDAY_VERSION_FULL)
f.close()
os.system('python buildapp.py py2app')

# Back to the normal work dir.
os.chdir(WORK_DIR)
copytree(SNOWBERRY_DIR + '/dist/Doomsday Engine.app', 'Doomsday Engine.app')

print 'Coping release binaries into the launcher bundle.'
duptree(os.path.join(MAC_WORK_DIR, 'engine/Doomsday.app'), 'Doomsday Engine.app/Contents/Doomsday.app')
for f in glob.glob(os.path.join(MAC_WORK_DIR, 'engine/*.bundle')):
# Exclude jDoom64.
if not 'jDoom64' in f:
duptree(f, 'Doomsday Engine.app/Contents/' + os.path.basename(f))

print 'Creating disk image:', target

masterDmg = target
volumeName = "Doomsday Engine " + DOOMSDAY_VERSION_FULL
templateFile = os.path.join(SNOWBERRY_DIR, 'template-image/template.dmg')
Expand All @@ -195,10 +195,10 @@ def mac_release():
remove('imaging/Read Me.rtf')
duptree('Doomsday Engine.app', 'imaging/Doomsday Engine.app')
shutil.copy(LAUNCH_DIR + "/mac/Read Me.rtf", 'imaging/Read Me.rtf')
os.system('/usr/sbin/diskutil rename ' + os.path.abspath('imaging') +

os.system('/usr/sbin/diskutil rename ' + os.path.abspath('imaging') +
' "' + "Doomsday Engine " + DOOMSDAY_VERSION_FULL + '"')

os.system('hdiutil detach -quiet imaging')
os.system('hdiutil convert imaging.dmg -format UDZO -imagekey zlib-level=9 -o "' + target + '"')
remove('imaging.dmg')
Expand Down Expand Up @@ -228,17 +228,17 @@ def win_release():
.replace('${BUILD}', DOOMSDAY_BUILD)
.replace('${VERSION}', DOOMSDAY_VERSION_FULL)
.replace('${VERSION_PLAIN}', DOOMSDAY_VERSION_FULL_PLAIN))

# Execute the win32 release script.
os.chdir('win32')
if os.system('dorel.bat ' + DOOMSDAY_BUILD_NUMBER):
raise Exception("Failure in the Windows release script.")


"""The Linux release procedure."""
def linux_release():
os.chdir(LAUNCH_DIR)

# Generate a launcher script.
f = file('linux/launch-doomsday', 'wt')
print >> f, """#!/usr/bin/python
Expand All @@ -248,21 +248,21 @@ def linux_release():
import snowberry"""
f.close()

def clean_products():
# Remove previously build deb packages.
os.system('rm -f ../doomsday*.deb ../doomsday*.changes ../doomsday*.tar.gz ../doomsday*.dsc')

clean_products()

if os.system('linux/gencontrol.sh && dpkg-buildpackage -b'):
raise Exception("Failure to build from source.")

# Place the result in the output directory.
shutil.copy(glob.glob('../doomsday*.deb')[0], OUTPUT_DIR)
shutil.copy(glob.glob('../doomsday*.changes')[0], OUTPUT_DIR)
shutil.copy(glob.glob('../doomsday*.changes')[0], OUTPUT_DIR)
clean_products()


def main():
prepare_work_dir()
Expand Down Expand Up @@ -291,7 +291,7 @@ def main():

os.chdir(LAUNCH_DIR)
print "Done."


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion distrib/win32/dorel.bat
Expand Up @@ -21,7 +21,7 @@ SET BUILDFAILURE=0
rd/s/q work
md work
cd work
qmake ..\..\..\doomsday\doomsday.pro CONFIG+=release DENG_BUILD=%DOOMSDAY_BUILD%
qmake ..\..\..\doomsday\doomsday.pro CONFIG+="release deng_packres" DENG_BUILD=%DOOMSDAY_BUILD%
IF NOT %ERRORLEVEL% == 0 SET BUILDFAILURE=1
%JOM%
IF NOT %ERRORLEVEL% == 0 SET BUILDFAILURE=1
Expand Down
4 changes: 3 additions & 1 deletion doomsday/build/build.pro
Expand Up @@ -9,7 +9,9 @@ TEMPLATE = subdirs
include(../config.pri)

# Update the PK3 files.
system(cd $$PWD/scripts/ && python packres.py \"$$OUT_PWD/..\")
deng_packres {
system(cd $$PWD/scripts/ && python packres.py \"$$OUT_PWD/..\")
}

# Install the launcher.
deng_snowberry {
Expand Down
9 changes: 5 additions & 4 deletions doomsday/config.pri
Expand Up @@ -6,6 +6,7 @@
# - deng_aptunstable Include the unstable apt repository
# - deng_nofixedasm Disable assembler fixed-point math
# - deng_openal Build the OpenAL sound driver
# - deng_packres Package the Doomsday resources
# - deng_rangecheck Parameter range checking/value assertions
# - deng_snowberry Include Snowberry in installation
# - deng_snowleopard (Mac OS X) Use 10.6 SDK
Expand Down Expand Up @@ -67,7 +68,7 @@ win32 {
DENG_LIB_DIR = $$DENG_BASE_DIR/bin
DENG_DATA_DIR = $$DENG_BASE_DIR/data
DENG_DOCS_DIR = $$DENG_BASE_DIR/doc

# Tell rc where to get the API headers.
QMAKE_RC = $$QMAKE_RC /I \"$$DENG_API_DIR\"

Expand All @@ -84,7 +85,7 @@ unix {
}
unix:!macx {
# Generic Unix build options.
CONFIG += deng_nofixedasm deng_snowberry
CONFIG += deng_nofixedasm deng_snowberry deng_packres

# Choose the apt repository to include in the distribution.
CONFIG += deng_aptunstable
Expand Down Expand Up @@ -157,13 +158,13 @@ macx {
QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.4u.sdk
QMAKE_CFLAGS += -mmacosx-version-min=10.4
DEFINES += MACOS_10_4
CONFIG += x86 ppc
CONFIG += x86 ppc
}

# Not using Qt, and anyway these would not point to the chosen SDK.
QMAKE_INCDIR_QT = ""
QMAKE_LIBDIR_QT = ""

defineTest(useFramework) {
LIBS += -framework $$1
INCLUDEPATH += $$QMAKE_MAC_SDK/System/Library/Frameworks/$${1}.framework/Headers
Expand Down

0 comments on commit 54102c5

Please sign in to comment.