From 60444c916943029b9239e48168a4cfbe93990828 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sat, 30 Mar 2013 20:48:59 +0000 Subject: [PATCH] build system updates, for mobile builds - main build.py will optionally build mobile. removed now obsolete mobile build scripts and symbolic links - external resource URL is now optional - it's no longer needed by the regular builds --- build.py | 39 +++++++++++++++++++++++++++++++++++---- buildsettings.py | 14 ++++++++++++-- mobile/.gitignore | 1 + mobile/assets/iitc.js | 1 - mobile/build_mobile.sh | 10 ---------- 5 files changed, 48 insertions(+), 17 deletions(-) delete mode 120000 mobile/assets/iitc.js delete mode 100755 mobile/build_mobile.sh diff --git a/build.py b/build.py index dd3ed93a..000e121b 100755 --- a/build.py +++ b/build.py @@ -8,6 +8,7 @@ import base64 import sys import os import shutil +import subprocess # load settings file @@ -49,9 +50,9 @@ buildDate = time.strftime('%Y-%m-%d-%H%M%S',utcTime) dateTimeVersion = time.strftime('%Y%m%d.%H%M%S',utcTime) # extract required values from the settings entry -resourceUrlBase = settings['resourceUrlBase'] -distUrlBase = settings['distUrlBase'] - +resourceUrlBase = settings.get('resourceUrlBase') +distUrlBase = settings.get('distUrlBase') +buildMobile = settings.get('buildMobile') def readfile(fn): @@ -90,7 +91,13 @@ def doReplacements(script,updateUrl,downloadUrl): script = script.replace('@@BUILDDATE@@', buildDate) script = script.replace('@@DATETIMEVERSION@@', dateTimeVersion) - script = script.replace('@@RESOURCEURLBASE@@', resourceUrlBase) + + if resourceUrlBase: + script = script.replace('@@RESOURCEURLBASE@@', resourceUrlBase) + else: + if '@@RESOURCEURLBASE@@' in script: + raise Exception("Error: '@@RESOURCEURLBASE@@' found in script, but no replacement defined") + script = script.replace('@@BUILDNAME@@', buildName) script = script.replace('@@UPDATEURL@@', updateUrl) @@ -151,4 +158,28 @@ for fn in glob.glob("plugins/*.user.js"): saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn)) +# if we're building mobile too +if buildMobile: + if buildMobile not in ['debug','release']: + raise Exception("Error: buildMobile must be 'debug' or 'release'") + + # first, copy the IITC script into the mobile folder. create the folder if needed + try: + os.makedirs("mobile/assets") + except: + pass + shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/iitc.js") + + # TODO? also copy plugins - once the mobile app supports plugins, that is + + + # now launch 'ant' to build the mobile project + retcode = subprocess.call(["ant", "-buildfile", "mobile/build.xml", buildMobile]) + + if retcode != 0: + print ("Error: mobile app failed to build. ant returned %d" % retcode) + else: + shutil.copy("mobile/bin/IITC_Mobile-%s.apk" % buildMobile, os.path.join(outDir,"IITC_Mobile-%s.apk" % buildMobile) ) + + # vim: ai si ts=4 sw=4 sts=4 et diff --git a/buildsettings.py b/buildsettings.py index 0288ea2c..9735ea9f 100644 --- a/buildsettings.py +++ b/buildsettings.py @@ -4,19 +4,29 @@ buildSettings = { # local: use this build if you're not modifying external resources - # external resources will be loaded from the public live release + # no external resources allowed - they're not needed any more 'local': { - 'resourceUrlBase': 'http://iitc.jonatkins.com/release', + 'resourceUrlBase': None, 'distUrlBase': None, }, # local8000: if you need to modify external resources, this build will load them from # the web server at http://0.0.0.0:8000/dist + # (This shouldn't be required any more - all resources are embedded. but, it remains just in case some new feature + # needs external resources) 'local8000': { 'resourceUrlBase': 'http://0.0.0.0:8000/dist', 'distUrlBase': None, }, + # mobile: default entry that also builds the mobile .apk + # you will need to have the android-sdk installed, and the file mobile/local.properties created as required + 'mobile': { + 'resourceUrlBase': None, + 'distUrlBase': None, + 'buildMobile': 'debug', + }, + # if you want to publish your own fork of the project, and host it on your own web site # create a localbuildsettings.py file containing something similar to this diff --git a/mobile/.gitignore b/mobile/.gitignore index a36f859a..a56e372f 100644 --- a/mobile/.gitignore +++ b/mobile/.gitignore @@ -6,3 +6,4 @@ gen/ libs/ proguard-project.txt local.properties +assets/iitc.js diff --git a/mobile/assets/iitc.js b/mobile/assets/iitc.js deleted file mode 120000 index cbb53766..00000000 --- a/mobile/assets/iitc.js +++ /dev/null @@ -1 +0,0 @@ -../../build/local8000/total-conversion-build.user.js \ No newline at end of file diff --git a/mobile/build_mobile.sh b/mobile/build_mobile.sh deleted file mode 100755 index cc350f2d..00000000 --- a/mobile/build_mobile.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -set -e - -cd `dirname "$0"` -cd .. -./build.py local8000 -cd build/local8000 -cd ../../mobile -ant debug